]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Avoid crash on creation of a plane when default size is set to 0
authorvsv <vsv@opencascade.com>
Mon, 8 Oct 2018 14:47:01 +0000 (17:47 +0300)
committervsv <vsv@opencascade.com>
Mon, 8 Oct 2018 14:47:01 +0000 (17:47 +0300)
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/GeomAPI/GeomAPI_Wire.cpp
src/PartSet/PartSet_PreviewPlanes.cpp
src/PartSet/PartSet_PreviewSketchPlane.cpp

index 3680ab50302fd64895e7c84891b99395a6ee83b3..ad046394a37ac7a5685644dcb02678c1eb7528d8 100644 (file)
@@ -45,6 +45,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
+
 static GeomShapePtr faceByThreeVertices(const std::shared_ptr<GeomAPI_Vertex> theV1,
                                         const std::shared_ptr<GeomAPI_Vertex> theV2,
                                         const std::shared_ptr<GeomAPI_Vertex> theV3);
@@ -180,7 +181,9 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByGeneralEquation
            aC = anAttrC->value(), aD = anAttrD->value();
     std::shared_ptr<GeomAPI_Pln> aPlane =
       std::shared_ptr<GeomAPI_Pln>(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);
   }
index 65729cbf7bed5f9d49b16703852d3c74f73a366e..05062a145cc25abc95b00133c5c7e91a7f52c145 100644 (file)
@@ -106,6 +106,9 @@ bool GeomAPI_Wire::isRectangle(std::list<GeomPointPtr>& 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())
index 379bd78a3fe01d84f077c6c773753e7ed86dcb49..7585f21be350561ffb95193bcca7cc5641c6f114 100755 (executable)
@@ -147,12 +147,15 @@ AISObjectPtr PartSet_PreviewPlanes::createPreviewPlane(std::shared_ptr<GeomAPI_P
                                                        std::shared_ptr<GeomAPI_Dir> 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<GeomAPI_Shape> 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;
 }
index 26e5dcad3fee008fe9d48e3a35c538bfccf4a782..56f6c33f6c0f1a2281fde3e7e0922c997068b56b 100644 (file)
@@ -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);