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