Salome HOME
Merge remote-tracking branch 'origin/BR_REENTRANCE_OPERATION' into origin_Dev_1.5.0
[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   /// Constructor based on SketchPlugin constraint
21   SketchSolver_ConstraintMultiTranslation(ConstraintPtr theConstraint) :
22       SketchSolver_ConstraintMulti(theConstraint),
23       myTranslationLine(SLVS_E_UNKNOWN)
24   {}
25
26   virtual int getType() const
27   { return SLVS_C_MULTI_TRANSLATION; }
28
29 protected:
30   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
31   virtual void process();
32
33   /// \brief Generate list of translated entities
34   /// \param[out] theStartPoint ID of start point of translation
35   /// \param[out] theEndPoint   ID of final point of translation
36   /// \param[out] thePoints     list of IDs of initial points and their translated copies
37   /// \param[out] theEntities   list of IDs of entities and their translated copies
38   void getAttributes(Slvs_hEntity& theStartPoint, Slvs_hEntity& theEndPoint,
39                      std::vector< std::vector<Slvs_hEntity> >& thePoints,
40                      std::vector< std::vector<Slvs_hEntity> >& theEntities);
41
42   /// \brief This method is used in derived objects to check consistence of constraint.
43   virtual void adjustConstraint();
44
45   /// \brief Update parameters (called from base class)
46   virtual void updateLocal()
47   {}
48
49 private:
50   /// \brief Convert absolute coordinates to relative coordinates
51   virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY);
52   /// \brief Convert relative coordinates to absolute coordinates
53   virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY);
54   /// \brief Apply transformation for relative coordinates
55   virtual void transformRelative(double& theX, double& theY);
56
57 private:
58   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
59   virtual const std::string& nameNbObjects();
60
61 private:
62   Slvs_hEntity myTranslationLine; ///< ID of translation line
63
64   double myDelta[2]; ///< increment of translation
65 };
66
67 #endif