Salome HOME
1fcb896e1b6d2d568fe078d8403aa1fc0c43be11
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintRigid.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintRigid.h
4 // Created: 30 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintRigid_H_
8 #define SketchSolver_ConstraintRigid_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
12
13 /** \class   SketchSolver_ConstraintRigid
14  *  \ingroup Plugins
15  *  \brief   Stores data of Rigid (Fixed) constraint
16  *
17  *  Rigid constraint may have NULL basic SketchPlugin constraint,
18  *  because the Rigid constraint may be temporary for correct moving of objects
19  */
20 class SketchSolver_ConstraintRigid : public SketchSolver_Constraint
21 {
22 public:
23   /// Creates constraint to manage the given constraint from plugin
24   SketchSolver_ConstraintRigid(ConstraintPtr theConstraint)
25     : SketchSolver_Constraint(theConstraint)
26   {}
27   /// Creates temporary constraint based on feature
28   SketchSolver_ConstraintRigid(FeaturePtr theFeature);
29
30   /// \brief Tries to remove constraint
31   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
32   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
33
34   /// \brief Returns the type of constraint
35   virtual int getType() const
36   { return SLVS_C_WHERE_DRAGGED; }
37
38 protected:
39   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
40   virtual void process();
41
42   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
43   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
44   /// \param[out] theAttributes list of attributes to be filled
45   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes);
46
47   /// \brief This method is used in derived objects to check consistence of constraint.
48   ///        E.g. the distance between line and point may be signed.
49   virtual void adjustConstraint();
50
51 private:
52   /// \brief Fixing line position (start and end points)
53   void fixLine(const Slvs_Entity& theLine);
54   /// \brief Fixing circle (center and radius)
55   void fixCircle(const Slvs_Entity& theCircle);
56   /// \brief The arc is fixed differently to avoid SolveSpace problems (overconstraint)
57   ///
58   /// There will be fixed start and end points and the radius of the arc.
59   void fixArc(const Slvs_Entity& theArc);
60
61   /// \brief Fix given point
62   void fixPoint(const Slvs_hEntity& thePointID);
63
64   /// \brief Verifies the entity is used in any equal constraint
65   /// \param[in]  theEntity entity to be found
66   /// \param[out] theEqual  constraint, which uses the entity
67   /// \return \c true, if the Equal constrait is found
68   bool isUsedInEqual(const Slvs_Entity& theEntity, Slvs_Constraint& theEqual) const;
69
70   /// \brief Check the entity is horizontal of vertical
71   bool isAxisParallel(const Slvs_Entity& theEntity) const;
72
73 protected:
74   FeaturePtr myBaseFeature; ///< fixed feature (when it is set, myBaseConstraint should be NULL)
75 };
76
77 #endif