1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SolveSpaceSolver_Solver_H_
21 #define SolveSpaceSolver_Solver_H_
23 #include <SketchSolver_ISolver.h>
25 // Need to be defined before including SolveSpace to avoid additional
26 // dependences on Windows platform
27 #if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES)
28 typedef unsigned int UINT32;
37 // Unknown constraint (for error reporting)
38 #define SLVS_C_UNKNOWN 0
39 // Fillet constraint identifier
40 #define SLVS_C_FILLET 100100
41 // Multi-rotation constraint identifier
42 #define SLVS_C_MULTI_ROTATION 100101
43 // Multi-translation constraint identifier
44 #define SLVS_C_MULTI_TRANSLATION 100102
46 #define SLVS_E_UNKNOWN 0
48 #define SLVS_G_UNKNOWN 0
49 // Group ID to store external objects
50 #define SLVS_G_OUTOFGROUP 1
52 /** \class SolveSpaceSolver_Solver
54 * \brief Performs high-level operations to solve sketch in SolveSpace.
56 class SolveSpaceSolver_Solver : public SketchSolver_ISolver
59 SolveSpaceSolver_Solver();
60 virtual ~SolveSpaceSolver_Solver();
62 /** \brief Change array of parameters
63 * \param[in] theParameters pointer to the array of parameters
64 * \param[in] theSize size of this array
66 void setParameters(Slvs_Param* theParameters, int theSize);
68 /** \brief Change array of entities
69 * \param[in] theEntities pointer to the array of entities
70 * \param[in] theSize size of this array
72 void setEntities(Slvs_Entity* theEntities, int theSize);
74 /** \brief Change array of constraints
75 * \param[in] theConstraints pointer to the array of constraints
76 * \param[in] theSize size of this array
78 void setConstraints(Slvs_Constraint* theConstraints, int theSize);
80 /** \brief Store the parameters of the point which was moved by user.
81 * The solver will watch this items to be constant
82 * \param[in] theDragged list of parameters (not more than 4) which should not be changed during solving
84 void setDraggedParameters(const Slvs_hParam* theDragged);
86 /** \brief Solve the set of equations
87 * \return identifier whether solution succeeded
89 virtual SketchSolver_SolveStatus solve();
91 /// \brief Prepare for solving. Store initial values of parameters for undo
92 virtual void prepare();
94 /// \brief Revert solution to initial values
97 /// \brief Check the constraint is conflicted with others
98 virtual bool isConflicting(const ConstraintID& theConstraint) const;
100 /// \brief Degrees of freedom
101 virtual int dof() const;
104 /// \brief Check whether degenerated arcs exist
105 bool hasDegeneratedArcs() const;
108 Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace
109 Slvs_Param* myParamsCopy; ///< copy of parameters