]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Projection of the last point of arc
authorazv <azv@opencascade.com>
Tue, 24 Jun 2014 15:33:11 +0000 (19:33 +0400)
committerazv <azv@opencascade.com>
Tue, 24 Jun 2014 15:33:11 +0000 (19:33 +0400)
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp

index a45a854191fea0e8216c70799919786d8029adfa..bd662e200e2ed7ebad9e31b8a3e334a8656e5a3b 100644 (file)
@@ -59,8 +59,8 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
 bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
 {
   return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND ||
-         theId == SKETCH_CIRCLE_KIND /*||
-         theId == SKETCH_ARC_KIND*/ ||
+         theId == SKETCH_CIRCLE_KIND ||
+         theId == SKETCH_ARC_KIND ||
          theId == SKETCH_CONSTRAINT_DISTANCE_KIND /*||
          theId == SKETCH_CONSTRAINT_LENGTH_KIND ||
          theId == SKETCH_CONSTRAINT_RADIUS_KIND ||
index 5bb8fa0d242862e16f24e07455d1647a0deae0c2..ed8d3be222a4874f54694d3ac2d7884ffe04347a 100644 (file)
@@ -6,6 +6,7 @@
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
 
+#include <GeomAPI_Circ2d.h>
 #include <GeomAPI_Pnt2d.h>
 
 #include <GeomDataAPI_Point2D.h>
@@ -15,6 +16,8 @@
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
 
+#include <Precision.hxx>
+
 SketchPlugin_Arc::SketchPlugin_Arc()
   : SketchPlugin_Feature()
 {
@@ -50,15 +53,23 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
       boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SKETCH_ATTR_NORM));
     bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
     if (aHasPlane) {
-      boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
+      boost::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
       // compute the arc start point
       boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ARC_ATTR_START));
       boost::shared_ptr<GeomAPI_Pnt> aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
 
-      // compute the arc end point
+      // compute and change the arc end point
       boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ARC_ATTR_END));
+      if (anEndAttr->isInitialized())
+      {
+        boost::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
+          new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
+        boost::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEndAttr->pnt());
+        if (aProjection && anEndAttr->pnt()->distance(aProjection) > Precision::Confusion())
+          anEndAttr->setValue(aProjection);
+      }
       boost::shared_ptr<GeomAPI_Pnt> aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
 
       boost::shared_ptr<GeomAPI_Shape> aCircleShape =