From 1dc044fab3350100372e3d326698cb12b99497f2 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 23 May 2017 16:12:02 +0300 Subject: [PATCH] Issue #2175: Moving a point of a rectangle is too slow Make moving only the dragged entity. --- .../SketchSolver_ConstraintFixed.cpp | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp index 9c4f23330..e75bda6a1 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp @@ -14,6 +14,8 @@ #include +// Verify the points are equal +static bool isEqual(const GCS::Point& thePoint1, const GCS::Point& thePoint2); // Verify the entities are equal static bool isEqual(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2); // Convert entity to the list of parameters @@ -96,17 +98,35 @@ void SketchSolver_ConstraintFixed::getAttributes(EntityWrapperPtr& theBaseEntity return; } + bool fixFullFeature = false; + theBaseEntity = EntityWrapperPtr(); + theFixedEntity = EntityWrapperPtr(); + // The feature is fixed. PlaneGCSSolver_FeatureBuilder aBuilder; std::list aBaseAttr = myBaseFeature->data()->attributes(std::string()); std::list::const_iterator anIt = aBaseAttr.begin(); - for (; anIt != aBaseAttr.end(); ++anIt) - aBuilder.createAttribute(*anIt); - theFixedEntity = aBuilder.createFeature(myBaseFeature); + for (; anIt != aBaseAttr.end(); ++anIt) { + EntityWrapperPtr anEntity = aBuilder.createAttribute(*anIt); + EntityWrapperPtr aBaseEntity = myStorage->entity(*anIt); + if (!anEntity || !aBaseEntity) + continue; + + if (!fixFullFeature && anEntity->type() == ENTITY_POINT && + !isEqual(anEntity, aBaseEntity)) { + if (theFixedEntity) + fixFullFeature = true; + theFixedEntity = anEntity; + theBaseEntity = aBaseEntity; + } + } - theBaseEntity = myStorage->entity(myBaseFeature); - if (isEqual(theBaseEntity, theFixedEntity)) - theBaseEntity = EntityWrapperPtr(); // do not want to fix already fixed entity + if (fixFullFeature) { + theFixedEntity = aBuilder.createFeature(myBaseFeature); + theBaseEntity = myStorage->entity(myBaseFeature); + if (isEqual(theBaseEntity, theFixedEntity)) + theBaseEntity = EntityWrapperPtr(); // do not want to fix already fixed entity + } } else if (myBaseConstraint) { // Constraint Fixed is added by user. @@ -194,6 +214,12 @@ GCS::VEC_pD toParameters(const EntityWrapperPtr& theEntity) return aParameters; } +bool isEqual(const GCS::Point& thePoint1, const GCS::Point& thePoint2) +{ + return fabs((*thePoint1.x) - (*thePoint2.x)) <= tolerance && + fabs((*thePoint1.y) - (*thePoint2.y)) <= tolerance; +} + bool isEqual(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2) { GCS::VEC_pD aParamList1 = toParameters(theEntity1); -- 2.39.2