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 PlaneGCSSolver_Solver_H_
22 #define PlaneGCSSolver_Solver_H_
24 #include <PlaneGCSSolver_Defs.h>
25 #include <PlaneGCSSolver_ConstraintWrapper.h>
29 /// \brief The main class that performs the high-level operations for connection to the PlaneGCS.
30 class PlaneGCSSolver_Solver
33 /// The result of constraints solution
38 STATUS_FAILED, // set if no one other status is applicable
39 STATUS_UNKNOWN // set for newly created groups
42 PlaneGCSSolver_Solver();
43 ~PlaneGCSSolver_Solver();
45 /// \brief Clear system of equations
48 /// \brief Add constraint to the system of equations
49 void addConstraint(GCSConstraintPtr theConstraint);
51 /// \brief Remove constraint from the system of equations
52 void removeConstraint(ConstraintID theID);
54 /// \brief Initialize memory for new solver's parameter
55 double* createParameter();
56 /// \brief Add parameters created elsewhere
57 void addParameters(const GCS::SET_pD& theParams);
58 /// \brief Release memory occupied by parameters
59 void removeParameters(const GCS::SET_pD& theParams);
61 /// \brief Preliminary initialization of solver (useful for moving a feature).
62 /// When called, the solve() method does not reinitialize a set of constraints.
65 /// \brief Solve the set of equations
66 /// \return identifier whether solution succeeded
69 /// \brief Revert solution to initial values
72 /// \brief Check the constraint is conflicted with others
73 bool isConflicting(const ConstraintID& theConstraint) const;
75 /// \brief Check conflicting/redundant constraints and DoF
78 /// \brief Degrees of freedom
82 void collectConflicting();
84 /// \brief Add fictive constraint if the sketch contains temporary constraints only
85 void addFictiveConstraintIfNecessary();
86 /// \brief Remove previously added fictive constraint
87 void removeFictiveConstraint();
90 typedef std::map<ConstraintID, std::set<GCSConstraintPtr> > ConstraintMap;
92 GCS::VEC_pD myParameters; ///< list of unknowns
93 ConstraintMap myConstraints; ///< list of constraints
95 std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
96 bool myDiagnoseBeforeSolve; ///< is the diagnostic necessary
97 bool myInitilized; ///< is the system already initialized
99 GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints
100 /// specifies the conflicting constraints are already collected
101 bool myConfCollected;
103 int myDOF; ///< degrees of freedom
105 GCS::Constraint* myFictiveConstraint;
108 typedef std::shared_ptr<PlaneGCSSolver_Solver> SolverPtr;