X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintLength.cpp;h=be89bb53d3f2c31f7e36f8853827c91465fbff3f;hb=4f565b2204d3fba046aa8c851abada2a5a17bf6c;hp=bf519342b2a2de8f74f28683e25e6265a73ecf89;hpb=fd4dd622a85a0dd19ff5616391f94e980abc26a1;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintLength.cpp b/src/SketchSolver/SketchSolver_ConstraintLength.cpp index bf519342b..be89bb53d 100644 --- a/src/SketchSolver/SketchSolver_ConstraintLength.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintLength.cpp @@ -1,42 +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 - 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(); + SketchSolver_Constraint::getAttributes(theValue, theAttributes); + if (!myErrorMsg.empty() || !theAttributes[2] || + theAttributes[2]->type() != ENTITY_LINE) { + theAttributes.clear(); return; } - 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(); -} + // 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; -void SketchSolver_ConstraintLength::adjustConstraint() -{ - // No need to store the line, which length is constrained - myFeatureMap.clear(); + myType = CONSTRAINT_PT_PT_DISTANCE; }