]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1649: Added "Perpendicular" option for creation plane by line and point.
authordbv <dbv@opencascade.com>
Tue, 2 Aug 2016 08:50:36 +0000 (11:50 +0300)
committerdbv <dbv@opencascade.com>
Wed, 3 Aug 2016 07:07:12 +0000 (10:07 +0300)
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ConstructionPlugin/ConstructionPlugin_Plane.h
src/ConstructionPlugin/plane_widget.xml

index 6dc998e6f9e671a970da91c62b7538b11a3438de..d1335f646dd1c2ea507badf5304331f0c2e98292 100644 (file)
@@ -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<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aProjPnt, aPnt);
+  std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aPnt, aProjPnt);
 
   ResultConstructionPtr aConstr = document()->createConstruction(data());
   aConstr->setInfinite(true);
index 31687872392de013d64f7a0b51399081cb8f04c5..29792e54bd808626b0532e4a2a0f7eb4e263627b 100644 (file)
@@ -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<GeomAPI_Shape> ConstructionPlugin_Plane::createByLineAndPoint()
     aLineShape = anEdgeSelection->context()->shape();
   }
   std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
-  std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
-  GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2);
-
 
   // Get point.
   AttributeSelectionPtr aPointSelection = selection(POINT());
@@ -219,7 +217,22 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByLineAndPoint()
   }
   std::shared_ptr<GeomAPI_Vertex> 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<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()));
+    int aSize = aLin->distance(aPnt);
+    aSize *= 2.0;
+    aRes = GeomAlgoAPI_FaceBuilder::squareFace(aNewPln, aSize);
+  } else {
+    std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
+    GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2);
+    aRes = faceByThreeVertices(aV1, aV2, aVertex);
+  }
 
   return aRes;
 }
index 15894a2f6ee7d34b13cdacf068e5c92e75fc287c..613062af94043431000c83d9f8d9ceab99cd5275 100644 (file)
@@ -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.
index be03113605cd8d830ed27dc4865f25cd9037afa0..5a9d746373c27181cb90e6741d1349a8df7ce2ed 100644 (file)
                       shape_types="vertex">
         <validator id="ConstructionPlugin_ValidatorPlaneLinePoint" parameters="line"/>
       </shape_selector>
+      <boolvalue id="perpendicular"
+           label="Perpendicular "
+           tooltip="Makes the plane perpendicular to the selected line."
+           default="false"/>
     </box>
     <box id="by_other_plane"
          title="By other plane"
                        label="Distance"
                        tooltip="Distance from selected face to plane."
                        icon="icons/Construction/distance_value.png"
-                       default="10"/>
-          <boolvalue id="distance_reverse"
+                       min="0"
+                       default="10">
+            <validator id="GeomValidators_Positive"/>
+          </doublevalue>
+          <boolvalue id="reverse"
                      label="Reverse"
-                     tooltip="Distance from plane."
+                     tooltip="Checked means on the other side of the selected plane."
                      default="false"/>
         </box>
         <box id="by_coincident_to_point"