Salome HOME
Correct processing parameter given as a value of angle in Python script (issue #1899)
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintAngle.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #include <SketchSolver_ConstraintAngle.h>
4 #include <SketchSolver_Manager.h>
5
6 #include <GeomAPI_Dir2d.h>
7 #include <GeomAPI_Lin2d.h>
8 #include <GeomAPI_Pnt2d.h>
9 #include <GeomAPI_XY.h>
10
11 #include <ModelAPI_AttributeInteger.h>
12
13 #include <SketchPlugin_ConstraintAngle.h>
14
15 #include <cmath>
16
17 void SketchSolver_ConstraintAngle::getAttributes(
18     double& theValue, std::vector<EntityWrapperPtr>& theAttributes)
19 {
20   SketchSolver_Constraint::getAttributes(theValue, theAttributes);
21
22   myAngle = theValue;
23   myType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value();
24 }
25
26
27 void SketchSolver_ConstraintAngle::adjustConstraint()
28 {
29   static const double aTol = 1000. * tolerance;
30   BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
31
32   ConstraintWrapperPtr aConstraint = myStorage->constraint(myBaseConstraint).front();
33   //if (fabs(myAngle - aConstraint->value()) < aTol)
34   //  return;
35   myAngle = aConstraint->value();
36   aBuilder->adjustConstraint(aConstraint);
37   myStorage->addConstraint(myBaseConstraint, aConstraint);
38
39   int aType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value();
40   if (aType != myType) {
41     myType = aType;
42     myStorage->setNeedToResolve(true);
43   }
44 }