Salome HOME
Remove extra files
[modules/shaper.git] / src / SketchSolver / SolveSpaceSolver / SolveSpaceSolver_Solver.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SolveSpaceSolver_Solver.h
4 // Created: 07 May 2014
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SolveSpaceSolver_Solver_H_
8 #define SolveSpaceSolver_Solver_H_
9
10 #include <SketchSolver_ISolver.h>
11
12 // Need to be defined before including SolveSpace to avoid additional 
13 // dependences on Windows platform
14 #if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES)
15 typedef unsigned int UINT32;
16 #else
17 #include <stdint.h>
18 #endif
19 #include <string.h>
20 #include <slvs.h>
21
22 #include <vector>
23
24 // Unknown constraint (for error reporting)
25 #define SLVS_C_UNKNOWN 0
26 // Fillet constraint identifier
27 #define SLVS_C_FILLET            100100
28 // Multi-rotation constraint identifier
29 #define SLVS_C_MULTI_ROTATION    100101
30 // Multi-translation constraint identifier
31 #define SLVS_C_MULTI_TRANSLATION 100102
32 // Unknown entity
33 #define SLVS_E_UNKNOWN 0
34 // Unknown group
35 #define SLVS_G_UNKNOWN 0
36 // Group ID to store external objects
37 #define SLVS_G_OUTOFGROUP 1
38
39 /** \class SolveSpaceSolver_Solver
40  *  \ingroup Plugins
41  *  \brief Performs high-level operations to solve sketch in SolveSpace.
42  */
43 class SolveSpaceSolver_Solver : public SketchSolver_ISolver
44 {
45 public:
46   SolveSpaceSolver_Solver();
47   virtual ~SolveSpaceSolver_Solver();
48
49   /** \brief Change array of parameters
50    *  \param[in] theParameters pointer to the array of parameters
51    *  \param[in] theSize       size of this array
52    */
53   void setParameters(Slvs_Param* theParameters, int theSize);
54
55   /** \brief Change array of entities
56    *  \param[in] theEntities pointer to the array of entities
57    *  \param[in] theSize     size of this array
58    */
59   void setEntities(Slvs_Entity* theEntities, int theSize);
60
61   /** \brief Change array of constraints
62    *  \param[in] theConstraints pointer to the array of constraints
63    *  \param[in] theSize        size of this array
64    */
65   void setConstraints(Slvs_Constraint* theConstraints, int theSize);
66
67   /** \brief Store the parameters of the point which was moved by user.
68    *         The solver will watch this items to be constant
69    *  \param[in] theDragged list of parameters (not more than 4) which should not be changed during solving
70    */
71   void setDraggedParameters(const Slvs_hParam* theDragged);
72
73   /** \brief Solve the set of equations
74    *  \return identifier whether solution succeeded
75    */
76   virtual SketchSolver_SolveStatus solve();
77
78   /// \brief Prepare for solving. Store initial values of parameters for undo
79   virtual void prepare();
80
81   /// \brief Revert solution to initial values
82   virtual void undo();
83
84   /// \brief Check the constraint is conflicted with others
85   virtual bool isConflicting(const ConstraintID& theConstraint) const;
86
87   /// \brief Degrees of freedom
88   virtual int dof() const;
89
90 private:
91   /// \brief Check whether degenerated arcs exist
92   bool hasDegeneratedArcs() const;
93
94 private:
95   Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace
96   Slvs_Param* myParamsCopy;      ///< copy of parameters
97 };
98
99 #endif