Salome HOME
Code optimization of multi-rotation and multi-translation in SketchSolver
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMultiTranslation.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintMultiTranslation.h
4 // Created: 1 Apr 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintMultiTranslation_H_
8 #define SketchSolver_ConstraintMultiTranslation_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_ConstraintMulti.h>
12
13 /** \class   SketchSolver_ConstraintMultiTranslation
14  *  \ingroup Plugins
15  *  \brief   Convert translated features to the list of SolveSpace constraints
16  */
17 class SketchSolver_ConstraintMultiTranslation : public SketchSolver_ConstraintMulti
18 {
19 public:
20   SketchSolver_ConstraintMultiTranslation(ConstraintPtr theConstraint) :
21       SketchSolver_ConstraintMulti(theConstraint),
22       myTranslationLine(SLVS_E_UNKNOWN)
23   {}
24
25   virtual int getType() const
26   { return SLVS_C_MULTI_TRANSLATION; }
27
28 protected:
29   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
30   virtual void process();
31
32   /// \brief Generate list of translated entities
33   /// \param[out] theStartPoint ID of start point of translation
34   /// \param[out] theEndPoint   ID of final point of translation
35   /// \param[out] thePoints     list of IDs of initial points and their translated copies
36   /// \param[out] theEntities   list of IDs of entities and their translated copies
37   void getAttributes(Slvs_hEntity& theStartPoint, Slvs_hEntity& theEndPoint,
38                      std::vector< std::vector<Slvs_hEntity> >& thePoints,
39                      std::vector< std::vector<Slvs_hEntity> >& theEntities);
40
41   /// \brief This method is used in derived objects to check consistence of constraint.
42   virtual void adjustConstraint();
43
44   /// \brief Update parameters (called from base class)
45   virtual void updateLocal()
46   {}
47
48 private:
49   /// \brief Convert absolute coordinates to relative coordinates
50   virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY);
51   /// \brief Convert relative coordinates to absolute coordinates
52   virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY);
53   /// \brief Apply transformation for relative coordinates
54   virtual void transformRelative(double& theX, double& theY);
55
56 private:
57   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
58   virtual const std::string& nameNbCopies();
59
60 private:
61   Slvs_hEntity myTranslationLine; ///< ID of translation line
62
63   double myDelta[2]; ///< increment of translation
64 };
65
66 #endif