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 boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
23 boost::shared_ptr<GeomAPI_PlanarEdges> aWirePtr =
24 boost::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 boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
49 myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
50 Set(aShapePtr->impl<TopoDS_Shape>());
51 AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
55 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
56 const Standard_Integer aMode)
59 if (aMode == TopAbs_FACE) {
60 BRep_Builder aBuilder;
61 TopoDS_Compound aComp;
62 aBuilder.MakeCompound(aComp);
63 aBuilder.Add(aComp, myOriginalShape);
64 std::list<boost::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
65 for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
66 TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
67 aBuilder.Add(aComp, aFace);
74 AIS_Shape::ComputeSelection(aSelection, aMode);