X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintDistance.cpp;h=afe792932bd99f06b85e9d2a49e76bb7b774b388;hb=4f565b2204d3fba046aa8c851abada2a5a17bf6c;hp=2a75e1293f85b4e1c4d69331fb2af61c4e5c6891;hpb=92f5ad57273b390a63ee94a985ced600e429cd27;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp index 2a75e1293..afe792932 100644 --- a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include @@ -54,26 +56,10 @@ void SketchSolver_ConstraintDistance::adjustConstraint() return; } - // Get constraint parameters and check the sign of constraint value + // Adjust the sign of constraint value BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); - std::shared_ptr aPoint; - std::shared_ptr aLine; - std::list aSubs = aConstraint->entities(); - std::list::const_iterator aSIt = aSubs.begin(); - for (; aSIt != aSubs.end(); ++aSIt) { - if ((*aSIt)->type() == ENTITY_POINT) - aPoint = aBuilder->point(*aSIt); - else if ((*aSIt)->type() == ENTITY_LINE) - aLine = aBuilder->line(*aSIt); - } - - std::shared_ptr aLineVec = aLine->direction()->xy(); - std::shared_ptr aPtLineVec = aPoint->xy()->decreased(aLine->location()->xy()); - if (aPtLineVec->cross(aLineVec) * aConstraint->value() < 0.0 || myIsNegative) { - aConstraint->setValue(aConstraint->value() * (-1.0)); - myStorage->addConstraint(myBaseConstraint, aConstraint); - myIsNegative = true; - } + aBuilder->adjustConstraint(aConstraint); + myStorage->addConstraint(myBaseConstraint, aConstraint); } void SketchSolver_ConstraintDistance::update()