]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
Salome HOME
Fix incorrect processing of the copied entities after the "Multi" constraint has...
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_Solver.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    PlaneGCSSolver_Solver.h
4 // Created: 14 Dec 2014
5 // Author:  Artem ZHIDKOV
6
7 #ifndef PlaneGCSSolver_Solver_H_
8 #define PlaneGCSSolver_Solver_H_
9
10 #include <PlaneGCSSolver_Defs.h>
11 #include <PlaneGCSSolver_ConstraintWrapper.h>
12
13 #include <GCS.h>
14
15 /// \brief The main class that performs the high-level operations for connection to the PlaneGCS.
16 class PlaneGCSSolver_Solver
17 {
18 public:
19   /// The result of constraints solution
20   enum SolveStatus {
21     STATUS_OK,
22     STATUS_INCONSISTENT,
23     STATUS_EMPTYSET,
24     STATUS_FAILED, // set if no one other status is applicable
25     STATUS_UNKNOWN // set for newly created groups
26   };
27
28   PlaneGCSSolver_Solver();
29   ~PlaneGCSSolver_Solver();
30
31   /// \brief Clear system of equations
32   void clear();
33
34   /// \brief Add constraint to the system of equations
35   void addConstraint(GCSConstraintPtr theConstraint);
36
37   /// \brief Remove constraint from the system of equations
38   void removeConstraint(ConstraintID theID);
39
40   /// \brief Initialize memory for new solver's parameter
41   double* createParameter();
42   /// \brief Add parameters created elsewhere
43   void addParameters(const GCS::SET_pD& theParams);
44   /// \brief Release memory occupied by parameters
45   void removeParameters(const GCS::SET_pD& theParams);
46
47   /// \brief Preliminary initialization of solver (useful for moving a feature).
48   ///        When called, the solve() method does not reinitialize a set of constraints.
49   void initialize();
50
51   /// \brief Solve the set of equations
52   /// \return identifier whether solution succeeded
53   SolveStatus solve();
54
55   /// \brief Revert solution to initial values
56   void undo();
57
58   /// \brief Check the constraint is conflicted with others
59   bool isConflicting(const ConstraintID& theConstraint) const;
60
61   /// \brief Check conflicting/redundant constraints and DoF
62   void diagnose();
63
64   /// \brief Degrees of freedom
65   int dof();
66
67 private:
68   void collectConflicting();
69
70 private:
71   typedef std::map<ConstraintID, std::set<GCSConstraintPtr> > ConstraintMap;
72
73   GCS::VEC_pD                  myParameters;     ///< list of unknowns
74   ConstraintMap                myConstraints;    ///< list of constraints
75
76   std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
77   bool                         myDiagnoseBeforeSolve; ///< is the diagnostic necessary
78   bool                         myInitilized;     ///< is the system already initialized
79
80   GCS::SET_I                   myConflictingIDs; ///< list of IDs of conflicting constraints
81   /// specifies the conflicting constraints are already collected
82   bool                         myConfCollected;
83
84   int                          myDOF;            ///< degrees of freedom
85 };
86
87 typedef std::shared_ptr<PlaneGCSSolver_Solver> SolverPtr;
88
89 #endif