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