X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintLength.cpp;h=be89bb53d3f2c31f7e36f8853827c91465fbff3f;hb=4f565b2204d3fba046aa8c851abada2a5a17bf6c;hp=3d1d1bf22e6426e664c8a6d1b9256c0ebccbefeb;hpb=9ea97108f0859c83264c469256f065e7e5b36512;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintLength.cpp b/src/SketchSolver/SketchSolver_ConstraintLength.cpp index 3d1d1bf22..be89bb53d 100644 --- a/src/SketchSolver/SketchSolver_ConstraintLength.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintLength.cpp @@ -1,36 +1,28 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include -#include #include -void SketchSolver_ConstraintLength::process() +void SketchSolver_ConstraintLength::getAttributes( + double& theValue, + std::vector& theAttributes) { - cleanErrorMsg(); - if (!myBaseConstraint || !myStorage || myGroup == 0) { - /// TODO: Put error message here + SketchSolver_Constraint::getAttributes(theValue, theAttributes); + if (!myErrorMsg.empty() || !theAttributes[2] || + theAttributes[2]->type() != ENTITY_LINE) { + theAttributes.clear(); return; } - if (!mySlvsConstraints.empty()) // some data is changed, update constraint - update(myBaseConstraint); - - double aValue; - std::vector anEntities; - getAttributes(aValue, anEntities); - if (!myErrorMsg.empty()) - return; - // Check the entity is a line - Slvs_Entity aLine = myStorage->getEntity(anEntities[2]); - if (aLine.type != SLVS_E_LINE_SEGMENT){ - myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE(); - return; - } + // Get boundary points of line segment and create point-point distance constraint + std::list aSubs = theAttributes[2]->subEntities(); + theAttributes.assign(theAttributes.size(), EntityWrapperPtr()); + std::vector::iterator anAttrIt = theAttributes.begin(); + std::list::const_iterator aSubIt = aSubs.begin(); + for (; aSubIt != aSubs.end(); ++aSubIt, ++anAttrIt) + *anAttrIt = *aSubIt; - Slvs_Constraint aConstraint = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(), - getType(), myGroup->getWorkplaneId(), aValue, - aLine.point[0], aLine.point[1], SLVS_E_UNKNOWN, SLVS_E_UNKNOWN); - aConstraint.h = myStorage->addConstraint(aConstraint); - mySlvsConstraints.push_back(aConstraint.h); - adjustConstraint(); + myType = CONSTRAINT_PT_PT_DISTANCE; }