1 // File: GeomAPI_Curve.cpp
2 // Created: 04 Sep 2014
3 // Author: Mikhail PONIKAROV
5 #include<GeomAPI_Curve.h>
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>
15 #define MY_CURVE (*(static_cast<Handle_Geom_Curve*>(myImpl)))
17 GeomAPI_Curve::GeomAPI_Curve()
18 : GeomAPI_Interface(new Handle_Geom_Curve())
22 GeomAPI_Curve::GeomAPI_Curve(const boost::shared_ptr<GeomAPI_Shape>& theShape)
23 : GeomAPI_Interface(new Handle_Geom_Curve()) // initially it is null
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));
36 bool GeomAPI_Curve::isNull() const
38 return MY_CURVE.IsNull() == Standard_True;
41 bool GeomAPI_Curve::isLine() const
43 return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Line);
46 bool GeomAPI_Curve::isCircle() const
48 return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Circle);