]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAPI/GeomAPI_Edge.cpp
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / GeomAPI / GeomAPI_Edge.cpp
1 // File:        GeomAPI_Edge.cpp
2 // Created:     24 Jul 2014
3 // Author:      Artem ZHIDKOV
4
5 #include<GeomAPI_Edge.h>
6
7 #include <TopoDS_Shape.hxx>
8 #include <BRep_TEdge.hxx>
9 #include <BRep_CurveRepresentation.hxx>
10 #include <Geom_Curve.hxx>
11 #include <Geom_Line.hxx>
12 #include <Geom_Circle.hxx>
13
14 GeomAPI_Edge::GeomAPI_Edge()
15   : GeomAPI_Shape()
16 {}
17
18 bool GeomAPI_Edge::isLine() const
19 {
20   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
21   Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape());
22   if (anEdge->Curves().Extent() != 1)
23     return false; // too many curves in the edge
24   Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D();
25   if (aCurve->IsKind(STANDARD_TYPE(Geom_Line)))
26     return true;
27   return false;
28 }
29
30 bool GeomAPI_Edge::isCircle() const
31 {
32   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
33   Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape());
34   if (anEdge->Curves().Extent() != 1)
35     return false; // too many curves in the edge
36   Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D();
37   if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle)) && aCurve->IsClosed())
38     return true;
39   return false;
40 }
41
42 bool GeomAPI_Edge::isArc() const
43 {
44   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
45   Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape());
46   if (anEdge->Curves().Extent() != 1)
47     return false; // too many curves in the edge
48   Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D();
49   if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle)) && !aCurve->IsClosed())
50     return true;
51   return false;
52 }