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);
#include <GeomAPI_Vertex.h>
#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeBoolean.h>
#include <Events_InfoMessage.h>
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;
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 "