]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Replaced manual naming in intersection feature.
authordbv <dbv@opencascade.com>
Fri, 26 Oct 2018 11:42:09 +0000 (14:42 +0300)
committermpv <mpv@opencascade.com>
Fri, 26 Oct 2018 17:06:01 +0000 (20:06 +0300)
src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp
src/FeaturesPlugin/FeaturesPlugin_Intersection.h

index b5fd9982b875dbafe8d635575e5724b9f3af1791..e2a48a02676b06e3ed06a3137030132a59c7c66b 100644 (file)
@@ -68,20 +68,20 @@ void FeaturesPlugin_Intersection::execute()
   int aResultIndex = 0;
 
   // Create result.
-  GeomAlgoAPI_Intersection anIntersectionAlgo(anObjects);
+  GeomMakeShapePtr anIntersectionAlgo(new GeomAlgoAPI_Intersection(anObjects));
 
   // Checking that the algorithm worked properly.
-  if (!anIntersectionAlgo.isDone()) {
+  if (!anIntersectionAlgo->isDone()) {
     static const std::string aFeatureError = "Error: Intersection algorithm failed.";
     setError(aFeatureError);
     return;
   }
-  if (anIntersectionAlgo.shape()->isNull()) {
+  if (anIntersectionAlgo->shape()->isNull()) {
     static const std::string aShapeError = "Error: Resulting shape is Null.";
     setError(aShapeError);
     return;
   }
-  if (!anIntersectionAlgo.isValid()) {
+  if (!anIntersectionAlgo->isValid()) {
     std::string aFeatureError = "Error: Resulting shape is not valid.";
     setError(aFeatureError);
     return;
@@ -98,60 +98,22 @@ void FeaturesPlugin_Intersection::execute()
 }
 
 //=================================================================================================
-void FeaturesPlugin_Intersection::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+void FeaturesPlugin_Intersection::loadNamingDS(ResultBodyPtr theResultBody,
                                                const ListOfShape& theObjects,
-                                               GeomAlgoAPI_MakeShape& theMakeShape)
+                                               const GeomMakeShapePtr& theMakeShape)
 {
-  std::shared_ptr<GeomAPI_Shape> aResultShape = theMakeShape.shape();
+  std::shared_ptr<GeomAPI_Shape> aResultShape = theMakeShape->shape();
   theResultBody->storeModified(theObjects.front(), aResultShape);
 
-  GeomAPI_DataMapOfShapeShape aShapesMap; // Map to store {result_shape, original_shape}
-  const int aShapeTypesNb = 2;
-  const GeomAPI_Shape::ShapeType aShapeTypes[aShapeTypesNb] =
-    {GeomAPI_Shape::VERTEX, GeomAPI_Shape::EDGE};
+  const int aShapeTypesNb = 3;
+  const GeomAPI_Shape::ShapeType aShapeTypes[aShapeTypesNb] = {GeomAPI_Shape::VERTEX,
+                                                               GeomAPI_Shape::EDGE,
+                                                               GeomAPI_Shape::FACE };
   for (ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) {
     const GeomShapePtr aShape = *anIt;
     for(int anIndex = 0; anIndex < aShapeTypesNb; ++anIndex) {
-      for(GeomAPI_ShapeExplorer anOrigShapeExp(aShape, aShapeTypes[anIndex]);
-          anOrigShapeExp.more();
-          anOrigShapeExp.next()) {
-        ListOfShape aHistory;
-        const GeomShapePtr aSubShape = anOrigShapeExp.current();
-        theMakeShape.modified(aSubShape, aHistory);
-        for(ListOfShape::const_iterator aHistoryIt = aHistory.cbegin();
-            aHistoryIt != aHistory.cend();
-            ++aHistoryIt) {
-          aShapesMap.bind(*aHistoryIt, aSubShape);
-        }
-      }
-    }
-  }
-
-  int aModifiedVertexIndex(1),
-      aGeneratedVertexIndex(1),
-      aModifiedEdgeIndex(1),
-      aGeneratedEdgeIndex(1);
-  int aTag = 4;
-  GeomAPI_DataMapOfShapeShape aStoredShapes;
-  for(int anIndex = 0; anIndex < aShapeTypesNb; ++anIndex) {
-    for(GeomAPI_ShapeExplorer aShapeExp(aResultShape, aShapeTypes[anIndex]);
-        aShapeExp.more();
-        aShapeExp.next()) {
-      const GeomShapePtr aSubShape = aShapeExp.current();
-      if(aStoredShapes.isBound(aSubShape)) {
-        continue;
-      }
-      if(aShapesMap.isBound(aSubShape)) {
-        theResultBody->modified(aShapesMap.find(aSubShape), aSubShape);
-      } else {
-        theResultBody->generated(
-          aSubShape,
-          std::string("Generated_")
-            + (anIndex == 0 ? "Vertex_" : "Edge_")
-            + std::to_string((long long)(anIndex == 0 ? aGeneratedVertexIndex++
-                                                      : aGeneratedEdgeIndex++)));
-      }
-      aStoredShapes.bind(aSubShape, aSubShape);
+      theResultBody->loadModifiedShapes(theMakeShape, aShape, aShapeTypes[anIndex]);
+      theResultBody->loadGeneratedShapes(theMakeShape, aShape, aShapeTypes[anIndex]);
     }
   }
 }
index c4a210fc857ae269dacd0f3a2f6eef998333709d..581c6e8608948677b4ee6ec8c2ca1ae0c0517f78 100644 (file)
@@ -73,7 +73,7 @@ private:
   /// Load Naming data structure of the feature to the document.
   void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     const ListOfShape& theObjects,
-                    GeomAlgoAPI_MakeShape& theMakeShape);
+                    const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape);
 };
 
 #endif