From 268d201ee47fc1896a1af0d59c5b3bf3844d3c9a Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 28 Sep 2016 12:07:20 +0300 Subject: [PATCH] Fix for the issue #1794: can't create a plane by a vertex and an axis if the vertex is collinear with the axis --- src/ConstructionPlugin/ConstructionPlugin_Plane.cpp | 8 +++++--- .../ConstructionPlugin_Validators.cpp | 11 ++++++++--- src/ConstructionPlugin/plane_widget.xml | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index 7eced565d..6fc73fa04 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -230,9 +230,11 @@ std::shared_ptr ConstructionPlugin_Plane::createByLineAndPoint() std::shared_ptr aLin = anEdge->line(); std::shared_ptr aPnt = aVertex->point(); std::shared_ptr 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 aV1, aV2; GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp b/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp index 5f90b9d44..6fa9cbd24 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp @@ -14,6 +14,7 @@ #include #include +#include #include @@ -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; diff --git a/src/ConstructionPlugin/plane_widget.xml b/src/ConstructionPlugin/plane_widget.xml index 478c97dc5..29b5f6653 100644 --- a/src/ConstructionPlugin/plane_widget.xml +++ b/src/ConstructionPlugin/plane_widget.xml @@ -38,14 +38,14 @@ icon="icons/Construction/edge.png" shape_types="edge"> - + - +