- myType = SLVS_C_UNKNOWN;
- if (!theConstraint)
- return getType();
-
- // Assign empty names of attributes
- myAttributesList.clear();
- for (int i = 0; i < CONSTRAINT_ATTR_SIZE; i++)
- myAttributesList.push_back(std::string());
-
- const std::string& aConstraintKind = theConstraint->getKind();
- // Constraint for coincidence of two points
- if (aConstraintKind.compare(SketchPlugin_ConstraintCoincidence::ID()) == 0) {
- int anAttrPos = 0;
- // Verify the constraint has only two attributes and they are points
- int aPt2d = 0; // bit-mapped field, each bit indicates whether the attribute is 2D point
- int aPt3d = 0; // bit-mapped field, the same information for 3D points
- for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) {
- boost::shared_ptr<ModelAPI_Attribute> anAttr = theConstraint->data()->attribute(
- SketchPlugin_Constraint::ATTRIBUTE(indAttr));
- if (!anAttr)
- continue;
- switch (typeOfAttribute(anAttr)) {
- case POINT2D: // the attribute is a 2D point
- aPt2d |= (1 << indAttr);
- myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
- break;
- case POINT3D: // the attribute is a 3D point
- aPt3d |= (1 << indAttr);
- myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
- break;
- default:
- // Attribute neither 2D nor 3D point is not supported by this type of constraint
- return getType();
- }
- }
- // The constrained points should be in first and second positions,
- // so the expected value of aPt2d or aPt3d is 3
- if ((aPt2d == 3 && aPt3d == 0) || (aPt2d == 0 && aPt3d == 3))
- myType = SLVS_C_POINTS_COINCIDENT;
- // Constraint parameters are wrong
- return getType();