From 2bfb970fba3017f9cbf766839cc8ff99a9a872b3 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 24 Jun 2014 19:33:11 +0400 Subject: [PATCH] Projection of the last point of arc --- src/PartSet/PartSet_OperationFeatureCreate.cpp | 4 ++-- src/SketchPlugin/SketchPlugin_Arc.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index a45a85419..bd662e200 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -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 || diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 5bb8fa0d2..ed8d3be22 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -6,6 +6,7 @@ #include "SketchPlugin_Sketch.h" #include +#include #include #include @@ -15,6 +16,8 @@ #include #include +#include + SketchPlugin_Arc::SketchPlugin_Arc() : SketchPlugin_Feature() { @@ -50,15 +53,23 @@ const boost::shared_ptr& SketchPlugin_Arc::preview() boost::dynamic_pointer_cast(aSketch->data()->attribute(SKETCH_ATTR_NORM)); bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0); if (aHasPlane) { - boost::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); + boost::shared_ptr aNormal = aNDir->dir(); // compute the arc start point boost::shared_ptr aStartAttr = boost::dynamic_pointer_cast(data()->attribute(ARC_ATTR_START)); boost::shared_ptr aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y())); - // compute the arc end point + // compute and change the arc end point boost::shared_ptr anEndAttr = boost::dynamic_pointer_cast(data()->attribute(ARC_ATTR_END)); + if (anEndAttr->isInitialized()) + { + boost::shared_ptr aCircleForArc( + new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt())); + boost::shared_ptr aProjection = aCircleForArc->project(anEndAttr->pnt()); + if (aProjection && anEndAttr->pnt()->distance(aProjection) > Precision::Confusion()) + anEndAttr->setValue(aProjection); + } boost::shared_ptr aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y())); boost::shared_ptr aCircleShape = -- 2.39.2