From: vsv Date: Mon, 8 Oct 2018 14:47:01 +0000 (+0300) Subject: Avoid crash on creation of a plane when default size is set to 0 X-Git-Tag: V9_2_0a2~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d8ff447afc547f3421d77eb7831133ee00946a3;p=modules%2Fshaper.git Avoid crash on creation of a plane when default size is set to 0 --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index 3680ab503..ad046394a 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -45,6 +45,7 @@ #include #include + static GeomShapePtr faceByThreeVertices(const std::shared_ptr theV1, const std::shared_ptr theV2, const std::shared_ptr theV3); @@ -180,7 +181,9 @@ std::shared_ptr ConstructionPlugin_Plane::createByGeneralEquation aC = anAttrC->value(), aD = anAttrD->value(); std::shared_ptr aPlane = std::shared_ptr(new GeomAPI_Pln(aA, aB, aC, aD)); - double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size"); + double aSize = Config_PropManager::real(SKETCH_TAB_NAME, "planes_size"); + if (aSize <= 1.e-7) + aSize = 200; // Set default value aSize *= 4.; aPlaneFace = GeomAlgoAPI_FaceBuilder::squareFace(aPlane, aSize); } diff --git a/src/GeomAPI/GeomAPI_Wire.cpp b/src/GeomAPI/GeomAPI_Wire.cpp index 65729cbf7..05062a145 100644 --- a/src/GeomAPI/GeomAPI_Wire.cpp +++ b/src/GeomAPI/GeomAPI_Wire.cpp @@ -106,6 +106,9 @@ bool GeomAPI_Wire::isRectangle(std::list& thePoints) const gp_Pnt aStart = aC3D->Value(aT1); gp_Pnt aEnd = aC3D->Value(aT2); + if (aStart.Distance(aEnd) <= Precision::Confusion()) + return false; + // check the edge is orthogonal to the previous gp_XYZ aCurDir = (aEnd.XYZ() - aStart.XYZ()).Normalized(); if (aPrevDir.Dot(aCurDir) < Precision::Confusion()) diff --git a/src/PartSet/PartSet_PreviewPlanes.cpp b/src/PartSet/PartSet_PreviewPlanes.cpp index 379bd78a3..7585f21be 100755 --- a/src/PartSet/PartSet_PreviewPlanes.cpp +++ b/src/PartSet/PartSet_PreviewPlanes.cpp @@ -147,12 +147,15 @@ AISObjectPtr PartSet_PreviewPlanes::createPreviewPlane(std::shared_ptr theNorm, const int theRGB[3]) { - double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size"); + double aSize = Config_PropManager::real(SKETCH_TAB_NAME, "planes_size"); + if (aSize <= Precision::Confusion()) + aSize = 200; // Set default value + std::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::squareFace(theOrigin, theNorm, aSize); AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject()); aAIS->createShape(aFace); - aAIS->setWidth(Config_PropManager::integer(SKETCH_TAB_NAME, "planes_thickness")); + aAIS->setWidth(Config_PropManager::real(SKETCH_TAB_NAME, "planes_thickness")); aAIS->setColor(theRGB[0], theRGB[1], theRGB[2]); return aAIS; } diff --git a/src/PartSet/PartSet_PreviewSketchPlane.cpp b/src/PartSet/PartSet_PreviewSketchPlane.cpp index 26e5dcad3..56f6c33f6 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.cpp +++ b/src/PartSet/PartSet_PreviewSketchPlane.cpp @@ -93,7 +93,9 @@ void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& th theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); double aFaceSize = myIsUseSizeOfView ? mySizeOfView - : Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size"); + : Config_PropManager::real(SKETCH_TAB_NAME, "planes_size"); + if (aFaceSize <= Precision::Confusion()) + aFaceSize = 200; // Set default value myShape = GeomAlgoAPI_FaceBuilder::squareFace( myViewCentralPoint.get() ? myViewCentralPoint : anOrigin->pnt(), aNormal->dir(), aFaceSize);