Salome HOME
4539ebbd2129e573d619ebb1b3a3dd399373b148
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_OperationPrs.cpp
4 // Created:     01 Jul 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #include "PartSet_OperationPrs.h"
8
9 //#include <ModelAPI_Tools.h>
10 //#include <ModelAPI_ResultConstruction.h>
11 //#include <GeomAPI_PlanarEdges.h>
12
13 //#include <BRep_Builder.hxx>
14 //#include <Prs3d_IsoAspect.hxx>
15 //#include <TopoDS_Builder.hxx>
16
17 IMPLEMENT_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape);
18 IMPLEMENT_STANDARD_RTTIEXT(PartSet_OperationPrs, ViewerData_AISShape);
19
20 PartSet_OperationPrs::PartSet_OperationPrs()
21   : ViewerData_AISShape(TopoDS_Shape()), myFeature(FeaturePtr())
22 {
23 }
24
25 void PartSet_OperationPrs::setFeature(FeaturePtr theFeature)
26 {
27 /*  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
28   std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
29     std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
30   if (aWirePtr) {
31     if (aWirePtr->hasPlane() ) {
32       // If this is a wire with plane defined thin it is a sketch-like object
33       // It must have invisible faces
34       myIsSketchMode = true;
35     }
36   }
37   Set(aShapePtr->impl<TopoDS_Shape>());
38 */
39 }
40
41
42 /*#include <TopExp_Explorer.hxx>
43 #include <TopoDS_Vertex.hxx>
44 #include <StdPrs_ShadedShape.hxx>
45 #include <StdPrs_WFDeflectionShape.hxx>
46 */
47 void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
48                                    const Handle(Prs3d_Presentation)& thePresentation, 
49                                    const Standard_Integer theMode)
50 {
51 /*  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
52   if (!aShapePtr)
53     return;
54   if (myIsSketchMode) {
55     myFacesList.clear();
56     ResultConstructionPtr aConstruction = 
57       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
58     if (aConstruction.get()) {
59       int aFacesNum = aConstruction->facesNum();
60       for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
61         myFacesList.push_back(aConstruction->face(aFaceIndex));
62       }
63     }
64   }
65   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
66   if (!myOriginalShape.IsNull()) {
67     Set(myOriginalShape);
68
69     AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
70     /*
71     TopExp_Explorer anExp(myOriginalShape, TopAbs_VERTEX);
72     Handle(Prs3d_Drawer) aDrawer = Attributes();
73     for (; anExp.More(); anExp.Next()) {
74       const TopoDS_Vertex& aVertex = (const TopoDS_Vertex&)anExp.Current();
75       StdPrs_WFDeflectionShape::Add(thePresentation, aVertex, aDrawer);
76     }*|/
77   }*/
78 }
79
80
81 void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
82                                             const Standard_Integer aMode)
83 {
84 /*  if (aMode > TopAbs_SHAPE)
85     // In order to avoid using custom selection modes
86     return;
87
88   if (myIsSketchMode) {
89     if (aMode == TopAbs_FACE) {
90       BRep_Builder aBuilder;
91       TopoDS_Compound aComp;
92       aBuilder.MakeCompound(aComp);
93       aBuilder.Add(aComp, myOriginalShape);
94       std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
95       for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
96         TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
97         aBuilder.Add(aComp, aFace);
98       }
99       Set(aComp);
100     } else {
101       Set(myOriginalShape);
102     }
103   }*/
104   AIS_Shape::ComputeSelection(aSelection, aMode);
105 }