]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ConstructionPlugin/ConstructionPlugin_Point.cpp
Salome HOME
2.3.3.1 Point creation by projection of another point on a line
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Point.cpp
index ee86684379ef1b211db52a43548f1d2fe6a3c293..60b0af1c56b534fc677a4a609792c0215c320876 100644 (file)
@@ -73,6 +73,9 @@ void ConstructionPlugin_Point::initAttributes()
   data()->addAttribute(RATIO(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(REVERSE(), ModelAPI_AttributeBoolean::typeId());
 
+  data()->addAttribute(POINT_TO_PROJECT_ON_EDGE(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(EDGE_FOR_POINT_PROJECTION(), ModelAPI_AttributeSelection::typeId());
+
   data()->addAttribute(POINT_TO_PROJECT_ON_FACE(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(FACE_FOR_POINT_PROJECTION(), ModelAPI_AttributeSelection::typeId());
 }
@@ -90,6 +93,8 @@ void ConstructionPlugin_Point::execute()
     aShape = createByXYZ();
   } else if(aCreationMethod == CREATION_METHOD_BY_DISTANCE_ON_EDGE()) {
     aShape = createByDistanceOnEdge();
+  } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION_ON_EDGE()) {
+    aShape = createByProjectionOnEdge();
   } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION_ON_FACE()) {
     aShape = createByProjectionOnFace();
   } /* else if(aCreationMethod == CREATION_METHOD_BY_LINES_INTERSECTION()) {
@@ -169,6 +174,28 @@ std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByDistanceOnEdge
   return GeomAlgoAPI_PointBuilder::vertexOnEdge(anEdge, aValue, anIsPercent, anIsReverse);
 }
 
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjectionOnEdge()
+{
+  // Get point.
+  AttributeSelectionPtr aPointSelection = selection(POINT_TO_PROJECT_ON_EDGE());
+  GeomShapePtr aPointShape = aPointSelection->value();
+  if (!aPointShape.get()) {
+    aPointShape = aPointSelection->context()->shape();
+  }
+  std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aPointShape));
+
+  // Get edge.
+  AttributeSelectionPtr anEdgeSelection = selection(EDGE_FOR_POINT_PROJECTION());
+  GeomShapePtr anEdgeShape = anEdgeSelection->value();
+  if (!anEdgeShape.get()) {
+    anEdgeShape = anEdgeSelection->context()->shape();
+  }
+  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(anEdgeShape));
+
+  return GeomAlgoAPI_PointBuilder::vertexByProjection(aVertex, anEdge);
+}
+
 //==================================================================================================
 std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjectionOnFace()
 {