]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchSolver/SketchSolver_ConstraintMultiTranslation.h
Salome HOME
Update behavior of calculation of Multi-Translation constraint
[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_Constraint.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_Constraint
18 {
19 public:
20   SketchSolver_ConstraintMultiTranslation(ConstraintPtr theConstraint) :
21       SketchSolver_Constraint(theConstraint),
22       myNumberOfObjects(0),
23       myNumberOfCopies(0),
24       myTranslationLine(SLVS_E_UNKNOWN)
25   {}
26
27   virtual int getType() const
28   { return SLVS_C_MULTI_TRANSLATION; }
29
30   /// \brief Update constraint
31   virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
32
33   /// \brief Tries to remove constraint
34   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
35   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
36
37   /// \brief Adds a feature to constraint and create its analogue in SolveSpace
38   virtual void addFeature(FeaturePtr theFeature);
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 translated entities
51   /// \param[out] theStartPoint ID of start point of translation
52   /// \param[out] theEndPoint   ID of final point of translation
53   /// \param[out] thePoints     list of IDs of initial points and their translated copies
54   /// \param[out] theEntities   list of IDs of entities and their translated copies
55   void getAttributes(Slvs_hEntity& theStartPoint, Slvs_hEntity& theEndPoint,
56                      std::vector< std::vector<Slvs_hEntity> >& thePoints,
57                      std::vector< std::vector<Slvs_hEntity> >& theEntities);
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 myTranslationLine; ///< ID of translation line
66   std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their translated copies
67   std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies;  ///< list of circles and their copies (to change their radii together)
68
69   std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user
70 };
71
72 #endif