Salome HOME
SketchSolver library refactoring
[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 // Fillet constraint identifier
28 #define SLVS_C_FILLET 100100
29 // Unknown entity
30 #define SLVS_E_UNKNOWN 0
31 // Unknown group
32 #define SLVS_G_UNKNOWN 0
33
34 /**
35  * The main class that performs the high-level operations for connection to the SolveSpace.
36  */
37 class SketchSolver_Solver
38 {
39  public:
40   SketchSolver_Solver();
41   ~SketchSolver_Solver();
42
43   /** \brief Initialize the ID of the group
44    */
45   inline void setGroupID(Slvs_hGroup theGroupID)
46   {
47     myGroupID = theGroupID;
48   }
49
50   /** \brief Change array of parameters
51    *  \param[in] theParameters pointer to the array of parameters
52    *  \param[in] theSize       size of this array
53    */
54   void setParameters(Slvs_Param* theParameters, int theSize);
55
56   /** \brief Change array of entities
57    *  \param[in] theEntities pointer to the array of entities
58    *  \param[in] theSize     size of this array
59    */
60   void setEntities(Slvs_Entity* theEntities, int theSize);
61
62   /** \brief Change array of constraints
63    *  \param[in] theConstraints pointer to the array of constraints
64    *  \param[in] theSize        size of this array
65    */
66   void setConstraints(Slvs_Constraint* theConstraints, int theSize);
67
68   /** \brief Store the parameters of the point which was moved by user.
69    *         The solver will watch this items to be constant
70    *  \param[in] theDragged list of parameters (not more than 4) which should not be changed during solving
71    */
72   void setDraggedParameters(const Slvs_hParam* theDragged);
73
74   /** \brief Solve the set of equations
75    *  \return identifier whether solution succeeded
76    */
77   int solve();
78
79   /** \brief Updates the list of parameters by calculated values
80    *  \param[in,out] theParameters parameters to be updated
81    *  \return \c true if parameters are updated correctly
82    */
83   bool getResult(std::vector<Slvs_Param>& theParameters);
84
85  private:
86   Slvs_hGroup myGroupID;         ///< identifier of the group to be solved
87   Slvs_System myEquationsSystem;  ///< set of equations for solving in SolveSpace
88 };
89
90 #endif