SHAPER  9.12.0
PlaneGCSSolver_Solver.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef PlaneGCSSolver_Solver_H_
21 #define PlaneGCSSolver_Solver_H_
22 
23 #include <PlaneGCSSolver_Defs.h>
24 #include <PlaneGCSSolver_ConstraintWrapper.h>
25 
26 #include <GCS.h>
27 
30 {
31 public:
33  enum SolveStatus {
34  STATUS_OK,
35  STATUS_INCONSISTENT,
36  STATUS_EMPTYSET,
37  STATUS_DEGENERATED,
38  STATUS_FAILED, // set if no one other status is applicable
39  STATUS_UNKNOWN // set for newly created groups
40  };
41 
44 
46  void clear();
47 
52  void addConstraint(const ConstraintID& theMultiConstraintID,
53  const std::list<GCSConstraintPtr>& theConstraints);
54 
56  void removeConstraint(const ConstraintID& theID);
57 
59  double* createParameter();
61  void addParameters(const GCS::SET_pD& theParams);
63  void removeParameters(const GCS::SET_pD& theParams);
64 
67  void initialize();
68 
72 
74  void undo();
75 
77  bool isConflicting(const ConstraintID& theConstraint) const;
78 
80  void diagnose(const GCS::Algorithm& theAlgo = GCS::DogLeg);
81 
83  void getFreeParameters(GCS::SET_pD& theFreeParams);
84 
86  int dof();
87 
88 private:
89  void collectConflicting(bool withRedundant = true);
90 
92  void addFictiveConstraintIfNecessary();
94  void removeFictiveConstraint();
95 
96 private:
97  typedef std::map<ConstraintID, std::list<GCSConstraintPtr> > ConstraintMap;
98 
99  GCS::VEC_pD myParameters;
100  ConstraintMap myConstraints;
101 
102  std::shared_ptr<GCS::System> myEquationSystem;
103  bool myDiagnoseBeforeSolve;
104  bool myInitilized;
105 
106  GCS::SET_I myConflictingIDs;
108  bool myConfCollected;
109 
110  int myDOF;
111 
112  GCS::Constraint* myFictiveConstraint;
113 };
114 
115 typedef std::shared_ptr<PlaneGCSSolver_Solver> SolverPtr;
116 
117 #endif
The main class that performs the high-level operations for connection to the PlaneGCS.
Definition: PlaneGCSSolver_Solver.h:30
void addParameters(const GCS::SET_pD &theParams)
Add parameters created elsewhere.
Definition: PlaneGCSSolver_Solver.cpp:107
SolveStatus solve()
Solve the set of equations.
Definition: PlaneGCSSolver_Solver.cpp:147
bool isConflicting(const ConstraintID &theConstraint) const
Check the constraint is conflicted with others.
Definition: PlaneGCSSolver_Solver.cpp:207
void diagnose(const GCS::Algorithm &theAlgo=GCS::DogLeg)
Check conflicting/redundant constraints and DoF.
Definition: PlaneGCSSolver_Solver.cpp:239
SolveStatus
The result of constraints solution.
Definition: PlaneGCSSolver_Solver.h:33
void undo()
Revert solution to initial values.
Definition: PlaneGCSSolver_Solver.cpp:202
double * createParameter()
Initialize memory for new solver's parameter.
Definition: PlaneGCSSolver_Solver.cpp:96
void getFreeParameters(GCS::SET_pD &theFreeParams)
Return the list of modifiable parameters.
Definition: PlaneGCSSolver_Solver.cpp:246
void removeParameters(const GCS::SET_pD &theParams)
Release memory occupied by parameters.
Definition: PlaneGCSSolver_Solver.cpp:123
void initialize()
Preliminary initialization of solver (useful for moving a feature).
Definition: PlaneGCSSolver_Solver.cpp:134
void addConstraint(const ConstraintID &theMultiConstraintID, const std::list< GCSConstraintPtr > &theConstraints)
Add constraint to the system of equations.
Definition: PlaneGCSSolver_Solver.cpp:53
int dof()
Degrees of freedom.
Definition: PlaneGCSSolver_Solver.cpp:232
void clear()
Clear system of equations.
Definition: PlaneGCSSolver_Solver.cpp:42
void removeConstraint(const ConstraintID &theID)
Remove constraints from the system of equations.
Definition: PlaneGCSSolver_Solver.cpp:76