From 3a9544a40cb35569ae239c201c9f1b6744a2632f Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 7 Jun 2016 14:14:12 +0300 Subject: [PATCH] Avoid the ""Conflicting constraints" message on constraint Mirror --- .../PlaneGCSSolver/PlaneGCSSolver_Builder.cpp | 3 ++- .../PlaneGCSSolver/PlaneGCSSolver_Storage.cpp | 6 +++++- .../SketchSolver_ConstraintMirror.cpp | 19 ++----------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp index 027d57a0a..0213cceaa 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp @@ -1197,6 +1197,7 @@ void adjustMirror(ConstraintWrapperPtr theConstraint) aMirrorLine = *anIt; } - makeMirrorPoints(aPoints[0], aPoints[1], aMirrorLine); + if (aPoints.size() == 2) + makeMirrorPoints(aPoints[0], aPoints[1], aMirrorLine); } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 423812008..aa011cc4f 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -387,7 +387,8 @@ void PlaneGCSSolver_Storage::processArc(const EntityWrapperPtr& theArc) double* aEndAngle = std::dynamic_pointer_cast(*aSubIt++)->scalar(); double* aRadius = std::dynamic_pointer_cast(*aSubIt)->scalar(); - FeaturePtr anArcFeature = theArc->baseFeature(); + std::shared_ptr anArcFeature = + std::dynamic_pointer_cast(theArc->baseFeature()); std::shared_ptr aCenterAttr = std::dynamic_pointer_cast( anArcFeature->attribute(SketchPlugin_Arc::CENTER_ID())); std::shared_ptr aStartAttr = std::dynamic_pointer_cast( @@ -409,6 +410,9 @@ void PlaneGCSSolver_Storage::processArc(const EntityWrapperPtr& theArc) return; anArcEdge->getRange(*aStartAngle, *aEndAngle); + // do not constraint copied arc + if (anArcFeature->isCopy()) + return; // No need to add constraints if they are already exist std::map >::const_iterator aFound = myArcConstraintMap.find(theArc); diff --git a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp index 4173be33b..db6387237 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp @@ -88,23 +88,6 @@ void SketchSolver_ConstraintMirror::process() std::vector::iterator aBIt = aBaseList.begin(); std::vector::iterator aMIt = aMirrorList.begin(); for (; aBIt != aBaseList.end(); ++aBIt, ++aMIt) { - if ((*aBIt)->type() == ENTITY_ARC) { - // add new points on arcs and mirror them - EntityWrapperPtr aBasePnt = myStorage->calculateMiddlePoint(*aBIt, 0.5); - EntityWrapperPtr aMirrPnt = myStorage->calculateMiddlePoint(*aMIt, 0.5); - // point on base arc - aNewConstraints = aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, - CONSTRAINT_PT_ON_CIRCLE, 0.0, aBasePnt, EntityWrapperPtr(), *aBIt); - aMirConstrList.insert(aMirConstrList.end(), aNewConstraints.begin(), aNewConstraints.end()); - // point on mirrored arc - aNewConstraints = aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, - CONSTRAINT_PT_ON_CIRCLE, 0.0, aMirrPnt, EntityWrapperPtr(), *aMIt); - aMirConstrList.insert(aMirConstrList.end(), aNewConstraints.begin(), aNewConstraints.end()); - // mirror these points - aNewConstraints = aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, - aConstrType, 0.0, aBasePnt, aMirrPnt, aMirrorLine); - aMirConstrList.insert(aMirConstrList.end(), aNewConstraints.begin(), aNewConstraints.end()); - } aNewConstraints = aBuilder->createConstraint( myBaseConstraint, myGroupID, mySketchID, aConstrType, 0.0, *aBIt, *aMIt, aMirrorLine); @@ -115,6 +98,8 @@ void SketchSolver_ConstraintMirror::process() for (aMIt = aMirrorList.begin(); aMIt != aMirrorList.end(); ++aMIt) myStorage->update((*aMIt)->baseFeature(), myGroupID); myStorage->addConstraint(myBaseConstraint, aMirConstrList); + + adjustConstraint(); } -- 2.39.2