Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.cpp
index 5031dac249edaa366522b15c03060c7eac8b0ffa..d6bd0cde8de26c65ad5b9724683b1612ec4e7ced 100644 (file)
@@ -7,8 +7,8 @@
 #include "ModuleBase_ResultPrs.h"
 
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultConstruction.h>
 #include <GeomAPI_PlanarEdges.h>
-#include <GeomAlgoAPI_SketchBuilder.h>
 
 #include <BRep_Builder.hxx>
 #include <AIS_Drawer.hxx>
@@ -28,18 +28,10 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
     if (aWirePtr->hasPlane() ) {
       // If this is a wire with plane defined thin it is a sketch-like object
       // It must have invisible faces
-      GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
-        aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
-
-      myOriginalShape = aWirePtr->impl<TopoDS_Shape>();
-      Set(myOriginalShape);
       myIsSketchMode = true;
-    } else {
-      Set(aWirePtr->impl<TopoDS_Shape>());
     }
-  } else {
-    Set(aShapePtr->impl<TopoDS_Shape>());
   }
+  Set(aShapePtr->impl<TopoDS_Shape>());
 }
 
 
@@ -50,9 +42,22 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
   if (!aShapePtr)
     return;
+  if (myIsSketchMode) {
+    myFacesList.clear();
+    ResultConstructionPtr aConstruction = 
+      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
+    if (aConstruction.get()) {
+      int aFacesNum = aConstruction->facesNum();
+      for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
+        myFacesList.push_back(aConstruction->face(aFaceIndex));
+      }
+    }
+  }
   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
-  Set(aShapePtr->impl<TopoDS_Shape>());
-  AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+  if (!myOriginalShape.IsNull()) {
+    Set(aShapePtr->impl<TopoDS_Shape>());
+    AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+  }
 }