From: dbv Date: Sun, 1 Jul 2018 17:50:53 +0000 (+0300) Subject: 3.6 Separation of Boolean operations X-Git-Tag: SHAPER_V9_1_0RC1~147 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=50cef8966d30d658565b08428b4b313f3449d23c;p=modules%2Fshaper.git 3.6 Separation of Boolean operations --- diff --git a/src/CollectionPlugin/Test/TestGroup.py b/src/CollectionPlugin/Test/TestGroup.py index ca834e5df..0ecbd0ddc 100644 --- a/src/CollectionPlugin/Test/TestGroup.py +++ b/src/CollectionPlugin/Test/TestGroup.py @@ -234,11 +234,9 @@ aCylinderBody = modelAPI_ResultBody(anExtrusionFt.firstResult()) # Create a cut #========================================================================= aSession.startOperation() -aBooleanFt = aPart.addFeature("Boolean") +aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(anExtrusionBody, None) aBooleanFt.selectionList("tool_objects").append(aCylinderBody, None) -aBooleanTypeCut = 0 -aBooleanFt.integer("bool_type").setValue(aBooleanTypeCut) aBooleanFt.execute() aSession.finishOperation() diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index 83e853688..b511fc640 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -22,7 +22,11 @@ INCLUDE(Common) SET(PROJECT_HEADERS FeaturesAPI.h - FeaturesAPI_Boolean.h + FeaturesAPI_BooleanCut.h + FeaturesAPI_BooleanFuse.h + FeaturesAPI_BooleanCommon.h + FeaturesAPI_BooleanSmash.h + FeaturesAPI_BooleanFill.h FeaturesAPI_Extrusion.h FeaturesAPI_ExtrusionBoolean.h FeaturesAPI_Fillet.h @@ -45,7 +49,11 @@ SET(PROJECT_HEADERS ) SET(PROJECT_SOURCES - FeaturesAPI_Boolean.cpp + FeaturesAPI_BooleanCut.cpp + FeaturesAPI_BooleanFuse.cpp + FeaturesAPI_BooleanCommon.cpp + FeaturesAPI_BooleanSmash.cpp + FeaturesAPI_BooleanFill.cpp FeaturesAPI_Extrusion.cpp FeaturesAPI_ExtrusionBoolean.cpp FeaturesAPI_Fillet.cpp diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index 01d1c9197..dd6b5897f 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -39,7 +39,11 @@ %include "std_shared_ptr.i" // shared pointers -%shared_ptr(FeaturesAPI_Boolean) +%shared_ptr(FeaturesAPI_BooleanCut) +%shared_ptr(FeaturesAPI_BooleanFuse) +%shared_ptr(FeaturesAPI_BooleanCommon) +%shared_ptr(FeaturesAPI_BooleanSmash) +%shared_ptr(FeaturesAPI_BooleanFill) %shared_ptr(FeaturesAPI_Extrusion) %shared_ptr(FeaturesAPI_ExtrusionBoolean) %shared_ptr(FeaturesAPI_ExtrusionCut) @@ -64,7 +68,11 @@ %shared_ptr(FeaturesAPI_Union) // all supported interfaces -%include "FeaturesAPI_Boolean.h" +%include "FeaturesAPI_BooleanCut.h" +%include "FeaturesAPI_BooleanFuse.h" +%include "FeaturesAPI_BooleanCommon.h" +%include "FeaturesAPI_BooleanSmash.h" +%include "FeaturesAPI_BooleanFill.h" %include "FeaturesAPI_Extrusion.h" %include "FeaturesAPI_ExtrusionBoolean.h" %include "FeaturesAPI_Fillet.h" diff --git a/src/FeaturesAPI/FeaturesAPI_Boolean.cpp b/src/FeaturesAPI/FeaturesAPI_Boolean.cpp deleted file mode 100644 index dda440542..000000000 --- a/src/FeaturesAPI/FeaturesAPI_Boolean.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2014-2017 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 "FeaturesAPI_Boolean.h" - -#include -#include -#include -#include - -//================================================================================================== -FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr& theFeature) -: ModelHighAPI_Interface(theFeature) -{ - initialize(); -} - -//================================================================================================== -FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr& theFeature, - const ModelHighAPI_Integer& theBoolType, - const std::list& theMainObjects, - const std::list& theToolObjects) -: ModelHighAPI_Interface(theFeature) -{ - if(initialize()) { - fillAttribute(theBoolType, myboolType); - fillAttribute(theMainObjects, mymainObjects); - fillAttribute(theToolObjects, mytoolObjects); - - execute(false); - } -} - -//================================================================================================== -FeaturesAPI_Boolean::~FeaturesAPI_Boolean() -{ - -} - -//================================================================================================== -void FeaturesAPI_Boolean::setBoolType(const ModelHighAPI_Integer& theBoolType) -{ - fillAttribute(theBoolType, myboolType); - - execute(); -} - -//================================================================================================== -void FeaturesAPI_Boolean::setMainObjects(const std::list& theMainObjects) -{ - fillAttribute(theMainObjects, mymainObjects); - - execute(); -} - -//================================================================================================== -void FeaturesAPI_Boolean::setToolObjects(const std::list& theToolObjects) -{ - fillAttribute(theToolObjects, mytoolObjects); - - execute(); -} - -//================================================================================================== -void FeaturesAPI_Boolean::dump(ModelHighAPI_Dumper& theDumper) const -{ - FeaturePtr aBase = feature(); - - FeaturesPlugin_Boolean::OperationType aType = - (FeaturesPlugin_Boolean::OperationType)aBase->integer( - FeaturesPlugin_Boolean::TYPE_ID())->value(); - - theDumper << aBase << " = model.add"; - - switch(aType) { - case FeaturesPlugin_Boolean::BOOL_CUT: theDumper << "Cut"; break; - case FeaturesPlugin_Boolean::BOOL_FUSE: theDumper << "Fuse"; break; - case FeaturesPlugin_Boolean::BOOL_COMMON: theDumper << "Common"; break; - case FeaturesPlugin_Boolean::BOOL_FILL: theDumper << "Fill"; break; - case FeaturesPlugin_Boolean::BOOL_SMASH: theDumper << "Smash"; break; - } - - const std::string& aDocName = theDumper.name(aBase->document()); - AttributeSelectionListPtr anObjects = - aBase->selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID()); - AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID()); - - theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl; -} - -//================================================================================================== -BooleanPtr addCut(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID()); - return BooleanPtr(new FeaturesAPI_Boolean(aFeature, - FeaturesPlugin_Boolean::BOOL_CUT, - theMainObjects, - theToolObjects)); -} - -//================================================================================================== -BooleanPtr addFuse(const std::shared_ptr& thePart, - const std::list& theObjects) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID()); - std::list aToolObjects; - return BooleanPtr(new FeaturesAPI_Boolean(aFeature, - FeaturesPlugin_Boolean::BOOL_FUSE, - theObjects, - aToolObjects)); -} - -//================================================================================================== -BooleanPtr addFuse(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID()); - return BooleanPtr(new FeaturesAPI_Boolean(aFeature, - FeaturesPlugin_Boolean::BOOL_FUSE, - theMainObjects, - theToolObjects)); -} - -//================================================================================================== -BooleanPtr addCommon(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID()); - return BooleanPtr(new FeaturesAPI_Boolean(aFeature, - FeaturesPlugin_Boolean::BOOL_COMMON, - theMainObjects, - theToolObjects)); -} - -//================================================================================================== -BooleanPtr addSmash(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID()); - return BooleanPtr(new FeaturesAPI_Boolean(aFeature, - FeaturesPlugin_Boolean::BOOL_SMASH, - theMainObjects, - theToolObjects)); -} - -//================================================================================================== -BooleanPtr addFill(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID()); - return BooleanPtr(new FeaturesAPI_Boolean(aFeature, - FeaturesPlugin_Boolean::BOOL_FILL, - theMainObjects, - theToolObjects)); -} diff --git a/src/FeaturesAPI/FeaturesAPI_Boolean.h b/src/FeaturesAPI/FeaturesAPI_Boolean.h deleted file mode 100644 index 7b1b25e31..000000000 --- a/src/FeaturesAPI/FeaturesAPI_Boolean.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2014-2017 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 FeaturesAPI_Boolean_H_ -#define FeaturesAPI_Boolean_H_ - -#include "FeaturesAPI.h" - -#include - -#include -#include - -class ModelHighAPI_Integer; -class ModelHighAPI_Selection; - -/// \class FeaturesAPI_Boolean -/// \ingroup CPPHighAPI -/// \brief Interface for Boolean feature. -class FeaturesAPI_Boolean: public ModelHighAPI_Interface -{ -public: - /// Constructor without values. - FEATURESAPI_EXPORT - explicit FeaturesAPI_Boolean(const std::shared_ptr& theFeature); - - /// Constructor with values. - FEATURESAPI_EXPORT - FeaturesAPI_Boolean(const std::shared_ptr& theFeature, - const ModelHighAPI_Integer& theBoolType, - const std::list& theMainObjects, - const std::list& theToolObjects); - - /// Destructor. - FEATURESAPI_EXPORT - virtual ~FeaturesAPI_Boolean(); - - INTERFACE_3(FeaturesPlugin_Boolean::ID(), - boolType, FeaturesPlugin_Boolean::TYPE_ID(), - ModelAPI_AttributeInteger, /** Operation type */, - mainObjects, FeaturesPlugin_Boolean::OBJECT_LIST_ID(), - ModelAPI_AttributeSelectionList, /** Main objects */, - toolObjects, FeaturesPlugin_Boolean::TOOL_LIST_ID(), - ModelAPI_AttributeSelectionList, /** Tool objects*/) - - /// Set operation type. - FEATURESAPI_EXPORT - void setBoolType(const ModelHighAPI_Integer& theBoolType); - - /// Set main objects. - FEATURESAPI_EXPORT - void setMainObjects(const std::list& theMainObjects); - - /// Set tool objects. - FEATURESAPI_EXPORT - void setToolObjects(const std::list& theToolObjects); - - /// Dump wrapped feature - FEATURESAPI_EXPORT - virtual void dump(ModelHighAPI_Dumper& theDumper) const; -}; - -/// Pointer on Boolean object. -typedef std::shared_ptr BooleanPtr; - -/// \ingroup CPPHighAPI -/// \brief Create Boolean Cut feature. -FEATURESAPI_EXPORT -BooleanPtr addCut(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects); - -/// \ingroup CPPHighAPI -/// \brief Create Boolean Fuse feature. -FEATURESAPI_EXPORT -BooleanPtr addFuse(const std::shared_ptr& thePart, - const std::list& theObjects); - -/// \ingroup CPPHighAPI -/// \brief Create Boolean Fuse feature. -FEATURESAPI_EXPORT -BooleanPtr addFuse(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects); - -/// \ingroup CPPHighAPI -/// \brief Create Boolean Common feature. -FEATURESAPI_EXPORT -BooleanPtr addCommon(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects); - -/// \ingroup CPPHighAPI -/// \brief Create Boolean Smash feature. -FEATURESAPI_EXPORT -BooleanPtr addSmash(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects); - -/// \ingroup CPPHighAPI -/// \brief Create Boolean Fill feature. -FEATURESAPI_EXPORT -BooleanPtr addFill(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects); - -#endif // FeaturesAPI_Boolean_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp new file mode 100644 index 000000000..bd53854ef --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp @@ -0,0 +1,99 @@ +// Copyright (C) 2014-2017 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 "FeaturesAPI_BooleanCommon.h" + +#include +#include +#include + +//================================================================================================== +FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( + const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theToolObjects, mytoolObjects); + + execute(false); + } +} + +//================================================================================================== +FeaturesAPI_BooleanCommon::~FeaturesAPI_BooleanCommon() +{ +} + + +//================================================================================================== +void FeaturesAPI_BooleanCommon::setMainObjects( + const std::list& theMainObjects) +{ + fillAttribute(theMainObjects, mymainObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanCommon::setToolObjects( + const std::list& theToolObjects) +{ + fillAttribute(theToolObjects, mytoolObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + + theDumper << aBase << " = model.addCommon"; + + const std::string& aDocName = theDumper.name(aBase->document()); + AttributeSelectionListPtr anObjects = + aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID()); + AttributeSelectionListPtr aTools = + aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID()); + + theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl; +} + +//================================================================================================== +BooleanCommonPtr addCommon(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID()); + return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, + theMainObjects, + theToolObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.h b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.h new file mode 100644 index 000000000..56e49bb79 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.h @@ -0,0 +1,83 @@ +// Copyright (C) 2014-2017 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 FeaturesAPI_BooleanCommon_H_ +#define FeaturesAPI_BooleanCommon_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Integer; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_BooleanCommon +/// \ingroup CPPHighAPI +/// \brief Interface for Boolean Common feature. +class FeaturesAPI_BooleanCommon: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_BooleanCommon(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_BooleanCommon(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_BooleanCommon(); + + INTERFACE_2(FeaturesPlugin_BooleanCommon::ID(), + mainObjects, FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Main objects */, + toolObjects, FeaturesPlugin_BooleanCommon::TOOL_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Tool objects*/) + + /// Set main objects. + FEATURESAPI_EXPORT + void setMainObjects(const std::list& theMainObjects); + + /// Set tool objects. + FEATURESAPI_EXPORT + void setToolObjects(const std::list& theToolObjects); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Boolean object. +typedef std::shared_ptr BooleanCommonPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Boolean Common feature. +FEATURESAPI_EXPORT +BooleanCommonPtr addCommon(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects); + +#endif // FeaturesAPI_BooleanCommon_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp new file mode 100644 index 000000000..496b1fdbc --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp @@ -0,0 +1,96 @@ +// Copyright (C) 2014-2017 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 "FeaturesAPI_BooleanCut.h" + +#include +#include +#include + +//================================================================================================== +FeaturesAPI_BooleanCut::FeaturesAPI_BooleanCut(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_BooleanCut::FeaturesAPI_BooleanCut( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theToolObjects, mytoolObjects); + + execute(false); + } +} + +//================================================================================================== +FeaturesAPI_BooleanCut::~FeaturesAPI_BooleanCut() +{ +} + + +//================================================================================================== +void FeaturesAPI_BooleanCut::setMainObjects(const std::list& theMainObjects) +{ + fillAttribute(theMainObjects, mymainObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanCut::setToolObjects(const std::list& theToolObjects) +{ + fillAttribute(theToolObjects, mytoolObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanCut::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + + theDumper << aBase << " = model.addCut"; + + const std::string& aDocName = theDumper.name(aBase->document()); + AttributeSelectionListPtr anObjects = + aBase->selectionList(FeaturesPlugin_BooleanCut::OBJECT_LIST_ID()); + AttributeSelectionListPtr aTools = + aBase->selectionList(FeaturesPlugin_BooleanCut::TOOL_LIST_ID()); + + theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl; +} + +//================================================================================================== +BooleanCutPtr addCut(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCut::ID()); + return BooleanCutPtr(new FeaturesAPI_BooleanCut(aFeature, + theMainObjects, + theToolObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCut.h b/src/FeaturesAPI/FeaturesAPI_BooleanCut.h new file mode 100644 index 000000000..c39dd49d3 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCut.h @@ -0,0 +1,83 @@ +// Copyright (C) 2014-2017 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 FeaturesAPI_BooleanCut_H_ +#define FeaturesAPI_BooleanCut_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Integer; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_BooleanCut +/// \ingroup CPPHighAPI +/// \brief Interface for Boolean Cut feature. +class FeaturesAPI_BooleanCut: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_BooleanCut(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_BooleanCut(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_BooleanCut(); + + INTERFACE_2(FeaturesPlugin_BooleanCut::ID(), + mainObjects, FeaturesPlugin_BooleanCut::OBJECT_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Main objects */, + toolObjects, FeaturesPlugin_BooleanCut::TOOL_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Tool objects*/) + + /// Set main objects. + FEATURESAPI_EXPORT + void setMainObjects(const std::list& theMainObjects); + + /// Set tool objects. + FEATURESAPI_EXPORT + void setToolObjects(const std::list& theToolObjects); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Boolean object. +typedef std::shared_ptr BooleanCutPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Boolean Cut feature. +FEATURESAPI_EXPORT +BooleanCutPtr addCut(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects); + +#endif // FeaturesAPI_BooleanCut_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp new file mode 100644 index 000000000..f9924204a --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp @@ -0,0 +1,99 @@ +// Copyright (C) 2014-2017 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 "FeaturesAPI_BooleanFill.h" + +#include +#include +#include + +//================================================================================================== +FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill( + const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theToolObjects, mytoolObjects); + + execute(false); + } +} + +//================================================================================================== +FeaturesAPI_BooleanFill::~FeaturesAPI_BooleanFill() +{ +} + + +//================================================================================================== +void FeaturesAPI_BooleanFill::setMainObjects( + const std::list& theMainObjects) +{ + fillAttribute(theMainObjects, mymainObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanFill::setToolObjects( + const std::list& theToolObjects) +{ + fillAttribute(theToolObjects, mytoolObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanFill::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + + theDumper << aBase << " = model.addFill"; + + const std::string& aDocName = theDumper.name(aBase->document()); + AttributeSelectionListPtr anObjects = + aBase->selectionList(FeaturesPlugin_BooleanFill::OBJECT_LIST_ID()); + AttributeSelectionListPtr aTools = + aBase->selectionList(FeaturesPlugin_BooleanFill::TOOL_LIST_ID()); + + theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl; +} + +//================================================================================================== +BooleanFillPtr addFill(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFill::ID()); + return BooleanFillPtr(new FeaturesAPI_BooleanFill(aFeature, + theMainObjects, + theToolObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFill.h b/src/FeaturesAPI/FeaturesAPI_BooleanFill.h new file mode 100644 index 000000000..32413f175 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFill.h @@ -0,0 +1,83 @@ +// Copyright (C) 2014-2017 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 FeaturesAPI_BooleanFill_H_ +#define FeaturesAPI_BooleanFill_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Integer; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_BooleanFill +/// \ingroup CPPHighAPI +/// \brief Interface for Boolean Fill feature. +class FeaturesAPI_BooleanFill: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_BooleanFill(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_BooleanFill(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_BooleanFill(); + + INTERFACE_2(FeaturesPlugin_BooleanFill::ID(), + mainObjects, FeaturesPlugin_BooleanFill::OBJECT_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Main objects */, + toolObjects, FeaturesPlugin_BooleanFill::TOOL_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Tool objects*/) + + /// Set main objects. + FEATURESAPI_EXPORT + void setMainObjects(const std::list& theMainObjects); + + /// Set tool objects. + FEATURESAPI_EXPORT + void setToolObjects(const std::list& theToolObjects); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Boolean object. +typedef std::shared_ptr BooleanFillPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Boolean Fill feature. +FEATURESAPI_EXPORT +BooleanFillPtr addFill(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects); + +#endif // FeaturesAPI_BooleanFill_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp new file mode 100644 index 000000000..c1a043d67 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp @@ -0,0 +1,110 @@ +// Copyright (C) 2014-2017 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 "FeaturesAPI_BooleanFuse.h" + +#include +#include +#include + +//================================================================================================== +FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( + const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theToolObjects, mytoolObjects); + + execute(false); + } +} + +//================================================================================================== +FeaturesAPI_BooleanFuse::~FeaturesAPI_BooleanFuse() +{ +} + + +//================================================================================================== +void FeaturesAPI_BooleanFuse::setMainObjects( + const std::list& theMainObjects) +{ + fillAttribute(theMainObjects, mymainObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanFuse::setToolObjects( + const std::list& theToolObjects) +{ + fillAttribute(theToolObjects, mytoolObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + + theDumper << aBase << " = model.addFuse"; + + const std::string& aDocName = theDumper.name(aBase->document()); + AttributeSelectionListPtr anObjects = + aBase->selectionList(FeaturesPlugin_BooleanFuse::OBJECT_LIST_ID()); + AttributeSelectionListPtr aTools = + aBase->selectionList(FeaturesPlugin_BooleanFuse::TOOL_LIST_ID()); + + theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl; +} + +//================================================================================================== +BooleanFusePtr addFuse(const std::shared_ptr& thePart, + const std::list& theObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID()); + std::list aToolObjects; + return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature, + theObjects, + aToolObjects)); +} + +//================================================================================================== +BooleanFusePtr addFuse(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID()); + return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature, + theMainObjects, + theToolObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h new file mode 100644 index 000000000..17b72f7f2 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h @@ -0,0 +1,89 @@ +// Copyright (C) 2014-2017 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 FeaturesAPI_BooleanFuse_H_ +#define FeaturesAPI_BooleanFuse_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Integer; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_BooleanFuse +/// \ingroup CPPHighAPI +/// \brief Interface for Boolean Fuse feature. +class FeaturesAPI_BooleanFuse: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_BooleanFuse(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_BooleanFuse(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_BooleanFuse(); + + INTERFACE_2(FeaturesPlugin_BooleanFuse::ID(), + mainObjects, FeaturesPlugin_BooleanFuse::OBJECT_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Main objects */, + toolObjects, FeaturesPlugin_BooleanFuse::TOOL_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Tool objects*/) + + /// Set main objects. + FEATURESAPI_EXPORT + void setMainObjects(const std::list& theMainObjects); + + /// Set tool objects. + FEATURESAPI_EXPORT + void setToolObjects(const std::list& theToolObjects); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Boolean object. +typedef std::shared_ptr BooleanFusePtr; + +/// \ingroup CPPHighAPI +/// \brief Create Boolean Fuse feature. +FEATURESAPI_EXPORT +BooleanFusePtr addFuse(const std::shared_ptr& thePart, + const std::list& theObjects); + +/// \ingroup CPPHighAPI +/// \brief Create Boolean Fuse feature. +FEATURESAPI_EXPORT +BooleanFusePtr addFuse(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects); + +#endif // FeaturesAPI_BooleanFuse_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp new file mode 100644 index 000000000..7c7583bbf --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp @@ -0,0 +1,99 @@ +// Copyright (C) 2014-2017 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 "FeaturesAPI_BooleanSmash.h" + +#include +#include +#include + +//================================================================================================== +FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash( + const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theToolObjects, mytoolObjects); + + execute(false); + } +} + +//================================================================================================== +FeaturesAPI_BooleanSmash::~FeaturesAPI_BooleanSmash() +{ +} + + +//================================================================================================== +void FeaturesAPI_BooleanSmash::setMainObjects( + const std::list& theMainObjects) +{ + fillAttribute(theMainObjects, mymainObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanSmash::setToolObjects( + const std::list& theToolObjects) +{ + fillAttribute(theToolObjects, mytoolObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + + theDumper << aBase << " = model.addSmash"; + + const std::string& aDocName = theDumper.name(aBase->document()); + AttributeSelectionListPtr anObjects = + aBase->selectionList(FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID()); + AttributeSelectionListPtr aTools = + aBase->selectionList(FeaturesPlugin_BooleanSmash::TOOL_LIST_ID()); + + theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl; +} + +//================================================================================================== +BooleanSmashPtr addSmash(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanSmash::ID()); + return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, + theMainObjects, + theToolObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.h b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.h new file mode 100644 index 000000000..bfe0d5e87 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.h @@ -0,0 +1,83 @@ +// Copyright (C) 2014-2017 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 FeaturesAPI_BooleanSmash_H_ +#define FeaturesAPI_BooleanSmash_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Integer; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_BooleanSmash +/// \ingroup CPPHighAPI +/// \brief Interface for Boolean Smash feature. +class FeaturesAPI_BooleanSmash: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_BooleanSmash(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_BooleanSmash(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_BooleanSmash(); + + INTERFACE_2(FeaturesPlugin_BooleanSmash::ID(), + mainObjects, FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Main objects */, + toolObjects, FeaturesPlugin_BooleanSmash::TOOL_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Tool objects*/) + + /// Set main objects. + FEATURESAPI_EXPORT + void setMainObjects(const std::list& theMainObjects); + + /// Set tool objects. + FEATURESAPI_EXPORT + void setToolObjects(const std::list& theToolObjects); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Boolean object. +typedef std::shared_ptr BooleanSmashPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Boolean Smash feature. +FEATURESAPI_EXPORT +BooleanSmashPtr addSmash(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const std::list& theToolObjects); + +#endif // FeaturesAPI_BooleanSmash_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index a45b780ca..1c7d2d40b 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -24,7 +24,11 @@ #include #include "FeaturesAPI.h" - #include "FeaturesAPI_Boolean.h" + #include "FeaturesAPI_BooleanCut.h" + #include "FeaturesAPI_BooleanFuse.h" + #include "FeaturesAPI_BooleanCommon.h" + #include "FeaturesAPI_BooleanSmash.h" + #include "FeaturesAPI_BooleanFill.h" #include "FeaturesAPI_Extrusion.h" #include "FeaturesAPI_ExtrusionBoolean.h" #include "FeaturesAPI_Fillet.h" diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index ed5523231..1f9d5df25 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -30,6 +30,11 @@ SET(PROJECT_HEADERS FeaturesPlugin_Rotation.h FeaturesPlugin_Translation.h FeaturesPlugin_Boolean.h + FeaturesPlugin_BooleanCut.h + FeaturesPlugin_BooleanFuse.h + FeaturesPlugin_BooleanCommon.h + FeaturesPlugin_BooleanSmash.h + FeaturesPlugin_BooleanFill.h FeaturesPlugin_Intersection.h FeaturesPlugin_Partition.h FeaturesPlugin_Pipe.h diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index 64072e62a..7a765a11c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -45,15 +45,14 @@ #include //================================================================================================= -FeaturesPlugin_Boolean::FeaturesPlugin_Boolean() +FeaturesPlugin_Boolean::FeaturesPlugin_Boolean(const OperationType theOperationType) +: myOperationType(theOperationType) { } //================================================================================================= void FeaturesPlugin_Boolean::initAttributes() { - data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId()); - AttributeSelectionListPtr aSelection = std::dynamic_pointer_cast(data()->addAttribute( FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); @@ -80,15 +79,14 @@ std::shared_ptr FeaturesPlugin_Boolean::getShape(const std::strin } //================================================================================================= -void FeaturesPlugin_Boolean::execute() +FeaturesPlugin_Boolean::OperationType FeaturesPlugin_Boolean::operationType() { - // Getting operation type. - std::shared_ptr aTypeAttr = std::dynamic_pointer_cast< - ModelAPI_AttributeInteger>(data()->attribute(FeaturesPlugin_Boolean::TYPE_ID())); - if (!aTypeAttr) - return; - OperationType aType = (FeaturesPlugin_Boolean::OperationType)aTypeAttr->value(); + return myOperationType; +} +//================================================================================================= +void FeaturesPlugin_Boolean::execute() +{ ListOfShape anObjects, aTools, anEdgesAndFaces, aPlanes; std::map, ListOfShape> aCompSolidsObjects; @@ -118,7 +116,7 @@ void FeaturesPlugin_Boolean::execute() aCompSolidsObjects[aContextShape].push_back(anObject); } } else { - if(aType != BOOL_FILL + if(myOperationType != BOOL_FILL && (anObject->shapeType() == GeomAPI_Shape::EDGE || anObject->shapeType() == GeomAPI_Shape::FACE)) { @@ -141,7 +139,7 @@ void FeaturesPlugin_Boolean::execute() ResultPtr aContext = aToolAttr->context(); aPlanes.push_back(aToolAttr->context()->shape()); } - else if(aType != BOOL_FILL + else if (myOperationType != BOOL_FILL && (aTool->shapeType() == GeomAPI_Shape::EDGE || aTool->shapeType() == GeomAPI_Shape::FACE)) { @@ -153,7 +151,7 @@ void FeaturesPlugin_Boolean::execute() int aResultIndex = 0; - switch(aType) { + switch(myOperationType) { case BOOL_CUT: case BOOL_COMMON: case BOOL_FILL: { @@ -174,7 +172,7 @@ void FeaturesPlugin_Boolean::execute() std::shared_ptr aBoolAlgo; GeomShapePtr aResShape; - switch(aType) { + switch(myOperationType) { case BOOL_CUT: { aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject, aTools, @@ -247,18 +245,19 @@ void FeaturesPlugin_Boolean::execute() aMakeShapeList.appendAlgo(aBoolAlgo); if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27 - || (aType != BOOL_CUT && aType != BOOL_COMMON)) + || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON)) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); ListOfShape aUsedTools = aTools; - if (aType == BOOL_FILL) { + if (myOperationType == BOOL_FILL) { aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end()); } loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, - aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()), aType == BOOL_FILL); + aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()), + myOperationType == BOOL_FILL); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -290,7 +289,7 @@ void FeaturesPlugin_Boolean::execute() GeomAlgoAPI_MakeShapeList aMakeShapeList; std::shared_ptr aBoolAlgo; - switch(aType) { + switch(myOperationType) { case BOOL_CUT: { aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids, aTools, @@ -367,13 +366,13 @@ void FeaturesPlugin_Boolean::execute() } if(GeomAlgoAPI_ShapeTools::volume(aResultShape) > 1.e-27 - || (aType != BOOL_CUT && aType != BOOL_COMMON)) + || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON)) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); ListOfShape aUsedTools = aTools; - if (aType == BOOL_FILL) { + if (myOperationType == BOOL_FILL) { aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end()); } @@ -383,7 +382,7 @@ void FeaturesPlugin_Boolean::execute() aResultShape, aMakeShapeList, aMapOfShapes, - aType == BOOL_FILL); + myOperationType == BOOL_FILL); setResult(aResultBody, aResultIndex); aResultIndex++; } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h index d49820686..ce70e57bc 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h @@ -18,8 +18,8 @@ // email : webmaster.salome@opencascade.com // -#ifndef FeaturesPlugin_Cut_H_ -#define FeaturesPlugin_Cut_H_ +#ifndef FeaturesPlugin_Boolean_H_ +#define FeaturesPlugin_Boolean_H_ #include "FeaturesPlugin.h" @@ -42,13 +42,6 @@ public: BOOL_SMASH }; - /// Feature kind. - inline static const std::string& ID() - { - static const std::string MY_ID("Boolean"); - return MY_ID; - } - /// Attribute name of main objects. inline static const std::string& OBJECT_LIST_ID() { @@ -63,19 +56,8 @@ public: return MY_TOOL_LIST_ID; } - /// Attribute name of operation type. - inline static const std::string& TYPE_ID() - { - static const std::string MY_TYPE_ID("bool_type"); - return MY_TYPE_ID; - } - - /// \return the kind of a feature. - FEATURESPLUGIN_EXPORT virtual const std::string& getKind() - { - static std::string MY_KIND = FeaturesPlugin_Boolean::ID(); - return MY_KIND; - } + /// \return boolean operation type. + FEATURESPLUGIN_EXPORT OperationType operationType(); /// Creates a new part document if needed. FEATURESPLUGIN_EXPORT virtual void execute(); @@ -83,8 +65,10 @@ public: /// Request for initialization of data model of the feature: adding all attributes. FEATURESPLUGIN_EXPORT virtual void initAttributes(); +protected: + /// Use plugin manager for features creation. - FeaturesPlugin_Boolean(); + FeaturesPlugin_Boolean(const OperationType theOperationType); private: std::shared_ptr getShape(const std::string& theAttrName); @@ -97,6 +81,9 @@ private: GeomAlgoAPI_MakeShape& theMakeShape, GeomAPI_DataMapOfShapeShape& theMapOfShapes, const bool theIsStoreAsGenerated = false); + +private: + OperationType myOperationType; }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h new file mode 100644 index 000000000..7acab2e31 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2017 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 FeaturesPlugin_BooleanCommon_H_ +#define FeaturesPlugin_BooleanCommon_H_ + +#include "FeaturesPlugin_Boolean.h" + +/// \class FeaturesPlugin_BooleanCommon +/// \ingroup Plugins +/// \brief Feature for applying of Boolean Common operation. +class FeaturesPlugin_BooleanCommon : public FeaturesPlugin_Boolean +{ +public: + + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_ID("Common"); + return MY_ID; + } + + /// \return the kind of a feature. + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_BooleanCommon::ID(); + return MY_KIND; + } + +public: + + /// Use plugin manager for features creation. + FeaturesPlugin_BooleanCommon(): FeaturesPlugin_Boolean(BOOL_COMMON) {}; + +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h new file mode 100644 index 000000000..f53afa973 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2017 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 FeaturesPlugin_BooleanCut_H_ +#define FeaturesPlugin_BooleanCut_H_ + +#include "FeaturesPlugin_Boolean.h" + +/// \class FeaturesPlugin_BooleanCut +/// \ingroup Plugins +/// \brief Feature for applying of Boolean Cut operation. +class FeaturesPlugin_BooleanCut : public FeaturesPlugin_Boolean +{ +public: + + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_ID("Cut"); + return MY_ID; + } + + /// \return the kind of a feature. + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_BooleanCut::ID(); + return MY_KIND; + } + +public: + + /// Use plugin manager for features creation. + FeaturesPlugin_BooleanCut(): FeaturesPlugin_Boolean(BOOL_CUT) {}; + +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.h new file mode 100644 index 000000000..b4cb73b94 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2017 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 FeaturesPlugin_BooleanFill_H_ +#define FeaturesPlugin_BooleanFill_H_ + +#include "FeaturesPlugin_Boolean.h" + +/// \class FeaturesPlugin_BooleanFill +/// \ingroup Plugins +/// \brief Feature for applying of Boolean Fill operation. +class FeaturesPlugin_BooleanFill : public FeaturesPlugin_Boolean +{ +public: + + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_ID("Fill"); + return MY_ID; + } + + /// \return the kind of a feature. + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_BooleanFill::ID(); + return MY_KIND; + } + +public: + + /// Use plugin manager for features creation. + FeaturesPlugin_BooleanFill(): FeaturesPlugin_Boolean(BOOL_FILL) {}; + +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h new file mode 100644 index 000000000..bbd6216ba --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2017 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 FeaturesPlugin_BooleanFuse_H_ +#define FeaturesPlugin_BooleanFuse_H_ + +#include "FeaturesPlugin_Boolean.h" + +/// \class FeaturesPlugin_BooleanFuse +/// \ingroup Plugins +/// \brief Feature for applying of Boolean Fuse operation. +class FeaturesPlugin_BooleanFuse : public FeaturesPlugin_Boolean +{ +public: + + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_ID("Fuse"); + return MY_ID; + } + + /// \return the kind of a feature. + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_BooleanFuse::ID(); + return MY_KIND; + } + +public: + + /// Use plugin manager for features creation. + FeaturesPlugin_BooleanFuse(): FeaturesPlugin_Boolean(BOOL_FUSE) {}; + +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h new file mode 100644 index 000000000..86809f9eb --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2017 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 FeaturesPlugin_BooleanSmash_H_ +#define FeaturesPlugin_BooleanSmash_H_ + +#include "FeaturesPlugin_Boolean.h" + +/// \class FeaturesPlugin_BooleanSmash +/// \ingroup Plugins +/// \brief Feature for applying of Boolean Smash operation. +class FeaturesPlugin_BooleanSmash : public FeaturesPlugin_Boolean +{ +public: + + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_ID("Smash"); + return MY_ID; + } + + /// \return the kind of a feature. + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_BooleanSmash::ID(); + return MY_KIND; + } + +public: + + /// Use plugin manager for features creation. + FeaturesPlugin_BooleanSmash(): FeaturesPlugin_Boolean(BOOL_SMASH) {}; + +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index 2a8023433..33f256c1f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -20,7 +20,11 @@ #include -#include +#include +#include +#include +#include +#include #include #include #include @@ -90,6 +94,8 @@ FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() new FeaturesPlugin_ValidatorFilletSelection); aFactory->registerValidator("FeaturesPlugin_ValidatorCircular", new FeaturesPlugin_ValidatorCircular); + aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanArguments", + new FeaturesPlugin_ValidatorBooleanArguments); // register this plugin ModelAPI_Session::get()->registerPlugin(this); @@ -105,8 +111,16 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new FeaturesPlugin_Rotation); } else if (theFeatureID == FeaturesPlugin_Translation::ID()) { return FeaturePtr(new FeaturesPlugin_Translation); - } else if (theFeatureID == FeaturesPlugin_Boolean::ID()) { - return FeaturePtr(new FeaturesPlugin_Boolean); + } else if (theFeatureID == FeaturesPlugin_BooleanCut::ID()) { + return FeaturePtr(new FeaturesPlugin_BooleanCut); + } else if (theFeatureID == FeaturesPlugin_BooleanFuse::ID()) { + return FeaturePtr(new FeaturesPlugin_BooleanFuse); + } else if (theFeatureID == FeaturesPlugin_BooleanCommon::ID()) { + return FeaturePtr(new FeaturesPlugin_BooleanCommon); + } else if (theFeatureID == FeaturesPlugin_BooleanSmash::ID()) { + return FeaturePtr(new FeaturesPlugin_BooleanSmash); + } else if (theFeatureID == FeaturesPlugin_BooleanFill::ID()) { + return FeaturePtr(new FeaturesPlugin_BooleanFill); } else if (theFeatureID == FeaturesPlugin_Intersection::ID()) { return FeaturePtr(new FeaturesPlugin_Intersection); } else if (theFeatureID == FeaturesPlugin_Partition::ID()) { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 5a06ceaac..0a85e1ab4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -571,8 +571,9 @@ bool FeaturesPlugin_ValidatorBooleanSelection::isValid(const AttributePtr& theAt "Error: This validator can only work with selection list attributes in \"Boolean\" feature."; return false; } - FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); - int anOperationType = aFeature->integer("bool_type")->value(); + std::shared_ptr aFeature = + std::dynamic_pointer_cast(theAttribute->owner()); + FeaturesPlugin_Boolean::OperationType anOperationType = aFeature->operationType(); for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) { AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex); @@ -1016,3 +1017,137 @@ bool FeaturesPlugin_ValidatorCircular::isValid(const AttributePtr& theAttribute, } return isValid; } + +//================================================================================================= +bool FeaturesPlugin_ValidatorBooleanArguments::isValid( + const std::shared_ptr& theFeature, + const std::list& theArguments, + Events_InfoMessage& theError) const +{ + if (theArguments.size() != 2) + { + theError = "Wrong number of arguments (expected 2)."; + return false; + } + + int anObjectsNb = 0, aToolsNb = 0; + //int anOperationType = 0; + + std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); + + bool isAllInSameCompSolid = true; + ResultCompSolidPtr aCompSolid; + + AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt); + if (anAttrSelList) + { + anObjectsNb = anAttrSelList->size(); + for (int anIndex = 0; anIndex < anObjectsNb; ++anIndex) + { + AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); + ResultPtr aContext = anAttr->context(); + ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); + if (aResCompSolidPtr.get()) + { + if (aCompSolid.get()) + { + isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + } + else + { + aCompSolid = aResCompSolidPtr; + } + } + else + { + isAllInSameCompSolid = false; + break; + } + } + } + anIt++; + + + anAttrSelList = theFeature->selectionList(*anIt); + if (anAttrSelList) + { + aToolsNb = anAttrSelList->size(); + if (isAllInSameCompSolid) + { + for (int anIndex = 0; anIndex < aToolsNb; ++anIndex) + { + AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); + ResultPtr aContext = anAttr->context(); + ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); + if (aResCompSolidPtr.get()) + { + if (aCompSolid.get()) + { + isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + } + else + { + aCompSolid = aResCompSolidPtr; + } + } + else + { + isAllInSameCompSolid = false; + break; + } + } + } + } + anIt++; + + std::shared_ptr aFeature = + std::dynamic_pointer_cast(theFeature); + FeaturesPlugin_Boolean::OperationType anOperationType = aFeature->operationType(); + + if (anOperationType == FeaturesPlugin_Boolean::BOOL_FUSE) + { + // Fuse operation + if (anObjectsNb + aToolsNb < 2) + { + theError = "Not enough arguments for Fuse operation."; + return false; + } + else if (isAllInSameCompSolid) + { + theError = "Operations only between sub-shapes of the same shape not allowed."; + return false; + } + } + else + { + if (anObjectsNb < 1) + { + theError = "Objects not selected."; + return false; + } + if (aToolsNb < 1) + { + theError = "Tools not selected."; + return false; + } + if (isAllInSameCompSolid) + { + theError = "Operations only between sub-shapes of the same shape not allowed."; + return false; + } + } + + return true; +} + +//================================================================================================= +bool FeaturesPlugin_ValidatorBooleanArguments::isNotObligatory(std::string theFeature, + std::string theAttribute) +{ + if (theAttribute == "main_objects" || theAttribute == "tool_objects") + { + return true; + } + + return false; +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.h b/src/FeaturesPlugin/FeaturesPlugin_Validators.h index 5824ce9dc..c75ad9737 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.h @@ -267,4 +267,25 @@ public: Events_InfoMessage& theError) const; }; +/** \class FeaturesPlugin_ValidatorBooleanArguments +* \ingroup Validators +* \brief Validates that boolean operation have enough arguments. +*/ +class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator +{ +public: + /** \brief Returns true if feature and/or attributes are valid. + * \param[in] theFeature the validated feature. + * \param[in] theArguments the arguments in the configuration file for this validator. + * \param[out] theError error message. + * \returns true if feature is valid. + */ + virtual bool isValid(const std::shared_ptr& theFeature, + const std::list& theArguments, + Events_InfoMessage& theError) const; + + /// \return true if the attribute in feature is not obligatory for the feature execution. + virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); +}; + #endif diff --git a/src/FeaturesPlugin/Test/Test2194.py b/src/FeaturesPlugin/Test/Test2194.py index fc260d330..d42a091f4 100644 --- a/src/FeaturesPlugin/Test/Test2194.py +++ b/src/FeaturesPlugin/Test/Test2194.py @@ -34,7 +34,7 @@ SketchCircle_3 = Sketch_2.addCircle(-41.97827733564338, 89.35676702647821, 6.102 model.do() Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")], model.selection(), 10, 0) Boolean_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")]) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_2_2/To_Face_1"), model.selection("FACE", "Extrusion_2_2/From_Face_1"), model.selection("FACE", "Extrusion_2_2/Generated_Face_1"), model.selection("FACE", "Extrusion_2_1/From_Face_1"), model.selection("FACE", "Boolean_1_1_1/Modified_Face_1"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Extrusion_2_2/From_Face_1"), model.selection("FACE", "Extrusion_2_1/Generated_Face_1"), model.selection("FACE", "Extrusion_2_1/From_Face_1"), model.selection("FACE", "Extrusion_2_1/To_Face_1")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_2_2/To_Face_1"), model.selection("FACE", "Extrusion_2_2/From_Face_1"), model.selection("FACE", "Extrusion_2_2/Generated_Face_1"), model.selection("FACE", "Extrusion_2_1/From_Face_1"), model.selection("FACE", "Smash_1_1_1/Modified_Face_1"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Extrusion_2_2/From_Face_1"), model.selection("FACE", "Extrusion_2_1/Generated_Face_1"), model.selection("FACE", "Extrusion_2_1/From_Face_1"), model.selection("FACE", "Extrusion_2_1/To_Face_1")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2375.py b/src/FeaturesPlugin/Test/Test2375.py index 16cb0352a..1fbbd14c5 100644 --- a/src/FeaturesPlugin/Test/Test2375.py +++ b/src/FeaturesPlugin/Test/Test2375.py @@ -206,15 +206,15 @@ SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_21.startPoint(), Sk model.do() Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection("EDGE", "PartSet/OZ"), 360, 0) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_13_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_14_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0) -Boolean_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_2_1")]) -Boolean_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "ExtrusionCut_3_1")], [model.selection("SOLID", "Boolean_1_1"), model.selection("SOLID", "Boolean_1_2")]) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_2_1")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "ExtrusionCut_3_1")], [model.selection("SOLID", "Common_1_1"), model.selection("SOLID", "Common_1_2")]) # skip 3 vertices, limitation -Group_1_objects = [model.selection("VERTEX", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Boolean_2_1/Modified_Face_1"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5095"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_7"), model.selection("VERTEX", "ExtrusionCut_3_1/Lateral_5004"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_9"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_8"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5108"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5082"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5069"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5043"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5024"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5006"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5015"), model.selection("VERTEX", "Extrusion_1_1/Lateral_4"), model.selection("VERTEX", "Extrusion_1_2/Lateral_4"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5033"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5031"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5022"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5004"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5013"), model.selection("VERTEX", "Boolean_1_2/Modified_Face_2&Boolean_1_2/Modified_Face_1"), model.selection("VERTEX", "Boolean_1_1/Modified_Face_2&Boolean_1_1/Modified_Face_1")] +Group_1_objects = [model.selection("VERTEX", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Cut_1_1/Modified_Face_1"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5095"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_7"), model.selection("VERTEX", "ExtrusionCut_3_1/Lateral_5004"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_9"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_8"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5108"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5082"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5069"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5043"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5024"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5006"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5015"), model.selection("VERTEX", "Extrusion_1_1/Lateral_4"), model.selection("VERTEX", "Extrusion_1_2/Lateral_4"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5033"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5031"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5022"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5004"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5013"), model.selection("VERTEX", "Common_1_2/Modified_Face_2&Common_1_2/Modified_Face_1"), model.selection("VERTEX", "Common_1_1/Modified_Face_2&Common_1_1/Modified_Face_1")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) # skip 3 edges, limitation -Group_2_objects = [model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "Boolean_2_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5011"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "Boolean_1_2/Modified_Face_2&Boolean_1_2/Modified_Face_1"), model.selection("EDGE", "Boolean_2_1/Modified_Face_1&Boolean_1_2/Modified_Face_2"), model.selection("EDGE", "Boolean_1_2/Modified_Edge_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_9"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_9&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "Boolean_2_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5002"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Boolean_1_1/Modified_Edge_1"), model.selection("EDGE", "Boolean_1_1/Modified_Face_2&Boolean_1_1/Modified_Face_1"), model.selection("EDGE", "Boolean_2_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "Boolean_2_1/Modified_Face_1&Boolean_1_1/Modified_Face_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "Boolean_2_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5029"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8&Boolean_2_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5020")] +Group_2_objects = [model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5011"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "Common_1_2/Modified_Face_2&Common_1_2/Modified_Face_1"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&Common_1_2/Modified_Face_2"), model.selection("EDGE", "Common_1_2/Modified_Edge_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_9"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_9&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5002"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Common_1_1/Modified_Edge_1"), model.selection("EDGE", "Common_1_1/Modified_Face_2&Common_1_1/Modified_Face_1"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&Common_1_1/Modified_Face_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5029"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5020")] Group_2 = model.addGroup(Part_1_doc, Group_2_objects) -Group_3_objects = [model.selection("FACE", "ExtrusionCut_2_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_8"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_3"), model.selection("FACE", "Boolean_1_2/Modified_Face_1"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_9"), model.selection("FACE", "Boolean_1_1/Modified_Face_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "Boolean_2_1/Modified_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_2"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_7"), model.selection("FACE", "Boolean_1_1/Modified_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_2"), model.selection("FACE", "Revolution_1_1/Generated_Face_4"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "Boolean_1_2/Modified_Face_2"), model.selection("FACE", "Revolution_1_1/Generated_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_8")] +Group_3_objects = [model.selection("FACE", "ExtrusionCut_2_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_8"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_3"), model.selection("FACE", "Common_1_2/Modified_Face_1"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_9"), model.selection("FACE", "Common_1_1/Modified_Face_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "Cut_1_1/Modified_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_2"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_7"), model.selection("FACE", "Common_1_1/Modified_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_2"), model.selection("FACE", "Revolution_1_1/Generated_Face_4"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "Common_1_2/Modified_Face_2"), model.selection("FACE", "Revolution_1_1/Generated_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_8")] Group_3 = model.addGroup(Part_1_doc, Group_3_objects) model.end() diff --git a/src/FeaturesPlugin/Test/Test2394.py b/src/FeaturesPlugin/Test/Test2394.py index e5e950d46..d3d2fde6c 100644 --- a/src/FeaturesPlugin/Test/Test2394.py +++ b/src/FeaturesPlugin/Test/Test2394.py @@ -85,10 +85,10 @@ SketchLine_9 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_4.startPoint(), SketchLine_9.result()) Extrusion_1.setNestedSketch(Sketch_2) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) Point_2 = model.addPoint(Part_1_doc, "x", "y", "-z") -Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Boolean_1_1_2/Modified_Face_3&Boolean_1_1_2/Modified_Face_2&Boolean_1_1_2/Modified_Face_1")) +Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Fill_1_1_2/Modified_Face_3&Fill_1_1_2/Modified_Face_2&Fill_1_1_2/Modified_Face_1")) Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "Point_1"), True) Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), "haut_ext_tuyau", True) Plane_5.result().setName("Plane_2 arrivee tuyau") @@ -96,17 +96,17 @@ Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Gene Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1"), 45) Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_4"), "90+45") -Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Boolean_1_1_1")], [model.selection("FACE", "Plane_5")]) -Boolean_3 = model.addFill(Part_1_doc, [model.selection("SOLID", "Boolean_2_1_2")], [model.selection("FACE", "Plane_3")]) -Boolean_4 = model.addFill(Part_1_doc, [model.selection("SOLID", "Boolean_3_1_2")], [model.selection("FACE", "Plane_4")]) -Boolean_4.result().setColor(102, 51, 51) -Boolean_4.result().subResult(0).setColor(153, 153, 76) -Boolean_4.result().subResult(1).setColor(0, 204, 204) -Boolean_4.result().subResult(2).setColor(51, 51, 102) -Boolean_4.result().subResult(3).setColor(102, 204, 102) -Boolean_4.result().subResult(4).setColor(204, 204, 0) +Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_1_1_1")], [model.selection("FACE", "Plane_5")]) +Fill_3 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_2_1_2")], [model.selection("FACE", "Plane_3")]) +Fill_4 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_3_1_2")], [model.selection("FACE", "Plane_4")]) +Fill_4.result().setColor(102, 51, 51) +Fill_4.result().subResult(0).setColor(153, 153, 76) +Fill_4.result().subResult(1).setColor(0, 204, 204) +Fill_4.result().subResult(2).setColor(51, 51, 102) +Fill_4.result().subResult(3).setColor(102, 204, 102) +Fill_4.result().subResult(4).setColor(204, 204, 0) -Union_1 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Boolean_4_1_4"), model.selection("SOLID", "Boolean_4_1_2")]) +Union_1 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Fill_4_1_4"), model.selection("SOLID", "Fill_4_1_2")]) Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("FACE", "Plane_2 arrivee tuyau")) @@ -170,33 +170,33 @@ model.do() Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchArc_2_2f-SketchLine_18r")], model.selection("EDGE", "Sketch_4/Edge-SketchLine_18"), 0, 180) -Boolean_5 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_2_1")], [model.selection("SOLID", "Extrusion_3_1")]) -Boolean_5.result().setName("demi-sphere") +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_2_1")], [model.selection("SOLID", "Extrusion_3_1")]) +Cut_1.result().setName("demi-sphere") Plane_9 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_10&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/From_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_10&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/To_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_10&Extrusion_2_1/To_Face_4")) Plane_10 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_12&Extrusion_2_1/Generated_Face_11&Extrusion_2_1/To_Face_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_13&Extrusion_2_1/Generated_Face_12&Extrusion_2_1/To_Face_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_13&Extrusion_2_1/Generated_Face_12&Extrusion_2_1/From_Face_1")) Plane_11 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_5&Extrusion_2_1/Generated_Face_7&Extrusion_2_1/To_Face_3"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_3&Extrusion_2_1/Generated_Face_7&Extrusion_2_1/To_Face_3"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_5&Extrusion_2_1/Generated_Face_7&Extrusion_2_1/From_Face_3")) Plane_12 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_1&Extrusion_2_1/Generated_Face_4&Extrusion_2_1/To_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_4&Extrusion_2_1/To_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_4&Extrusion_2_1/From_Face_4")) -Recover_1 = model.addRecover(Part_1_doc, Boolean_5, [Extrusion_3.result()]) +Recover_1 = model.addRecover(Part_1_doc, Cut_1, [Extrusion_3.result()]) Plane_13 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape4"), model.selection("EDGE", "Recover_1_1/Shape4&Recover_1_1/Shape6"), "90+45") Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape1"), model.selection("EDGE", "Recover_1_1/Shape1&Recover_1_1/Shape6"), "90+45") Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape2"), model.selection("EDGE", "Recover_1_1/Shape2&Recover_1_1/Shape6"), "90+45") Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape6"), model.selection("EDGE", "Recover_1_1/Shape3&Recover_1_1/Shape6"), 45) -Boolean_6_objects_2 = [model.selection("FACE", "Plane_6"), model.selection("FACE", "Plane_7"), model.selection("FACE", "Plane_8"), model.selection("FACE", "Plane_9"), model.selection("FACE", "Plane_10"), model.selection("FACE", "Plane_11"), model.selection("FACE", "Plane_12"), model.selection("FACE", "Plane_13")] -Boolean_6 = model.addFill(Part_1_doc, [model.selection("SOLID", "demi-sphere")], Boolean_6_objects_2) +Fill_5_objects_2 = [model.selection("FACE", "Plane_6"), model.selection("FACE", "Plane_7"), model.selection("FACE", "Plane_8"), model.selection("FACE", "Plane_9"), model.selection("FACE", "Plane_10"), model.selection("FACE", "Plane_11"), model.selection("FACE", "Plane_12"), model.selection("FACE", "Plane_13")] +Fill_5 = model.addFill(Part_1_doc, [model.selection("SOLID", "demi-sphere")], Fill_5_objects_2) -Union_2_objects = [model.selection("SOLID", "Boolean_6_1_16"), model.selection("SOLID", "Boolean_6_1_13"), model.selection("SOLID", "Boolean_6_1_14")] +Union_2_objects = [model.selection("SOLID", "Fill_5_1_16"), model.selection("SOLID", "Fill_5_1_13"), model.selection("SOLID", "Fill_5_1_14")] Union_2 = model.addUnion(Part_1_doc, Union_2_objects) -Union_3_objects = [model.selection("SOLID", "Boolean_6_1_10/Boolean_6_1_10"), model.selection("SOLID", "Boolean_6_1_3/Boolean_6_1_3"), model.selection("SOLID", "Boolean_6_1_5/Boolean_6_1_5"), model.selection("SOLID", "Boolean_6_1_11/Boolean_6_1_11")] +Union_3_objects = [model.selection("SOLID", "Fill_5_1_10/Fill_5_1_10"), model.selection("SOLID", "Fill_5_1_3/Fill_5_1_3"), model.selection("SOLID", "Fill_5_1_5/Fill_5_1_5"), model.selection("SOLID", "Fill_5_1_11/Fill_5_1_11")] Union_3 = model.addUnion(Part_1_doc, Union_3_objects) -Union_4_objects = [model.selection("SOLID", "Boolean_6_1_12/Boolean_6_1_12"), model.selection("SOLID", "Boolean_6_1_6/Boolean_6_1_6"), model.selection("SOLID", "Boolean_6_1_4/Boolean_6_1_4")] +Union_4_objects = [model.selection("SOLID", "Fill_5_1_12/Fill_5_1_12"), model.selection("SOLID", "Fill_5_1_6/Fill_5_1_6"), model.selection("SOLID", "Fill_5_1_4/Fill_5_1_4")] Union_4 = model.addUnion(Part_1_doc, Union_4_objects) -Union_5_objects = [model.selection("SOLID", "Boolean_6_1_2/Boolean_6_1_2"), model.selection("SOLID", "Boolean_6_1_1/Boolean_6_1_1"), model.selection("SOLID", "Boolean_6_1_7/Boolean_6_1_7")] +Union_5_objects = [model.selection("SOLID", "Fill_5_1_2/Fill_5_1_2"), model.selection("SOLID", "Fill_5_1_1/Fill_5_1_1"), model.selection("SOLID", "Fill_5_1_7/Fill_5_1_7")] Union_5 = model.addUnion(Part_1_doc, Union_5_objects) -Union_6_objects = [model.selection("SOLID", "Boolean_6_1_8/Boolean_6_1_8"), model.selection("SOLID", "Boolean_6_1_9/Boolean_6_1_9"), model.selection("SOLID", "Boolean_6_1_15/Boolean_6_1_15")] +Union_6_objects = [model.selection("SOLID", "Fill_5_1_8/Fill_5_1_8"), model.selection("SOLID", "Fill_5_1_9/Fill_5_1_9"), model.selection("SOLID", "Fill_5_1_15/Fill_5_1_15")] Union_6 = model.addUnion(Part_1_doc, Union_6_objects) Union_6.result().setColor(0, 0, 204) Union_6.result().subResult(0).setColor(204, 102, 102) diff --git a/src/FeaturesPlugin/Test/TestBoolean.py b/src/FeaturesPlugin/Test/TestBoolean.py index 8398e133a..84c893e42 100644 --- a/src/FeaturesPlugin/Test/TestBoolean.py +++ b/src/FeaturesPlugin/Test/TestBoolean.py @@ -124,11 +124,9 @@ aSession.finishOperation() # Create a pacman as boolean cut of the prism from the cylinder #========================================================================= aSession.startOperation() -aBooleanFt = aPart.addFeature("Boolean") +aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(extrudedObjects[0], extrudedObjects[0].shape()) aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], extrudedObjects[1].shape()) -kBooleanTypeCut = 0 -aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut) aBooleanFt.execute() aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py index e2589d6d7..aad16ba71 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py +++ b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py @@ -117,11 +117,9 @@ aSession.finishOperation() # Create a pacman as boolean cut of the prism from the cylinder #========================================================================= aSession.startOperation() -aBooleanFt = aPart.addFeature("Boolean") +aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(modelAPI_ResultCompSolid(extrudedObjects[0]).subResult(1), None) aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], None) -aBooleanType = 0 -aBooleanFt.integer("bool_type").setValue(aBooleanType) aBooleanFt.execute() aSession.finishOperation() @@ -134,11 +132,9 @@ aSession.undo() # Fuse #========================================================================= aSession.startOperation() -aBooleanFt = aPart.addFeature("Boolean") +aBooleanFt = aPart.addFeature("Fuse") aBooleanFt.selectionList("main_objects").append(modelAPI_ResultCompSolid(extrudedObjects[0]).subResult(1), None) aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], None) -aBooleanType = 1 -aBooleanFt.integer("bool_type").setValue(aBooleanType) aBooleanFt.execute() aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash.py b/src/FeaturesPlugin/Test/TestBooleanSmash.py index 410c09da8..4be9090f0 100644 --- a/src/FeaturesPlugin/Test/TestBooleanSmash.py +++ b/src/FeaturesPlugin/Test/TestBooleanSmash.py @@ -108,11 +108,9 @@ aSession.finishOperation() # Smash prism into the cylinder #========================================================================= aSession.startOperation() -aBooleanFt = aPart.addFeature("Boolean") +aBooleanFt = aPart.addFeature("Smash") aBooleanFt.selectionList("main_objects").append(extrudedObjects[0], extrudedObjects[0].shape()) aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], extrudedObjects[1].shape()) -kBooleanTypeSmash = 3 -aBooleanFt.integer("bool_type").setValue(kBooleanTypeSmash) aBooleanFt.execute() aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py b/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py index 1fc541327..1f58f43bf 100644 --- a/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py +++ b/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py @@ -52,7 +52,7 @@ model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift", True) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) -Boolean_2 = model.addFill(Part_1_doc, [model.selection("COMPOUND", "Boolean_1_1")], [model.selection("SOLID", "Box_1_1")]) +Boolean_2 = model.addFill(Part_1_doc, [model.selection("COMPOUND", "Fill_1_1")], [model.selection("SOLID", "Box_1_1")]) model.do() model.checkBooleansResult(Boolean_2, model, 1, [6], [0], [6], [22], [44]) diff --git a/src/FeaturesPlugin/Test/TestFillShellSolid.py b/src/FeaturesPlugin/Test/TestFillShellSolid.py index c1e57f1d7..07d7fcaa1 100644 --- a/src/FeaturesPlugin/Test/TestFillShellSolid.py +++ b/src/FeaturesPlugin/Test/TestFillShellSolid.py @@ -52,7 +52,7 @@ model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift", True) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Boolean_1_1_2"), model.selection("FACE", "Boolean_1_1_1")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Fill_1_1_2"), model.selection("FACE", "Fill_1_1_1")]) Boolean_2 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("SOLID", "Box_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestFillSolidCompFace.py b/src/FeaturesPlugin/Test/TestFillSolidCompFace.py index 759c501ad..370f919ad 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidCompFace.py +++ b/src/FeaturesPlugin/Test/TestFillSolidCompFace.py @@ -52,7 +52,7 @@ model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) -Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Boolean_1_1")]) +Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Fill_1_1")]) model.do() model.checkBooleansResult(Boolean_2, model, 1, [2], [2], [14], [60], [120]) diff --git a/src/FeaturesPlugin/Test/TestFillSolidCompShell.py b/src/FeaturesPlugin/Test/TestFillSolidCompShell.py index 8e965a51c..ec7fe1163 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidCompShell.py +++ b/src/FeaturesPlugin/Test/TestFillSolidCompShell.py @@ -52,7 +52,7 @@ model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Boolean_1_1_2"), model.selection("FACE", "Boolean_1_1_1")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Fill_1_1_2"), model.selection("FACE", "Fill_1_1_1")]) MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), 1, 3) Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "LinearCopy_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestFillSolidShell.py b/src/FeaturesPlugin/Test/TestFillSolidShell.py index 6cf9389d1..beb13ea39 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidShell.py +++ b/src/FeaturesPlugin/Test/TestFillSolidShell.py @@ -52,7 +52,7 @@ model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Boolean_1_1_2"), model.selection("FACE", "Boolean_1_1_1")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Fill_1_1_2"), model.selection("FACE", "Fill_1_1_1")]) Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("SHELL", "Shell_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestMultiBoolean.py b/src/FeaturesPlugin/Test/TestMultiBoolean.py index 6884e490e..d332d786f 100644 --- a/src/FeaturesPlugin/Test/TestMultiBoolean.py +++ b/src/FeaturesPlugin/Test/TestMultiBoolean.py @@ -114,7 +114,7 @@ for i in xrange(0, N * N): anExtrusionFt.real("from_size").setValue(0) anExtrusionFt.real("to_size").setValue(10) anExtrusionFt.real("to_offset").setValue(0) #TODO: remove - anExtrusionFt.real("from_offset").setValue(0) #TODO: remove + anExtrusionFt.real("from_offset").setValue(0) #TODO: remove # v1.0.2 from master # anExtrusionFt.selection("extrusion_face").setValue( # aSketchResult, aSketchFaces[0]) @@ -194,13 +194,11 @@ aSession.finishOperation() aCurrentResult = modelAPI_ResultBody(aBox.firstResult()) aSession.startOperation() -aBooleanFt = aPart.addFeature("Boolean") +aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(aCurrentResult, aCurrentResult.shape()) for i in xrange(0, N * N): anExtrusionResult = modelAPI_ResultBody(anExtrusions[i].firstResult()) aBooleanFt.selectionList("tool_objects").append(anExtrusionResult, anExtrusionResult.shape()) -kBooleanTypeCut = 0 -aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut) aBooleanFt.execute() aFactory = ModelAPI_Session.get().validators() assert (aFactory.validate(aBooleanFt)) diff --git a/src/FeaturesPlugin/Test/TestSerialBoolean.py b/src/FeaturesPlugin/Test/TestSerialBoolean.py index c7361d274..08f4887d0 100644 --- a/src/FeaturesPlugin/Test/TestSerialBoolean.py +++ b/src/FeaturesPlugin/Test/TestSerialBoolean.py @@ -114,7 +114,7 @@ for i in xrange(0, N * N): anExtrusionFt.real("from_size").setValue(0) anExtrusionFt.real("to_size").setValue(10) anExtrusionFt.real("to_offset").setValue(0) #TODO: remove - anExtrusionFt.real("from_offset").setValue(0) #TODO: remove + anExtrusionFt.real("from_offset").setValue(0) #TODO: remove # v1.0.2 from master # anExtrusionFt.selection("extrusion_face").setValue( # aSketchResult, aSketchFaces[0]) @@ -197,11 +197,9 @@ aSession.startOperation() aFactory = ModelAPI_Session.get().validators() for i in xrange(0, N * N): anExtrusionResult = modelAPI_ResultBody(anExtrusions[i].firstResult()) - aBooleanFt = aPart.addFeature("Boolean") + aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(aCurrentResult, aCurrentResult.shape()) aBooleanFt.selectionList("tool_objects").append(anExtrusionResult, anExtrusionResult.shape()) - kBooleanTypeCut = 0 - aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut) aBooleanFt.execute() assert (aFactory.validate(aBooleanFt)) assert (len(aBooleanFt.results()) > 0) diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index 015c1d0e5..888ccf803 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -20,16 +20,6 @@ email : webmaster.salome@opencascade.com - - + diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 5a4ac2f52..099693180 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -54,7 +54,19 @@ email : webmaster.salome@opencascade.com - + + + + + + + + + @@ -65,6 +77,10 @@ email : webmaster.salome@opencascade.com + + + diff --git a/src/GeomValidators/CMakeLists.txt b/src/GeomValidators/CMakeLists.txt index 3b343b292..f8cb4d1e6 100644 --- a/src/GeomValidators/CMakeLists.txt +++ b/src/GeomValidators/CMakeLists.txt @@ -23,7 +23,6 @@ INCLUDE(Common) SET(PROJECT_HEADERS GeomValidators.h GeomValidators_BodyShapes.h - GeomValidators_BooleanArguments.h GeomValidators_ConstructionComposite.h GeomValidators_DifferentShapes.h GeomValidators_Face.h @@ -43,7 +42,6 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES GeomValidators_BodyShapes.cpp - GeomValidators_BooleanArguments.cpp GeomValidators_ConstructionComposite.cpp GeomValidators_DifferentShapes.cpp GeomValidators_Face.cpp diff --git a/src/GeomValidators/GeomValidators_BooleanArguments.cpp b/src/GeomValidators/GeomValidators_BooleanArguments.cpp deleted file mode 100644 index 7c16a6263..000000000 --- a/src/GeomValidators/GeomValidators_BooleanArguments.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2014-2017 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 - -#include - -#include -#include -#include -#include - -//================================================================================================= -bool GeomValidators_BooleanArguments::isValid(const std::shared_ptr& theFeature, - const std::list& theArguments, - Events_InfoMessage& theError) const -{ - if(theArguments.size() != 3) { - theError = "Wrong number of arguments (expected 3)."; - return false; - } - - int anObjectsNb = 0, aToolsNb = 0; - int anOperationType = 0; - - std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); - - bool isAllInSameCompSolid = true; - ResultCompSolidPtr aCompSolid; - - AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt); - if(anAttrSelList) { - anObjectsNb = anAttrSelList->size(); - for(int anIndex = 0; anIndex < anObjectsNb; ++anIndex) { - AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); - ResultPtr aContext = anAttr->context(); - ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); - if(aResCompSolidPtr.get()) { - if(aCompSolid.get()) { - isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; - } else { - aCompSolid = aResCompSolidPtr; - } - } else { - isAllInSameCompSolid = false; - break; - } - } - } - anIt++; - - - anAttrSelList = theFeature->selectionList(*anIt); - if(anAttrSelList) { - aToolsNb = anAttrSelList->size(); - if(isAllInSameCompSolid) { - for(int anIndex = 0; anIndex < aToolsNb; ++anIndex) { - AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); - ResultPtr aContext = anAttr->context(); - ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); - if(aResCompSolidPtr.get()) { - if(aCompSolid.get()) { - isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; - } else { - aCompSolid = aResCompSolidPtr; - } - } else { - isAllInSameCompSolid = false; - break; - } - } - } - } - anIt++; - - std::shared_ptr anAttrInt = theFeature->integer(*anIt); - if(anAttrInt) { - anOperationType = anAttrInt->value(); - } - - if(anOperationType == 1) { - // Fuse operation - if(anObjectsNb + aToolsNb < 2) { - theError = "Not enough arguments for Fuse operation."; - return false; - } else if(isAllInSameCompSolid) { - theError = "Operations only between sub-shapes of the same shape not allowed."; - return false; - } - } else { - if(anObjectsNb < 1) { - theError = "Objects not selected."; - return false; - } - if(aToolsNb < 1) { - theError = "Tools not selected."; - return false; - } - if(isAllInSameCompSolid) { - theError = "Operations only between sub-shapes of the same shape not allowed."; - return false; - } - } - - return true; -} - -//================================================================================================= -bool GeomValidators_BooleanArguments::isNotObligatory(std::string theFeature, - std::string theAttribute) -{ - if(theAttribute == "main_objects" || theAttribute == "tool_objects") { - return true; - } - - return false; -} diff --git a/src/GeomValidators/GeomValidators_BooleanArguments.h b/src/GeomValidators/GeomValidators_BooleanArguments.h deleted file mode 100644 index a246b4242..000000000 --- a/src/GeomValidators/GeomValidators_BooleanArguments.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2014-2017 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 GeomValidators_BooleanArguments_H -#define GeomValidators_BooleanArguments_H - -#include -#include -#include - -/** \class GeomValidators_BooleanArguments - * \ingroup Validators - * \brief Validates that boolean operation have enough arguments. - */ -class GeomValidators_BooleanArguments : public ModelAPI_FeatureValidator -{ -public: - /** \brief Returns true if feature and/or attributes are valid. - * \param[in] theFeature the validated feature. - * \param[in] theArguments the arguments in the configuration file for this validator. - * \param[out] theError error message. - * \returns true if feature is valid. - */ - GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, - const std::list& theArguments, - Events_InfoMessage& theError) const; - - /// \return true if the attribute in feature is not obligatory for the feature execution. - GEOMVALIDATORS_EXPORT virtual - bool isNotObligatory(std::string theFeature, std::string theAttribute); -}; - -#endif diff --git a/src/GeomValidators/GeomValidators_Plugin.cpp b/src/GeomValidators/GeomValidators_Plugin.cpp index 54ee61429..2f80b4995 100644 --- a/src/GeomValidators/GeomValidators_Plugin.cpp +++ b/src/GeomValidators/GeomValidators_Plugin.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -47,8 +46,6 @@ GeomValidators_Plugin::GeomValidators_Plugin() ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); aFactory->registerValidator("GeomValidators_BodyShapes", new GeomValidators_BodyShapes); - aFactory->registerValidator("GeomValidators_BooleanArguments", - new GeomValidators_BooleanArguments); aFactory->registerValidator("GeomValidators_ConstructionComposite", new GeomValidators_ConstructionComposite); aFactory->registerValidator("GeomValidators_Different", new GeomValidators_Different); diff --git a/src/ModelAPI/Test/Test1512.py b/src/ModelAPI/Test/Test1512.py index 9afa65d1c..4a3be33be 100755 --- a/src/ModelAPI/Test/Test1512.py +++ b/src/ModelAPI/Test/Test1512.py @@ -104,10 +104,9 @@ aSession.finishOperation() # Do cut a hole from a box #========================================================================= aSession.startOperation() -aCut1 = aPart.addFeature("Boolean") +aCut1 = aPart.addFeature("Cut") aCut1.selectionList("main_objects").append(aBox.firstResult(), None) aCut1.selectionList("tool_objects").append(aHoleExt.firstResult(), None) -aCut1.integer("bool_type").setValue(0) # cut aSession.finishOperation() #========================================================================= @@ -136,10 +135,9 @@ aSession.finishOperation() # Do fuse with a tower. Tower must be an argument (not tool) to add the problem to the faces owners detection. #========================================================================= aSession.startOperation() -aFuse = aPart.addFeature("Boolean") +aFuse = aPart.addFeature("Fuse") aFuse.selectionList("main_objects").append(aTower.firstResult(), None) aFuse.selectionList("tool_objects").append(aCut1.firstResult(), None) -aFuse.integer("bool_type").setValue(1) # fuse aSession.finishOperation() #========================================================================= @@ -156,12 +154,12 @@ def check_owner(selection, topology_type, feature): # check faces check_owner("Extrusion_1_1/Generated_Face_1", "face", aBox) -check_owner("Boolean_2_1/Modified_Face_3", "face", aBox) -check_owner("Boolean_1_1/Modified_Face_1", "face", aHoleExt) -check_owner("Boolean_2_1/Modified_Face_1", "face", aTower) +check_owner("Fuse_1_1/Modified_Face_3", "face", aBox) +check_owner("Cut_1_1/Modified_Face_1", "face", aHoleExt) +check_owner("Fuse_1_1/Modified_Face_1", "face", aTower) # check edges without ambiguity -check_owner("Boolean_2_1/Modified_Face_2&Extrusion_1_1/Generated_Face_2", "edge", aBox) -check_owner("Boolean_2_1/Modified_Face_1&Extrusion_3_1/To_Face_1_1", "edge", aTower) +check_owner("Fuse_1_1/Modified_Face_2&Extrusion_1_1/Generated_Face_2", "edge", aBox) +check_owner("Fuse_1_1/Modified_Face_1&Extrusion_3_1/To_Face_1_1", "edge", aTower) # check the connected topology method: solid is not a compound of connected topology assert(aFuse.firstResult().shape().isConnectedTopology() == False) diff --git a/src/ModelAPI/Test/Test2228.py b/src/ModelAPI/Test/Test2228.py index 666faafe6..46c17b094 100644 --- a/src/ModelAPI/Test/Test2228.py +++ b/src/ModelAPI/Test/Test2228.py @@ -57,7 +57,7 @@ model.do() Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_1")]) Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_2_2f")], model.selection(), model.selection("FACE", "Extrusion_2_1/From_Face_1"), 0, model.selection(), 0) Boolean_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_4_1")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Boolean_1_1"), model.selection("SOLID", "Boolean_2_1"), model.selection("FACE", "Face_1_1")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Cut_1_1"), model.selection("SOLID", "Cut_2_1"), model.selection("FACE", "Face_1_1")]) Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPOUND", "Partition_1_1")) Remove_SubShapes_1.setSubShapesToKeep([model.selection("COMPSOLID", "Partition_1_1_1")]) model.end()