1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include <SketchSolver_ConstraintCollinear.h>
4 #include <SketchSolver_Manager.h>
6 #include <SketchPlugin_Line.h>
8 SketchSolver_ConstraintCollinear::SketchSolver_ConstraintCollinear(ConstraintPtr theConstraint)
9 : SketchSolver_Constraint(theConstraint)
13 void SketchSolver_ConstraintCollinear::notifyCoincidenceChanged(
14 EntityWrapperPtr theCoincAttr1,
15 EntityWrapperPtr theCoincAttr2)
19 // obtain IDs of all boundary points of lines
20 EntityID aPointIDs[4];
21 for (int i = 0; i < 2; ++i) {
22 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
23 myBaseConstraint->attribute(SketchPlugin_Constraint::ATTRIBUTE(i)));
24 if (!aRefAttr->object())
26 FeaturePtr aLine = ModelAPI_Feature::feature(aRefAttr->object());
27 AttributePtr aLinePt = aLine->attribute(SketchPlugin_Line::START_ID());
28 aPointIDs[2*i] = myStorage->entity(aLinePt)->id();
29 aLinePt = aLine->attribute(SketchPlugin_Line::END_ID());
30 aPointIDs[2*i + 1] = myStorage->entity(aLinePt)->id();
33 EntityWrapperPtr anAttrs[2] = {theCoincAttr1, theCoincAttr2};
34 for (int i = 0; i < 2 && used; ++i) {
35 if (anAttrs[i]->baseAttribute())
36 used = used && isUsed(anAttrs[i]->baseAttribute());
38 used = used && isUsed(anAttrs[i]->baseFeature());
41 if (anAttrs[i]->type() == ENTITY_POINT) {
42 EntityID anID = anAttrs[i]->id();
43 for (int j = 0; j < 4; ++j)
44 if (anID == aPointIDs[j]) {