1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_Solver.h
4 // Created: 07 May 2014
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_Solver_H_
8 #define SketchSolver_Solver_H_
10 #include "SketchSolver.h"
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;
23 #define SLVS_RESULT_EMPTY_SET -1
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
34 #define SLVS_E_UNKNOWN 0
36 #define SLVS_G_UNKNOWN 0
39 * The main class that performs the high-level operations for connection to the SolveSpace.
41 class SketchSolver_Solver
44 SketchSolver_Solver();
45 ~SketchSolver_Solver();
47 /** \brief Initialize the ID of the group
49 inline void setGroupID(Slvs_hGroup theGroupID)
51 myGroupID = theGroupID;
54 /** \brief Change array of parameters
55 * \param[in] theParameters pointer to the array of parameters
56 * \param[in] theSize size of this array
58 void setParameters(Slvs_Param* theParameters, int theSize);
60 /** \brief Change array of entities
61 * \param[in] theEntities pointer to the array of entities
62 * \param[in] theSize size of this array
64 void setEntities(Slvs_Entity* theEntities, int theSize);
66 /** \brief Change array of constraints
67 * \param[in] theConstraints pointer to the array of constraints
68 * \param[in] theSize size of this array
70 void setConstraints(Slvs_Constraint* theConstraints, int theSize);
72 /** \brief Store the parameters of the point which was moved by user.
73 * The solver will watch this items to be constant
74 * \param[in] theDragged list of parameters (not more than 4) which should not be changed during solving
76 void setDraggedParameters(const Slvs_hParam* theDragged);
78 /** \brief Set or unset the flag which allows to find all failed constraints
80 void calculateFailedConstraints(bool theSic)
81 { myEquationsSystem.calculateFaileds = theSic ? 1 : 0; }
83 /** \brief Solve the set of equations
84 * \return identifier whether solution succeeded
88 /** \brief Updates the list of parameters by calculated values
89 * \param[in,out] theParameters parameters to be updated
90 * \return \c true if parameters are updated correctly
92 bool getResult(std::vector<Slvs_Param>& theParameters);
95 Slvs_hGroup myGroupID; ///< identifier of the group to be solved
96 Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace