Salome HOME
Task 2.12. New entities: ellipses and arcs of ellipses (issue #3003)
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Projection.cpp
1 // Copyright (C) 2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <GeomAlgoAPI_Projection.h>
21
22 #include <GeomAPI_Curve.h>
23 #include <GeomAPI_Edge.h>
24 #include <GeomAPI_Pln.h>
25
26 #include <Geom_Curve.hxx>
27 #include <Geom_Plane.hxx>
28 #include <GeomProjLib.hxx>
29
30 GeomAlgoAPI_Projection::GeomAlgoAPI_Projection(const GeomPlanePtr& thePlane)
31   : myPlane(thePlane)
32 {
33 }
34
35 GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomCurvePtr& theCurve)
36 {
37   Handle(Geom_Curve) aCurve = theCurve->impl<Handle_Geom_Curve>();
38   Handle(Geom_Plane) aPlane = new Geom_Plane(myPlane->impl<gp_Ax3>());
39
40   Handle(Geom_Curve) aProj = GeomProjLib::Project(aCurve, aPlane);
41
42   GeomCurvePtr aProjCurve(new GeomAPI_Curve);
43   aProjCurve->setImpl(new Handle_Geom_Curve(aProj));
44   return aProjCurve;
45 }
46
47 GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomEdgePtr& theEdge)
48 {
49   GeomCurvePtr aCurve(new GeomAPI_Curve(theEdge));
50   return project(aCurve);
51 }