Salome HOME
"Conflicting constraints" should appear when a center of fillet is coincident with...
[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 dependences 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 // Unknown constraint (for error reporting)
24 #define SLVS_C_UNKNOWN 0
25 // Fillet constraint identifier
26 #define SLVS_C_FILLET            100100
27 // Multi-rotation constraint identifier
28 #define SLVS_C_MULTI_ROTATION    100101
29 // Multi-translation constraint identifier
30 #define SLVS_C_MULTI_TRANSLATION 100102
31 // Unknown entity
32 #define SLVS_E_UNKNOWN 0
33 // Unknown group
34 #define SLVS_G_UNKNOWN 0
35 // Group ID to store external objects
36 #define SLVS_G_OUTOFGROUP 1
37
38 /** \class SolveSpaceSolver_Solver
39  *  \ingroup Plugins
40  *  \brief Performs high-level operations to solve sketch in SolveSpace.
41  */
42 class SolveSpaceSolver_Solver : public SketchSolver_ISolver
43 {
44 public:
45   SolveSpaceSolver_Solver();
46   virtual ~SolveSpaceSolver_Solver();
47
48   /** \brief Change array of parameters
49    *  \param[in] theParameters pointer to the array of parameters
50    *  \param[in] theSize       size of this array
51    */
52   void setParameters(Slvs_Param* theParameters, int theSize);
53
54   /** \brief Change array of entities
55    *  \param[in] theEntities pointer to the array of entities
56    *  \param[in] theSize     size of this array
57    */
58   void setEntities(Slvs_Entity* theEntities, int theSize);
59
60   /** \brief Change array of constraints
61    *  \param[in] theConstraints pointer to the array of constraints
62    *  \param[in] theSize        size of this array
63    */
64   void setConstraints(Slvs_Constraint* theConstraints, int theSize);
65
66   /** \brief Store the parameters of the point which was moved by user.
67    *         The solver will watch this items to be constant
68    *  \param[in] theDragged list of parameters (not more than 4) which should not be changed during solving
69    */
70   void setDraggedParameters(const Slvs_hParam* theDragged);
71
72   /** \brief Solve the set of equations
73    *  \return identifier whether solution succeeded
74    */
75   virtual SketchSolver_SolveStatus solve();
76
77   /// \brief Prepare for solving. Store initial values of parameters for undo
78   virtual void prepare();
79
80   /// \brief Revert solution to initial values
81   virtual void undo();
82
83 private:
84   /// \brief Check whether degenerated arcs exist
85   bool hasDegeneratedArcs() const;
86
87 private:
88   Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace
89   Slvs_Param* myParamsCopy;      ///< copy of parameters
90 };
91
92 #endif