Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Projection.cpp
index 21a66fa026b54f5e0f92d1d1deb20a01ca8ca8bd..acb5c6b4e6166b76051dba0290ce6c3f5685a0d0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019  CEA/DEN, EDF R&D
+// Copyright (C) 2019-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include <Geom_Plane.hxx>
 #include <GeomProjLib.hxx>
 
+#include <BRep_Tool.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
 GeomAlgoAPI_Projection::GeomAlgoAPI_Projection(const GeomPlanePtr& thePlane)
   : myPlane(thePlane)
 {
@@ -37,7 +42,8 @@ GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomCurvePtr& theCurve)
   Handle(Geom_Curve) aCurve = theCurve->impl<Handle_Geom_Curve>();
   Handle(Geom_Plane) aPlane = new Geom_Plane(myPlane->impl<gp_Ax3>());
 
-  Handle(Geom_Curve) aProj = GeomProjLib::Project(aCurve, aPlane);
+  Handle(Geom_Curve) aProj =
+      GeomProjLib::ProjectOnPlane(aCurve, aPlane, aPlane->Axis().Direction(), false);
 
   GeomCurvePtr aProjCurve(new GeomAPI_Curve);
   aProjCurve->setImpl(new Handle_Geom_Curve(aProj));
@@ -46,6 +52,17 @@ GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomCurvePtr& theCurve)
 
 GeomCurvePtr GeomAlgoAPI_Projection::project(const GeomEdgePtr& theEdge)
 {
-  GeomCurvePtr aCurve(new GeomAPI_Curve(theEdge));
+  GeomCurvePtr aCurve(new GeomAPI_Curve);
+
+  const TopoDS_Shape& aShape = theEdge->impl<TopoDS_Shape>();
+  TopoDS_Edge anEdge = TopoDS::Edge(aShape);
+  if (!anEdge.IsNull()) {
+    double aStart, aEnd;
+    Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(anEdge, aStart, aEnd);
+    if (!anEdgeCurve.IsNull() && !BRep_Tool::IsClosed(anEdge))
+      anEdgeCurve = new Geom_TrimmedCurve(anEdgeCurve, aStart, aEnd);
+    aCurve->setImpl(new Handle_Geom_Curve(anEdgeCurve));
+  }
+
   return project(aCurve);
 }