From: Artem Zhidkov Date: Fri, 20 Mar 2020 13:25:47 +0000 (+0300) Subject: Protect normalization of zero-length vector. X-Git-Tag: V9_5_0a2~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b6b18134a237fe4882fa4069a1d505c49a932a02;p=modules%2Fshaper.git Protect normalization of zero-length vector. --- diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 0fd66fd48..2e049d19d 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -168,18 +168,23 @@ Handle(V3d_View) theView, gp_Pnt EyePoint(XEye, YEye, ZEye); gp_Pnt AtPoint(XAt, YAt, ZAt); - gp_Vec anEyeVec(EyePoint, AtPoint); - anEyeVec.Normalize(); + if (EyePoint.Distance(AtPoint) > gp::Resolution()) { + gp_Vec anEyeVec(EyePoint, AtPoint); + anEyeVec.Normalize(); - std::shared_ptr aNormal = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::NORM_ID())); - gp_Vec aNormalVec(aNormal->x(), aNormal->y(), aNormal->z()); + std::shared_ptr aNormal = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + gp_Vec aNormalVec(aNormal->x(), aNormal->y(), aNormal->z()); - double aDen = anEyeVec * aNormalVec; - double aLVec = aDen != 0 ? aVec * aNormalVec / aDen : DBL_MAX; + double aDen = anEyeVec * aNormalVec; + double aLVec = aDen != 0 ? aVec * aNormalVec / aDen : DBL_MAX; - gp_Vec aDeltaVec = anEyeVec * aLVec; - aVec = aVec - aDeltaVec; + gp_Vec aDeltaVec = anEyeVec * aLVec; + aVec = aVec - aDeltaVec; + } +else { + int qq = 0; +} } theX = aVec.X() * aX->x() + aVec.Y() * aX->y() + aVec.Z() * aX->z(); theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();