Salome HOME
Add tools
[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   /// Constructor based on SketchPlugin constraint
22   SketchSolver_ConstraintCoincidence(ConstraintPtr theConstraint) :
23       SketchSolver_Constraint(theConstraint),
24       myType(SLVS_C_UNKNOWN)
25   {}
26
27   virtual int getType() const
28   { return myType; }
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 Checks the constraint is used by current object
35   virtual bool hasConstraint(ConstraintPtr theConstraint) const;
36
37   /// \brief Return list of SketchPlugin constraints attached to this object
38   virtual std::list<ConstraintPtr> constraints() const;
39
40   /// \brief Verifies the two Coincidence constraints are intersects (have shared point)
41   bool isCoincide(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint) const;
42
43   /// \brief Append all data of coincidence constaint to the current
44   void attach(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint);
45
46 protected:
47   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
48   virtual void process();
49
50   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
51   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
52   /// \param[out] theAttributes list of attributes to be filled
53   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes);
54
55 private:
56   /// \brief Creates new coincidence constraint
57   Slvs_hConstraint addConstraint(Slvs_hEntity thePoint1, Slvs_hEntity thePoint2);
58
59   /// \brief Create full SolveSpace structure according to given constraint
60   void addConstraint(ConstraintPtr theConstraint);
61
62   /// \brief Create constraint of point concident to the line or circle
63   Slvs_hConstraint addPointOnEntity(Slvs_hEntity thePoint, Slvs_hEntity theEntity);
64
65 private:
66   int myType; ///< type of constraint (applicable SLVS_C_POINTS_COINCIDENT or SLVS_C_PT_ON_LINE or SLVS_C_PT_ON_CIRCLE)
67   std::map<ConstraintPtr, Slvs_hConstraint> myExtraCoincidence; ///< multiple coincidence of points
68   std::set<AttributePtr> myCoincidentPoints; ///< list of points under the Coincidence constraint
69 };
70
71 #endif