From: dbv Date: Tue, 2 Aug 2016 08:50:36 +0000 (+0300) Subject: Issue #1649: Added "Perpendicular" option for creation plane by line and point. X-Git-Tag: V_2.5.0~147 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=567098358058bc74ece82bcb721c5e81d84829ca;p=modules%2Fshaper.git Issue #1649: Added "Perpendicular" option for creation plane by line and point. --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 6dc998e6f..d1335f646 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -33,7 +33,7 @@ using namespace std; -static const double defaultAxisSize = 50; +static const double defaultAxisSize = 100; ConstructionPlugin_Axis::ConstructionPlugin_Axis() { @@ -226,7 +226,7 @@ void ConstructionPlugin_Axis::createAxisByPlaneAndPoint() aPnt->translate(aPln->direction(), defaultAxisSize); } - std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aProjPnt, aPnt); + std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aPnt, aProjPnt); ResultConstructionPtr aConstr = document()->createConstruction(data()); aConstr->setInfinite(true); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index 316878723..29792e54b 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -63,12 +63,13 @@ void ConstructionPlugin_Plane::initAttributes() // By line and point. data()->addAttribute(LINE(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(POINT(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(PERPENDICULAR(), ModelAPI_AttributeBoolean::typeId()); // By other plane. data()->addAttribute(CREATION_METHOD_BY_OTHER_PLANE_OPTION(), ModelAPI_AttributeString::typeId()); data()->addAttribute(PLANE(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(DISTANCE(), ModelAPI_AttributeDouble::typeId()); - data()->addAttribute(DISTANCE_REVERSE(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(REVERSE(), ModelAPI_AttributeBoolean::typeId()); data()->addAttribute(COINCIDENT_POINT(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(AXIS(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(ANGLE(), ModelAPI_AttributeDouble::typeId()); @@ -207,9 +208,6 @@ std::shared_ptr ConstructionPlugin_Plane::createByLineAndPoint() aLineShape = anEdgeSelection->context()->shape(); } std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); - std::shared_ptr aV1, aV2; - GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2); - // Get point. AttributeSelectionPtr aPointSelection = selection(POINT()); @@ -219,7 +217,22 @@ std::shared_ptr ConstructionPlugin_Plane::createByLineAndPoint() } std::shared_ptr aVertex(new GeomAPI_Vertex(aPointShape)); - GeomShapePtr aRes = faceByThreeVertices(aV1, aV2, aVertex); + // Get perpendicular flag. + bool anIsPerpendicular= boolean(PERPENDICULAR())->value(); + + GeomShapePtr aRes; + if(anIsPerpendicular) { + std::shared_ptr aLin = anEdge->line(); + std::shared_ptr aPnt = aVertex->point(); + std::shared_ptr aNewPln(new GeomAPI_Pln(aPnt, aLin->direction())); + int aSize = aLin->distance(aPnt); + aSize *= 2.0; + aRes = GeomAlgoAPI_FaceBuilder::squareFace(aNewPln, aSize); + } else { + std::shared_ptr aV1, aV2; + GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2); + aRes = faceByThreeVertices(aV1, aV2, aVertex); + } return aRes; } diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.h b/src/ConstructionPlugin/ConstructionPlugin_Plane.h index 15894a2f6..613062af9 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.h @@ -145,6 +145,13 @@ public: return ATTR_ID; } + /// Attribute name for perpendicular flag. + inline static const std::string& PERPENDICULAR() + { + static const std::string ATTR_ID("perpendicular"); + return ATTR_ID; + } + /// Attribute name for selected plane. inline static const std::string& PLANE() { @@ -159,11 +166,11 @@ public: return ATTR_ID; } - /// Attribute name for reverse in distance from other case - inline static const std::string& DISTANCE_REVERSE() + /// Attribute name for reverse flag. + inline static const std::string& REVERSE() { - static const std::string ATTR_DISTANCE_REVERSE_ID("distance_reverse"); - return ATTR_DISTANCE_REVERSE_ID; + static const std::string ATTR_ID("reverse"); + return ATTR_ID; } /// Attribute name for coincident point. diff --git a/src/ConstructionPlugin/plane_widget.xml b/src/ConstructionPlugin/plane_widget.xml index be0311360..5a9d74637 100644 --- a/src/ConstructionPlugin/plane_widget.xml +++ b/src/ConstructionPlugin/plane_widget.xml @@ -47,6 +47,10 @@ shape_types="vertex"> + - + + +