]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_FilterLinearEdge.cpp
Salome HOME
b101cdbf427ac38491074b76946815765b666f79
[modules/shaper.git] / src / ModuleBase / ModuleBase_FilterLinearEdge.cpp
1 // File:        ModuleBase_FilterLinearEdge.cpp
2 // Created:     10 Dec 2014
3 // Author:      Natalia ERMOLAEVA
4
5
6 #include "ModuleBase_FilterLinearEdge.h"
7 #include "ModuleBase_IWorkshop.h"
8
9 #include <ModelAPI_Session.h>
10 #include <ModelAPI_Document.h>
11 #include <ModelAPI_ResultConstruction.h>
12
13 #include <AIS_InteractiveObject.hxx>
14 #include <AIS_Shape.hxx>
15
16 #include <StdSelect_BRepOwner.hxx>
17
18 #include <GeomAPI_Edge.h>
19
20 #include <BRep_Tool.hxx>
21 #include <TopoDS.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <Geom_Curve.hxx>
24
25
26 IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterLinearEdge, SelectMgr_Filter);
27 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterLinearEdge, SelectMgr_Filter);
28
29
30 Standard_Boolean ModuleBase_FilterLinearEdge::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
31 {
32   Standard_Boolean isOk = ModuleBase_Filter::IsOk(theOwner);
33   if (isOk && theOwner->HasSelectable()) {
34     Handle(AIS_InteractiveObject) anAIS = 
35       Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
36     if (!anAIS.IsNull()) {
37       Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
38       if (aShapeAIS) {
39         const TopoDS_Shape& aShape = aShapeAIS->Shape();
40         if (aShape.ShapeType()  == TopAbs_EDGE) {
41           std::shared_ptr<GeomAPI_Edge> anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
42           anEdge->setImpl(new TopoDS_Shape(aShape));
43
44           isOk = anEdge->isLine();
45         }
46       }
47     }
48   }
49   return Standard_False;
50 }