Salome HOME
Sources formated according to the codeing standards
[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
19 bool GeomAPI_Edge::isLine() const
20 {
21   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
22   Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape());
23   if (anEdge->Curves().Extent() != 1)
24     return false;  // too many curves in the edge
25   Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D();
26   if (aCurve->IsKind(STANDARD_TYPE(Geom_Line)))
27     return true;
28   return false;
29 }
30
31 bool GeomAPI_Edge::isCircle() const
32 {
33   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
34   Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape());
35   if (anEdge->Curves().Extent() != 1)
36     return false;  // too many curves in the edge
37   Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D();
38   if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle)) && aCurve->IsClosed())
39     return true;
40   return false;
41 }
42
43 bool GeomAPI_Edge::isArc() const
44 {
45   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
46   Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape());
47   if (anEdge->Curves().Extent() != 1)
48     return false;  // too many curves in the edge
49   Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D();
50   if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle)) && !aCurve->IsClosed())
51     return true;
52   return false;
53 }