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