1 // Copyright (C) 2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <GeomAlgoAPI_Projection.h>
22 #include <GeomAPI_Curve.h>
23 #include <GeomAPI_Edge.h>
24 #include <GeomAPI_Pln.h>
26 #include <Geom_Curve.hxx>
27 #include <Geom_Plane.hxx>
28 #include <GeomProjLib.hxx>
30 #include <BRep_Tool.hxx>
31 #include <Geom_TrimmedCurve.hxx>
33 #include <TopoDS_Edge.hxx>
35 GeomAlgoAPI_Projection::GeomAlgoAPI_Projection(const GeomPlanePtr& thePlane)
40 GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomCurvePtr& theCurve)
42 Handle(Geom_Curve) aCurve = theCurve->impl<Handle_Geom_Curve>();
43 Handle(Geom_Plane) aPlane = new Geom_Plane(myPlane->impl<gp_Ax3>());
45 Handle(Geom_Curve) aProj = GeomProjLib::Project(aCurve, aPlane);
47 GeomCurvePtr aProjCurve(new GeomAPI_Curve);
48 aProjCurve->setImpl(new Handle_Geom_Curve(aProj));
52 GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomEdgePtr& theEdge)
54 GeomCurvePtr aCurve(new GeomAPI_Curve);
56 const TopoDS_Shape& aShape = theEdge->impl<TopoDS_Shape>();
57 TopoDS_Edge anEdge = TopoDS::Edge(aShape);
58 if (!anEdge.IsNull()) {
60 Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(anEdge, aStart, aEnd);
61 if (!anEdgeCurve.IsNull() && !BRep_Tool::IsClosed(anEdge))
62 anEdgeCurve = new Geom_TrimmedCurve(anEdgeCurve, aStart, aEnd);
63 aCurve->setImpl(new Handle_Geom_Curve(anEdgeCurve));
66 return project(aCurve);