1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAPI_Curve.cpp
4 // Created: 04 Sep 2014
5 // Author: Mikhail PONIKAROV
7 #include<GeomAPI_Curve.h>
9 #include <TopoDS_Shape.hxx>
10 #include <Geom_Curve.hxx>
11 #include <Geom_Line.hxx>
12 #include <Geom_Circle.hxx>
13 #include <BRep_Tool.hxx>
14 #include <TopoDS_Edge.hxx>
17 #define MY_CURVE (*(static_cast<Handle_Geom_Curve*>(myImpl)))
19 GeomAPI_Curve::GeomAPI_Curve()
20 : GeomAPI_Interface(new Handle_Geom_Curve())
24 GeomAPI_Curve::GeomAPI_Curve(const std::shared_ptr<GeomAPI_Shape>& theShape)
25 : GeomAPI_Interface(new Handle_Geom_Curve()) // initially it is null
27 const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
28 TopoDS_Edge anEdge = TopoDS::Edge(aShape);
29 if (!anEdge.IsNull()) {
30 Standard_Real aStart, anEnd;
31 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aStart, anEnd);
32 if (!aCurve.IsNull()) {
33 setImpl(new Handle(Geom_Curve)(aCurve));
38 bool GeomAPI_Curve::isNull() const
40 return MY_CURVE.IsNull() == Standard_True;
43 bool GeomAPI_Curve::isLine() const
45 return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Line);
48 bool GeomAPI_Curve::isCircle() const
50 return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Circle);