]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
General approach of versioning the feature. Update Boolean operations according.
authorazv <azv@opencascade.com>
Mon, 10 Feb 2020 12:20:22 +0000 (15:20 +0300)
committerazv <azv@opencascade.com>
Tue, 11 Feb 2020 07:02:05 +0000 (10:02 +0300)
30 files changed:
src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp
src/FeaturesAPI/FeaturesAPI_BooleanCommon.h
src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp
src/FeaturesAPI/FeaturesAPI_BooleanCut.h
src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp
src/FeaturesAPI/FeaturesAPI_BooleanFill.h
src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp
src/FeaturesAPI/FeaturesAPI_BooleanFuse.h
src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp
src/FeaturesAPI/FeaturesAPI_BooleanSmash.h
src/FeaturesAPI/FeaturesAPI_Partition.cpp
src/FeaturesAPI/FeaturesAPI_Partition.h
src/FeaturesAPI/FeaturesAPI_Union.cpp
src/FeaturesAPI/FeaturesAPI_Union.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/FeaturesPlugin/FeaturesPlugin_Union.cpp
src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.h
src/FeaturesPlugin/Test/Test3139.py [new file with mode: 0644]
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/ModelAPI/ModelAPI_Data.h
test.hdfs/Test3139.hdf [new file with mode: 0644]
test.hdfs/Test3139.py [new file with mode: 0644]

index 6b723697828d1f0f47e54f8ebc04f0014a6f29ed..c288682874d47a4050140029f91f8347234b518e 100644 (file)
@@ -34,13 +34,11 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
 //==================================================================================================
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
-  const std::list<ModelHighAPI_Selection>& theMainObjects,
-  const int theVersion)
+  const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
-  const std::list<ModelHighAPI_Selection>& theToolObjects,
-  const int theVersion)
+  const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
-                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                  const int theVersion)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
-  return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theVersion));
-}
-
-//==================================================================================================
-static BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
-                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                  const std::list<ModelHighAPI_Selection>& theToolObjects,
-                                  const int theVersion)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
-  return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature,
-                                                        theMainObjects,
-                                                        theToolObjects,
-                                                        theVersion));
-}
-
 //==================================================================================================
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
                            const std::list<ModelHighAPI_Selection>& theMainObjects,
                            const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Feature> 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;
 }
index 66d4e74cdbe266b8c6a324435d3048bbdaa4b2a3..f7bc955be15ce568a82eb01de59256a81fc4afdd 100644 (file)
@@ -43,15 +43,13 @@ public:
     /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                            const std::list<ModelHighAPI_Selection>& theMainObjects,
-                            const int theVersion = 0);
+                            const std::list<ModelHighAPI_Selection>& theMainObjects);
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                             const std::list<ModelHighAPI_Selection>& theMainObjects,
-                            const std::list<ModelHighAPI_Selection>& theToolObjects,
-                            const int theVersion = 0);
+                            const std::list<ModelHighAPI_Selection>& theToolObjects);
 
   /// Destructor.
   FEATURESAPI_EXPORT
index 6c44139de891e69c7b188843b91ee0cc632695e7..64b4f4d469603b5a22068113b246c39df22cced3 100644 (file)
@@ -34,12 +34,10 @@ FeaturesAPI_BooleanCut::FeaturesAPI_BooleanCut(const std::shared_ptr<ModelAPI_Fe
 FeaturesAPI_BooleanCut::FeaturesAPI_BooleanCut(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
-  const std::list<ModelHighAPI_Selection>& theToolObjects,
-  const int theVersion)
+  const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
                      const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> 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));
 }
index 80beb317581d26dd88d083bfc4182a8b053e6653..9c9c6bad39905638b5d9e78a1d328fd04463526e 100644 (file)
@@ -44,8 +44,7 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                          const std::list<ModelHighAPI_Selection>& theMainObjects,
-                         const std::list<ModelHighAPI_Selection>& theToolObjects,
-                         const int theVersion = 0);
+                         const std::list<ModelHighAPI_Selection>& theToolObjects);
 
   /// Destructor.
   FEATURESAPI_EXPORT
index da25a8b4330df50bae539cf46414d0a197905f47..6bd8c314ae8be5e3fa51ac3204a9d2e193ac8bca 100644 (file)
@@ -35,12 +35,10 @@ FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill(
 FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
-  const std::list<ModelHighAPI_Selection>& theToolObjects,
-  const int theVersion)
+  const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
                         const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> 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));
 }
index 7375db2cfbe56c0481849835a1433042a43a4fe2..7efc0e772e2389f382e73efde9fd88e4ac3aad17 100644 (file)
@@ -44,8 +44,7 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanFill(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                           const std::list<ModelHighAPI_Selection>& theMainObjects,
-                          const std::list<ModelHighAPI_Selection>& theToolObjects,
-                          const int theVersion = 0);
+                          const std::list<ModelHighAPI_Selection>& theToolObjects);
 
   /// Destructor.
   FEATURESAPI_EXPORT
index a80b069082843fd50028d1f6d5ef34350cd8f5c2..74d45c3bebc2ba017fdc4f779771db73404827dc 100644 (file)
@@ -35,13 +35,11 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
 FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
   const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
-                              const std::list<ModelHighAPI_Selection>& theObjects,
-                              const bool theRemoveEdges,
-                              const int theVersion)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID());
-  return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature,
-                                                    theObjects,
-                                                    theRemoveEdges,
-                                                    theVersion));
-}
-
-//==================================================================================================
-static BooleanFusePtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
-                              const std::list<ModelHighAPI_Selection>& theMainObjects,
-                              const std::list<ModelHighAPI_Selection>& theToolObjects,
-                              const bool theRemoveEdges,
-                              const int theVersion)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID());
-  return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature,
-                                                    theMainObjects,
-                                                    theToolObjects,
-                                                    theRemoveEdges,
-                                                    theVersion));
-}
-
 //==================================================================================================
 BooleanFusePtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
                        const std::list<ModelHighAPI_Selection>& theMainObjects,
@@ -185,12 +149,20 @@ BooleanFusePtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
                        const bool theRemoveEdges,
                        const bool keepSubResults)
 {
-  int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1
-                                : FeaturesPlugin_VersionedBoolean::THE_VERSION_0;
+  std::shared_ptr<ModelAPI_Feature> 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;
 }
index 307a886bbaa7eb0d1e0d66d6a084e84e7c6e0bd5..552f13807d07cb0d5bcb3bc42d5d0be08125c6a2 100644 (file)
@@ -44,16 +44,14 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                           const std::list<ModelHighAPI_Selection>& theMainObjects,
-                          const bool theRemoveEdges = false,
-                          const int theVersion = 0);
+                          const bool theRemoveEdges = false);
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                           const std::list<ModelHighAPI_Selection>& theMainObjects,
                           const std::list<ModelHighAPI_Selection>& theToolObjects,
-                          const bool theRemoveEdges = false,
-                          const int theVersion = 0);
+                          const bool theRemoveEdges = false);
 
   /// Destructor.
   FEATURESAPI_EXPORT
index a91647c0979b8e4977479451c6a14cc24ee8e78a..0d2abf81f36fff3df4e704437be28a3404cc99dc 100644 (file)
@@ -35,12 +35,10 @@ FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash(
 FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
-  const std::list<ModelHighAPI_Selection>& theToolObjects,
-  const int theVersion)
+  const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
                          const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> 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));
 }
index 46d9fd870e181a863f8c6926bc01690f2c52be6d..503255ff180c1936f9c05b7cc980f32880901aa8 100644 (file)
@@ -44,8 +44,7 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanSmash(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                            const std::list<ModelHighAPI_Selection>& theMainObjects,
-                           const std::list<ModelHighAPI_Selection>& theToolObjects,
-                           const int theVersion = 0);
+                           const std::list<ModelHighAPI_Selection>& theToolObjects);
 
   /// Destructor.
   FEATURESAPI_EXPORT
index 8e5ac5658d9c16e5453b8fb28d397d57b8932855..6d383f422aaf9b6bc323dbbc28084beb36178fd1 100644 (file)
@@ -32,12 +32,10 @@ FeaturesAPI_Partition::FeaturesAPI_Partition(const std::shared_ptr<ModelAPI_Feat
 //==================================================================================================
 FeaturesAPI_Partition::FeaturesAPI_Partition(
     const std::shared_ptr<ModelAPI_Feature>& theFeature,
-    const std::list<ModelHighAPI_Selection>& theBaseObjects,
-    const int theVersion)
+    const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
                           const bool keepSubResults)
 {
-  int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1
-                                : FeaturesPlugin_VersionedBoolean::THE_VERSION_0;
   std::shared_ptr<ModelAPI_Feature> 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));
 }
index 392aa59077fb2ef357fd585378040aa99e8b957f..e324b26b10a9c2c5979aac9ed568ff6c7bcee711 100644 (file)
@@ -43,8 +43,7 @@ public:
   /// Constructor with values.
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_Partition(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                 const std::list<ModelHighAPI_Selection>& theBaseObjects,
-                                 const int theVersion = 0);
+                                 const std::list<ModelHighAPI_Selection>& theBaseObjects);
 
   /// Destructor.
   FEATURESAPI_EXPORT
index bc8bc1859a8f1a13701ba0f53db3ab10bf17b505..7e20fb1a5a11a83705b687b94ed8b2a6ef74cdc1 100644 (file)
@@ -31,12 +31,10 @@ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& th
 
 //================================================================================================
 FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                     const std::list<ModelHighAPI_Selection>& theBaseObjects,
-                                     const int theVersion)
+                                     const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
                   const bool keepSubResults)
 {
-  int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1
-                                : FeaturesPlugin_VersionedBoolean::THE_VERSION_0;
   std::shared_ptr<ModelAPI_Feature> 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));
 }
index bcc6aee2e474f0dbac52457479f0c30126a0c199..693a06b5ec86ee1fab16accb053dbd84c0324777 100644 (file)
@@ -43,8 +43,7 @@ public:
   /// Constructor with values.
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                             const std::list<ModelHighAPI_Selection>& theBaseObjects,
-                             const int theVersion = 0);
+                             const std::list<ModelHighAPI_Selection>& theBaseObjects);
 
   /// Destructor.
   FEATURESAPI_EXPORT
index f307e317b30a762cc89dacb8b7b0e0f12e57e20d..bdca89390e6009fd40a278b100582831cdef192d 100644 (file)
@@ -568,4 +568,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestDefeaturing_OnCompound.py
                Test3137_1.py
                Test3137_2.py
+               Test3139.py
 )
index 1afe60e8bf1c214270da3ba81fc7f26905463ca3..be2c09a50fd9bd8df72c94df2cf828210382612b 100644 (file)
@@ -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);
index d954e917d50671b09ddb1a6cc253a97fc6d89863..bc67a28e119c0178cb1e0af003b7392cbb06b8c2 100644 (file)
@@ -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<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
   std::string anError;
@@ -77,7 +74,7 @@ void FeaturesPlugin_BooleanCut::execute()
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> 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);
index 6db4eb4d9ef67ffa6928563f1f1d4f661dc0bc99..3f6dd4cc0ff8f48d6db7d51d57a9c8921737966b 100644 (file)
@@ -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<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
 
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> 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);
index 242629097c356f4da09edfce3d72be2deb57fcbb..a7a1b0cc10643c378d7fc512f4ed984a6b6ac3be 100644 (file)
@@ -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);
index 11b47079e232ed19668b398edf1b95014b29fa4b..9d053f0e9d6b51d0d7d03fd71d6641721352da16 100644 (file)
@@ -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);
index 824a9cb469c9c7a9454c00612f770513f067a4d9..58b3784e933ceca8d75408aa84dbfe381128a56d 100644 (file)
@@ -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()) {
index 5663d69188ca8d3ee1d7991ba93cff9154e7c355..0a3107b76e53358230c38cc835e6045f1ab9f1a6 100644 (file)
@@ -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<FeaturesPlugin_Tools::ResultBaseAlgo> 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();
index ea18dd5a9fa50e89dbb0e87d46caec09b0c28faf..bba9645aa9e90f81ceff04cc4fa35eed3d512423 100644 (file)
@@ -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)
index 21db544d7024769e247b23449e131ea1831cfe6a..098509c3c4842a85aab0afd590119efc428896de 100644 (file)
@@ -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<ModelAPI_Attribute> theObjectsAttr
                             = std::shared_ptr<ModelAPI_Attribute>(),
                    const std::shared_ptr<ModelAPI_Attribute> theToolsAttr
@@ -203,9 +197,6 @@ protected:
       const ObjectHierarchy& theToolsHierarchy,
       std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList);
 
-  /// Return version of the feature
-  int version();
-
 private:
   void parentForShape(const GeomShapePtr& theShape,
                       const std::shared_ptr<ModelAPI_Result>& theContext,
diff --git a/src/FeaturesPlugin/Test/Test3139.py b/src/FeaturesPlugin/Test/Test3139.py
new file mode 100644 (file)
index 0000000..351beba
--- /dev/null
@@ -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])
index 2a25c5136913462dd8887e5249277880e80ac42a..a47d95c2fa49b1db4321432f53b7515651e303f6 100644 (file)
@@ -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<ModelAPI_Data> kInvalid(new Model_Data());
@@ -85,6 +85,9 @@ const static std::shared_ptr<ModelAPI_Data> 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)
 {
index 7f9fa9b01584f120771ad4405ceaa1dfe24022bd..fa833bdd32cd5a196db37dfad015c76aa49dfb3b 100644 (file)
@@ -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<ModelAPI_AttributeDocRef> document(const std::string& theID);
   /// Returns the attribute that contains real value with double precision
index de771058d6515795882ecba3f8830d88f31ae738..bed7201ac7de9939ff5bb6404b9241ebc61f69f3 100644 (file)
@@ -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<ModelAPI_AttributeDocRef> 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 (file)
index 0000000..cbd6dd3
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 (file)
index 0000000..7787a0e
--- /dev/null
@@ -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])