Salome HOME
Update Multi-Rotation tool to be used by solver
[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 /** \class   SketchSolver_ConstraintMultiRotation
14  *  \ingroup Plugins
15  *  \brief   Convert rotated features to the list of SolveSpace constraints
16  */
17 class SketchSolver_ConstraintMultiRotation : public SketchSolver_Constraint
18 {
19 public:
20   SketchSolver_ConstraintMultiRotation(ConstraintPtr theConstraint) :
21       SketchSolver_Constraint(theConstraint),
22       myNumberOfObjects(0),
23       myNumberOfCopies(0)
24   {}
25
26   virtual int getType() const
27   { return SLVS_C_MULTI_ROTATION; }
28
29   /// \brief Update constraint
30   virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
31
32   /// \brief Tries to remove constraint
33   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
34   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
35
36 protected:
37   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
38   virtual void process();
39
40   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
41   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
42   /// \param[out] theAttributes list of attributes to be filled
43   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
44   { /* do nothing here */ }
45
46   /// \brief Generate list of rotated entities
47   /// \param[out] theCenter   ID of central point of rotation
48   /// \param[out] theAngle    rotation angle
49   /// \param[out] thePoints   list of IDs of initial points and their rotated copies
50   /// \param[out] theCircular list of IDs of arcs and circles and their copies
51   void getAttributes(Slvs_hEntity& theCenter, double& theAngle,
52                      std::vector<std::vector<Slvs_hEntity> >& thePoints,
53                      std::vector<std::vector<Slvs_hEntity> >& theCircular);
54
55   /// \brief This method is used in derived objects to check consistence of constraint.
56   virtual void adjustConstraint();
57
58 private:
59   size_t myNumberOfObjects; ///< number of previous initial objects
60   size_t myNumberOfCopies;  ///< number of previous copies of initial objects
61   Slvs_hEntity myRotationCenter; ///< ID of center of rotation
62   double myAngle;           ///< angle of rotation
63 };
64
65 #endif