From: azv Date: Fri, 22 Dec 2017 14:32:44 +0000 (+0300) Subject: Issue #2386: New build features: Solid, Compsolid, Compound X-Git-Tag: V_2.10.1~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dfa8d5cc9a33eb949f364e1999dc36e75fd1ffe8;p=modules%2Fshaper.git 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 --- 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 000000000..800dc6f52 Binary files /dev/null and b/src/BuildPlugin/icons/feature_compound.png differ diff --git a/src/BuildPlugin/icons/feature_compsolid.png b/src/BuildPlugin/icons/feature_compsolid.png new file mode 100644 index 000000000..6fdf0dbf3 Binary files /dev/null and b/src/BuildPlugin/icons/feature_compsolid.png differ diff --git a/src/BuildPlugin/icons/feature_filling.png b/src/BuildPlugin/icons/feature_filling.png index ef16696bb..e8a46f662 100644 Binary files a/src/BuildPlugin/icons/feature_filling.png and b/src/BuildPlugin/icons/feature_filling.png differ diff --git a/src/BuildPlugin/icons/feature_solid.png b/src/BuildPlugin/icons/feature_solid.png new file mode 100644 index 000000000..84dca6be1 Binary files /dev/null and b/src/BuildPlugin/icons/feature_solid.png differ diff --git a/src/BuildPlugin/plugin-Build.xml b/src/BuildPlugin/plugin-Build.xml index 4fde67f69..2d98507d6 100644 --- a/src/BuildPlugin/plugin-Build.xml +++ b/src/BuildPlugin/plugin-Build.xml @@ -37,6 +37,15 @@ email : webmaster.salome@opencascade.com + + + + + + + + + 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