From dfa8d5cc9a33eb949f364e1999dc36e75fd1ffe8 Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 22 Dec 2017 17:32:44 +0300 Subject: [PATCH] Issue #2386: New build features: Solid, Compsolid, Compound 1. Implementation of Solid, Compsolid and Compound Features 2. Python API and Python dump 3. Unit tests --- src/BuildAPI/BuildAPI.i | 6 + src/BuildAPI/BuildAPI_CompSolid.cpp | 71 ++++++++ src/BuildAPI/BuildAPI_CompSolid.h | 74 ++++++++ src/BuildAPI/BuildAPI_Compound.cpp | 71 ++++++++ src/BuildAPI/BuildAPI_Compound.h | 74 ++++++++ src/BuildAPI/BuildAPI_Solid.cpp | 71 ++++++++ src/BuildAPI/BuildAPI_Solid.h | 74 ++++++++ src/BuildAPI/BuildAPI_swig.h | 3 + src/BuildAPI/CMakeLists.txt | 6 + src/BuildPlugin/BuildPlugin_CompSolid.cpp | 58 ++++++ src/BuildPlugin/BuildPlugin_CompSolid.h | 64 +++++++ src/BuildPlugin/BuildPlugin_Compound.cpp | 84 +++++++++ src/BuildPlugin/BuildPlugin_Compound.h | 65 +++++++ src/BuildPlugin/BuildPlugin_Filling.cpp | 4 +- src/BuildPlugin/BuildPlugin_Filling.h | 2 +- src/BuildPlugin/BuildPlugin_Plugin.cpp | 9 + src/BuildPlugin/BuildPlugin_Solid.cpp | 155 ++++++++++++++++ src/BuildPlugin/BuildPlugin_Solid.h | 88 +++++++++ src/BuildPlugin/CMakeLists.txt | 12 ++ src/BuildPlugin/Test/TestCompSolid.py | 186 ++++++++++++++++++++ src/BuildPlugin/Test/TestCompound.py | 91 ++++++++++ src/BuildPlugin/Test/TestSolid.py | 162 +++++++++++++++++ src/BuildPlugin/compound_widget.xml | 29 +++ src/BuildPlugin/compsolid_widget.xml | 29 +++ src/BuildPlugin/icons/feature_compound.png | Bin 0 -> 904 bytes src/BuildPlugin/icons/feature_compsolid.png | Bin 0 -> 900 bytes src/BuildPlugin/icons/feature_filling.png | Bin 592 -> 635 bytes src/BuildPlugin/icons/feature_solid.png | Bin 0 -> 835 bytes src/BuildPlugin/plugin-Build.xml | 9 + src/BuildPlugin/solid_widget.xml | 29 +++ src/GeomAlgoAPI/GeomAlgoAPI_MakeVolume.cpp | 2 +- src/PythonAPI/model/build/__init__.py | 2 +- 32 files changed, 1525 insertions(+), 5 deletions(-) create mode 100644 src/BuildAPI/BuildAPI_CompSolid.cpp create mode 100644 src/BuildAPI/BuildAPI_CompSolid.h create mode 100644 src/BuildAPI/BuildAPI_Compound.cpp create mode 100644 src/BuildAPI/BuildAPI_Compound.h create mode 100644 src/BuildAPI/BuildAPI_Solid.cpp create mode 100644 src/BuildAPI/BuildAPI_Solid.h create mode 100644 src/BuildPlugin/BuildPlugin_CompSolid.cpp create mode 100644 src/BuildPlugin/BuildPlugin_CompSolid.h create mode 100644 src/BuildPlugin/BuildPlugin_Compound.cpp create mode 100644 src/BuildPlugin/BuildPlugin_Compound.h create mode 100644 src/BuildPlugin/BuildPlugin_Solid.cpp create mode 100644 src/BuildPlugin/BuildPlugin_Solid.h create mode 100644 src/BuildPlugin/Test/TestCompSolid.py create mode 100644 src/BuildPlugin/Test/TestCompound.py create mode 100644 src/BuildPlugin/Test/TestSolid.py create mode 100644 src/BuildPlugin/compound_widget.xml create mode 100644 src/BuildPlugin/compsolid_widget.xml create mode 100644 src/BuildPlugin/icons/feature_compound.png create mode 100644 src/BuildPlugin/icons/feature_compsolid.png create mode 100644 src/BuildPlugin/icons/feature_solid.png create mode 100644 src/BuildPlugin/solid_widget.xml diff --git a/src/BuildAPI/BuildAPI.i b/src/BuildAPI/BuildAPI.i index 8977df7ce..a9c01420a 100644 --- a/src/BuildAPI/BuildAPI.i +++ b/src/BuildAPI/BuildAPI.i @@ -39,19 +39,25 @@ %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" diff --git a/src/BuildAPI/BuildAPI_CompSolid.cpp b/src/BuildAPI/BuildAPI_CompSolid.cpp new file mode 100644 index 000000000..fbe84fc25 --- /dev/null +++ b/src/BuildAPI/BuildAPI_CompSolid.cpp @@ -0,0 +1,71 @@ +// 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 +// + +#include "BuildAPI_CompSolid.h" + +#include +#include + +//================================================================================================== +BuildAPI_CompSolid::BuildAPI_CompSolid(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +BuildAPI_CompSolid::BuildAPI_CompSolid(const std::shared_ptr& theFeature, + const std::list& theBaseObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBaseObjects); + } +} + +//================================================================================================== +BuildAPI_CompSolid::~BuildAPI_CompSolid() +{ +} + +//================================================================================================== +void BuildAPI_CompSolid::setBase(const std::list& 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& thePart, + const std::list& theBaseObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(BuildAPI_CompSolid::ID()); + return CompSolidPtr(new BuildAPI_CompSolid(aFeature, theBaseObjects)); +} diff --git a/src/BuildAPI/BuildAPI_CompSolid.h b/src/BuildAPI/BuildAPI_CompSolid.h new file mode 100644 index 000000000..c3652e549 --- /dev/null +++ b/src/BuildAPI/BuildAPI_CompSolid.h @@ -0,0 +1,74 @@ +// 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 +// + +#ifndef BuildAPI_CompSolid_H_ +#define BuildAPI_CompSolid_H_ + +#include "BuildAPI.h" + +#include + +#include +#include + +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& theFeature); + + /// Constructor with values. + BUILDAPI_EXPORT + explicit BuildAPI_CompSolid(const std::shared_ptr& theFeature, + const std::list& 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& theBaseObjects); + + /// Dump wrapped feature + BUILDAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on CompSolid object. +typedef std::shared_ptr CompSolidPtr; + +/// \ingroup CPPHighAPI +/// \brief Create CompSolid feature. +BUILDAPI_EXPORT +CompSolidPtr addCompSolid(const std::shared_ptr& thePart, + const std::list& theBaseObjects); + +#endif // BuildAPI_CompSolid_H_ diff --git a/src/BuildAPI/BuildAPI_Compound.cpp b/src/BuildAPI/BuildAPI_Compound.cpp new file mode 100644 index 000000000..5f036566a --- /dev/null +++ b/src/BuildAPI/BuildAPI_Compound.cpp @@ -0,0 +1,71 @@ +// 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 +// + +#include "BuildAPI_Compound.h" + +#include +#include + +//================================================================================================== +BuildAPI_Compound::BuildAPI_Compound(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +BuildAPI_Compound::BuildAPI_Compound(const std::shared_ptr& theFeature, + const std::list& theBaseObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBaseObjects); + } +} + +//================================================================================================== +BuildAPI_Compound::~BuildAPI_Compound() +{ +} + +//================================================================================================== +void BuildAPI_Compound::setBase(const std::list& 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& thePart, + const std::list& theBaseObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(BuildAPI_Compound::ID()); + return CompoundPtr(new BuildAPI_Compound(aFeature, theBaseObjects)); +} diff --git a/src/BuildAPI/BuildAPI_Compound.h b/src/BuildAPI/BuildAPI_Compound.h new file mode 100644 index 000000000..80daee6f8 --- /dev/null +++ b/src/BuildAPI/BuildAPI_Compound.h @@ -0,0 +1,74 @@ +// 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 +// + +#ifndef BuildAPI_Compound_H_ +#define BuildAPI_Compound_H_ + +#include "BuildAPI.h" + +#include + +#include +#include + +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& theFeature); + + /// Constructor with values. + BUILDAPI_EXPORT + explicit BuildAPI_Compound(const std::shared_ptr& theFeature, + const std::list& 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& theBaseObjects); + + /// Dump wrapped feature + BUILDAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Compound object. +typedef std::shared_ptr CompoundPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Compound feature. +BUILDAPI_EXPORT +CompoundPtr addCompound(const std::shared_ptr& thePart, + const std::list& theBaseObjects); + +#endif // BuildAPI_Compound_H_ diff --git a/src/BuildAPI/BuildAPI_Solid.cpp b/src/BuildAPI/BuildAPI_Solid.cpp new file mode 100644 index 000000000..a2c7892a1 --- /dev/null +++ b/src/BuildAPI/BuildAPI_Solid.cpp @@ -0,0 +1,71 @@ +// 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 +// + +#include "BuildAPI_Solid.h" + +#include +#include + +//================================================================================================== +BuildAPI_Solid::BuildAPI_Solid(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +BuildAPI_Solid::BuildAPI_Solid(const std::shared_ptr& theFeature, + const std::list& theBaseObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBaseObjects); + } +} + +//================================================================================================== +BuildAPI_Solid::~BuildAPI_Solid() +{ +} + +//================================================================================================== +void BuildAPI_Solid::setBase(const std::list& 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& thePart, + const std::list& theBaseObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(BuildAPI_Solid::ID()); + return SolidPtr(new BuildAPI_Solid(aFeature, theBaseObjects)); +} diff --git a/src/BuildAPI/BuildAPI_Solid.h b/src/BuildAPI/BuildAPI_Solid.h new file mode 100644 index 000000000..1ab00044b --- /dev/null +++ b/src/BuildAPI/BuildAPI_Solid.h @@ -0,0 +1,74 @@ +// 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 +// + +#ifndef BuildAPI_Solid_H_ +#define BuildAPI_Solid_H_ + +#include "BuildAPI.h" + +#include + +#include +#include + +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& theFeature); + + /// Constructor with values. + BUILDAPI_EXPORT + explicit BuildAPI_Solid(const std::shared_ptr& theFeature, + const std::list& 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& theBaseObjects); + + /// Dump wrapped feature + BUILDAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Solid object. +typedef std::shared_ptr SolidPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Solid feature. +BUILDAPI_EXPORT +SolidPtr addSolid(const std::shared_ptr& thePart, + const std::list& theBaseObjects); + +#endif // BuildAPI_Solid_H_ diff --git a/src/BuildAPI/BuildAPI_swig.h b/src/BuildAPI/BuildAPI_swig.h index 96ee58c0e..616486f64 100644 --- a/src/BuildAPI/BuildAPI_swig.h +++ b/src/BuildAPI/BuildAPI_swig.h @@ -23,10 +23,13 @@ #include + #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" diff --git a/src/BuildAPI/CMakeLists.txt b/src/BuildAPI/CMakeLists.txt index bf4951210..2e0358404 100644 --- a/src/BuildAPI/CMakeLists.txt +++ b/src/BuildAPI/CMakeLists.txt @@ -22,20 +22,26 @@ INCLUDE(Common) 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 diff --git a/src/BuildPlugin/BuildPlugin_CompSolid.cpp b/src/BuildPlugin/BuildPlugin_CompSolid.cpp new file mode 100644 index 000000000..8b19e13f3 --- /dev/null +++ b/src/BuildPlugin/BuildPlugin_CompSolid.cpp @@ -0,0 +1,58 @@ +// 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 +// + +#include "BuildPlugin_CompSolid.h" + +#include +#include + +//================================================================================================= +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 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); +} diff --git a/src/BuildPlugin/BuildPlugin_CompSolid.h b/src/BuildPlugin/BuildPlugin_CompSolid.h new file mode 100644 index 000000000..e31865a13 --- /dev/null +++ b/src/BuildPlugin/BuildPlugin_CompSolid.h @@ -0,0 +1,64 @@ +// 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 +// + +#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 diff --git a/src/BuildPlugin/BuildPlugin_Compound.cpp b/src/BuildPlugin/BuildPlugin_Compound.cpp new file mode 100644 index 000000000..4df84ee1f --- /dev/null +++ b/src/BuildPlugin/BuildPlugin_Compound.cpp @@ -0,0 +1,84 @@ +// 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 +// + +#include "BuildPlugin_Compound.h" + +#include +#include + +#include + + +//================================================================================================= +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 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); +} diff --git a/src/BuildPlugin/BuildPlugin_Compound.h b/src/BuildPlugin/BuildPlugin_Compound.h new file mode 100644 index 000000000..5a014314c --- /dev/null +++ b/src/BuildPlugin/BuildPlugin_Compound.h @@ -0,0 +1,65 @@ +// 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 +// + +#ifndef BuildPlugin_Compound_H_ +#define BuildPlugin_Compound_H_ + +#include "BuildPlugin.h" + +#include + +/// \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 diff --git a/src/BuildPlugin/BuildPlugin_Filling.cpp b/src/BuildPlugin/BuildPlugin_Filling.cpp index e9b376399..7e2c884ce 100644 --- a/src/BuildPlugin/BuildPlugin_Filling.cpp +++ b/src/BuildPlugin/BuildPlugin_Filling.cpp @@ -114,7 +114,7 @@ void BuildPlugin_Filling::execute() // build result aFilling->build(aParameters.isApprox); - if (isFailed(aFilling)) { + if (isAlgorithmFailed(aFilling)) { removeResults(0); return; } @@ -132,7 +132,7 @@ void BuildPlugin_Filling::execute() setResult(aResultBody, 0); } -bool BuildPlugin_Filling::isFailed( +bool BuildPlugin_Filling::isAlgorithmFailed( const std::shared_ptr& theAlgorithm) { if (!theAlgorithm->isDone()) { diff --git a/src/BuildPlugin/BuildPlugin_Filling.h b/src/BuildPlugin/BuildPlugin_Filling.h index e4a23b609..cb19f063f 100644 --- a/src/BuildPlugin/BuildPlugin_Filling.h +++ b/src/BuildPlugin/BuildPlugin_Filling.h @@ -165,7 +165,7 @@ public: private: /// Check the filling algorithm is failed - bool isFailed(const std::shared_ptr& theAlgorithm); + bool isAlgorithmFailed(const std::shared_ptr& theAlgorithm); /// Convert shape to edge according to construction method std::shared_ptr toEdge(const std::shared_ptr& theShape, diff --git a/src/BuildPlugin/BuildPlugin_Plugin.cpp b/src/BuildPlugin/BuildPlugin_Plugin.cpp index 2042eb2f1..7915c1447 100644 --- a/src/BuildPlugin/BuildPlugin_Plugin.cpp +++ b/src/BuildPlugin/BuildPlugin_Plugin.cpp @@ -28,6 +28,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -69,6 +72,12 @@ FeaturePtr BuildPlugin_Plugin::createFeature(std::string theFeatureID) 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()) { diff --git a/src/BuildPlugin/BuildPlugin_Solid.cpp b/src/BuildPlugin/BuildPlugin_Solid.cpp new file mode 100644 index 000000000..1066c3f58 --- /dev/null +++ b/src/BuildPlugin/BuildPlugin_Solid.cpp @@ -0,0 +1,155 @@ +// 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 +// + +#include "BuildPlugin_Solid.h" + +#include +#include + +#include + +#include + +//================================================================================================= +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 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& 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(new GeomAlgoAPI_MakeVolume(theOriginalShapes)); + return !isAlgorithmFailed(theAlgorithm); +} + +void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes, + const GeomShapePtr& theResultShape, + const std::shared_ptr& theAlgorithm) +{ + ResultBodyPtr aResultBody = document()->createBody(data()); + aResultBody->store(theResultShape); + + // Store faces + std::shared_ptr 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& 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; +} diff --git a/src/BuildPlugin/BuildPlugin_Solid.h b/src/BuildPlugin/BuildPlugin_Solid.h new file mode 100644 index 000000000..549ee49d0 --- /dev/null +++ b/src/BuildPlugin/BuildPlugin_Solid.h @@ -0,0 +1,88 @@ +// 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 +// + +#ifndef BuildPlugin_Solid_H_ +#define BuildPlugin_Solid_H_ + +#include "BuildPlugin.h" + +#include +#include + +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& theAlgorithm); + + /// Store result of algorithm + void storeResult(const ListOfShape& theOriginalShapes, + const GeomShapePtr& theResultShape, + const std::shared_ptr& theAlgorithm); + + /// Check the algorithm is failed + bool isAlgorithmFailed(const std::shared_ptr& 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 diff --git a/src/BuildPlugin/CMakeLists.txt b/src/BuildPlugin/CMakeLists.txt index aeba2d0bc..61497aa7c 100644 --- a/src/BuildPlugin/CMakeLists.txt +++ b/src/BuildPlugin/CMakeLists.txt @@ -37,6 +37,9 @@ SET(PROJECT_HEADERS 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 @@ -49,6 +52,9 @@ SET(PROJECT_SOURCES 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 @@ -61,6 +67,9 @@ SET(XML_RESOURCES wire_widget.xml face_widget.xml shell_widget.xml + solid_widget.xml + compsolid_widget.xml + compound_widget.xml subshapes_widget.xml filling_widget.xml ) @@ -94,6 +103,9 @@ ADD_UNIT_TESTS(TestVertex.py TestWire.py TestFace.py TestShell.py + TestSolid.py + TestCompSolid.py + TestCompound.py TestSubShapes.py TestFilling_ByEdges.py TestFilling_ByWires.py diff --git a/src/BuildPlugin/Test/TestCompSolid.py b/src/BuildPlugin/Test/TestCompSolid.py new file mode 100644 index 000000000..824358d77 --- /dev/null +++ b/src/BuildPlugin/Test/TestCompSolid.py @@ -0,0 +1,186 @@ +## 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 +## + +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()) diff --git a/src/BuildPlugin/Test/TestCompound.py b/src/BuildPlugin/Test/TestCompound.py new file mode 100644 index 000000000..6a25a8ec7 --- /dev/null +++ b/src/BuildPlugin/Test/TestCompound.py @@ -0,0 +1,91 @@ +## 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 +## + +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()) diff --git a/src/BuildPlugin/Test/TestSolid.py b/src/BuildPlugin/Test/TestSolid.py new file mode 100644 index 000000000..2c9672d53 --- /dev/null +++ b/src/BuildPlugin/Test/TestSolid.py @@ -0,0 +1,162 @@ +## 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 +## + +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()) diff --git a/src/BuildPlugin/compound_widget.xml b/src/BuildPlugin/compound_widget.xml new file mode 100644 index 000000000..32efcf2d2 --- /dev/null +++ b/src/BuildPlugin/compound_widget.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/src/BuildPlugin/compsolid_widget.xml b/src/BuildPlugin/compsolid_widget.xml new file mode 100644 index 000000000..61f18f7aa --- /dev/null +++ b/src/BuildPlugin/compsolid_widget.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/src/BuildPlugin/icons/feature_compound.png b/src/BuildPlugin/icons/feature_compound.png new file mode 100644 index 0000000000000000000000000000000000000000..800dc6f52e4a418ae4cea0450be9df3661401b63 GIT binary patch literal 904 zcmV;319$w1P){1@-MdAKaf&I)+*T_?W#=|fjCnSAgJpmo!Yxmoza`x)=AA9u1~L6HuE+yGuqqRD?1`57j0FEb`3OtaW@w%2Uq|Uh;2Vp|JQVN zw;cYg%vse809ZBtB|MK#_t!+sZ3+M+lgSK_1c1YtpFbb~-vAg5g+f!_^1mx}PY&t8 zM%V!I!#B};&W6X;^2)dG5YbZ4WEe(R)3g!Gvb=8ROvklXV!zfB)~WQP$D}>saTQTgref!!bF{$T37A zVUdtc30w@4l9ZTWLZWB{FCZowxiH?j3lkF$(P|_PbPmSIAR#8ui78Wa^vD{~1#2oVSbwjDp( z-ZXMn+qY?DxUXm_&6Xuv{1v~yHFtmBfs=2xomLd3f6{bE{>a$BZ187Sc)dE69+RD` ze?BsNPCo%c{393$1P*Ab_4=B+q1)S6{nBzZ+Eh0%)B?cX-8zMp@BXD^rCBm|6o+vJ zGiU4hq`&Q}q*>anu3NkMf+f|uWZK@))a-MW_zwuhxq@eFZqQ)+0Su4?9c!(R94hy(#hLt?(%db~vK>f8CsnqQSfY|k12ardOdu4M zCAIa``0`X0LM*Ske?$XN6pN&5AL+8^$=v#gAHF@o!o{_0+W#u*(hh73B4l%t^6FXu z?9MV8mfggHQEj#Z)2@TuOc)Tp*5 zaW%rybsZS7lQ=vc+?7uOpenGiH2WAan=e7vb7({Hx?@F4Vbr+6i;b_~tf-=MYd?l_ zFAx8<`!QS}7$h3mkH>DjrW7sF2k^8ziud6uV1Bd*BZA(+Rp{~0slL}CV|SuR35glU zb80v|c&4{I^y$HEKkByhwe=;r5lV6+WEV7H+BcIP{*Fr*M;V`X;z(Vj-hJ)2Tv6+d zC&~>=YVU~IWg0%GAB!iv?{|kc3-_WT?X8!se8yBh?rWEsyv}mpz2k43I{)5(cER74 z|KO)zH}oY;2P1J855{d*YL%c#s1T(7EJUGpp_U+$lqyzZV_Pa_CP|sO zF0^H+Noel!zVDoO&wH1c8MT&S7*S>(CZZ9!67*tzUNzSOM}H);yB(m5Ksx~VK=7$r z-5x7%3W9UxKZ67y>FK4bfd85xM`aMm4KT3(U>F~#-*UZbJ|K65r*pY>+mtU!BY*vU0V~oN-*0G!5o`; zG~QFAmH|Kzuzv&qy7)P(B%kQ*@GnQB z(Ykm%Zk06vfXrj%7{hnJ=-u1$BXmnCdD}t6mwLlZV{WdZ0RUts)i#zr6Uh(94}HqE zN{ZHC+`JLH>t;kHF#v?m6w=e_=Kgn?kYxV0u)6r|+-9b#0RZ$5y`K}rcLX_EBD%f# a{12QMyAk~LXv6>j0000$XD;HL@Dujw_2?`bzbRj7FMcH`+5hX zf(X|{RojA3-WB6&$t55O;C`4OSbmisNfo!)8$p@(Ut*?ej;L@POOlORaP2MP|I7l| zBH{pJp-3ci|3z*yLJF0Xh1sowG#k&|y2{+m0*Rf{{a_4i+mNYw>~drM9$-*_jh}UI z<~GF=WS(gP;D1jOyQ+((@9Ukm{Wv%}@zNLyl`7K!0ysncoVa_%8h3{{uo6DWa_llH zfmVF>dnI~kayylJ;O`V>#ViG_X%)_uLwmeWZraprXFYDoXmVR5(-`_^j7yK~Nwp;H zS>eEEcg9}bw7)Kuo)1R{E`q<#v$@8t$7-{_*5bxn$z{9waSfMl)TK%@+|mGG_^7_2 zT-~eUJsvDf;e0%c@mE8wa@*`Zl6z>K&!&yPW2DOu26zoPjXD4Ic@D?rI=`1gfioQ& i0FG@~unh~%75oBmg-1BdW(S7=0000DW`K~y-6jgxCgQ*ju^pZA>8IcLu4+@+OS870)RSXq=>K?Hp< zM7r1oi~{XKMMXr^mm>O@5EX)>Ai5Y45d}q{DV1Ro(#0-9=8dIpZENdTJ7@F!|9z8m z3B8}6-;d|R`w-_Glij|()pd-c0uT=Q{r-FZ$_SIe?G5g&jMIM3X?l(|em>Afmj4p; zJ(hhvk23B#>_Xk*0*zU%0#+6FPBWsJjXe+LWfSwnIY&)RjYlBXWL1pZ?WO7!mS>*r(sEIdlhfb$t{Zm*pwM)7&TI=1ylVgJF>gp;Yx()y(B`(Y;JqRX@Z!E9` z9FYsijx}gq{r0bookii_hFmKFz?tAdil1&?E(=|ATpyYVOgPalEw*w zy&Ol4)|}y55Z3_!8Co+KWEkoq5Z9p&`7s>$ z4#o+CF}H8*4*=lPU6L&p>99$*BZgY&3VF`To}uFaH+j^3lpNuUhMeq)HNEq8y&oum z$)}vCudi>XiDT-2C@)Eoa-ln1u)Oi@0?SO-Pn0cfkBEGvnV5NQPPy^^?|hm70Q# + + + + + + + + + diff --git a/src/BuildPlugin/solid_widget.xml b/src/BuildPlugin/solid_widget.xml new file mode 100644 index 000000000..9f2b49cd8 --- /dev/null +++ b/src/BuildPlugin/solid_widget.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeVolume.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeVolume.cpp index 0dc7ef9a7..c942dd1cb 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeVolume.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeVolume.cpp @@ -68,7 +68,7 @@ void GeomAlgoAPI_MakeVolume::build(const ListOfShape& theFaces) #ifdef USE_OCCT_720 aVolumeMaker->SetAvoidInternalShapes(true); #endif - aVolumeMaker->SetGlue(BOPAlgo_GlueShift); + aVolumeMaker->SetGlue(BOPAlgo_GlueOff); // building and getting result aVolumeMaker->Perform(); diff --git a/src/PythonAPI/model/build/__init__.py b/src/PythonAPI/model/build/__init__.py index ed30370e4..ad57a024e 100644 --- a/src/PythonAPI/model/build/__init__.py +++ b/src/PythonAPI/model/build/__init__.py @@ -1,6 +1,6 @@ """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 -- 2.30.2