Salome HOME
80a6fb5e359fa266affa436fe6f676d8092a5971
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintDistance.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintDistance.h
4 // Created: 31 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintDistance_H_
8 #define SketchSolver_ConstraintDistance_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
12
13 /** \class   SketchSolver_ConstraintDistance
14  *  \ingroup Plugins
15  *  \brief   Convert distance constraint to SolveSpace structure
16  */
17 class SketchSolver_ConstraintDistance : public SketchSolver_Constraint
18 {
19 public:
20   /// Constructor based on SketchPlugin constraint
21   SketchSolver_ConstraintDistance(ConstraintPtr theConstraint) :
22       SketchSolver_Constraint(theConstraint),
23       myIsNegative(false)
24   {}
25
26   /// \brief Update constraint
27   virtual void update();
28
29 protected:
30   /// \brief Generate list of attributes of constraint in order useful for constraints
31   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
32   /// \param[out] theAttributes list of attributes to be filled
33   virtual void getAttributes(double& theValue, std::vector<EntityWrapperPtr>& theAttributes);
34
35   /// \brief This method is used in derived objects to check consistence of constraint.
36   ///        E.g. the distance between line and point may be signed.
37   virtual void adjustConstraint();
38
39 private:
40   double myPrevValue; ///< previous value of distance (for correct calculation of a distance sign)
41
42   /// \c true, if the point if placed rightside of line direction (SLVS_C_PT_LINE_DISTANCE only)
43   bool myIsNegative;
44 };
45
46 #endif