%include "std_shared_ptr.i"
// shared pointers
+%shared_ptr(BuildAPI_Compound)
+%shared_ptr(BuildAPI_CompSolid)
%shared_ptr(BuildAPI_Edge)
%shared_ptr(BuildAPI_Face)
%shared_ptr(BuildAPI_Filling)
%shared_ptr(BuildAPI_Shell)
+%shared_ptr(BuildAPI_Solid)
%shared_ptr(BuildAPI_SubShapes)
%shared_ptr(BuildAPI_Vertex)
%shared_ptr(BuildAPI_Wire)
// all supported interfaces
+%include "BuildAPI_Compound.h"
+%include "BuildAPI_CompSolid.h"
%include "BuildAPI_Edge.h"
%include "BuildAPI_Face.h"
%include "BuildAPI_Filling.h"
%include "BuildAPI_Shell.h"
+%include "BuildAPI_Solid.h"
%include "BuildAPI_SubShapes.h"
%include "BuildAPI_Vertex.h"
%include "BuildAPI_Wire.h"
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "BuildAPI_CompSolid.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+BuildAPI_CompSolid::BuildAPI_CompSolid(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+BuildAPI_CompSolid::BuildAPI_CompSolid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setBase(theBaseObjects);
+ }
+}
+
+//==================================================================================================
+BuildAPI_CompSolid::~BuildAPI_CompSolid()
+{
+}
+
+//==================================================================================================
+void BuildAPI_CompSolid::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+ fillAttribute(theBaseObjects, mybaseObjects);
+ execute();
+}
+
+//==================================================================================================
+void BuildAPI_CompSolid::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ std::string aPartName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addCompSolid(" << aPartName << ", "
+ << aBase->selectionList(BuildPlugin_CompSolid::BASE_OBJECTS_ID()) << ")" << std::endl;
+}
+
+//==================================================================================================
+CompSolidPtr addCompSolid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_CompSolid::ID());
+ return CompSolidPtr(new BuildAPI_CompSolid(aFeature, theBaseObjects));
+}
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef BuildAPI_CompSolid_H_
+#define BuildAPI_CompSolid_H_
+
+#include "BuildAPI.h"
+
+#include <BuildPlugin_CompSolid.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Selection;
+
+/// \class BuildAPI_CompSolid
+/// \ingroup CPPHighAPI
+/// \brief Interface for CompSolid feature.
+class BuildAPI_CompSolid: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ BUILDAPI_EXPORT
+ explicit BuildAPI_CompSolid(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ BUILDAPI_EXPORT
+ explicit BuildAPI_CompSolid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Destructor.
+ BUILDAPI_EXPORT
+ virtual ~BuildAPI_CompSolid();
+
+ INTERFACE_1(BuildPlugin_CompSolid::ID(),
+ baseObjects, BuildPlugin_CompSolid::BASE_OBJECTS_ID(),
+ ModelAPI_AttributeSelectionList, /** Base objects */)
+
+ /// Modify base attribute of the feature.
+ BUILDAPI_EXPORT
+ void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Dump wrapped feature
+ BUILDAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on CompSolid object.
+typedef std::shared_ptr<BuildAPI_CompSolid> CompSolidPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create CompSolid feature.
+BUILDAPI_EXPORT
+CompSolidPtr addCompSolid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+#endif // BuildAPI_CompSolid_H_
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "BuildAPI_Compound.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+BuildAPI_Compound::BuildAPI_Compound(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+BuildAPI_Compound::BuildAPI_Compound(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setBase(theBaseObjects);
+ }
+}
+
+//==================================================================================================
+BuildAPI_Compound::~BuildAPI_Compound()
+{
+}
+
+//==================================================================================================
+void BuildAPI_Compound::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+ fillAttribute(theBaseObjects, mybaseObjects);
+ execute();
+}
+
+//==================================================================================================
+void BuildAPI_Compound::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ std::string aPartName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addCompound(" << aPartName << ", "
+ << aBase->selectionList(BuildPlugin_Compound::BASE_OBJECTS_ID()) << ")" << std::endl;
+}
+
+//==================================================================================================
+CompoundPtr addCompound(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_Compound::ID());
+ return CompoundPtr(new BuildAPI_Compound(aFeature, theBaseObjects));
+}
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef BuildAPI_Compound_H_
+#define BuildAPI_Compound_H_
+
+#include "BuildAPI.h"
+
+#include <BuildPlugin_Compound.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Selection;
+
+/// \class BuildAPI_Compound
+/// \ingroup CPPHighAPI
+/// \brief Interface for Compound feature.
+class BuildAPI_Compound: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ BUILDAPI_EXPORT
+ explicit BuildAPI_Compound(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ BUILDAPI_EXPORT
+ explicit BuildAPI_Compound(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Destructor.
+ BUILDAPI_EXPORT
+ virtual ~BuildAPI_Compound();
+
+ INTERFACE_1(BuildPlugin_Compound::ID(),
+ baseObjects, BuildPlugin_Compound::BASE_OBJECTS_ID(),
+ ModelAPI_AttributeSelectionList, /** Base objects */)
+
+ /// Modify base attribute of the feature.
+ BUILDAPI_EXPORT
+ void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Dump wrapped feature
+ BUILDAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Compound object.
+typedef std::shared_ptr<BuildAPI_Compound> CompoundPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Compound feature.
+BUILDAPI_EXPORT
+CompoundPtr addCompound(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+#endif // BuildAPI_Compound_H_
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "BuildAPI_Solid.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+BuildAPI_Solid::BuildAPI_Solid(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+BuildAPI_Solid::BuildAPI_Solid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setBase(theBaseObjects);
+ }
+}
+
+//==================================================================================================
+BuildAPI_Solid::~BuildAPI_Solid()
+{
+}
+
+//==================================================================================================
+void BuildAPI_Solid::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+ fillAttribute(theBaseObjects, mybaseObjects);
+ execute();
+}
+
+//==================================================================================================
+void BuildAPI_Solid::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ std::string aPartName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addSolid(" << aPartName << ", "
+ << aBase->selectionList(BuildPlugin_Solid::BASE_OBJECTS_ID()) << ")" << std::endl;
+}
+
+//==================================================================================================
+SolidPtr addSolid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_Solid::ID());
+ return SolidPtr(new BuildAPI_Solid(aFeature, theBaseObjects));
+}
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef BuildAPI_Solid_H_
+#define BuildAPI_Solid_H_
+
+#include "BuildAPI.h"
+
+#include <BuildPlugin_Solid.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Selection;
+
+/// \class BuildAPI_Solid
+/// \ingroup CPPHighAPI
+/// \brief Interface for Solid feature.
+class BuildAPI_Solid: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ BUILDAPI_EXPORT
+ explicit BuildAPI_Solid(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ BUILDAPI_EXPORT
+ explicit BuildAPI_Solid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Destructor.
+ BUILDAPI_EXPORT
+ virtual ~BuildAPI_Solid();
+
+ INTERFACE_1(BuildPlugin_Solid::ID(),
+ baseObjects, BuildPlugin_Solid::BASE_OBJECTS_ID(),
+ ModelAPI_AttributeSelectionList, /** Base objects */)
+
+ /// Modify base attribute of the feature.
+ BUILDAPI_EXPORT
+ void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Dump wrapped feature
+ BUILDAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Solid object.
+typedef std::shared_ptr<BuildAPI_Solid> SolidPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Solid feature.
+BUILDAPI_EXPORT
+SolidPtr addSolid(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+#endif // BuildAPI_Solid_H_
#include <ModelHighAPI_swig.h>
+ #include "BuildAPI_Compound.h"
+ #include "BuildAPI_CompSolid.h"
#include "BuildAPI_Edge.h"
#include "BuildAPI_Face.h"
#include "BuildAPI_Filling.h"
#include "BuildAPI_Shell.h"
+ #include "BuildAPI_Solid.h"
#include "BuildAPI_SubShapes.h"
#include "BuildAPI_Vertex.h"
#include "BuildAPI_Wire.h"
SET(PROJECT_HEADERS
BuildAPI.h
+ BuildAPI_Compound.h
+ BuildAPI_CompSolid.h
BuildAPI_Edge.h
BuildAPI_Face.h
BuildAPI_Filling.h
BuildAPI_Shell.h
+ BuildAPI_Solid.h
BuildAPI_SubShapes.h
BuildAPI_Vertex.h
BuildAPI_Wire.h
)
SET(PROJECT_SOURCES
+ BuildAPI_Compound.cpp
+ BuildAPI_CompSolid.cpp
BuildAPI_Edge.cpp
BuildAPI_Face.cpp
BuildAPI_Filling.cpp
BuildAPI_Shell.cpp
+ BuildAPI_Solid.cpp
BuildAPI_SubShapes.cpp
BuildAPI_Vertex.cpp
BuildAPI_Wire.cpp
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "BuildPlugin_CompSolid.h"
+
+#include <GeomAlgoAPI_MakeShape.h>
+#include <ModelAPI_AttributeSelectionList.h>
+
+//=================================================================================================
+BuildPlugin_CompSolid::BuildPlugin_CompSolid()
+{
+}
+
+//=================================================================================================
+void BuildPlugin_CompSolid::initAttributes()
+{
+ data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+//=================================================================================================
+void BuildPlugin_CompSolid::execute()
+{
+ ListOfShape anOriginalShapes;
+ std::shared_ptr<GeomAlgoAPI_MakeShape> aVolumeMaker;
+ if (!build(anOriginalShapes, aVolumeMaker))
+ return;
+
+ GeomShapePtr aVolumeRes = aVolumeMaker->shape();
+
+ // check and process result of volume maker
+ GeomShapePtr aResShape = getSingleSubshape(aVolumeRes, GeomAPI_Shape::COMPSOLID);
+ if (!aResShape) // try to build a solid
+ aResShape = getSingleSubshape(aVolumeRes, GeomAPI_Shape::SOLID);
+
+ int anIndex = 0;
+ if (aResShape) {
+ storeResult(anOriginalShapes, aResShape, aVolumeMaker);
+ ++anIndex;
+ }
+ removeResults(anIndex);
+}
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef BuildPlugin_CompSolid_H_
+#define BuildPlugin_CompSolid_H_
+
+#include "BuildPlugin.h"
+#include "BuildPlugin_Solid.h"
+
+/// \class BuildPlugin_CompSolid
+/// \ingroup Plugins
+/// \brief Feature for creation of compsolid from solids or compsolids.
+class BuildPlugin_CompSolid: public BuildPlugin_Solid
+{
+public:
+ /// Use plugin manager for features creation
+ BuildPlugin_CompSolid();
+
+ /// Feature kind.
+ inline static const std::string& ID()
+ {
+ static const std::string MY_ID("CompSolid");
+ return MY_ID;
+ }
+
+ /// Attribute name of base objects.
+ inline static const std::string& BASE_OBJECTS_ID()
+ {
+ static const std::string MY_BASE_OBJECTS_ID("base_objects");
+ return MY_BASE_OBJECTS_ID;
+ }
+
+ /// \return the kind of a feature.
+ BUILDPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = BuildPlugin_CompSolid::ID();
+ return MY_KIND;
+ }
+
+ /// Request for initialization of data model of the feature: adding all attributes.
+ BUILDPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Creates a new part document if needed.
+ BUILDPLUGIN_EXPORT virtual void execute();
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "BuildPlugin_Compound.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultBody.h>
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+
+
+//=================================================================================================
+BuildPlugin_Compound::BuildPlugin_Compound()
+{
+}
+
+//=================================================================================================
+void BuildPlugin_Compound::initAttributes()
+{
+ data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+//=================================================================================================
+void BuildPlugin_Compound::execute()
+{
+ // Get base objects list.
+ AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
+ if(!aSelectionList.get()) {
+ setError("Error: Could not get selection list.");
+ return;
+ }
+ if(aSelectionList->size() == 0) {
+ setError("Error: Empty selection list.");
+ return;
+ }
+
+ // Collect base shapes.
+ ListOfShape anOriginalShapes;
+ for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+ GeomShapePtr aShape = aSelection->value();
+ if (!aShape.get())
+ aShape = aSelection->context()->shape();
+ anOriginalShapes.push_back(aShape);
+ }
+
+ // Build compound.
+ GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(anOriginalShapes);
+ int anIndexToRemove = 0;
+ if (aCompound) {
+ ResultBodyPtr aResultBody = document()->createBody(data(), anIndexToRemove++);
+ aResultBody->store(aCompound);
+
+//// // Store faces
+//// std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubs = theAlgorithm->mapOfSubShapes();
+//// int aModifiedTag = 1;
+//// for(ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
+//// anIt != theOriginalShapes.cend(); ++anIt) {
+//// GeomShapePtr aShape = *anIt;
+//// aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE,
+//// aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true);
+//// }
+
+ setResult(aResultBody);
+ }
+ removeResults(anIndexToRemove);
+}
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef BuildPlugin_Compound_H_
+#define BuildPlugin_Compound_H_
+
+#include "BuildPlugin.h"
+
+#include <ModelAPI_Feature.h>
+
+/// \class BuildPlugin_Compound
+/// \ingroup Plugins
+/// \brief Feature for creation of compound from different kinds of shapes.
+class BuildPlugin_Compound: public ModelAPI_Feature
+{
+public:
+ /// Use plugin manager for features creation
+ BuildPlugin_Compound();
+
+ /// Feature kind.
+ inline static const std::string& ID()
+ {
+ static const std::string MY_ID("Compound");
+ return MY_ID;
+ }
+
+ /// Attribute name of base objects.
+ inline static const std::string& BASE_OBJECTS_ID()
+ {
+ static const std::string MY_BASE_OBJECTS_ID("base_objects");
+ return MY_BASE_OBJECTS_ID;
+ }
+
+ /// \return the kind of a feature.
+ BUILDPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = BuildPlugin_Compound::ID();
+ return MY_KIND;
+ }
+
+ /// Request for initialization of data model of the feature: adding all attributes.
+ BUILDPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Creates a new part document if needed.
+ BUILDPLUGIN_EXPORT virtual void execute();
+};
+
+#endif
// build result
aFilling->build(aParameters.isApprox);
- if (isFailed(aFilling)) {
+ if (isAlgorithmFailed(aFilling)) {
removeResults(0);
return;
}
setResult(aResultBody, 0);
}
-bool BuildPlugin_Filling::isFailed(
+bool BuildPlugin_Filling::isAlgorithmFailed(
const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
{
if (!theAlgorithm->isDone()) {
private:
/// Check the filling algorithm is failed
- bool isFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
+ bool isAlgorithmFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
/// Convert shape to edge according to construction method
std::shared_ptr<GeomAPI_Edge> toEdge(const std::shared_ptr<GeomAPI_Shape>& theShape,
#include <BuildPlugin_Wire.h>
#include <BuildPlugin_Face.h>
#include <BuildPlugin_Shell.h>
+#include <BuildPlugin_Solid.h>
+#include <BuildPlugin_CompSolid.h>
+#include <BuildPlugin_Compound.h>
#include <BuildPlugin_SubShapes.h>
#include <BuildPlugin_Filling.h>
#include <BuildPlugin_Validators.h>
return FeaturePtr(new BuildPlugin_Face());
} else if(theFeatureID == BuildPlugin_Shell::ID()) {
return FeaturePtr(new BuildPlugin_Shell());
+ } else if(theFeatureID == BuildPlugin_Solid::ID()) {
+ return FeaturePtr(new BuildPlugin_Solid());
+ } else if(theFeatureID == BuildPlugin_CompSolid::ID()) {
+ return FeaturePtr(new BuildPlugin_CompSolid());
+ } else if(theFeatureID == BuildPlugin_Compound::ID()) {
+ return FeaturePtr(new BuildPlugin_Compound());
} else if(theFeatureID == BuildPlugin_SubShapes::ID()) {
return FeaturePtr(new BuildPlugin_SubShapes());
} else if(theFeatureID == BuildPlugin_Filling::ID()) {
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "BuildPlugin_Solid.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultBody.h>
+
+#include <GeomAPI_ShapeIterator.h>
+
+#include <GeomAlgoAPI_MakeVolume.h>
+
+//=================================================================================================
+BuildPlugin_Solid::BuildPlugin_Solid()
+{
+}
+
+//=================================================================================================
+void BuildPlugin_Solid::initAttributes()
+{
+ data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+//=================================================================================================
+void BuildPlugin_Solid::execute()
+{
+ ListOfShape anOriginalShapes;
+ std::shared_ptr<GeomAlgoAPI_MakeShape> aVolumeMaker;
+ if (!build(anOriginalShapes, aVolumeMaker))
+ return;
+
+ // check and process result of volume maker
+ GeomShapePtr aResShape = getSingleSubshape(aVolumeMaker->shape(), GeomAPI_Shape::SOLID);
+ int anIndex = 0;
+ if (aResShape) {
+ storeResult(anOriginalShapes, aResShape, aVolumeMaker);
+ ++anIndex;
+ }
+ removeResults(anIndex);
+}
+
+//=================================================================================================
+bool BuildPlugin_Solid::build(ListOfShape& theOriginalShapes,
+ std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
+{
+ // Get base objects list.
+ AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
+ if (!aSelectionList.get()) {
+ setError("Error: Could not get selection list.");
+ return false;
+ }
+ if (aSelectionList->size() == 0) {
+ setError("Error: Empty selection list.");
+ return false;
+ }
+
+ // Collect base shapes.
+ for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+ GeomShapePtr aShape = aSelection->value();
+ if (!aShape.get())
+ aShape = aSelection->context()->shape();
+ theOriginalShapes.push_back(aShape);
+ }
+
+ theAlgorithm =
+ std::shared_ptr<GeomAlgoAPI_MakeVolume>(new GeomAlgoAPI_MakeVolume(theOriginalShapes));
+ return !isAlgorithmFailed(theAlgorithm);
+}
+
+void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes,
+ const GeomShapePtr& theResultShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
+{
+ ResultBodyPtr aResultBody = document()->createBody(data());
+ aResultBody->store(theResultShape);
+
+ // Store faces
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubs = theAlgorithm->mapOfSubShapes();
+ int aModifiedTag = 1;
+ for(ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
+ anIt != theOriginalShapes.cend(); ++anIt) {
+ GeomShapePtr aShape = *anIt;
+ aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE,
+ aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true);
+ }
+
+ setResult(aResultBody);
+}
+
+GeomShapePtr BuildPlugin_Solid::getSingleSubshape(const GeomShapePtr& theCompound,
+ const GeomAPI_Shape::ShapeType theShapeType)
+{
+ if (theCompound->shapeType() == theShapeType)
+ return theCompound;
+ else if (theCompound->shapeType() == GeomAPI_Shape::COMPOUND) {
+ GeomAPI_ShapeIterator anIt(theCompound);
+ GeomShapePtr aFoundSub;
+ for (; anIt.more() && !aFoundSub; anIt.next()) {
+ aFoundSub = anIt.current();
+ if (aFoundSub->shapeType() != theShapeType)
+ return GeomShapePtr(); // not alone sub-shape
+ }
+ if (anIt.more()) {
+ std::string anError = "Error: unable to build a ";
+ switch (theShapeType) {
+ case GeomAPI_Shape::SOLID: anError += "solid"; break;
+ case GeomAPI_Shape::COMPSOLID: anError += "compsolid"; break;
+ default: anError += "subshape"; break;
+ }
+ setError(anError);
+ } else
+ return aFoundSub;
+ }
+ // not a solid
+ return GeomShapePtr();
+}
+
+bool BuildPlugin_Solid::isAlgorithmFailed(
+ const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
+{
+ if (!theAlgorithm->isDone()) {
+ static const std::string aFeatureError = "Error: MakeVolume algorithm failed.";
+ setError(aFeatureError);
+ return true;
+ }
+ if (theAlgorithm->shape()->isNull()) {
+ static const std::string aShapeError = "Error: Resulting shape of MakeVolume is Null.";
+ setError(aShapeError);
+ return true;
+ }
+ if (!theAlgorithm->isValid()) {
+ std::string aFeatureError = "Error: Resulting shape of MakeVolume is not valid.";
+ setError(aFeatureError);
+ return true;
+ }
+ return false;
+}
--- /dev/null
+// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef BuildPlugin_Solid_H_
+#define BuildPlugin_Solid_H_
+
+#include "BuildPlugin.h"
+
+#include <GeomAPI_Shape.h>
+#include <ModelAPI_Feature.h>
+
+class GeomAlgoAPI_MakeShape;
+
+/// \class BuildPlugin_Solid
+/// \ingroup Plugins
+/// \brief Feature for creation of solid from faces or shells.
+class BuildPlugin_Solid: public ModelAPI_Feature
+{
+public:
+ /// Use plugin manager for features creation
+ BuildPlugin_Solid();
+
+ /// Feature kind.
+ inline static const std::string& ID()
+ {
+ static const std::string MY_ID("Solid");
+ return MY_ID;
+ }
+
+ /// Attribute name of base objects.
+ inline static const std::string& BASE_OBJECTS_ID()
+ {
+ static const std::string MY_BASE_OBJECTS_ID("base_objects");
+ return MY_BASE_OBJECTS_ID;
+ }
+
+ /// \return the kind of a feature.
+ BUILDPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = BuildPlugin_Solid::ID();
+ return MY_KIND;
+ }
+
+ /// Request for initialization of data model of the feature: adding all attributes.
+ BUILDPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Creates a new part document if needed.
+ BUILDPLUGIN_EXPORT virtual void execute();
+
+protected:
+ /// Build result
+ /// \param[out] theOriginalShapes list of original shapes
+ /// \param[out] theAlgorithm algorithm to build result
+ /// \return \c true if algorithm finished without errors
+ bool build(ListOfShape& theOriginalShapes, std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
+
+ /// Store result of algorithm
+ void storeResult(const ListOfShape& theOriginalShapes,
+ const GeomShapePtr& theResultShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
+
+ /// Check the algorithm is failed
+ bool isAlgorithmFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
+
+ /// Explode compound to get single shape of specified type
+ /// \return Empty shape if there is more than one shape in compound
+ GeomShapePtr getSingleSubshape(const GeomShapePtr& theCompound,
+ const GeomAPI_Shape::ShapeType theShapeType);
+};
+
+#endif
BuildPlugin_Wire.h
BuildPlugin_Face.h
BuildPlugin_Shell.h
+ BuildPlugin_Solid.h
+ BuildPlugin_CompSolid.h
+ BuildPlugin_Compound.h
BuildPlugin_SubShapes.h
BuildPlugin_Filling.h
BuildPlugin_Validators.h
BuildPlugin_Wire.cpp
BuildPlugin_Face.cpp
BuildPlugin_Shell.cpp
+ BuildPlugin_Solid.cpp
+ BuildPlugin_CompSolid.cpp
+ BuildPlugin_Compound.cpp
BuildPlugin_SubShapes.cpp
BuildPlugin_Filling.cpp
BuildPlugin_Validators.cpp
wire_widget.xml
face_widget.xml
shell_widget.xml
+ solid_widget.xml
+ compsolid_widget.xml
+ compound_widget.xml
subshapes_widget.xml
filling_widget.xml
)
TestWire.py
TestFace.py
TestShell.py
+ TestSolid.py
+ TestCompSolid.py
+ TestCompound.py
TestSubShapes.py
TestFilling_ByEdges.py
TestFilling_ByWires.py
--- /dev/null
+## Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from SketchAPI import *
+from GeomAPI import GeomAPI_Shape
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(40, 0, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 0, 0, 40)
+SketchLine_3 = Sketch_1.addLine(0, 40, 40, 40)
+SketchLine_4 = Sketch_1.addLine(40, 40, 40, 0)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40)
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")])
+Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
+SketchLine_5 = Sketch_2.addLine(20, 0, 0, 0)
+SketchLine_6 = Sketch_2.addLine(0, 0, 0, 20)
+SketchLine_7 = Sketch_2.addLine(0, 20, 20, 20)
+SketchLine_8 = Sketch_2.addLine(20, 20, 20, 0)
+SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result())
+SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result())
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False)
+SketchLine_9 = SketchProjection_2.createdFeature()
+SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchLine_5.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_9).startPoint(), SketchLine_5.endPoint())
+SketchConstraintEqual_2 = Sketch_2.setEqual(SketchLine_5.result(), SketchLine_6.result())
+SketchLine_10 = Sketch_2.addLine(20, 20, 20, 40)
+SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_10.startPoint())
+SketchLine_11 = Sketch_2.addLine(20, 40, 0, 40)
+SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
+SketchLine_12 = Sketch_2.addLine(0, 40, 0, 20)
+SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
+SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_12.endPoint())
+SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_10.result())
+SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_11.result())
+SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_12.result())
+SketchConstraintEqual_3 = Sketch_2.setEqual(SketchLine_6.result(), SketchLine_12.result())
+model.do()
+Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")])
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 270, 2)
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "AngularCopy_1_1_1"), model.selection("FACE", "AngularCopy_1_1_2")])
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7f-SketchLine_10f-SketchLine_11f-SketchLine_12f")], model.selection(), 40, 0)
+Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_13 = Sketch_3.addLine(40, 0, 20, 0)
+SketchLine_14 = Sketch_3.addLine(20, 0, 20, 40)
+SketchLine_15 = Sketch_3.addLine(20, 40, 40, 40)
+SketchLine_16 = Sketch_3.addLine(40, 40, 40, 0)
+SketchConstraintCoincidence_15 = Sketch_3.setCoincident(SketchLine_16.endPoint(), SketchLine_13.startPoint())
+SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
+SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
+SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
+SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_13.result())
+SketchConstraintVertical_7 = Sketch_3.setVertical(SketchLine_14.result())
+SketchConstraintHorizontal_7 = Sketch_3.setHorizontal(SketchLine_15.result())
+SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_16.result())
+SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_5s-SketchLine_15s-SketchLine_8e-SketchLine_14e"), False)
+SketchPoint_2 = SketchProjection_3.createdFeature()
+SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates())
+SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_11s-SketchLine_10e"), False)
+SketchPoint_3 = SketchProjection_4.createdFeature()
+SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchAPI_Point(SketchPoint_3).coordinates())
+SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e"), False)
+SketchPoint_4 = SketchProjection_5.createdFeature()
+SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_13.startPoint(), SketchAPI_Point(SketchPoint_4).coordinates())
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r")], model.selection(), 20, 0)
+Box_1 = model.addBox(Part_1_doc, 20, 20, 20)
+model.do()
+
+def createCompSolidStepByStep(theSelection, theExpectedType):
+ CompSolid = model.addCompSolid(Part_1_doc, [theSelection[0]])
+ aList = []
+ for selection, expected in zip(theSelection, theExpectedType):
+ aList.append(selection)
+ CompSolid.setBase(aList)
+ if expected == GeomAPI_Shape.SHAPE:
+ assert(len(CompSolid.results()) == 0), "FAILED: CompSolid should not be built"
+ else:
+ assert(len(CompSolid.results()) > 0), "FAILED: CompSolid is not built"
+ resultType = CompSolid.results()[0].resultSubShapePair()[0].shape().shapeType()
+ assert(resultType == expected), "FAILED: Result has unexpected type"
+ # remove solid if it is not built
+ if len(CompSolid.results()) == 0:
+ Part_1_doc.removeFeature(CompSolid.feature())
+ return None
+ return CompSolid
+
+# =============================================================================
+# Test 1. Build compsolid cointaining 2 solids
+# =============================================================================
+boundaries1 = [model.selection("FACE", "Face_1_1"),
+ model.selection("SHELL", "Shell_1_1"),
+ model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"),
+ model.selection("FACE", "Extrusion_1_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_2"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_3"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_2_1/To_Face_1"),
+ model.selection("FACE", "Box_1_1/Front")]
+expectType1 = [GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SOLID,
+ GeomAPI_Shape.COMPSOLID]
+CompSolid_1 = createCompSolidStepByStep(boundaries1, expectType1)
+
+model.checkBooleansResult(CompSolid_1, model, 1, [2], [2], [13], [54], [108])
+model.testHaveNamingSubshapes(CompSolid_1, model, Part_1_doc)
+
+# =============================================================================
+# Test 2. Build compsolid containing 3 solids
+# =============================================================================
+boundaries2 = [model.selection("FACE", "Face_1_1"),
+ model.selection("SHELL", "Shell_1_1"),
+ model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"),
+ model.selection("FACE", "Extrusion_1_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_1_1/Generated_Face_3"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_3"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_2_1/To_Face_1"),
+ model.selection("FACE", "Box_1_1/Front"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_2"),
+ model.selection("SOLID", "Extrusion_1_1")]
+expectType2 = [GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SHAPE,
+ GeomAPI_Shape.SOLID,
+ GeomAPI_Shape.COMPSOLID,
+ GeomAPI_Shape.COMPSOLID]
+CompSolid_2 = createCompSolidStepByStep(boundaries2, expectType2)
+
+model.checkBooleansResult(CompSolid_2, model, 1, [3], [3], [21], [88], [176])
+model.testHaveNamingSubshapes(CompSolid_2, model, Part_1_doc)
+
+model.end()
+
+assert(model.checkPythonDump())
--- /dev/null
+## Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-19.49406233194174, -69.37451616542793, -72.71146724766345, -69.37451616542793)
+SketchLine_2 = Sketch_1.addLine(-72.71146724766345, -69.37451616542793, -72.71146724766345, -28.67067780808921)
+SketchLine_3 = Sketch_1.addLine(-72.71146724766345, -28.67067780808921, -19.49406233194174, -28.67067780808921)
+SketchLine_4 = Sketch_1.addLine(-19.49406233194174, -28.67067780808921, -19.49406233194174, -69.37451616542793)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchLine_5 = Sketch_1.addLine(16.67888107989752, -75.92151145213565, 19.40636912075787, -34.81908596556777)
+SketchPoint_1 = Sketch_1.addPoint(0.6128545881206371, -78.63973361497078)
+SketchCircle_1 = Sketch_1.addCircle(51.0302184611028, -58.25492948210744, 14.6764214847306)
+SketchCircle_2 = Sketch_1.addCircle(57.27434431552349, -55.3477547099222, 30.40870102508203)
+model.do()
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "PartSet/Origin")])
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_5")])
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_2_2")])
+Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")])
+Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
+SketchLine_6 = Sketch_2.addLine(73.69205241424749, 19.68979803478298, 29.86213888681927, 19.68979803478298)
+SketchLine_7 = Sketch_2.addLine(29.86213888681927, 19.68979803478298, 29.86213888681927, 46.16063196348271)
+SketchLine_8 = Sketch_2.addLine(29.86213888681927, 46.16063196348271, 73.69205241424749, 46.16063196348271)
+SketchLine_9 = Sketch_2.addLine(73.69205241424749, 46.16063196348271, 73.69205241424749, 19.68979803478298)
+SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_6.result())
+SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_7.result())
+SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_8.result())
+SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_9.result())
+model.do()
+Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r")])
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_6"), 120, 2)
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "AngularCopy_1_1_1"), model.selection("FACE", "AngularCopy_1_1_2")])
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_2_1/Front"), 5, True)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("FACE", "Plane_1")])
+Compound_1_objects = [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"),
+ model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"),
+ model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r"),
+ model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r"),
+ model.selection("VERTEX", "Vertex_1_1"),
+ model.selection("EDGE", "Edge_1_1"),
+ model.selection("WIRE", "Wire_1_1"),
+ model.selection("FACE", "Face_1_1"),
+ model.selection("SHELL", "Shell_1_1"),
+ model.selection("SOLID", "Translation_1_1"),
+ model.selection("COMPSOLID", "Partition_1_1")]
+Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
+model.do()
+
+model.checkBooleansResult(Compound_1, model, 1, [11], [3], [22], [92], [186])
+
+model.end()
+
+assert(model.checkPythonDump())
--- /dev/null
+## Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(40, 0, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 0, 0, 40)
+SketchLine_3 = Sketch_1.addLine(0, 40, 40, 40)
+SketchLine_4 = Sketch_1.addLine(40, 40, 40, 0)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40)
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")])
+Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
+SketchLine_5 = Sketch_2.addLine(20, 0, 0, 0)
+SketchLine_6 = Sketch_2.addLine(0, 0, 0, 20)
+SketchLine_7 = Sketch_2.addLine(0, 20, 20, 20)
+SketchLine_8 = Sketch_2.addLine(20, 20, 20, 0)
+SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result())
+SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result())
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False)
+SketchLine_9 = SketchProjection_2.createdFeature()
+SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchLine_5.startPoint(), SketchLine_9.result())
+SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_9).startPoint(), SketchLine_5.endPoint())
+SketchConstraintEqual_2 = Sketch_2.setEqual(SketchLine_5.result(), SketchLine_6.result())
+SketchLine_10 = Sketch_2.addLine(20, 20, 20, 40)
+SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_10.startPoint())
+SketchLine_11 = Sketch_2.addLine(20, 40, 0, 40)
+SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
+SketchLine_12 = Sketch_2.addLine(0, 40, 0, 20)
+SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
+SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_12.endPoint())
+SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_10.result())
+SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_11.result())
+SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_12.result())
+SketchConstraintEqual_3 = Sketch_2.setEqual(SketchLine_6.result(), SketchLine_12.result())
+model.do()
+Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")])
+AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 270, 2)
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "AngularCopy_1_1_1"), model.selection("FACE", "AngularCopy_1_1_2")])
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7f-SketchLine_10f-SketchLine_11f-SketchLine_12f")], model.selection(), 40, 0)
+Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_13 = Sketch_3.addLine(40, 0, 20, 0)
+SketchLine_14 = Sketch_3.addLine(20, 0, 20, 40)
+SketchLine_15 = Sketch_3.addLine(20, 40, 40, 40)
+SketchLine_16 = Sketch_3.addLine(40, 40, 40, 0)
+SketchConstraintCoincidence_15 = Sketch_3.setCoincident(SketchLine_16.endPoint(), SketchLine_13.startPoint())
+SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
+SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
+SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
+SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_13.result())
+SketchConstraintVertical_7 = Sketch_3.setVertical(SketchLine_14.result())
+SketchConstraintHorizontal_7 = Sketch_3.setHorizontal(SketchLine_15.result())
+SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_16.result())
+SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_5s-SketchLine_15s-SketchLine_8e-SketchLine_14e"), False)
+SketchPoint_2 = SketchProjection_3.createdFeature()
+SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates())
+SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_11s-SketchLine_10e"), False)
+SketchPoint_3 = SketchProjection_4.createdFeature()
+SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchAPI_Point(SketchPoint_3).coordinates())
+SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e"), False)
+SketchPoint_4 = SketchProjection_5.createdFeature()
+SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_13.startPoint(), SketchAPI_Point(SketchPoint_4).coordinates())
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r")], model.selection(), 20, 0)
+Box_1 = model.addBox(Part_1_doc, 20, 20, 20)
+model.do()
+
+def createSolidStepByStep(theSelection, theExpected):
+ Solid = model.addSolid(Part_1_doc, [theSelection[0]])
+ aList = []
+ for selection, expected in zip(theSelection, theExpected):
+ aList.append(selection)
+ Solid.setBase(aList)
+ if expected:
+ assert(len(Solid.results()) > 0), "FAILED: Solid is not built"
+ else:
+ assert(len(Solid.results()) == 0), "FAILED: Solid should not be built"
+ # remove solid if it is not built
+ if len(Solid.results()) == 0:
+ Part_1_doc.removeFeature(Solid.feature())
+ return None
+ return Solid
+
+# =============================================================================
+# Test 1. Build solid from faces applicable for compsolid
+# =============================================================================
+boundaries1 = [model.selection("FACE", "Face_1_1"),
+ model.selection("SHELL", "Shell_1_1"),
+ model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"),
+ model.selection("FACE", "Extrusion_1_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_2"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_3"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_2_1/To_Face_1"),
+ model.selection("FACE", "Box_1_1/Front")]
+expectSolid1 = [False, False, False, False, False, False, False, True, False]
+Solid_1 = createSolidStepByStep(boundaries1, expectSolid1)
+assert(Solid_1 is None)
+
+# =============================================================================
+# Test 2. Build correct solid
+# =============================================================================
+boundaries2 = [model.selection("FACE", "Face_1_1"),
+ model.selection("SHELL", "Shell_1_1"),
+ model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"),
+ model.selection("FACE", "Extrusion_1_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_1_1/Generated_Face_3"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_3"),
+ model.selection("FACE", "Extrusion_2_1/Generated_Face_4"),
+ model.selection("FACE", "Extrusion_2_1/To_Face_1"),
+ model.selection("FACE", "Box_1_1/Front")]
+expectSolid2 = [False, False, False, False, False, False, False, False, True]
+Solid_2 = createSolidStepByStep(boundaries2, expectSolid2)
+
+model.checkBooleansResult(Solid_2, model, 1, [0], [1], [10], [44], [88])
+model.testHaveNamingSubshapes(Solid_2, model, Part_1_doc)
+
+model.end()
+
+assert(model.checkPythonDump())
--- /dev/null
+<!--
+Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+See http:##www.salome-platform.org/ or
+email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+-->
+
+<source>
+ <multi_selector id="base_objects"
+ label="Objects:"
+ tooltip="Select any kind of objects."
+ type_choice="vertices edges wires faces shells solids compsolids compounds"
+ concealment="true">
+ </multi_selector>
+</source>
--- /dev/null
+<!--
+Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+See http:##www.salome-platform.org/ or
+email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+-->
+
+<source>
+ <multi_selector id="base_objects"
+ label="Solids and CompSolids:"
+ tooltip="Select solids or compsolids."
+ type_choice="faces shells solids compsolids"
+ concealment="true">
+ </multi_selector>
+</source>
<feature id="Shell" title="Shell" tooltip ="Create a shell from faces or shells objects" icon="icons/Build/feature_shell.png">
<source path="shell_widget.xml"/>
</feature>
+ <feature id="Solid" title="Solid" tooltip ="Create a solid from faces or shells" icon="icons/Build/feature_solid.png">
+ <source path="solid_widget.xml"/>
+ </feature>
+ <feature id="CompSolid" title="CompSolid" tooltip ="Create a compsolid from solids or another compsolids" icon="icons/Build/feature_compsolid.png">
+ <source path="compsolid_widget.xml"/>
+ </feature>
+ <feature id="Compound" title="Compound" tooltip ="Create a compound of objects" icon="icons/Build/feature_compound.png">
+ <source path="compound_widget.xml"/>
+ </feature>
</group>
<group id="Modify">
<feature id="SubShapes" title="Sub-Shapes" tooltip ="Allows to add or to remove sub-shapes of the selected shape" icon="icons/Build/feature_subshapes.png">
--- /dev/null
+<!--
+Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+See http:##www.salome-platform.org/ or
+email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+-->
+
+<source>
+ <multi_selector id="base_objects"
+ label="Faces and shells:"
+ tooltip="Select faces or shells."
+ type_choice="faces shells"
+ concealment="true">
+ </multi_selector>
+</source>
#ifdef USE_OCCT_720
aVolumeMaker->SetAvoidInternalShapes(true);
#endif
- aVolumeMaker->SetGlue(BOPAlgo_GlueShift);
+ aVolumeMaker->SetGlue(BOPAlgo_GlueOff);
// building and getting result
aVolumeMaker->Perform();
"""Package for Build plugin for the Parametric Geometry API of the Modeler.
"""
-from BuildAPI import addVertex, addEdge, addWire, addFace, addShell
+from BuildAPI import addVertex, addEdge, addWire, addFace, addShell, addSolid, addCompSolid, addCompound
from BuildAPI import addSubShapes
from BuildAPI import addFilling