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