1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PlaneGCSSolver_Solver.h
4 // Created: 14 Dec 2014
5 // Author: Artem ZHIDKOV
7 #ifndef PlaneGCSSolver_Solver_H_
8 #define PlaneGCSSolver_Solver_H_
10 #include <PlaneGCSSolver_Defs.h>
11 #include <PlaneGCSSolver_ConstraintWrapper.h>
15 /// \brief The main class that performs the high-level operations for connection to the PlaneGCS.
16 class PlaneGCSSolver_Solver
19 /// The result of constraints solution
24 STATUS_FAILED, // set if no one other status is applicable
25 STATUS_UNKNOWN // set for newly created groups
28 PlaneGCSSolver_Solver();
29 ~PlaneGCSSolver_Solver();
31 /// \brief Clear system of equations
34 /// \brief Add constraint to the system of equations
35 void addConstraint(GCSConstraintPtr theConstraint);
37 /// \brief Remove constraint from the system of equations
38 void removeConstraint(ConstraintID theID);
40 /// \brief Initialize memory for new solver's parameter
41 double* createParameter();
42 /// \brief Release memory occupied by parameters
43 void removeParameters(const GCS::SET_pD& theParams);
45 /// \brief Preliminary initialization of solver (useful for moving a feature).
46 /// When called, the solve() method does not reinitialize a set of constraints.
49 /// \brief Solve the set of equations
50 /// \return identifier whether solution succeeded
53 /// \brief Revert solution to initial values
56 /// \brief Check the constraint is conflicted with others
57 bool isConflicting(const ConstraintID& theConstraint) const;
59 /// \brief Check conflicting/redundant constraints and DoF
62 /// \brief Degrees of freedom
66 void collectConflicting();
68 /// \brief Add fictive constraint if the sketch contains temporary constraints only
69 void addFictiveConstraintIfNecessary();
70 /// \brief Remove previously added fictive constraint
71 void removeFictiveConstraint();
74 typedef std::map<ConstraintID, std::set<GCSConstraintPtr> > ConstraintMap;
76 GCS::VEC_pD myParameters; ///< list of unknowns
77 ConstraintMap myConstraints; ///< list of constraints
79 std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
80 bool myDiagnoseBeforeSolve; ///< is the diagnostic necessary
81 bool myInitilized; ///< is the system already initialized
83 GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints
84 /// specifies the conflicting constraints are already collected
87 int myDOF; ///< degrees of freedom
89 GCS::Constraint* myFictiveConstraint;
92 typedef std::shared_ptr<PlaneGCSSolver_Solver> SolverPtr;