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 PlaneGCSSolver_Solver_H_
21 #define PlaneGCSSolver_Solver_H_
23 #include <PlaneGCSSolver_Defs.h>
24 #include <PlaneGCSSolver_ConstraintWrapper.h>
28 /// \brief The main class that performs the high-level operations for connection to the PlaneGCS.
29 class PlaneGCSSolver_Solver
32 /// 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 /// \param[in] theMultiConstraintID ID of the multi constraint which may consists of
50 /// several primitive constraints
51 /// \param[in] theConstraints list of primitive constraints
52 void addConstraint(const ConstraintID& theMultiConstraintID,
53 const std::list<GCSConstraintPtr>& theConstraints);
55 /// \brief Remove constraints from the system of equations
56 void removeConstraint(const ConstraintID& theID);
58 /// \brief Initialize memory for new solver's parameter
59 double* createParameter();
60 /// \brief Add parameters created elsewhere
61 void addParameters(const GCS::SET_pD& theParams);
62 /// \brief Release memory occupied by parameters
63 void removeParameters(const GCS::SET_pD& theParams);
65 /// \brief Preliminary initialization of solver (useful for moving a feature).
66 /// When called, the solve() method does not reinitialize a set of constraints.
69 /// \brief Solve the set of equations
70 /// \return identifier whether solution succeeded
73 /// \brief Revert solution to initial values
76 /// \brief Check the constraint is conflicted with others
77 bool isConflicting(const ConstraintID& theConstraint) const;
79 /// \brief Check conflicting/redundant constraints and DoF
80 void diagnose(const GCS::Algorithm& theAlgo = GCS::DogLeg);
82 /// \brief Return the list of modifiable parameters
83 void getFreeParameters(GCS::SET_pD& theFreeParams);
85 /// \brief Degrees of freedom
89 void collectConflicting(bool withRedundant = true);
91 /// \brief Add fictive constraint if the sketch contains temporary constraints only
92 void addFictiveConstraintIfNecessary();
93 /// \brief Remove previously added fictive constraint
94 void removeFictiveConstraint();
97 typedef std::map<ConstraintID, std::list<GCSConstraintPtr> > ConstraintMap;
99 GCS::VEC_pD myParameters; ///< list of unknowns
100 ConstraintMap myConstraints; ///< list of constraints
102 std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
103 bool myDiagnoseBeforeSolve; ///< is the diagnostic necessary
104 bool myInitilized; ///< is the system already initialized
106 GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints
107 /// specifies the conflicting constraints are already collected
108 bool myConfCollected;
110 int myDOF; ///< degrees of freedom
112 GCS::Constraint* myFictiveConstraint;
115 typedef std::shared_ptr<PlaneGCSSolver_Solver> SolverPtr;