Salome HOME
Merge branch 'Dev_1.1.1' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintCoincidence.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintCoincidence.h
4 // Created: 29 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintCoincidence_H_
8 #define SketchSolver_ConstraintCoincidence_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
12 #include <SketchSolver_Storage.h>
13
14 /** \class   SketchSolver_ConstraintCoincidence
15  *  \ingroup Plugins
16  *  \brief   Convert coincidence constraint to SolveSpace structure
17  */
18 class SketchSolver_ConstraintCoincidence : public SketchSolver_Constraint
19 {
20 public:
21   SketchSolver_ConstraintCoincidence(ConstraintPtr theConstraint) :
22       SketchSolver_Constraint(theConstraint),
23       myType(SLVS_C_UNKNOWN)
24   {}
25
26   virtual int getType() const
27   { return myType; }
28
29   /// \brief Tries to remove constraint
30   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
31   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
32
33   /// \brief Checks the constraint is used by current object
34   virtual bool hasConstraint(ConstraintPtr theConstraint) const;
35
36   /// \brief Return list of SketchPlugin constraints attached to this object
37   virtual std::list<ConstraintPtr> constraints() const;
38
39   /// \brief Verifies the two Coincidence constraints are intersects (have shared point)
40   bool isCoincide(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint) const;
41
42   /// \brief Append all data of coincidence constaint to the current
43   void attach(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint);
44
45 protected:
46   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
47   virtual void process();
48
49   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
50   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
51   /// \param[out] theAttributes list of attributes to be filled
52   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes);
53
54 private:
55   /// \brief Creates new coincidence constraint
56   Slvs_hConstraint addConstraint(Slvs_hEntity thePoint1, Slvs_hEntity thePoint2);
57
58   /// \brief Create full SolveSpace structure according to given constraint
59   void addConstraint(ConstraintPtr theConstraint);
60
61 private:
62   int myType; ///< type of constraint (applicable SLVS_C_POINTS_COINCIDENT or SLVS_C_PT_ON_LINE or SLVS_C_PT_ON_CIRCLE)
63   std::map<Slvs_hConstraint, ConstraintPtr> myExtraCoincidence; ///< multiple coincidence of points
64   std::set<AttributePtr> myCoincidentPoints; ///< list of points under the Coincidence constraint
65 };
66
67 #endif