- // Constraint for the given length of a line
- if (aConstraintKind.compare(SketchPlugin_ConstraintLength::ID()) == 0) {
- int aNbLines = 0;
- for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) {
- std::shared_ptr<ModelAPI_Attribute> anAttr =
- aConstrData->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr));
- if (typeOfAttribute(anAttr) == LINE)
- myAttributesList[aNbLines++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
- }
- if (aNbLines == 1)
- myType = SLVS_C_PT_PT_DISTANCE;
- return getType();
- }
+SketchSolver_ConstraintType SketchSolver_Constraint::TYPE(ConstraintPtr theConstraint)
+{
+ const std::string& aType = theConstraint->getKind();
+ if (aType == SketchPlugin_ConstraintCoincidence::ID())
+ return CONSTRAINT_COINCIDENCE;
+ else if (aType == SketchPlugin_ConstraintRigid::ID())
+ return CONSTRAINT_FIXED;
+ else if (aType == SketchPlugin_ConstraintHorizontal::ID())
+ return CONSTRAINT_HORIZONTAL;
+ else if (aType == SketchPlugin_ConstraintVertical::ID())
+ return CONSTRAINT_VERTICAL;
+ else if (aType == SketchPlugin_ConstraintAngle::ID())
+ return CONSTRAINT_ANGLE;
+ else if (aType == SketchPlugin_ConstraintDistance::ID())
+ return CONSTRAINT_DISTANCE;
+ else if (aType == SketchPlugin_ConstraintEqual::ID())
+ return CONSTRAINT_EQUAL;
+ else if (aType == SketchPlugin_ConstraintLength::ID())
+ return CONSTRAINT_PT_PT_DISTANCE;
+ else if (aType == SketchPlugin_ConstraintMirror::ID())
+ return CONSTRAINT_SYMMETRIC;
+ else if (aType == SketchPlugin_ConstraintParallel::ID())
+ return CONSTRAINT_PARALLEL;
+ else if (aType == SketchPlugin_ConstraintPerpendicular::ID())
+ return CONSTRAINT_PERPENDICULAR;
+ else if (aType == SketchPlugin_ConstraintRadius::ID())
+ return CONSTRAINT_RADIUS;
+ else if (aType == SketchPlugin_ConstraintTangent::ID())
+ return CONSTRAINT_TANGENT;
+ else if (aType == SketchPlugin_ConstraintCollinear::ID())
+ return CONSTRAINT_COLLINEAR;
+ else if (aType == SketchPlugin_ConstraintMiddle::ID())
+ return CONSTRAINT_MIDDLE_POINT;
+ return CONSTRAINT_UNKNOWN;
+}