Salome HOME
Issue #332: Find point by coordinates comparison instead selection
[modules/shaper.git] / src / SketchSolver / SketchSolver_Solver.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_Solver.h
4 // Created: 07 May 2014
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_Solver_H_
8 #define SketchSolver_Solver_H_
9
10 #include "SketchSolver.h"
11
12 // Need to be defined before including SolveSpace to avoid additional dependances on Windows platform
13 #if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES)
14 typedef unsigned int UINT32;
15 #else
16 #include <stdint.h>
17 #endif
18 #include <string.h>
19 #include <slvs.h>
20
21 #include <vector>
22
23 #define SLVS_RESULT_EMPTY_SET -1
24
25 // Unknown constraint (for error reporting)
26 #define SLVS_C_UNKNOWN 0
27 // Unknown entity
28 #define SLVS_E_UNKNOWN 0
29
30 class SketchSolver_Solver
31 {
32  public:
33   SketchSolver_Solver();
34   ~SketchSolver_Solver();
35
36   /** \brief Initialize the ID of the group
37    */
38   inline void setGroupID(Slvs_hGroup theGroupID)
39   {
40     myGroupID = theGroupID;
41   }
42
43   /** \brief Change array of parameters
44    *  \param[in] theParameters vector of parameters
45    */
46   void setParameters(const std::vector<Slvs_Param>& theParameters);
47
48   /** \brief Change array of entities
49    *  \param[in] theEntities vector of entities
50    */
51   void setEntities(const std::vector<Slvs_Entity>& theEntities);
52
53   /** \brief Change array of constraints
54    *  \param[in] theConstraints vector of constraints
55    */
56   void setConstraints(const std::vector<Slvs_Constraint>& theConstraints);
57
58   /** \brief Store the parameters of the point which was moved by user.
59    *         The solver will watch this items to be constant
60    *  \param[in] theDragged list of parameters (not more than 4) which should not be changed during solving
61    */
62   void setDraggedParameters(const std::vector<Slvs_hParam>& theDragged);
63
64   /** \brief Solve the set of equations
65    *  \return identifier whether solution succeeded
66    */
67   int solve();
68
69   /** \brief Updates the list of parameters by calculated values
70    *  \param[in,out] theParameters parameters to be updated
71    *  \return \c true if parameters are updated correctly
72    */
73   bool getResult(std::vector<Slvs_Param>& theParameters);
74
75  private:
76   Slvs_hGroup myGroupID;         ///< identifier of the group to be solved
77   Slvs_System myEquationsSystem;  ///< set of equations for solving in SolveSpace
78 };
79
80 #endif