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_Wire.h>
9 #include <GeomAlgoAPI_SketchBuilder.h>
11 #include <BRep_Builder.hxx>
12 #include <AIS_Drawer.hxx>
13 #include <Prs3d_IsoAspect.hxx>
15 IMPLEMENT_STANDARD_HANDLE(ModuleBase_ResultPrs, AIS_Shape);
16 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, AIS_Shape);
18 ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
19 : AIS_Shape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
21 boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
22 boost::shared_ptr<GeomAPI_Wire> aWirePtr =
23 boost::dynamic_pointer_cast<GeomAPI_Wire>(aShapePtr);
25 if (aWirePtr->hasPlane() ) {
26 // If this is a wire with plane defined thin it is a sketch-like object
27 // It must have invisible faces
28 std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
29 GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
30 aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, aFaces);
32 BRep_Builder aBuilder;
33 TopoDS_Shape aShape = aWirePtr->impl<TopoDS_Shape>();
34 std::list<boost::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
35 for (aIt = aFaces.cbegin(); aIt != aFaces.cend(); ++aIt) {
36 TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
37 aBuilder.Add(aShape, aFace);
40 myIsSketchMode = true;
41 // Define number of ISO lines
42 //Handle(AIS_Drawer) aDrawer = Attributes();
43 //Attributes()->SetIsoOnPlane(Standard_False);
44 //SetAttributes(aDrawer);
46 Set(aWirePtr->impl<TopoDS_Shape>());
49 Set(aShapePtr->impl<TopoDS_Shape>());
54 Standard_Boolean ModuleBase_ResultPrs::AcceptDisplayMode(const Standard_Integer theMode) const
59 return AIS_Shape::AcceptDisplayMode(theMode);
62 void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
63 const Handle(Prs3d_Presentation)& thePresentation,
64 const Standard_Integer theMode)
67 Handle(AIS_Drawer) aDrawer = Attributes();
68 aDrawer->SetIsoOnPlane(Standard_False);
69 aDrawer->UIsoAspect()->SetNumber(0);
70 aDrawer->VIsoAspect()->SetNumber(0);
71 SetAttributes(aDrawer);
73 AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);