1 #include <SketchSolver_ConstraintCollinear.h>
2 #include <SketchSolver_Manager.h>
4 #include <SketchPlugin_Line.h>
6 SketchSolver_ConstraintCollinear::SketchSolver_ConstraintCollinear(ConstraintPtr theConstraint)
7 : SketchSolver_Constraint(theConstraint)
11 void SketchSolver_ConstraintCollinear::notifyCoincidenceChanged(
12 EntityWrapperPtr theCoincAttr1,
13 EntityWrapperPtr theCoincAttr2)
17 // obtain IDs of all boundary points of lines
18 EntityID aPointIDs[4];
19 for (int i = 0; i < 2; ++i) {
20 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
21 myBaseConstraint->attribute(SketchPlugin_Constraint::ATTRIBUTE(i)));
22 if (!aRefAttr->object())
24 FeaturePtr aLine = ModelAPI_Feature::feature(aRefAttr->object());
25 AttributePtr aLinePt = aLine->attribute(SketchPlugin_Line::START_ID());
26 aPointIDs[2*i] = myStorage->entity(aLinePt)->id();
27 aLinePt = aLine->attribute(SketchPlugin_Line::END_ID());
28 aPointIDs[2*i + 1] = myStorage->entity(aLinePt)->id();
31 EntityWrapperPtr anAttrs[2] = {theCoincAttr1, theCoincAttr2};
32 for (int i = 0; i < 2 && used; ++i) {
33 if (anAttrs[i]->baseAttribute())
34 used = used && isUsed(anAttrs[i]->baseAttribute());
36 used = used && isUsed(anAttrs[i]->baseFeature());
39 if (anAttrs[i]->type() == ENTITY_POINT) {
40 EntityID anID = anAttrs[i]->id();
41 for (int j = 0; j < 4; ++j)
42 if (anID == aPointIDs[j]) {