Salome HOME
Fix pyconfig redefined declarations for _XOPEN_SOURCE and _POSIX_C_SOURCE
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.cpp
index b039e9bfd34ee9223d29f27acbf8d207968f362c..211fdde73eaf137bffbf5561039171d38c328670 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ResultPrs.cpp
 // Created:     21 October 2014
 // Author:      Vitaly SMETANNIKOV
@@ -5,11 +7,10 @@
 #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>
 #include <Prs3d_IsoAspect.hxx>
 #include <TopoDS_Builder.hxx>
 
@@ -19,25 +20,17 @@ IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, AIS_Shape);
 ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
   : AIS_Shape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
 {
-  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
-  boost::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
-    boost::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
+  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
+  std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
+    std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
   if (aWirePtr) {
     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>());
 }
 
 
@@ -45,23 +38,42 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
 {
-  boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
+  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(myOriginalShape);
+    AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+  }
 }
 
 
 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                             const Standard_Integer aMode)
 {
+  if (aMode > TopAbs_SHAPE)
+    // In order to avoid using custom selection modes
+    return;
+
   if (myIsSketchMode) {
     if (aMode == TopAbs_FACE) {
       BRep_Builder aBuilder;
       TopoDS_Compound aComp;
       aBuilder.MakeCompound(aComp);
       aBuilder.Add(aComp, myOriginalShape);
-      std::list<boost::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
+      std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
       for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
         TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
         aBuilder.Add(aComp, aFace);