1 // File: ModuleBase_ResultPrs.cpp
2 // Created: 21 October 2014
3 // Author: Vitaly SMETANNIKOV
5 #include "ModuleBase_ResultPrs.h"
7 #include <ModelAPI_Tools.h>
8 #include <GeomAPI_PlanarEdges.h>
9 #include <GeomAlgoAPI_SketchBuilder.h>
11 #include <BRep_Builder.hxx>
12 #include <AIS_Drawer.hxx>
13 #include <Prs3d_IsoAspect.hxx>
14 #include <TopoDS_Builder.hxx>
16 IMPLEMENT_STANDARD_HANDLE(ModuleBase_ResultPrs, AIS_Shape);
17 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, AIS_Shape);
19 ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
20 : AIS_Shape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
22 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
23 std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr =
24 std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
26 if (aWirePtr->hasPlane() ) {
27 // If this is a wire with plane defined thin it is a sketch-like object
28 // It must have invisible faces
29 GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
30 aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
32 myOriginalShape = aWirePtr->impl<TopoDS_Shape>();
34 myIsSketchMode = true;
36 Set(aWirePtr->impl<TopoDS_Shape>());
39 Set(aShapePtr->impl<TopoDS_Shape>());
44 void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
45 const Handle(Prs3d_Presentation)& thePresentation,
46 const Standard_Integer theMode)
48 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
51 myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
52 Set(aShapePtr->impl<TopoDS_Shape>());
53 AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
57 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
58 const Standard_Integer aMode)
61 if (aMode == TopAbs_FACE) {
62 BRep_Builder aBuilder;
63 TopoDS_Compound aComp;
64 aBuilder.MakeCompound(aComp);
65 aBuilder.Add(aComp, myOriginalShape);
66 std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
67 for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
68 TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
69 aBuilder.Add(aComp, aFace);
76 AIS_Shape::ComputeSelection(aSelection, aMode);