From: azv Date: Mon, 10 Feb 2020 12:20:22 +0000 (+0300) Subject: General approach of versioning the feature. Update Boolean operations according. X-Git-Tag: V9_5_0a1^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=524d88b5c908ef4995ddd2b3975a4333a6db558d;p=modules%2Fshaper.git General approach of versioning the feature. Update Boolean operations according. --- diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp index 6b7236978..c28868287 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp @@ -34,13 +34,11 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( //================================================================================================== FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( const std::shared_ptr& theFeature, - const std::list& theMainObjects, - const int theVersion) + const std::list& theMainObjects) : ModelHighAPI_Interface(theFeature) { if(initialize()) { fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod); - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); fillAttribute(theMainObjects, mymainObjects); execute(false); @@ -51,13 +49,11 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion) + const std::list& theToolObjects) : ModelHighAPI_Interface(theFeature) { if(initialize()) { fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod); - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); fillAttribute(theMainObjects, mymainObjects); fillAttribute(theToolObjects, mytoolObjects); @@ -115,8 +111,6 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_BooleanCommon::VERSION_ID()); theDumper << "(" << aDocName << ", " << anObjects; @@ -124,44 +118,25 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const theDumper << ", " << aTools; } - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) { + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; - } theDumper << ")" << std::endl; } -//================================================================================================== -static BooleanCommonPtr addCommon(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const int theVersion) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID()); - return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theVersion)); -} - -//================================================================================================== -static BooleanCommonPtr addCommon(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID()); - return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, - theMainObjects, - theToolObjects, - theVersion)); -} - //================================================================================================== BooleanCommonPtr addCommon(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects, const bool keepSubResults) { - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; - return theToolObjects.empty() ? addCommon(thePart, theMainObjects, aVersion) - : addCommon(thePart, theMainObjects, theToolObjects, aVersion); + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID()); + if (!keepSubResults) + aFeature->data()->setVersion(""); + BooleanCommonPtr aCommon; + if (theToolObjects.empty()) + aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects)); + else + aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theToolObjects)); + return aCommon; } diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.h b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.h index 66d4e74cd..f7bc955be 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.h +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.h @@ -43,15 +43,13 @@ public: /// Constructor with values. FEATURESAPI_EXPORT FeaturesAPI_BooleanCommon(const std::shared_ptr& theFeature, - const std::list& theMainObjects, - const int theVersion = 0); + const std::list& theMainObjects); /// Constructor with values. FEATURESAPI_EXPORT FeaturesAPI_BooleanCommon(const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion = 0); + const std::list& theToolObjects); /// Destructor. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp index 6c44139de..64b4f4d46 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp @@ -34,12 +34,10 @@ FeaturesAPI_BooleanCut::FeaturesAPI_BooleanCut(const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion) + const std::list& theToolObjects) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); fillAttribute(theMainObjects, mymainObjects); fillAttribute(theToolObjects, mytoolObjects); @@ -81,13 +79,10 @@ void FeaturesAPI_BooleanCut::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_BooleanCut::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_BooleanCut::TOOL_LIST_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_BooleanCut::VERSION_ID()); theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools; - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; theDumper << ")" << std::endl; @@ -100,10 +95,9 @@ BooleanCutPtr addCut(const std::shared_ptr& thePart, const bool keepSubResults) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCut::ID()); - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; + if (!keepSubResults) + aFeature->data()->setVersion(""); return BooleanCutPtr(new FeaturesAPI_BooleanCut(aFeature, theMainObjects, - theToolObjects, - aVersion)); + theToolObjects)); } diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCut.h b/src/FeaturesAPI/FeaturesAPI_BooleanCut.h index 80beb3175..9c9c6bad3 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanCut.h +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCut.h @@ -44,8 +44,7 @@ public: FEATURESAPI_EXPORT FeaturesAPI_BooleanCut(const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion = 0); + const std::list& theToolObjects); /// Destructor. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp index da25a8b43..6bd8c314a 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp @@ -35,12 +35,10 @@ FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill( FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill( const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion) + const std::list& theToolObjects) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); fillAttribute(theMainObjects, mymainObjects); fillAttribute(theToolObjects, mytoolObjects); @@ -84,13 +82,10 @@ void FeaturesAPI_BooleanFill::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_BooleanFill::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_BooleanFill::TOOL_LIST_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_BooleanFill::VERSION_ID()); theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools; - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; theDumper << ")" << std::endl; @@ -103,10 +98,7 @@ BooleanFillPtr addSplit(const std::shared_ptr& thePart, const bool keepSubResults) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFill::ID()); - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; - return BooleanFillPtr(new FeaturesAPI_BooleanFill(aFeature, - theMainObjects, - theToolObjects, - aVersion)); + if (!keepSubResults) + aFeature->data()->setVersion(""); + return BooleanFillPtr(new FeaturesAPI_BooleanFill(aFeature, theMainObjects, theToolObjects)); } diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFill.h b/src/FeaturesAPI/FeaturesAPI_BooleanFill.h index 7375db2cf..7efc0e772 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanFill.h +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFill.h @@ -44,8 +44,7 @@ public: FEATURESAPI_EXPORT FeaturesAPI_BooleanFill(const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion = 0); + const std::list& theToolObjects); /// Destructor. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp index a80b06908..74d45c3be 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp @@ -35,13 +35,11 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( const std::shared_ptr& theFeature, const std::list& theMainObjects, - const bool theRemoveEdges, - const int theVersion) + const bool theRemoveEdges) : ModelHighAPI_Interface(theFeature) { if (initialize()) { fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod); - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); fillAttribute(theMainObjects, mymainObjects); fillAttribute(theRemoveEdges, myremoveEdges); @@ -54,13 +52,11 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( const std::shared_ptr& theFeature, const std::list& theMainObjects, const std::list& theToolObjects, - const bool theRemoveEdges, - const int theVersion) + const bool theRemoveEdges) : ModelHighAPI_Interface(theFeature) { if(initialize()) { fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod); - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); fillAttribute(theMainObjects, mymainObjects); fillAttribute(theToolObjects, mytoolObjects); fillAttribute(theRemoveEdges, myremoveEdges); @@ -129,8 +125,6 @@ void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_BooleanFuse::TOOL_LIST_ID()); AttributeBooleanPtr aRemoveEdges = aBase->boolean(FeaturesPlugin_BooleanFuse::REMOVE_INTERSECTION_EDGES_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_BooleanFuse::VERSION_ID()); theDumper << "(" << aDocName << ", " << anObjects; @@ -142,42 +136,12 @@ void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const theDumper << ", removeEdges = True"; } - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) { + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; - } theDumper << ")" << std::endl; } -//================================================================================================== -static BooleanFusePtr addFuse(const std::shared_ptr& thePart, - const std::list& theObjects, - const bool theRemoveEdges, - const int theVersion) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID()); - return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature, - theObjects, - theRemoveEdges, - theVersion)); -} - -//================================================================================================== -static BooleanFusePtr addFuse(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const std::list& theToolObjects, - const bool theRemoveEdges, - const int theVersion) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID()); - return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature, - theMainObjects, - theToolObjects, - theRemoveEdges, - theVersion)); -} - //================================================================================================== BooleanFusePtr addFuse(const std::shared_ptr& thePart, const std::list& theMainObjects, @@ -185,12 +149,20 @@ BooleanFusePtr addFuse(const std::shared_ptr& thePart, const bool theRemoveEdges, const bool keepSubResults) { - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID()); + if (!keepSubResults) + aFeature->data()->setVersion(""); + bool aRemoveEdges = theRemoveEdges; if (theToolObjects.first.empty()) aRemoveEdges = aRemoveEdges || theToolObjects.second; - return theToolObjects.first.empty() ? - addFuse(thePart, theMainObjects, aRemoveEdges, aVersion) : - addFuse(thePart, theMainObjects, theToolObjects.first, aRemoveEdges, aVersion); + + BooleanFusePtr aFuse; + if (theToolObjects.first.empty()) + aFuse.reset(new FeaturesAPI_BooleanFuse(aFeature, theMainObjects, aRemoveEdges)); + else { + aFuse.reset(new FeaturesAPI_BooleanFuse(aFeature, theMainObjects, theToolObjects.first, + aRemoveEdges)); + } + return aFuse; } diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h index 307a886bb..552f13807 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h @@ -44,16 +44,14 @@ public: FEATURESAPI_EXPORT FeaturesAPI_BooleanFuse(const std::shared_ptr& theFeature, const std::list& theMainObjects, - const bool theRemoveEdges = false, - const int theVersion = 0); + const bool theRemoveEdges = false); /// Constructor with values. FEATURESAPI_EXPORT FeaturesAPI_BooleanFuse(const std::shared_ptr& theFeature, const std::list& theMainObjects, const std::list& theToolObjects, - const bool theRemoveEdges = false, - const int theVersion = 0); + const bool theRemoveEdges = false); /// Destructor. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp index a91647c09..0d2abf81f 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp @@ -35,12 +35,10 @@ FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash( FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash( const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion) + const std::list& theToolObjects) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); fillAttribute(theMainObjects, mymainObjects); fillAttribute(theToolObjects, mytoolObjects); @@ -84,13 +82,10 @@ void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_BooleanSmash::TOOL_LIST_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_BooleanSmash::VERSION_ID()); theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools; - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; theDumper << ")" << std::endl; @@ -103,10 +98,7 @@ BooleanSmashPtr addSmash(const std::shared_ptr& thePart, const bool keepSubResults) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanSmash::ID()); - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; - return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, - theMainObjects, - theToolObjects, - aVersion)); + if (!keepSubResults) + aFeature->data()->setVersion(""); + return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, theMainObjects, theToolObjects)); } diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.h b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.h index 46d9fd870..503255ff1 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.h +++ b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.h @@ -44,8 +44,7 @@ public: FEATURESAPI_EXPORT FeaturesAPI_BooleanSmash(const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects, - const int theVersion = 0); + const std::list& theToolObjects); /// Destructor. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_Partition.cpp b/src/FeaturesAPI/FeaturesAPI_Partition.cpp index 8e5ac5658..6d383f422 100644 --- a/src/FeaturesAPI/FeaturesAPI_Partition.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Partition.cpp @@ -32,12 +32,10 @@ FeaturesAPI_Partition::FeaturesAPI_Partition(const std::shared_ptr& theFeature, - const std::list& theBaseObjects, - const int theVersion) + const std::list& theBaseObjects) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Partition::VERSION_ID())); setBase(theBaseObjects); } } @@ -64,13 +62,10 @@ void FeaturesAPI_Partition::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Partition::BASE_OBJECTS_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_Partition::VERSION_ID()); theDumper << aBase << " = model.addPartition(" << aDocName << ", " << anAttrObjects; - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; theDumper << ")" << std::endl; @@ -81,8 +76,8 @@ PartitionPtr addPartition(const std::shared_ptr& thePart, const std::list& theBaseObjects, const bool keepSubResults) { - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Partition::ID()); - return PartitionPtr(new FeaturesAPI_Partition(aFeature, theBaseObjects, aVersion)); + if (!keepSubResults) + aFeature->data()->setVersion(""); + return PartitionPtr(new FeaturesAPI_Partition(aFeature, theBaseObjects)); } diff --git a/src/FeaturesAPI/FeaturesAPI_Partition.h b/src/FeaturesAPI/FeaturesAPI_Partition.h index 392aa5907..e324b26b1 100644 --- a/src/FeaturesAPI/FeaturesAPI_Partition.h +++ b/src/FeaturesAPI/FeaturesAPI_Partition.h @@ -43,8 +43,7 @@ public: /// Constructor with values. FEATURESAPI_EXPORT explicit FeaturesAPI_Partition(const std::shared_ptr& theFeature, - const std::list& theBaseObjects, - const int theVersion = 0); + const std::list& theBaseObjects); /// Destructor. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_Union.cpp b/src/FeaturesAPI/FeaturesAPI_Union.cpp index bc8bc1859..7e20fb1a5 100644 --- a/src/FeaturesAPI/FeaturesAPI_Union.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Union.cpp @@ -31,12 +31,10 @@ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& th //================================================================================================ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& theFeature, - const std::list& theBaseObjects, - const int theVersion) + const std::list& theBaseObjects) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_VersionedBoolean::VERSION_ID())); setBase(theBaseObjects); } } @@ -63,13 +61,10 @@ void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_Union::VERSION_ID()); theDumper << aBase << " = model.addUnion(" << aDocName << ", " << anAttrObjects; - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; theDumper << ")" << std::endl; @@ -80,8 +75,8 @@ UnionPtr addUnion(const std::shared_ptr& thePart, const std::list& theBaseObjects, const bool keepSubResults) { - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Union::ID()); - return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects, aVersion)); + if (!keepSubResults) + aFeature->data()->setVersion(""); + return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects)); } diff --git a/src/FeaturesAPI/FeaturesAPI_Union.h b/src/FeaturesAPI/FeaturesAPI_Union.h index bcc6aee2e..693a06b5e 100644 --- a/src/FeaturesAPI/FeaturesAPI_Union.h +++ b/src/FeaturesAPI/FeaturesAPI_Union.h @@ -43,8 +43,7 @@ public: /// Constructor with values. FEATURESAPI_EXPORT explicit FeaturesAPI_Union(const std::shared_ptr& theFeature, - const std::list& theBaseObjects, - const int theVersion = 0); + const std::list& theBaseObjects); /// Destructor. FEATURESAPI_EXPORT diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index f307e317b..bdca89390 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -568,4 +568,5 @@ ADD_UNIT_TESTS(TestExtrusion.py TestDefeaturing_OnCompound.py Test3137_1.py Test3137_2.py + Test3139.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp index 1afe60e8b..be2c09a50 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp @@ -52,7 +52,7 @@ void FeaturesPlugin_BooleanCommon::initAttributes() data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); - initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); } //================================================================================================== @@ -87,7 +87,7 @@ void FeaturesPlugin_BooleanCommon::execute() } // version of COMMON feature - int aCommonVersion = version(); + const std::string aCommonVersion = data()->version(); int aResultIndex = 0; GeomShapePtr aResultCompound; @@ -115,7 +115,7 @@ void FeaturesPlugin_BooleanCommon::execute() aMakeShapeList->appendAlgo(aCommonAlgo); } - if (aCommonVersion == THE_VERSION_1) { + if (aCommonVersion == BOP_VERSION_9_4()) { // merge hierarchies of compounds containing objects and tools // and append the result of the FUSE operation aShape = keepUnusedSubsOfCompound(aShape, anObjects, aTools, aMakeShapeList); @@ -147,7 +147,7 @@ void FeaturesPlugin_BooleanCommon::execute() aResultShapesList.push_back(aShape); } } else { - if (aCommonVersion == THE_VERSION_1) { + if (aCommonVersion == BOP_VERSION_9_4()) { // merge hierarchies of compounds containing objects and tools aResultCompound = keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList); diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp index d954e917d..bc67a28e1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp @@ -45,7 +45,7 @@ FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut() void FeaturesPlugin_BooleanCut::initAttributes() { FeaturesPlugin_Boolean::initAttributes(); - initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); } //================================================================================================== @@ -67,9 +67,6 @@ void FeaturesPlugin_BooleanCut::execute() return; } - // version of CUT feature - int aCutVersion = version(); - std::vector aResultBaseAlgoList; ListOfShape aResultShapesList; std::string anError; @@ -77,7 +74,7 @@ void FeaturesPlugin_BooleanCut::execute() std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); GeomShapePtr aResultCompound; - if (aCutVersion == THE_VERSION_1) { + if (data()->version() == BOP_VERSION_9_4()) { // merge hierarchies of compounds containing objects and tools aResultCompound = keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList); diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp index 6db4eb4d9..3f6dd4cc0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp @@ -50,7 +50,7 @@ FeaturesPlugin_BooleanFill::FeaturesPlugin_BooleanFill() void FeaturesPlugin_BooleanFill::initAttributes() { FeaturesPlugin_Boolean::initAttributes(); - initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); } //================================================================================================= @@ -78,16 +78,13 @@ void FeaturesPlugin_BooleanFill::execute() return; } - // version of Split feature - int aSplitVersion = version(); - std::vector aResultBaseAlgoList; ListOfShape aResultShapesList; std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); GeomShapePtr aResultCompound; - if (aSplitVersion == THE_VERSION_1) { + if (data()->version() == BOP_VERSION_9_4()) { // merge hierarchies of compounds containing objects and tools aResultCompound = keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList); diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp index 242629097..a7a1b0cc1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp @@ -60,7 +60,7 @@ void FeaturesPlugin_BooleanFuse::initAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID()); - initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); } //================================================================================================== @@ -102,7 +102,7 @@ void FeaturesPlugin_BooleanFuse::execute() } // version of FUSE feature - int aFuseVersion = version(); + const std::string aFuseVersion = data()->version(); // Collecting all solids which will be fused. ListOfShape aSolidsToFuse; @@ -111,7 +111,7 @@ void FeaturesPlugin_BooleanFuse::execute() // Collecting solids from compsolids which will not be modified // in boolean operation and will be added to result. - bool isProcessCompsolid = !isSimpleCreation || aFuseVersion >= THE_VERSION_1; + bool isProcessCompsolid = !isSimpleCreation || !aFuseVersion.empty(); ListOfShape aShapesToAdd; for (ObjectHierarchy::Iterator anObjectsIt = anObjectsHierarchy.Begin(); isProcessCompsolid && anObjectsIt != anObjectsHierarchy.End(); @@ -234,7 +234,7 @@ void FeaturesPlugin_BooleanFuse::execute() aMakeShapeList->appendAlgo(aUnifyAlgo); } - if (aFuseVersion == THE_VERSION_1) { + if (aFuseVersion == BOP_VERSION_9_4()) { // merge hierarchies of compounds containing objects and tools // and append the result of the FUSE operation aShape = keepUnusedSubsOfCompound(aShape, anObjectsHierarchy, aToolsHierarchy, aMakeShapeList); diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp index 11b47079e..9d053f0e9 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp @@ -47,7 +47,7 @@ void FeaturesPlugin_BooleanSmash::initAttributes() data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); - initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); } //================================================================================================== @@ -167,8 +167,7 @@ void FeaturesPlugin_BooleanSmash::execute() } // take into account a version of SMASH feature - int aSmashVersion = version(); - if (aSmashVersion == THE_VERSION_1) { + if (data()->version() == BOP_VERSION_9_4()) { // merge hierarchies of compounds containing objects and tools // and append the result of the FUSE operation aShape = keepUnusedSubsOfCompound(aShape, anObjectsHistory, aToolsHistory, aMakeShapeList); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index 824a9cb46..58b3784e9 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -58,7 +58,7 @@ FeaturesPlugin_Partition::FeaturesPlugin_Partition() void FeaturesPlugin_Partition::initAttributes() { data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); - initVersion(THE_VERSION_1, selectionList(BASE_OBJECTS_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID())); } //================================================================================================= @@ -124,8 +124,7 @@ void FeaturesPlugin_Partition::execute() int aResultIndex = 0; - int aPartitionVersion = version(); - if (aPartitionVersion < THE_VERSION_1) { + if (data()->version().empty()) { // default behaviors of Partition if(aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) { for(GeomAPI_ShapeIterator anIt(aResultShape); anIt.more(); anIt.next()) { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp index 5663d6918..0a3107b76 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp @@ -42,7 +42,7 @@ FeaturesPlugin_Union::FeaturesPlugin_Union() void FeaturesPlugin_Union::initAttributes() { data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); - initVersion(THE_VERSION_1, selectionList(BASE_OBJECTS_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID())); } //================================================================================================= @@ -65,7 +65,6 @@ void FeaturesPlugin_Union::execute() std::vector aResultBaseAlgoList; ListOfShape aResultShapesList; - int aUnionVersion = version(); GeomShapePtr aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(ListOfShape()); // Fuse objects. @@ -102,7 +101,7 @@ void FeaturesPlugin_Union::execute() GeomShapePtr aShape; GeomAPI_ShapeIterator aCIt(aResultCompound); - if (aUnionVersion < THE_VERSION_1) { + if (data()->version().empty()) { // if the compound consists of a single sub-shape, take it, // otherwise, take the full compound aShape = aCIt.current(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp index ea18dd5a9..bba9645aa 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp @@ -71,19 +71,20 @@ static void performBoolean(const GeomAlgoAPI_Tools::BOPType theBooleanType, } //================================================================================================= -void FeaturesPlugin_VersionedBoolean::initVersion(const int theVersion, +void FeaturesPlugin_VersionedBoolean::initVersion(const std::string& theVersion, const AttributePtr theObjectsAttr, const AttributePtr theToolsAttr) { - AttributePtr aVerAttr = data()->addAttribute(VERSION_ID(), ModelAPI_AttributeInteger::typeId()); - aVerAttr->setIsArgument(false); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID()); - if (!integer(VERSION_ID())->isInitialized() && - (!theObjectsAttr || !theObjectsAttr->isInitialized()) && - (!theToolsAttr || !theToolsAttr->isInitialized())) { + AttributeIntegerPtr anOldVersionAttr = integer("version"); + if (anOldVersionAttr && anOldVersionAttr->isInitialized() && data()->version().empty()) { + // move value to the common version interface in ModelAPI_Data + data()->setVersion(BOP_VERSION_9_4()); + } + else if ((!theObjectsAttr || !theObjectsAttr->isInitialized()) && + (!theToolsAttr || !theToolsAttr->isInitialized())) { // this is a newly created feature (not read from file), // so, initialize the latest version - integer(VERSION_ID())->setValue(theVersion); + data()->setVersion(theVersion); } } @@ -450,16 +451,6 @@ void FeaturesPlugin_VersionedBoolean::resizePlanes( } } -//================================================================================================= -int FeaturesPlugin_VersionedBoolean::version() -{ - AttributeIntegerPtr aVersionAttr = integer(VERSION_ID()); - int aVersion = 0; - if (aVersionAttr && aVersionAttr->isInitialized()) - aVersion = aVersionAttr->value(); - return aVersion; -} - //================================================================================================= void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddObject(const GeomShapePtr& theObject) diff --git a/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.h index 21db544d7..098509c3c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.h @@ -36,26 +36,20 @@ class GeomAlgoAPI_MakeShapeList; /// \brief Feature controls a version of Boolean operations. class FeaturesPlugin_VersionedBoolean : public ModelAPI_Feature { -public: - static const int THE_VERSION_0 = 0; - static const int THE_VERSION_1 = 20190506; - - /// Attribute name of the version of Boolean feature - inline static const std::string& VERSION_ID() +protected: + static const std::string& BOP_VERSION_9_4() { - static const std::string MY_VERSION_ID("version"); - return MY_VERSION_ID; + static const std::string VERSION("v9.4"); + return VERSION; } -protected: - /// Use plugin manager for features creation. FeaturesPlugin_VersionedBoolean() {} /// Initialize version field of the Boolean feature. /// The version is initialized for newly created features, /// not read from previously stored document. - void initVersion(const int theVersion, + void initVersion(const std::string& theVersion, const std::shared_ptr theObjectsAttr = std::shared_ptr(), const std::shared_ptr theToolsAttr @@ -203,9 +197,6 @@ protected: const ObjectHierarchy& theToolsHierarchy, std::shared_ptr theMakeShapeList); - /// Return version of the feature - int version(); - private: void parentForShape(const GeomShapePtr& theShape, const std::shared_ptr& theContext, diff --git a/src/FeaturesPlugin/Test/Test3139.py b/src/FeaturesPlugin/Test/Test3139.py new file mode 100644 index 000000000..351bebad0 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test3139.py @@ -0,0 +1,124 @@ +# Copyright (C) 2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(52.9121725731895, 8.799859429739596, 7.781201848998454, 8.799859429739596) +SketchLine_2 = Sketch_1.addLine(7.781201848998454, 8.799859429739596, 7.781201848998454, 36.33111129445148) +SketchLine_3 = Sketch_1.addLine(7.781201848998454, 36.33111129445148, 52.9121725731895, 36.33111129445148) +SketchLine_4 = Sketch_1.addLine(52.9121725731895, 36.33111129445148, 52.9121725731895, 8.799859429739596) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +SketchLine_5 = Sketch_1.addLine(29.87981510015411, 36.33111129445148, 29.87981510015411, 8.799859429739596) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_3.result()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_1.result()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_5.result()) +SketchCircle_1 = Sketch_1.addCircle(88.70570107858241, 30.96918335901386, 15.95582825781952) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 20, 0) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchLine_6 = Sketch_2.addLine(91.78842679005474, 52.44197384283513, 18.42664179347724, 52.44197384283513) +SketchLine_7 = Sketch_2.addLine(18.42664179347724, 52.44197384283513, 18.42664179347724, 23.73518840939176) +SketchLine_8 = Sketch_2.addLine(18.42664179347724, 23.73518840939176, 91.78842679005474, 23.73518840939176) +SketchLine_9 = Sketch_2.addLine(91.78842679005474, 23.73518840939176, 91.78842679005474, 52.44197384283513) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_6.result()) +SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_7.result()) +SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_8.result()) +SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_9.result()) +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7f-SketchLine_8f-SketchLine_9f")], model.selection(), 10, 0) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) +model.do() + +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() +Sketch_3 = model.addSketch(Part_2_doc, model.defaultPlane("XOY")) +SketchLine_10 = Sketch_3.addLine(52.9121725731895, 8.799859429739596, 7.781201848998454, 8.799859429739596) +SketchLine_11 = Sketch_3.addLine(7.781201848998454, 8.799859429739596, 7.781201848998454, 36.33111129445148) +SketchLine_12 = Sketch_3.addLine(7.781201848998454, 36.33111129445148, 52.9121725731895, 36.33111129445148) +SketchLine_13 = Sketch_3.addLine(52.9121725731895, 36.33111129445148, 52.9121725731895, 8.799859429739596) +SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_10.result()) +SketchConstraintVertical_6 = Sketch_3.setVertical(SketchLine_11.result()) +SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_12.result()) +SketchConstraintVertical_7 = Sketch_3.setVertical(SketchLine_13.result()) +SketchLine_14 = Sketch_3.addLine(29.87981510015411, 36.33111129445148, 29.87981510015411, 8.799859429739596) +SketchConstraintCoincidence_15 = Sketch_3.setCoincident(SketchLine_14.startPoint(), SketchLine_12.result()) +SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_10.result()) +SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_14.result()) +SketchCircle_2 = Sketch_3.addCircle(88.70570107858241, 30.96918335901386, 15.95582825781952) +model.do() +Extrusion_3 = model.addExtrusion(Part_2_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 20, 0) +Compound_2 = model.addCompound(Part_2_doc, [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) +Sketch_4 = model.addSketch(Part_2_doc, model.standardPlane("XOY")) +SketchLine_15 = Sketch_4.addLine(91.78842679005474, 52.44197384283513, 18.42664179347724, 52.44197384283513) +SketchLine_16 = Sketch_4.addLine(18.42664179347724, 52.44197384283513, 18.42664179347724, 23.73518840939176) +SketchLine_17 = Sketch_4.addLine(18.42664179347724, 23.73518840939176, 91.78842679005474, 23.73518840939176) +SketchLine_18 = Sketch_4.addLine(91.78842679005474, 23.73518840939176, 91.78842679005474, 52.44197384283513) +SketchConstraintCoincidence_17 = Sketch_4.setCoincident(SketchLine_18.endPoint(), SketchLine_15.startPoint()) +SketchConstraintCoincidence_18 = Sketch_4.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +SketchConstraintCoincidence_19 = Sketch_4.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint()) +SketchConstraintCoincidence_20 = Sketch_4.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint()) +SketchConstraintHorizontal_7 = Sketch_4.setHorizontal(SketchLine_15.result()) +SketchConstraintVertical_9 = Sketch_4.setVertical(SketchLine_16.result()) +SketchConstraintHorizontal_8 = Sketch_4.setHorizontal(SketchLine_17.result()) +SketchConstraintVertical_10 = Sketch_4.setVertical(SketchLine_18.result()) +model.do() +Extrusion_4 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7f-SketchLine_8f-SketchLine_9f")], model.selection(), 10, 0) +Cut_2 = model.addCut(Part_2_doc, [model.selection("SOLID", "Compound_1_1_1_1")], [model.selection("SOLID", "Extrusion_2_1")], keepSubResults = True) +model.do() + +model.end() + +from GeomAPI import * + +model.testNbResults(Part_1, 1) +model.testNbSubResults(Part_1, [0]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [16]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [74]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [148]) +model.testResultsVolumes(Part_1, [23407.60956]) + +model.testNbResults(Part_2, 1) +model.testNbSubResults(Part_2, [0]) +model.testNbSubShapes(Part_2, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Part_2, GeomAPI_Shape.FACE, [19]) +model.testNbSubShapes(Part_2, GeomAPI_Shape.EDGE, [80]) +model.testNbSubShapes(Part_2, GeomAPI_Shape.VERTEX, [160]) +model.testResultsVolumes(Part_2, [39403.873983562]) diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 2a25c5136..a47d95c2f 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -77,7 +77,7 @@ static const int kFlagDisplayed = 1; static const int kFlagDeleted = 2; // TDataStd_Integer - 0 if the name of the object is generated automatically, // otherwise the name is defined by user -Standard_GUID kUSER_DEFINED_NAME("9c694d18-a83c-4a56-bc9b-8020628a8244"); +static const Standard_GUID kUSER_DEFINED_NAME("9c694d18-a83c-4a56-bc9b-8020628a8244"); // invalid data const static std::shared_ptr kInvalid(new Model_Data()); @@ -85,6 +85,9 @@ const static std::shared_ptr kInvalid(new Model_Data()); static const Standard_GUID kGroupAttributeGroupID("df64ea4c-fc42-4bf8-ad7e-08f7a54bf1b8"); static const Standard_GUID kGroupAttributeID("ebdcb22a-e045-455b-9a7f-cfd38d68e185"); +// id of attribute to store the version of the feature +static const Standard_GUID kVERSION_ID("61cdb78a-1ba7-4942-976f-63bea7f4a2b1"); + Model_Data::Model_Data() : mySendAttributeUpdated(true), myWasChangedButBlocked(false) { @@ -158,6 +161,24 @@ bool Model_Data::hasUserDefinedName() const return shapeLab().IsAttribute(kUSER_DEFINED_NAME); } +std::string Model_Data::version() +{ + Handle(TDataStd_Name) aVersionAttr; + std::string aVersion; + if (shapeLab().FindAttribute(kVERSION_ID, aVersionAttr)) + aVersion = TCollection_AsciiString(aVersionAttr->Get()).ToCString(); + return aVersion; +} + +void Model_Data::setVersion(const std::string& theVersion) +{ + Handle(TDataStd_Name) aVersionAttr; + std::string aVersion; + if (!shapeLab().FindAttribute(kVERSION_ID, aVersionAttr)) + aVersionAttr = TDataStd_Name::Set(shapeLab(), kVERSION_ID, TCollection_ExtendedString()); + aVersionAttr->Set(theVersion.c_str()); +} + AttributePtr Model_Data::addAttribute( const std::string& theID, const std::string theAttrType, const int theIndex) { diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 7f9fa9b01..fa833bdd3 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -107,6 +107,10 @@ class Model_Data : public ModelAPI_Data MODEL_EXPORT virtual void setName(const std::string& theName); /// Return \c true if the object has been renamed by the user MODEL_EXPORT virtual bool hasUserDefinedName() const; + /// Returns version of the feature (empty string if not applicable) + MODEL_EXPORT virtual std::string version(); + /// Initialize the version of the feature + MODEL_EXPORT virtual void setVersion(const std::string& theVersion); /// Returns the attribute that references to another document MODEL_EXPORT virtual std::shared_ptr document(const std::string& theID); /// Returns the attribute that contains real value with double precision diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index de771058d..bed7201ac 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -78,6 +78,11 @@ class MODELAPI_EXPORT ModelAPI_Data /// Return \c true if the object has been renamed by the user virtual bool hasUserDefinedName() const = 0; + /// Returns version of the feature (empty string if not applicable) + virtual std::string version() = 0; + /// Initialize the version of the feature + virtual void setVersion(const std::string& theVersion) = 0; + /// Returns the attribute that references to another document virtual std::shared_ptr document(const std::string& theID) = 0; /// Returns the attribute that contains real value with double precision diff --git a/test.hdfs/Test3139.hdf b/test.hdfs/Test3139.hdf new file mode 100644 index 000000000..cbd6dd31a Binary files /dev/null and b/test.hdfs/Test3139.hdf differ diff --git a/test.hdfs/Test3139.py b/test.hdfs/Test3139.py new file mode 100644 index 000000000..7787a0e05 --- /dev/null +++ b/test.hdfs/Test3139.py @@ -0,0 +1,37 @@ +# Copyright (C) 2020 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 +# + +if __name__ == "__main__": + aPartFeature = locals()["Part_1"] + model.testNbResults(aPartFeature, 1) + model.testNbSubResults(aPartFeature, [0]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [2]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [16]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [74]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [148]) + model.testResultsVolumes(aPartFeature, [23407.60956]) + + aPartFeature = locals()["Part_2"] + model.testNbResults(aPartFeature, 1) + model.testNbSubResults(aPartFeature, [0]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [3]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [19]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [80]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [160]) + model.testResultsVolumes(aPartFeature, [39403.873983562])