]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Updated primitives shapes storing.
authordbv <dbv@opencascade.com>
Wed, 17 Oct 2018 15:29:21 +0000 (18:29 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/FeaturesPlugin/FeaturesPlugin_Recover.cpp
src/Model/Model_BodyBuilder.cpp
src/Model/Model_BodyBuilder.h
src/ModelAPI/ModelAPI_BodyBuilder.h
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_ResultBody.h

index ef70f9a6619a9ec1ca3428dd3cabc422b4862b42..b8b864acc2d034e259d31729d56ee1932a88bd0f 100644 (file)
@@ -410,5 +410,5 @@ void ExchangePlugin_ImportFeature::loadNamingDS(
 
   int aTag(1);
   std::string aNameMS = "Shape";
-  theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag);
+  theResultBody->loadFirstLevel(theGeomShape, aNameMS);
 }
index cf16130b979520cbe8f40c9d3cd43f0aad4b6716..ba575fbeaa74c39f6926550eeef953aee90006ff 100644 (file)
@@ -83,7 +83,7 @@ void FeaturesPlugin_Recover::execute()
     // like in import: forget any history
     int aTag(1);
     std::string aNameMS = "Shape";
-    aResultBody->loadFirstLevel(aCopyAlgo.shape(), aNameMS, aTag);
+    aResultBody->loadFirstLevel(aCopyAlgo.shape(), aNameMS);
 
     setResult(aResultBody, aResultIndex);
     ++aResultIndex;
index cc4f64f65d6bf0bf5d1f5ea1095c921777b61ff8..6d7fe12db8016ad869beb2216720a694ffcfac4a 100755 (executable)
@@ -125,11 +125,7 @@ static bool isAlreadyStored(const TNaming_Builder* theBuilder,
 
 Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner)
 : ModelAPI_BodyBuilder(theOwner),
-  myPrimitiveTag(PRIMITIVES_START_TAG),
-  myDividedIndex(1),
-  myVIndex(1),
-  myEIndex(1),
-  myFIndex(1)
+  myFreePrimitiveTag(PRIMITIVES_START_TAG)
 {
 }
 
@@ -289,11 +285,7 @@ void Model_BodyBuilder::clean()
   myBuilders.clear();
   // remove the old reference (if any)
   aLab.ForgetAttribute(TDF_Reference::GetID());
-  myPrimitiveTag = PRIMITIVES_START_TAG;
-  myDividedIndex = 1;
-  myVIndex = 1;
-  myEIndex = 1;
-  myFIndex = 1;
+  myFreePrimitiveTag = PRIMITIVES_START_TAG;
 }
 
 Model_BodyBuilder::~Model_BodyBuilder()
@@ -322,12 +314,12 @@ void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
                                   const std::string& theName)
 {
   TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
-  builder(myPrimitiveTag)->Generated(aShape);
+  builder(myFreePrimitiveTag)->Generated(aShape);
   if (!theName.empty()) {
-    buildName(myPrimitiveTag, theName);
+    buildName(myFreePrimitiveTag, theName);
   }
 
-  ++myPrimitiveTag;
+  ++myFreePrimitiveTag;
 }
 
 void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape,
@@ -640,7 +632,7 @@ void loadGeneratedDangleShapes(
 
 //=======================================================================
 void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
-  const std::string& theName, int&  theTag)
+                                       const std::string& theName)
 {
   if(theShape->isNull()) return;
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
@@ -648,11 +640,11 @@ void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
   if (aShape.ShapeType() == TopAbs_SOLID) {
     TopExp_Explorer expl(aShape, TopAbs_FACE);
     for (; expl.More(); expl.Next()) {
-      builder(theTag)->Generated(expl.Current());
-      TCollection_AsciiString aStr(theTag);
-      aName = theName + aStr.ToCString();
-      buildName(theTag, aName);
-      theTag++;
+      builder(myFreePrimitiveTag)->Generated(expl.Current());
+      TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+      aName = theName + "_" + aStr.ToCString();
+      buildName(myFreePrimitiveTag, aName);
+      ++myFreePrimitiveTag;
     }
   }
   else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) {
@@ -662,11 +654,11 @@ void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
     if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
       TopExp_Explorer expl(aShape, TopAbs_FACE);
       for (; expl.More(); expl.Next()) {
-        builder(theTag)->Generated(expl.Current());
-        TCollection_AsciiString aStr(theTag);
-        aName = theName + aStr.ToCString();
-        buildName(theTag, aName);
-        theTag++;
+        builder(myFreePrimitiveTag)->Generated(expl.Current());
+        TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+        aName = theName + "_" + aStr.ToCString();
+        buildName(myFreePrimitiveTag, aName);
+        ++myFreePrimitiveTag;
       }
     }
     TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
@@ -677,21 +669,21 @@ void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
       if (aLL.Extent() < 2) {
         if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeAndNeighbourFaces.FindKey(i))))
           continue;
-        builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
-        TCollection_AsciiString aStr(theTag);
-        aName = theName + aStr.ToCString();
-        buildName(theTag, aName);
-        theTag++;
+        builder(myFreePrimitiveTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
+        TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+        aName = theName + "_" + aStr.ToCString();
+        buildName(myFreePrimitiveTag, aName);
+        ++myFreePrimitiveTag;
       } else {
         TopTools_ListIteratorOfListOfShape anIter(aLL);
         const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
         anIter.Next();
         if(aFace.IsEqual(anIter.Value())) {
-          builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
-          TCollection_AsciiString aStr(theTag);
-          aName = theName + aStr.ToCString();
-          buildName(theTag, aName);
-          theTag++;
+          builder(myFreePrimitiveTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
+          TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+          aName = theName + "_" + aStr.ToCString();
+          buildName(myFreePrimitiveTag, aName);
+          ++myFreePrimitiveTag;
         }
       }
     }
@@ -699,40 +691,40 @@ void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
     TopTools_IndexedMapOfShape Edges;
     BRepTools::Map3DEdges(aShape, Edges);
     if (Edges.Extent() == 1) {
-      builder(theTag++)->Generated(Edges.FindKey(1));
+      builder(myFreePrimitiveTag++)->Generated(Edges.FindKey(1));
       TopExp_Explorer expl(aShape, TopAbs_VERTEX);
       for (; expl.More(); expl.Next()) {
-        builder(theTag)->Generated(expl.Current());
-        TCollection_AsciiString aStr(theTag);
-        aName = theName + aStr.ToCString();
-        buildName(theTag, aName);
-        theTag++;
+        builder(myFreePrimitiveTag)->Generated(expl.Current());
+        TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+        aName = theName + "_" + aStr.ToCString();
+        buildName(myFreePrimitiveTag, aName);
+        ++myFreePrimitiveTag;
       }
     } else {
       TopExp_Explorer expl(aShape, TopAbs_EDGE);
       for (; expl.More(); expl.Next()) {
-        builder(theTag)->Generated(expl.Current());
-        TCollection_AsciiString aStr(theTag);
-        aName = theName + aStr.ToCString();
-        buildName(theTag, aName);
-        theTag++;
+        builder(myFreePrimitiveTag)->Generated(expl.Current());
+        TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+        aName = theName + "_" + aStr.ToCString();
+        buildName(myFreePrimitiveTag, aName);
+        ++myFreePrimitiveTag;
       }
       // and load generated vertices.
       TopTools_DataMapOfShapeShape generated;
       if (getDangleShapes(aShape, TopAbs_EDGE, generated))
       {
-        TNaming_Builder* pBuilder = builder(theTag++);
+        TNaming_Builder* pBuilder = builder(myFreePrimitiveTag++);
         loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);
       }
     }
   } else if (aShape.ShapeType() == TopAbs_EDGE) {
     TopExp_Explorer expl(aShape, TopAbs_VERTEX);
     for (; expl.More(); expl.Next()) {
-      builder(theTag)->Generated(expl.Current());
-      TCollection_AsciiString aStr(theTag);
-      aName = theName + aStr.ToCString();
-      buildName(theTag, aName);
-      theTag++;
+      builder(myFreePrimitiveTag)->Generated(expl.Current());
+      TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+      aName = theName + "_" + aStr.ToCString();
+      buildName(myFreePrimitiveTag, aName);
+      ++myFreePrimitiveTag;
     }
   }
 }
@@ -795,8 +787,7 @@ int findAmbiguities(const TopoDS_Shape&           theShapeIn,
 }
 
 //=======================================================================
-void Model_BodyBuilder::loadFirstLevel(
-  GeomShapePtr theShape, const std::string& theName, int&  theTag)
+void Model_BodyBuilder::loadFirstLevel(GeomShapePtr theShape, const std::string& theName)
 {
   if(theShape->isNull()) return;
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
@@ -804,44 +795,42 @@ void Model_BodyBuilder::loadFirstLevel(
   if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
     TopoDS_Iterator itr(aShape);
     for (; itr.More(); itr.Next()) {
-      builder(theTag)->Generated(itr.Value());
-      TCollection_AsciiString aStr(theTag);
-      aName = theName + aStr.ToCString();
-      buildName(theTag, aName);
-      if(!theName.empty()) buildName(theTag, aName);
-      theTag++;
+      builder(myFreePrimitiveTag)->Generated(itr.Value());
+      TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+      aName = theName + "_" + aStr.ToCString();
+      buildName(myFreePrimitiveTag, aName);
+      ++myFreePrimitiveTag;
       if (itr.Value().ShapeType() == TopAbs_COMPOUND ||
         itr.Value().ShapeType() == TopAbs_COMPSOLID)
       {
         GeomShapePtr itrShape(new GeomAPI_Shape());
         itrShape->setImpl(new TopoDS_Shape(itr.Value()));
-        loadFirstLevel(itrShape, theName, theTag);
+        loadFirstLevel(itrShape, theName);
       } else {
         GeomShapePtr itrShape(new GeomAPI_Shape());
         itrShape->setImpl(new TopoDS_Shape(itr.Value()));
-        loadNextLevels(itrShape, theName, theTag);
+        loadNextLevels(itrShape, theName);
       }
     }
   } else {
     GeomShapePtr itrShape(new GeomAPI_Shape());
     itrShape->setImpl(new TopoDS_Shape(aShape));
-    loadNextLevels(itrShape, theName, theTag);
+    loadNextLevels(itrShape, theName);
   }
   TopTools_ListOfShape   aList;
   if(findAmbiguities(aShape, aList)) {
     TopTools_ListIteratorOfListOfShape it(aList);
-    for (; it.More(); it.Next(),theTag++) {
-      builder(theTag)->Generated(it.Value());
-      TCollection_AsciiString aStr(theTag);
-      aName = theName + aStr.ToCString();
-      buildName(theTag, aName);
+    for (; it.More(); it.Next(), ++myFreePrimitiveTag) {
+      builder(myFreePrimitiveTag)->Generated(it.Value());
+      TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+      aName = theName + "_" + aStr.ToCString();
+      buildName(myFreePrimitiveTag, aName);
     }
   }
 }
 
 //=======================================================================
-void Model_BodyBuilder::loadDisconnectedEdges(
-  GeomShapePtr theShape, const std::string& theName, int&  theTag)
+void Model_BodyBuilder::loadDisconnectedEdges(GeomShapePtr theShape, const std::string& theName)
 {
   if(theShape->isNull()) return;
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
@@ -890,12 +879,12 @@ void Model_BodyBuilder::loadDisconnectedEdges(
               if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
           if (aMatches == aList1.Extent()) {
             aC0=Standard_True;
-            builder(theTag)->Generated(anEdge2);
+            builder(myFreePrimitiveTag)->Generated(anEdge2);
             anEdgesToDelete.Add(anEdge2);
-            TCollection_AsciiString aStr(theTag);
-            aName = theName + aStr.ToCString();
-            buildName(theTag, aName);
-            theTag++;
+            TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+            aName = theName + "_" + aStr.ToCString();
+            buildName(myFreePrimitiveTag, aName);
+            ++myFreePrimitiveTag;
           }
         }
       }
@@ -905,17 +894,17 @@ void Model_BodyBuilder::loadDisconnectedEdges(
       edgeNaborFaces.UnBind(anEdge1);
     }
     if (aC0) {
-      builder(theTag)->Generated(anEdge1);
-      TCollection_AsciiString aStr(theTag);
-      aName = theName + aStr.ToCString();
-      buildName(theTag, aName);
-      theTag++;
+      builder(myFreePrimitiveTag)->Generated(anEdge1);
+      TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+      aName = theName + "_" + aStr.ToCString();
+      buildName(myFreePrimitiveTag, aName);
+      ++myFreePrimitiveTag;
     }
   }
 }
 
 void Model_BodyBuilder::loadDisconnectedVertexes(GeomShapePtr theShape,
-                                                 const std::string& theName, int&  theTag)
+                                                 const std::string& theName)
 {
   if(theShape->isNull()) return;
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
@@ -946,11 +935,11 @@ void Model_BodyBuilder::loadDisconnectedVertexes(GeomShapePtr theShape,
   for (; itr.More(); itr.Next()) {
     const TopTools_ListOfShape& naborEdges = itr.Value();
     if (naborEdges.Extent() < 2) {
-      builder(theTag)->Generated(itr.Key());
-      TCollection_AsciiString aStr(theTag);
-      aName = theName + aStr.ToCString();
-      buildName(theTag, aName);
-      theTag++;
+      builder(myFreePrimitiveTag)->Generated(itr.Key());
+      TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
+      aName = theName + "_" + aStr.ToCString();
+      buildName(myFreePrimitiveTag, aName);
+      ++myFreePrimitiveTag;
     }
   }
 }
index 60e345fee0ea18984bd7c398e9a1bc9636218449..899fe1cc390e197c7a722aaac0a76da725a075c4 100755 (executable)
@@ -110,18 +110,15 @@ public:
 
   /// Loads shapes of the first level (to be used during shape import)
   MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
-                                           const std::string& theName,
-                                           int& theTag);
+                                           const std::string& theName) override;
 
   /// Loads disconnected edges
   MODEL_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
-                                                  const std::string& theName,
-                                                  int& theTag);
+                                                  const std::string& theName) override;
 
   /// Loads disconnected vetexes
   MODEL_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
-                                                     const std::string& theName,
-                                                     int& theTag);
+                                                     const std::string& theName) override;
 
   /// Removes the stored builders
   MODEL_EXPORT virtual ~Model_BodyBuilder();
@@ -143,17 +140,13 @@ protected:
 private:
   /// Loads shapes of the next level (to be used during shape import)
   void loadNextLevels(GeomShapePtr theShape,
-                      const std::string& theName, int&  theTag);
+                      const std::string& theName);
 
   /// builds name for the shape kept at the specified tag
   void buildName(const int theTag, const std::string& theName);
 
 private:
-  int myPrimitiveTag;
-  int myDividedIndex;
-  int myVIndex;
-  int myEIndex;
-  int myFIndex;
+  int myFreePrimitiveTag;
 
 private:
   friend class Model_ResultBody;
index 84e9400c706c13ec3d5544e50d900a4271a2dbc5..b44e0d2b9916f16954afec2ec2ffd6f8c285d921 100755 (executable)
@@ -102,18 +102,15 @@ public:
 
   /// load shapes of the first level (to be used during shape import)
   virtual void loadFirstLevel(GeomShapePtr theShape,
-                              const std::string& theName,
-                              int& theTag) = 0;
+                              const std::string& theName) = 0;
 
   /// load disconnected edges
   virtual void loadDisconnectedEdges(GeomShapePtr theShape,
-                                     const std::string& theName,
-                                     int& theTag) = 0;
+                                     const std::string& theName) = 0;
 
   /// load disconnected vetexes
   virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
-                                        const std::string& theName,
-                                        int& theTag) = 0;
+                                        const std::string& theName) = 0;
 
   /// Returns true if the latest modification of this body in the naming history
   // is equal to the given shape
index cdc10a70323e4bb361c183d216879ca1068da7df..806df516e21668514e1acb4ab1a4b0b9d1da20bb 100644 (file)
@@ -149,24 +149,21 @@ void ModelAPI_ResultBody::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
 }
 
 void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
-                                         const std::string& theName,
-                                         int& theTag)
+                                         const std::string& theName)
 {
-  myBuilder->loadFirstLevel(theShape, theName, theTag);
+  myBuilder->loadFirstLevel(theShape, theName);
 }
 
 void ModelAPI_ResultBody::loadDisconnectedEdges(GeomShapePtr theShape,
-                                                const std::string& theName,
-                                                int& theTag)
+                                                const std::string& theName)
 {
-  myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
+  myBuilder->loadDisconnectedEdges(theShape, theName);
 }
 
 void ModelAPI_ResultBody::loadDisconnectedVertexes(GeomShapePtr theShape,
-                                                   const std::string& theName,
-                                                    int& theTag)
+                                                   const std::string& theName)
 {
-  myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
+  myBuilder->loadDisconnectedVertexes(theShape, theName);
 }
 
 bool ModelAPI_ResultBody::isConnectedTopology()
index e7d13c8f8763e9d8e1e5ac1f230e48625650386e..aaf1bbecc6f3a7b6a06681905a660a7bafd280a2 100644 (file)
@@ -158,18 +158,15 @@ public:
 
   /// load shapes of the first level (to be used during shape import)
   MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
-                                              const std::string& theName,
-                                              int& theTag);
+                                              const std::string& theName);
 
   /// load disconnected edges
   MODELAPI_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
-                                                     const std::string& theName,
-                                                     int& theTag);
+                                                     const std::string& theName);
 
   /// load disconnected vetexes
   MODELAPI_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
-                                                        const std::string& theName,
-                                                        int& theTag);
+                                                        const std::string& theName);
 
   /// Returns true if the latest modification of this body in the naming history
   // is equal to the given shape