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
39 STATUS_FAILED, // set if no one other status is applicable
40 STATUS_UNKNOWN // set for newly created groups
43 PlaneGCSSolver_Solver();
44 ~PlaneGCSSolver_Solver();
46 /// \brief Clear system of equations
49 /// \brief Add constraint to the system of equations
50 /// \param[in] theMultiConstraintID ID of the multi constraint which may consists of
51 /// several primitive constraints
52 /// \param[in] theConstraints list of primitive constraints
53 void addConstraint(const ConstraintID& theMultiConstraintID,
54 const std::list<GCSConstraintPtr>& theConstraints);
56 /// \brief Remove constraints from the system of equations
57 void removeConstraint(const ConstraintID& theID);
59 /// \brief Initialize memory for new solver's parameter
60 double* createParameter();
61 /// \brief Add parameters created elsewhere
62 void addParameters(const GCS::SET_pD& theParams);
63 /// \brief Release memory occupied by parameters
64 void removeParameters(const GCS::SET_pD& theParams);
66 /// \brief Preliminary initialization of solver (useful for moving a feature).
67 /// When called, the solve() method does not reinitialize a set of constraints.
70 /// \brief Solve the set of equations
71 /// \return identifier whether solution succeeded
74 /// \brief Revert solution to initial values
77 /// \brief Check the constraint is conflicted with others
78 bool isConflicting(const ConstraintID& theConstraint) const;
80 /// \brief Check conflicting/redundant constraints and DoF
83 /// \brief Degrees of freedom
87 void collectConflicting(bool withRedundant = true);
89 /// \brief Add fictive constraint if the sketch contains temporary constraints only
90 void addFictiveConstraintIfNecessary();
91 /// \brief Remove previously added fictive constraint
92 void removeFictiveConstraint();
95 typedef std::map<ConstraintID, std::set<GCSConstraintPtr> > ConstraintMap;
97 GCS::VEC_pD myParameters; ///< list of unknowns
98 ConstraintMap myConstraints; ///< list of constraints
100 std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
101 bool myDiagnoseBeforeSolve; ///< is the diagnostic necessary
102 bool myInitilized; ///< is the system already initialized
104 GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints
105 /// specifies the conflicting constraints are already collected
106 bool myConfCollected;
108 int myDOF; ///< degrees of freedom
110 GCS::Constraint* myFictiveConstraint;
113 typedef std::shared_ptr<PlaneGCSSolver_Solver> SolverPtr;