Salome HOME
Fixed wire selection for extrusion and revolution
authordbv <dbv@opencascade.com>
Tue, 19 Apr 2016 12:16:46 +0000 (15:16 +0300)
committerdbv <dbv@opencascade.com>
Tue, 19 Apr 2016 13:42:09 +0000 (16:42 +0300)
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp

index 665840127a26a3c281e21ebedd53e324efe4b6f7..1759b26b88cc6e136e9556f04bf6f69fce0d2ed4 100644 (file)
@@ -139,17 +139,15 @@ void FeaturesPlugin_CompositeSketch::getBaseShapes(ListOfShape& theBaseShapesLis
         setError("Error: Selected shapes has unsupported type.");
         return;
       }
-      if(aST == GeomAPI_Shape::WIRE) {
-        ResultConstructionPtr aConstruction =
-          std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseObjectSelection->context());
-        if(aConstruction.get() && !aBaseShape->isEqual(aConstruction->shape())) {
-          // It is a wire on the sketch, store it to make face later.
-          aSketchWiresMap[aConstruction].push_back(aBaseShape);
-          continue;
-        }
+      ResultConstructionPtr aConstruction =
+        std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseObjectSelection->context());
+      if(aConstruction.get() && !aBaseShape->isEqual(aConstruction->shape()) && aST == GeomAPI_Shape::WIRE) {
+        // It is a wire on the sketch, store it to make face later.
+        aSketchWiresMap[aConstruction].push_back(aBaseShape);
+        continue;
       } else {
-        aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) :
-                                     theBaseShapesList.push_back(aBaseShape);
+      aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) :
+                                   theBaseShapesList.push_back(aBaseShape);
       }
     } else {
       // This may be the whole sketch result selected, check and get faces.
index 4f3e1675be3bbc8312baafe1fcb6dfd631cf9d3b..101034de0cbf5300e9680c46d4c75805f30fb1e0 100644 (file)
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_Pipe.h>
-#include <GeomAPI_ShapeExplorer.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAPI_PlanarEdges.h>
+#include <GeomAPI_ShapeExplorer.h>
 
+#include <map>
 #include <sstream>
 
 //=================================================================================================
@@ -47,6 +49,7 @@ void FeaturesPlugin_Pipe::execute()
 
   // Getting base objects.
   ListOfShape aBaseShapesList, aBaseFacesList;
+  std::map<ResultConstructionPtr, ListOfShape> aSketchWiresMap;
   AttributeSelectionListPtr aBaseObjectsSelectionList = selectionList(BASE_OBJECTS_ID());
   if(!aBaseObjectsSelectionList.get()) {
     setError("Error: Could not get base objects selection list.");
@@ -64,8 +67,17 @@ void FeaturesPlugin_Pipe::execute()
     }
     std::shared_ptr<GeomAPI_Shape> aBaseShape = aBaseObjectSelection->value();
     if(aBaseShape.get() && !aBaseShape->isNull()) {
-      aBaseShape->shapeType() == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) :
-                                                       aBaseShapesList.push_back(aBaseShape);
+      GeomAPI_Shape::ShapeType aST = aBaseShape->shapeType();
+      ResultConstructionPtr aConstruction =
+        std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseObjectSelection->context());
+      if(aConstruction.get() && !aBaseShape->isEqual(aConstruction->shape()) && aST == GeomAPI_Shape::WIRE) {
+        // It is a wire on the sketch, store it to make face later.
+        aSketchWiresMap[aConstruction].push_back(aBaseShape);
+        continue;
+      } else {
+      aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) :
+                                   aBaseShapesList.push_back(aBaseShape);
+      }
     } else {
       // This may be the whole sketch result selected, check and get faces.
       ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseObjectSelection->context());
@@ -94,6 +106,20 @@ void FeaturesPlugin_Pipe::execute()
     }
   }
 
+  // Make faces from sketch wires.
+  for(std::map<ResultConstructionPtr, ListOfShape>::const_iterator anIt = aSketchWiresMap.cbegin();
+      anIt != aSketchWiresMap.cend(); ++anIt) {
+    const std::shared_ptr<GeomAPI_PlanarEdges> aSketchPlanarEdges =
+      std::dynamic_pointer_cast<GeomAPI_PlanarEdges>((*anIt).first->shape());
+    const ListOfShape& aWiresList = (*anIt).second;
+    ListOfShape aFaces;
+    GeomAlgoAPI_ShapeTools::makeFacesWithHoles(aSketchPlanarEdges->origin(),
+                                               aSketchPlanarEdges->norm(),
+                                               aWiresList,
+                                               aFaces);
+    aBaseFacesList.insert(aBaseFacesList.end(), aFaces.begin(), aFaces.end());
+  }
+
   // Searching faces with common edges.
   if(aCreationMethod == "simple") {
     ListOfShape aShells;