]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchSolver/SketchSolver_ConstraintMulti.h
Salome HOME
Code optimization of multi-rotation and multi-translation in SketchSolver
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMulti.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintMulti.h
4 // Created: 2 Sep 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintMulti_H_
8 #define SketchSolver_ConstraintMulti_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
12
13 #include <vector>
14
15 /** \class   SketchSolver_ConstraintMulti
16  *  \ingroup Plugins
17  *  \brief   Common base class for the Multi constraints
18  */
19 class SketchSolver_ConstraintMulti : public SketchSolver_Constraint
20 {
21 public:
22   SketchSolver_ConstraintMulti(ConstraintPtr theConstraint) :
23       SketchSolver_Constraint(theConstraint),
24       myNumberOfObjects(0),
25       myNumberOfCopies(0)
26   {}
27
28   virtual int getType() const
29   { return SLVS_C_UNKNOWN; }
30
31   /// \brief Update constraint
32   virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
33
34   /// \brief Tries to remove constraint
35   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
36   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
37
38   /// \brief Adds a feature to constraint and create its analogue in SolveSpace
39   virtual void addFeature(FeaturePtr theFeature);
40
41 protected:
42   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
43   virtual void process()
44   { /* do nothing here */ }
45
46   /// \brief Collect entities and their copies, like circles and arcs
47   void processEntities(const std::vector< std::vector<Slvs_hEntity> >& theEntAndCopies);
48
49   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
50   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
51   /// \param[out] theAttributes list of attributes to be filled
52   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
53   { /* do nothing here */ }
54
55   /// \brief This method is used in derived objects to check consistence of constraint.
56   virtual void adjustConstraint();
57
58   /// \brief Update parameters of derived classes
59   virtual void updateLocal() = 0;
60
61   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
62   virtual const std::string& nameNbCopies() = 0;
63
64 protected:
65   /// \brief Convert absolute coordinates to relative coordinates
66   virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
67   /// \brief Convert relative coordinates to absolute coordinates
68   virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
69   /// \brief Apply transformation for relative coordinates
70   virtual void transformRelative(double& theX, double& theY) = 0;
71
72 protected:
73   size_t myNumberOfObjects; ///< number of previous initial objects
74   size_t myNumberOfCopies;  ///< number of previous copies of initial objects
75
76   std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their copies
77   std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies;  ///< list of circles and their copies (to change their radii together)
78
79   std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user
80   std::set<Slvs_hEntity> myInitialPoints;     ///< list of points containing initial objects
81 };
82
83 #endif