From: azv Date: Fri, 12 Jan 2018 13:48:25 +0000 (+0300) Subject: Issue #2387: Sketcher conservation of constraints in fillet feature X-Git-Tag: V_3.0.0RC1~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6e587166bdb1b47d17337a681f1e2a575fc9a83c;p=modules%2Fshaper.git Issue #2387: Sketcher conservation of constraints in fillet feature 1. Make the apex point auxiliary 2. Keep positions of constraints. --- diff --git a/src/SketchPlugin/SketchPlugin_Fillet.cpp b/src/SketchPlugin/SketchPlugin_Fillet.cpp index b38352be8..106b3a7cf 100644 --- a/src/SketchPlugin/SketchPlugin_Fillet.cpp +++ b/src/SketchPlugin/SketchPlugin_Fillet.cpp @@ -332,6 +332,7 @@ FeaturePtr SketchPlugin_Fillet::createFilletApex(const GeomPnt2dPtr& theCoordina AttributePoint2DPtr aCoord = std::dynamic_pointer_cast( anApex->attribute(SketchPlugin_Point::COORD_ID())); aCoord->setValue(theCoordinates); + anApex->boolean(SketchPlugin_Point::AUXILIARY_ID())->setValue(true); // additional coincidence constraints static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -416,7 +417,7 @@ void SketchPlugin_Fillet::removeReferencesButKeepDistances( AttributePoint2DPtr aFlyoutAttr = std::dynamic_pointer_cast( aLength->attribute(SketchPlugin_ConstraintLength::FLYOUT_VALUE_PNT())); if (aFlyoutAttr && aFlyoutAttr->isInitialized()) - aNewLength.myFlyoutPoint = aFlyoutAttr->pnt(); + aNewLength.myFlyoutPoint = SketchPlugin_Tools::flyoutPointCoordinates(aLength); AttributeIntegerPtr aLocationAttr = aLength->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID()); if (aLocationAttr && aLocationAttr->isInitialized()) diff --git a/src/SketchPlugin/SketchPlugin_Tools.cpp b/src/SketchPlugin/SketchPlugin_Tools.cpp index d0c13c069..758de8b29 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.cpp +++ b/src/SketchPlugin/SketchPlugin_Tools.cpp @@ -21,7 +21,9 @@ #include "SketchPlugin_Tools.h" #include "SketchPlugin_ConstraintCoincidence.h" +#include "SketchPlugin_ConstraintLength.h" #include "SketchPlugin_ConstraintTangent.h" +#include "SketchPlugin_Line.h" #include "SketchPlugin_Point.h" #include "SketchPlugin_SketchEntity.h" @@ -29,6 +31,10 @@ #include +#include +#include +#include + #include #include @@ -390,4 +396,35 @@ FeaturePtr createConstraintObjectObject(SketchPlugin_Sketch* theSketch, return aConstraint; } +GeomPnt2dPtr flyoutPointCoordinates(const ConstraintPtr& theConstraint) +{ + // currently process Length constraints only + if (theConstraint->getKind() != SketchPlugin_ConstraintLength::ID()) + return GeomPnt2dPtr(); + + AttributeRefAttrPtr aLineAttr = theConstraint->refattr(SketchPlugin_Constraint::ENTITY_A()); + if (!aLineAttr || !aLineAttr->isObject()) + return GeomPnt2dPtr(); + FeaturePtr aLine = ModelAPI_Feature::feature(aLineAttr->object()); + if (!aLine || aLine->getKind() != SketchPlugin_Line::ID()) + return GeomPnt2dPtr(); + + std::shared_ptr aStartPnt = std::dynamic_pointer_cast( + aLine->attribute(SketchPlugin_Line::START_ID()))->pnt()->xy(); + std::shared_ptr aEndPnt = std::dynamic_pointer_cast( + aLine->attribute(SketchPlugin_Line::END_ID()))->pnt()->xy(); + + std::shared_ptr aFlyoutAttr = + std::dynamic_pointer_cast( + theConstraint->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + std::shared_ptr aFltPnt = aFlyoutAttr->pnt(); + + std::shared_ptr aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt))); + + double X = aStartPnt->x() + aFltPnt->x() * aLineDir->x() - aFltPnt->y() * aLineDir->y(); + double Y = aStartPnt->y() + aFltPnt->x() * aLineDir->y() + aFltPnt->y() * aLineDir->x(); + + return GeomPnt2dPtr(new GeomAPI_Pnt2d(X, Y)); +} + } // namespace SketchPlugin_Tools diff --git a/src/SketchPlugin/SketchPlugin_Tools.h b/src/SketchPlugin/SketchPlugin_Tools.h index 42c2f439f..d889b3d61 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.h +++ b/src/SketchPlugin/SketchPlugin_Tools.h @@ -28,6 +28,7 @@ #include #include +class SketchPlugin_Constraint; class SketchPlugin_Feature; class SketchPlugin_Sketch; @@ -112,6 +113,10 @@ void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr& theRefA const AttributePtr& theDefaultAttr, std::shared_ptr& theTangentCurve, std::shared_ptr& thePassingPoint); + + +/// Calculate global coordinates for flyout point of Length constraint +GeomPnt2dPtr flyoutPointCoordinates(const std::shared_ptr& theConstraint); }; // namespace SketchPlugin_Tools #endif // SKETCHPLUGIN_TOOLS_H_ \ No newline at end of file