]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ConstructionPlugin/ConstructionPlugin_Point.cpp
Salome HOME
Added option to create Construction Point by intersection of two lines.
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Point.cpp
index 380393db703ea60e5feb37ac5c474aacea46f967..22f91d732f9e2cb0d6677cb379eb1b3b8ef3c9d8 100644 (file)
@@ -46,6 +46,9 @@ void ConstructionPlugin_Point::initAttributes()
 
   data()->addAttribute(POINT(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(PLANE(), ModelAPI_AttributeSelection::typeId());
+
+  data()->addAttribute(FIRST_LINE(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(SECOND_LINE(), ModelAPI_AttributeSelection::typeId());
 }
 
 //==================================================================================================
@@ -60,6 +63,8 @@ void ConstructionPlugin_Point::execute()
     aShape = createByDistanceOnEdge();
   } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION()) {
     aShape = createByProjection();
+  } else if(aCreationMethod == CREATION_METHOD_BY_LINES_INTERSECTION()) {
+    aShape = createByIntersection();
   }
 
   if(aShape.get()) {
@@ -130,3 +135,25 @@ std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjection()
 
   return GeomAlgoAPI_PointBuilder::vertexByProjection(aVertex, aFace);
 }
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByIntersection()
+{
+  // Get first line.
+  AttributeSelectionPtr aFirstLineSelection= selection(FIRST_LINE());
+  GeomShapePtr aFirstLineShape = aFirstLineSelection->value();
+  if(!aFirstLineShape.get()) {
+    aFirstLineShape = aFirstLineSelection->context()->shape();
+  }
+  std::shared_ptr<GeomAPI_Edge> aFirstEdge(new GeomAPI_Edge(aFirstLineShape));
+
+  // Get first line.
+  AttributeSelectionPtr aSecondLineSelection= selection(SECOND_LINE());
+  GeomShapePtr aSecondLineShape = aSecondLineSelection->value();
+  if(!aSecondLineShape.get()) {
+    aSecondLineShape = aSecondLineSelection->context()->shape();
+  }
+  std::shared_ptr<GeomAPI_Edge> aSecondEdge(new GeomAPI_Edge(aSecondLineShape));
+
+  return GeomAlgoAPI_PointBuilder::vertexByIntersection(aFirstEdge, aSecondEdge);
+}