1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef SolveSpaceSolver_Solver_H_
22 #define SolveSpaceSolver_Solver_H_
24 #include <SketchSolver_ISolver.h>
26 // Need to be defined before including SolveSpace to avoid additional
27 // dependences on Windows platform
28 #if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES)
29 typedef unsigned int UINT32;
38 // Unknown constraint (for error reporting)
39 #define SLVS_C_UNKNOWN 0
40 // Fillet constraint identifier
41 #define SLVS_C_FILLET 100100
42 // Multi-rotation constraint identifier
43 #define SLVS_C_MULTI_ROTATION 100101
44 // Multi-translation constraint identifier
45 #define SLVS_C_MULTI_TRANSLATION 100102
47 #define SLVS_E_UNKNOWN 0
49 #define SLVS_G_UNKNOWN 0
50 // Group ID to store external objects
51 #define SLVS_G_OUTOFGROUP 1
53 /** \class SolveSpaceSolver_Solver
55 * \brief Performs high-level operations to solve sketch in SolveSpace.
57 class SolveSpaceSolver_Solver : public SketchSolver_ISolver
60 SolveSpaceSolver_Solver();
61 virtual ~SolveSpaceSolver_Solver();
63 /** \brief Change array of parameters
64 * \param[in] theParameters pointer to the array of parameters
65 * \param[in] theSize size of this array
67 void setParameters(Slvs_Param* theParameters, int theSize);
69 /** \brief Change array of entities
70 * \param[in] theEntities pointer to the array of entities
71 * \param[in] theSize size of this array
73 void setEntities(Slvs_Entity* theEntities, int theSize);
75 /** \brief Change array of constraints
76 * \param[in] theConstraints pointer to the array of constraints
77 * \param[in] theSize size of this array
79 void setConstraints(Slvs_Constraint* theConstraints, int theSize);
81 /** \brief Store the parameters of the point which was moved by user.
82 * The solver will watch this items to be constant
83 * \param[in] theDragged list of parameters (not more than 4) which should not be changed during solving
85 void setDraggedParameters(const Slvs_hParam* theDragged);
87 /** \brief Solve the set of equations
88 * \return identifier whether solution succeeded
90 virtual SketchSolver_SolveStatus solve();
92 /// \brief Prepare for solving. Store initial values of parameters for undo
93 virtual void prepare();
95 /// \brief Revert solution to initial values
98 /// \brief Check the constraint is conflicted with others
99 virtual bool isConflicting(const ConstraintID& theConstraint) const;
101 /// \brief Degrees of freedom
102 virtual int dof() const;
105 /// \brief Check whether degenerated arcs exist
106 bool hasDegeneratedArcs() const;
109 Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace
110 Slvs_Param* myParamsCopy; ///< copy of parameters