1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include <SketchSolver_ConstraintEqual.h>
4 #include <SketchSolver_Error.h>
6 void SketchSolver_ConstraintEqual::getAttributes(
8 std::vector<EntityWrapperPtr>& theAttributes)
10 SketchSolver_Constraint::getAttributes(theValue, theAttributes);
11 if (!myErrorMsg.empty() || !theAttributes[2] || !theAttributes[3]) {
12 theAttributes.clear();
16 // Check the quantity of entities of each type
20 bool isArcFirst = false; // in line-arc equivalence, the line should be first
21 std::vector<EntityWrapperPtr>::iterator anAttrIt = theAttributes.begin() + 2;
22 for (; anAttrIt != theAttributes.end(); ++anAttrIt) {
23 SketchSolver_EntityType aType = (*anAttrIt)->type();
24 if (aType == ENTITY_LINE)
26 else if (aType == ENTITY_CIRCLE)
28 else if (aType == ENTITY_ARC) {
30 isArcFirst = (aNbLines == 0);
34 if (aNbLines + aNbArcs + aNbCircs != 2 ||
35 (aNbLines == aNbCircs && aNbArcs == 0)) {
36 myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
42 myType = CONSTRAINT_EQUAL_RADIUS;
45 myType = CONSTRAINT_EQUAL_LINE_ARC;
46 if (isArcFirst) { // change the order of arc and line
47 EntityWrapperPtr aTmp = theAttributes[2];
48 theAttributes[2] = theAttributes[3];
49 theAttributes[3] = aTmp;
53 myType = CONSTRAINT_EQUAL_LINES;