From a3cf47c475fe1adc481eb8eba186f3ef96e44e7d Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 23 Aug 2013 17:14:48 +0000
Subject: [PATCH] complain if curve.IsNull in closestPoint()

---
 Geo/OCCEdge.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp
index a797f1b878..589d9a1668 100644
--- a/Geo/OCCEdge.cpp
+++ b/Geo/OCCEdge.cpp
@@ -110,13 +110,19 @@ SPoint2 OCCEdge::reparamOnFace(const GFace *face, double epar, int dir) const
   }
 
 }
+
 GPoint OCCEdge::closestPoint(const SPoint3 &qp, double &param) const
 {
+  if(curve.IsNull()){
+    Msg::Error("OCC curve is null in closestPoint");
+    return GPoint(0, 0);
+  }
+
   gp_Pnt pnt(qp.x(), qp.y(), qp.z());
   GeomAPI_ProjectPointOnCurve proj(pnt, curve, s0, s1);
 
   if(!proj.NbPoints()){
-    Msg::Error("OCC Project Point on Curve FAIL");
+    Msg::Error("OCC ProjectPointOnCurve failed");
     return GPoint(0, 0);
   }
 
-- 
GitLab