From: Artem Zhidkov Date: Thu, 25 Jun 2020 11:14:00 +0000 (+0300) Subject: Issue #19725: Error when loading python dump X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Ffixes_for_950;p=modules%2Fshaper.git Issue #19725: Error when loading python dump Fix crash when projecting B-spline is not planar and findPlane() returns empty. --- diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 91b76d1b1..b09094fd5 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -1252,21 +1252,23 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute, std::shared_ptr aCurve(new GeomAPI_Curve(anEdge)); std::shared_ptr aBSpline(new GeomAPI_BSpline(aCurve)); if (aBSpline->isPeriodic()) { - GeomPlanePtr aPlane = GeomAlgoAPI_ShapeTools::findPlane(ListOfShape(1, anEdge)); - std::shared_ptr aBSplineNormal = aPlane->direction(); - double aDot = fabs(aNormal->dot(aBSplineNormal)); - aValid = fabs(aDot - 1.0) <= tolerance * tolerance; - if (!aValid) { - // B-spline's plane is orthogonal to the sketch plane, - // thus, need to check whether B-spline is planar. - std::list aPoles = aBSpline->poles(); - for (std::list::iterator it = aPoles.begin(); - it != aPoles.end() && !aValid; ++it) { - if (aPlane->distance(*it) > tolerance) - aValid = true; // non-planar B-spline curve + GeomPlanePtr aBSplinePlane = GeomAlgoAPI_ShapeTools::findPlane(ListOfShape(1, anEdge)); + if (aBSplinePlane) { + std::shared_ptr aBSplineNormal = aBSplinePlane->direction(); + double aDot = fabs(aNormal->dot(aBSplineNormal)); + aValid = fabs(aDot - 1.0) <= tolerance * tolerance; + if (!aValid) { + // B-spline's plane is orthogonal to the sketch plane, + // thus, need to check whether B-spline is planar. + std::list aPoles = aBSpline->poles(); + for (std::list::iterator it = aPoles.begin(); + it != aPoles.end() && !aValid; ++it) { + if (aBSplinePlane->distance(*it) > tolerance) + aValid = true; // non-planar B-spline curve + } + if (!aValid) + theError = "Error: Periodic B-spline is orthogonal to the sketch plane."; } - if (!aValid) - theError = "Error: Periodic B-spline is orthogonal to the sketch plane."; } } }