Salome HOME
Update coincidence constraints
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMultiRotation.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintMultiRotation.h
4 // Created: 1 Apr 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintMultiRotation_H_
8 #define SketchSolver_ConstraintMultiRotation_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
12
13 #include <vector>
14
15 /** \class   SketchSolver_ConstraintMultiRotation
16  *  \ingroup Plugins
17  *  \brief   Convert rotated features to the list of SolveSpace constraints
18  */
19 class SketchSolver_ConstraintMultiRotation : public SketchSolver_Constraint
20 {
21 public:
22   SketchSolver_ConstraintMultiRotation(ConstraintPtr theConstraint) :
23       SketchSolver_Constraint(theConstraint),
24       myNumberOfObjects(0),
25       myNumberOfCopies(0)
26   {}
27
28   virtual int getType() const
29   { return SLVS_C_MULTI_ROTATION; }
30
31   /// \brief Update constraint
32   virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
33
34   /// \brief Tries to remove constraint
35   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
36   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
37
38   /// \brief Adds a feature to constraint and create its analogue in SolveSpace
39   virtual void addFeature(FeaturePtr theFeature);
40
41 protected:
42   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
43   virtual void process();
44
45   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
46   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
47   /// \param[out] theAttributes list of attributes to be filled
48   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
49   { /* do nothing here */ }
50
51   /// \brief Generate list of rotated entities
52   /// \param[out] theCenter   ID of central point of rotation
53   /// \param[out] theAngle    rotation angle
54   /// \param[out] thePoints   list of IDs of initial points and their rotated copies
55   /// \param[out] theEntities list of IDs of entities and their rotated copies
56   void getAttributes(Slvs_hEntity& theCenter, double& theAngle,
57                      std::vector< std::vector<Slvs_hEntity> >& thePoints,
58                      std::vector< std::vector<Slvs_hEntity> >& theEntities);
59
60   /// \brief This method is used in derived objects to check consistence of constraint.
61   virtual void adjustConstraint();
62
63 private:
64   size_t myNumberOfObjects; ///< number of previous initial objects
65   size_t myNumberOfCopies;  ///< number of previous copies of initial objects
66   Slvs_hEntity myRotationCenter; ///< ID of center of rotation
67   double myAngle;           ///< angle of rotation
68   std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their rotated copies
69   std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies;  ///< list of circles and their copies (to change their radii together)
70
71   std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user
72   std::set<Slvs_hEntity> myInitialPoints;     ///< list of points containig initial objects
73 };
74
75 #endif