X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintEqual.cpp;h=a6120533ecb1a46f21b0a1673071e8aa8b3a4410;hb=68a3f0934001109743353b6cc2ac42d8b92bd868;hp=e91ca2cf0f2a8d0f25db12649303f8e081ac013e;hpb=8f10db487ef409d859a62aa6e2235a17d9b56723;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintEqual.cpp b/src/SketchSolver/SketchSolver_ConstraintEqual.cpp index e91ca2cf0..a6120533e 100644 --- a/src/SketchSolver/SketchSolver_ConstraintEqual.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintEqual.cpp @@ -1,70 +1,54 @@ #include -#include #include - -void SketchSolver_ConstraintEqual::process() +void SketchSolver_ConstraintEqual::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[3]) { + 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 quantity of entities of each type int aNbLines = 0; int aNbArcs = 0; int aNbCircs = 0; bool isArcFirst = false; // in line-arc equivalence, the line should be first - std::vector::iterator anEntIter = anEntities.begin(); - for (; anEntIter != anEntities.end(); anEntIter++) { - Slvs_Entity anEnt = myStorage->getEntity(*anEntIter); - if (anEnt.type == SLVS_E_LINE_SEGMENT) - aNbLines++; - else if (anEnt.type == SLVS_E_CIRCLE) - aNbCircs++; - else if (anEnt.type == SLVS_E_ARC_OF_CIRCLE) { - aNbArcs++; + std::vector::iterator anAttrIt = theAttributes.begin() + 2; + for (; anAttrIt != theAttributes.end(); ++anAttrIt) { + SketchSolver_EntityType aType = (*anAttrIt)->type(); + if (aType == ENTITY_LINE) + ++aNbLines; + else if (aType == ENTITY_CIRCLE) + ++aNbCircs; + else if (aType == ENTITY_ARC) { + ++aNbArcs; isArcFirst = (aNbLines == 0); } } if (aNbLines + aNbArcs + aNbCircs != 2 || - (aNbLines == aNbCircs && aNbArcs == 0)) { + (aNbLines == aNbCircs && aNbArcs == 0)) { myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE(); return; } switch (aNbLines) { case 0: - myType = SLVS_C_EQUAL_RADIUS; + myType = CONSTRAINT_EQUAL_RADIUS; break; case 1: - myType = SLVS_C_EQUAL_LINE_ARC_LEN; + myType = CONSTRAINT_EQUAL_LINE_ARC; if (isArcFirst) { // change the order of arc and line - Slvs_hEntity aTmp = anEntities[2]; - anEntities[2] = anEntities[3]; - anEntities[3] = aTmp; + EntityWrapperPtr aTmp = theAttributes[2]; + theAttributes[2] = theAttributes[3]; + theAttributes[3] = aTmp; } break; default: - myType = SLVS_C_EQUAL_LENGTH_LINES; + myType = CONSTRAINT_EQUAL_LINES; break; } - - Slvs_Constraint aConstraint = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(), - getType(), myGroup->getWorkplaneId(), aValue, - anEntities[0], anEntities[1], anEntities[2], anEntities[3]); - aConstraint.h = myStorage->addConstraint(aConstraint); - mySlvsConstraints.push_back(aConstraint.h); - adjustConstraint(); } -