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>
8 #include<GeomAPI_Pnt.h>
10 #include <TopoDS_Shape.hxx>
11 #include <Geom_Curve.hxx>
12 #include <Geom_Line.hxx>
13 #include <Geom_Circle.hxx>
14 #include <BRep_Tool.hxx>
15 #include <TopoDS_Edge.hxx>
17 #include <GeomAdaptor_Curve.hxx>
19 #define MY_CURVE (*(implPtr<Handle_Geom_Curve>()))
21 GeomAPI_Curve::GeomAPI_Curve()
22 : GeomAPI_Interface(new Handle_Geom_Curve()), myStart(0), myEnd(1)
26 GeomAPI_Curve::GeomAPI_Curve(const std::shared_ptr<GeomAPI_Shape>& theShape)
27 : GeomAPI_Interface(new Handle_Geom_Curve()) // initially it is null
29 const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
30 TopoDS_Edge anEdge = TopoDS::Edge(aShape);
31 if (!anEdge.IsNull()) {
32 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, myStart, myEnd);
33 if (!aCurve.IsNull()) {
34 setImpl(new Handle(Geom_Curve)(aCurve));
39 bool GeomAPI_Curve::isNull() const
41 return MY_CURVE.IsNull() == Standard_True;
44 bool GeomAPI_Curve::isLine() const
46 return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Line);
49 bool GeomAPI_Curve::isCircle() const
51 return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Circle);
54 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Curve::getPoint(double theParam)
56 GeomAdaptor_Curve aAdaptor(MY_CURVE, myStart, myEnd);
57 gp_Pnt aPnt = aAdaptor.Value(theParam);
58 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));