- std::list<AttributePtr> anAttrList =
- theConstraint->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
- std::list<AttributePtr>::iterator anIter = anAttrList.begin();
- std::vector<Slvs_hEntity> aPoints;
- Slvs_hEntity anEntity = SLVS_E_UNKNOWN;
- int anEntType;
- for (; anIter != anAttrList.end(); anIter++) {
- Slvs_hEntity aPointID = SLVS_E_UNKNOWN;
- AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIter);
- if (!aRefAttr)
- continue;
-
- AttributePtr aPointAttr;
- if (aRefAttr->isObject()) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
- std::map<FeaturePtr, Slvs_hEntity>::const_iterator aFeatFound =
- myFeatureMap.find(aFeature);
- if (aFeatFound != myFeatureMap.end())
- anEntity = aFeatFound->second;
- else {
- anEntity = myGroup->getFeatureId(aFeature);
- if (anEntity == SLVS_E_UNKNOWN)
- anEntity = changeEntity(aFeature, anEntType);
- else {
- myFeatureMap[aFeature] = anEntity;
- // Obtain relations between attributes of the feature and SolveSpace entities
- std::list<AttributePtr> anAttrList =
- aFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
- std::list<AttributePtr>::iterator anIt = anAttrList.begin();
- for (; anIt != anAttrList.end(); ++anIt) {
- Slvs_hEntity anAttrID = myGroup->getAttributeId(*anIt);
- if (anAttrID != SLVS_E_UNKNOWN)
- myAttributeMap[*anIt] = anAttrID;
- }
- }
- }
- // If the feature is a point, add it to the list of coincident points
- if (aFeature->getKind() == SketchPlugin_Point::ID()) {
- aPointID = anEntity;
- anEntity = SLVS_E_UNKNOWN;
- aPointAttr = aFeature->attribute(SketchPlugin_Point::COORD_ID());
- }
- } else {
- aPointAttr = aRefAttr->attr();
- std::map<AttributePtr, Slvs_hEntity>::const_iterator anAttrFound =
- myAttributeMap.find(aPointAttr);
- if (anAttrFound != myAttributeMap.end())
- aPointID = anAttrFound->second;
- else {
- aPointID = myGroup->getAttributeId(aPointAttr);
- if (aPointID == SLVS_E_UNKNOWN)
- aPointID = changeEntity(aPointAttr, anEntType);
- }
- }
-
- if (aPointAttr) { // the point is found
- aPoints.push_back(aPointID);
- myCoincidentPoints.insert(aPointAttr);
- myAttributeMap[aPointAttr] = aPointID;
- }
- }
+ if (theAttributes[1])
+ myType = CONSTRAINT_PT_PT_COINCIDENT;
+ else if (theAttributes[2]) {
+ // check the type of entity (line or circle)
+ SketchSolver_EntityType anEntType = theAttributes[2]->type();
+ if (anEntType == ENTITY_LINE)
+ myType = CONSTRAINT_PT_ON_LINE;
+ else if (anEntType == ENTITY_CIRCLE || anEntType == ENTITY_ARC)
+ myType = CONSTRAINT_PT_ON_CIRCLE;
+ else
+ myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();