X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintLength.cpp;h=5c3bbc088637187d5ee63c0cd3d746e27c89196f;hb=a4de236e09b921bc33a28b6a6e0fc3208a86355b;hp=06d854d175ba7a4724bf8ef920249746be45ceea;hpb=f3574f89e45265d8c8cd0d322c8b3ba81bf60867;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintLength.cpp b/src/SketchSolver/SketchSolver_ConstraintLength.cpp index 06d854d17..5c3bbc088 100644 --- a/src/SketchSolver/SketchSolver_ConstraintLength.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintLength.cpp @@ -1,44 +1,26 @@ #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(); -} - -void SketchSolver_ConstraintLength::adjustConstraint() -{ - // No need to store the line, which length is constrained - // Upd: The line need to be stored to check that constraint - // is changed/unchanged during modifications in GUI - //myFeatureMap.clear(); + myType = CONSTRAINT_PT_PT_DISTANCE; }