1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include <SketchSolver_ConstraintCoincidence.h>
4 #include <SketchSolver_Error.h>
5 #include <SketchSolver_Manager.h>
7 void SketchSolver_ConstraintCoincidence::getAttributes(
9 std::vector<EntityWrapperPtr>& theAttributes)
11 SketchSolver_Constraint::getAttributes(theValue, theAttributes);
12 if (!myErrorMsg.empty() || !theAttributes[0]) {
13 theAttributes.clear();
17 if (theAttributes[1]) {
18 myType = CONSTRAINT_PT_PT_COINCIDENT;
19 if (myStorage->isFixed(theAttributes[1]) && !myStorage->isFixed(theAttributes[0])) {
20 // fixed point should go first
21 EntityWrapperPtr aTemp = theAttributes[0];
22 theAttributes[0] = theAttributes[1];
23 theAttributes[1] = aTemp;
25 // Set the slave (second) point the same as master (first) point.
26 // This will allow to skip adding point-point coincidence to the set of constraints
27 // and give us speed-up in solving the set of equations
28 myStorage->addCoincidentPoints(theAttributes[0], theAttributes[1]);
30 else if (theAttributes[2]) {
31 // check the type of entity (line or circle)
32 SketchSolver_EntityType anEntType = theAttributes[2]->type();
33 if (anEntType == ENTITY_LINE)
34 myType = CONSTRAINT_PT_ON_LINE;
35 else if (anEntType == ENTITY_CIRCLE || anEntType == ENTITY_ARC)
36 myType = CONSTRAINT_PT_ON_CIRCLE;
38 myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
40 myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();