Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.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   {}
24
25   virtual int getType() const
26   { return SLVS_C_POINTS_COINCIDENT; }
27
28   /// \brief Tries to remove constraint
29   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
30   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
31
32   /// \brief Checks the constraint is used by current object
33   virtual bool hasConstraint(ConstraintPtr theConstraint) const;
34
35   /// \brief Return list of SketchPlugin constraints attached to this object
36   virtual std::list<ConstraintPtr> constraints() const;
37
38   /// \brief Verifies the two Coincidence constraints are intersects (have shared point)
39   bool isCoincide(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint) const;
40
41   /// \brief Append all data of coincidence constaint to the current
42   void attach(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint);
43
44 private:
45   /// \brief Creates new coincidence constraint
46   Slvs_hConstraint addConstraint(Slvs_hEntity thePoint1, Slvs_hEntity thePoint2);
47
48   /// \brief Create full SolveSpace structure according to given constraint
49   void addConstraint(ConstraintPtr theConstraint);
50
51 private:
52   std::map<Slvs_hConstraint, ConstraintPtr> myExtraCoincidence; ///< multiple coincidence of points
53   std::set<AttributePtr> myCoincidentPoints; ///< list of points under the Coincidence constraint
54 };
55
56 #endif