Salome HOME
be89bb53d3f2c31f7e36f8853827c91465fbff3f
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintLength.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #include <SketchSolver_ConstraintLength.h>
4 #include <SketchSolver_Error.h>
5
6
7 void SketchSolver_ConstraintLength::getAttributes(
8     double& theValue,
9     std::vector<EntityWrapperPtr>& theAttributes)
10 {
11   SketchSolver_Constraint::getAttributes(theValue, theAttributes);
12   if (!myErrorMsg.empty() || !theAttributes[2] ||
13       theAttributes[2]->type() != ENTITY_LINE) {
14     theAttributes.clear();
15     return;
16   }
17
18   // Get boundary points of line segment and create point-point distance constraint
19   std::list<EntityWrapperPtr> aSubs = theAttributes[2]->subEntities();
20   theAttributes.assign(theAttributes.size(), EntityWrapperPtr());
21   std::vector<EntityWrapperPtr>::iterator anAttrIt = theAttributes.begin();
22   std::list<EntityWrapperPtr>::const_iterator aSubIt = aSubs.begin();
23   for (; aSubIt != aSubs.end(); ++aSubIt, ++anAttrIt)
24     *anAttrIt = *aSubIt;
25
26   myType = CONSTRAINT_PT_PT_DISTANCE;
27 }
28