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