Salome HOME
Create Presentation for rigid constraint
[modules/shaper.git] / src / GeomAPI / GeomAPI_Curve.cpp
1 // File:        GeomAPI_Curve.cpp
2 // Created:     04 Sep 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include<GeomAPI_Curve.h>
6
7 #include <TopoDS_Shape.hxx>
8 #include <Geom_Curve.hxx>
9 #include <Geom_Line.hxx>
10 #include <Geom_Circle.hxx>
11 #include <BRep_Tool.hxx>
12 #include <TopoDS_Edge.hxx>
13 #include <TopoDS.hxx>
14
15 #define MY_CURVE (*(static_cast<Handle_Geom_Curve*>(myImpl)))
16
17 GeomAPI_Curve::GeomAPI_Curve()
18     : GeomAPI_Interface(new Handle_Geom_Curve())
19 {
20 }
21
22 GeomAPI_Curve::GeomAPI_Curve(const boost::shared_ptr<GeomAPI_Shape>& theShape)
23   : GeomAPI_Interface(new Handle_Geom_Curve()) // initially it is null
24 {
25   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
26   TopoDS_Edge anEdge = TopoDS::Edge(aShape);
27   if (!anEdge.IsNull()) {
28     Standard_Real aStart, anEnd;
29     Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aStart, anEnd);
30     if (!aCurve.IsNull()) {
31       setImpl(new Handle(Geom_Curve)(aCurve));
32     }
33   }
34 }
35
36 bool GeomAPI_Curve::isNull() const
37 {
38   return MY_CURVE.IsNull() == Standard_True;
39 }
40
41 bool GeomAPI_Curve::isLine() const
42 {
43   return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Line);
44 }
45
46 bool GeomAPI_Curve::isCircle() const
47 {
48   return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Circle);
49 }