Salome HOME
The crash was fixed in SketchSolver on undo/redo operations
[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_Headerfile
6 #define SketchSolver_Solver_Headerfile
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
25 class SketchSolver_Solver
26 {
27 public:
28   SketchSolver_Solver();
29   ~SketchSolver_Solver();
30
31   /** \brief Initialize the ID of the group
32    */
33   inline void setGroupID(Slvs_hGroup theGroupID)
34   { myGroupID = theGroupID; }
35
36   /** \brief Change array of parameters
37    *  \param[in] theParameters vector of parameters
38    */
39   void setParameters(const std::vector<Slvs_Param>& theParameters);
40
41   /** \brief Change array of entities
42    *  \param[in] theEntities vector of entities
43    */
44   void setEntities(const std::vector<Slvs_Entity>& theEntities);
45
46   /** \brief Change array of constraints
47    *  \param[in] theConstraints vector of constraints
48    */
49   void setConstraints(const std::vector<Slvs_Constraint>& theConstraints);
50
51   /** \brief Solve the set of equations
52    *  \return identifier whether solution succeeded
53    */
54   int solve();
55
56   /** \brief Updates the list of parameters by calculated values
57    *  \param[in,out] theParameters parameters to be updated
58    *  \return \c true if parameters are updated correctly
59    */
60   bool getResult(std::vector<Slvs_Param>& theParameters);
61
62 private:
63   Slvs_hGroup myGroupID;         ///< identifier of the group to be solved
64   Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace
65 };
66
67 #endif