]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #1794: can't create a plane by a vertex and an axis if the vertex...
authormpv <mpv@opencascade.com>
Wed, 28 Sep 2016 09:07:20 +0000 (12:07 +0300)
committermpv <mpv@opencascade.com>
Wed, 28 Sep 2016 09:07:20 +0000 (12:07 +0300)
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ConstructionPlugin/ConstructionPlugin_Validators.cpp
src/ConstructionPlugin/plane_widget.xml

index 7eced565dbbf5383e37109f2ca3defa38b7cf91a..6fc73fa04d8dbc11e62c91c505d58440a0b86a4f 100644 (file)
@@ -230,9 +230,11 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByLineAndPoint()
     std::shared_ptr<GeomAPI_Lin> aLin = anEdge->line();
     std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
     std::shared_ptr<GeomAPI_Pln> aNewPln(new GeomAPI_Pln(aPnt, aLin->direction()));
-    double aSize = aLin->distance(aPnt);
-    aSize *= 2.0;
-    aRes = GeomAlgoAPI_FaceBuilder::squareFace(aNewPln, aSize);
+    double aSize = aLin->distance(aPnt) * 2;
+    // point may belong to line, so for the face size use maximum distance between point and line
+    // and the line size (distance between the start and end point)
+    double aDistance = anEdge->firstPoint()->distance(anEdge->lastPoint());
+    aRes = GeomAlgoAPI_FaceBuilder::squareFace(aNewPln, aSize > aDistance ? aSize : aDistance);
   } else {
     std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
     GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2);
index 5f90b9d44bef419dd50e7b1dffd3720915a5ae1e..6fa9cbd240ac42b0f013398bcedaec07abed30a4 100644 (file)
@@ -14,6 +14,7 @@
 #include <GeomAPI_Vertex.h>
 
 #include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeBoolean.h>
 
 #include <Events_InfoMessage.h>
 
@@ -244,9 +245,13 @@ bool ConstructionPlugin_ValidatorPlaneLinePoint::isValid(
     return false;
   }
 
-  if(aLin->contains(aPnt)) {
-    theError = "Point lies on the line.";
-    return false;
+  // line should not contain point only for not-prependicular case
+  AttributeBooleanPtr aBoolAttr = aFeature->boolean(theArguments.back());
+  if (aBoolAttr.get() && !aBoolAttr->value()) {
+    if(aLin->contains(aPnt)) {
+      theError = "Point lies on the line.";
+      return false;
+    }
   }
 
   return true;
index 478c97dc5626d3e67d50b31df8e38f82b48a9ea3..29b5f665376999c8d5809038fe0ea5dacbca58b8 100644 (file)
                       icon="icons/Construction/edge.png"
                       shape_types="edge">
         <validator id="GeomValidators_ShapeType" parameters="line"/>
-        <validator id="ConstructionPlugin_ValidatorPlaneLinePoint" parameters="point"/>
+        <validator id="ConstructionPlugin_ValidatorPlaneLinePoint" parameters="point,perpendicular"/>
       </shape_selector>
       <shape_selector id="point"
                       label="Point"
                       tooltip="Select point."
                       icon="icons/Construction/point.png"
                       shape_types="vertex">
-        <validator id="ConstructionPlugin_ValidatorPlaneLinePoint" parameters="line"/>
+        <validator id="ConstructionPlugin_ValidatorPlaneLinePoint" parameters="line,perpendicular"/>
       </shape_selector>
       <boolvalue id="perpendicular"
            label="Perpendicular "