Salome HOME
0f1520590501e35cebffd417ea26ac3809a73bdf
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMultiRotation.h
1 // Copyright (C) 2014-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SketchSolver_ConstraintMultiRotation_H_
21 #define SketchSolver_ConstraintMultiRotation_H_
22
23 #include <SketchSolver_ConstraintMulti.h>
24
25 #include "GeomDataAPI_Point2D.h"
26
27 /** \class   SketchSolver_ConstraintMultiRotation
28  *  \ingroup Plugins
29  *  \brief   Convert rotated features to the list of SolveSpace constraints
30  */
31 class SketchSolver_ConstraintMultiRotation : public SketchSolver_ConstraintMulti
32 {
33 public:
34   /// Constructor based on SketchPlugin constraint
35   SketchSolver_ConstraintMultiRotation(ConstraintPtr theConstraint) :
36       SketchSolver_ConstraintMulti(theConstraint)
37   {}
38
39 protected:
40   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
41   virtual void process();
42
43   /// \brief Generate list of rotated entities
44   /// \param[out] theCenter    central point of rotation
45   /// \param[out] theAngle     rotation angle
46   /// \param[out] theFullValue applying translation using the distance as a full or single value
47   /// \param[out] theReversed  rotation angle is negative
48   /// \param[out] theEntities  list of base entities
49   void getAttributes(EntityWrapperPtr&            theCenter,
50                      ScalarWrapperPtr&            theAngle,
51                      bool&                        theFullValue,
52                      bool&                        theReversed,
53                      std::list<EntityWrapperPtr>& theEntities);
54
55   /// \brief This method is used in derived objects to check consistence of constraint.
56   virtual void adjustConstraint();
57
58   /// \brief Update parameters (called from base class)
59   virtual void updateLocal();
60
61 private:
62   /// \brief Convert absolute coordinates to relative coordinates
63   virtual void getRelative(double theAbsX, double theAbsY,
64                            double& theRelX, double& theRelY);
65   /// \brief Convert relative coordinates to absolute coordinates
66   virtual void getAbsolute(double theRelX, double theRelY,
67                            double& theAbsX, double& theAbsY);
68   /// \brief Apply transformation for relative coordinates
69   virtual void transformRelative(double& theX, double& theY);
70
71   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
72   virtual const std::string& nameNbObjects();
73
74 private:
75   AttributePoint2DPtr myCenterPointAttribute; ///< a center of rotation
76   ScalarWrapperPtr    myAngle;                ///< angle of rotation
77   bool myIsRevered; ///< angle of rotation is negative
78
79   double myCenterCoord[2]; ///< coordinates of rotation center
80   double myRotationVal[2]; ///< sinus and cosine of rotation angle
81 };
82
83 #endif