Salome HOME
9c25caf722e06ee3300856f8edef641f6cec9bdb
[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 <SketchSolver_ISolver.h>
11 #include <SketchSolver_IConstraintWrapper.h>
12 #include <PlaneGCSSolver_Defs.h>
13
14 #include <GCS.h>
15
16 /// \brief The main class that performs the high-level operations for connection to the PlaneGCS.
17 class PlaneGCSSolver_Solver : public SketchSolver_ISolver
18 {
19 public:
20   PlaneGCSSolver_Solver();
21   ~PlaneGCSSolver_Solver();
22
23   /// \brief Clear system of equations
24   void clear();
25
26   /// \brief Add constraint to the system of equations
27   void addConstraint(GCSConstraintPtr theConstraint);
28
29   /// \brief Remove constraint from the system of equations
30   void removeConstraint(ConstraintID theID);
31
32   /// \brief Initialize memory for new solver's parameter
33   double* createParameter();
34   /// \brief Release memory occupied by parameters
35   void removeParameters(const GCS::SET_pD& theParams);
36
37   /// \brief Solve the set of equations
38   /// \return identifier whether solution succeeded
39   virtual SketchSolver_SolveStatus solve();
40
41   /// \brief Prepare for solving. Store initial values of parameters for undo
42   virtual void prepare()
43   { /* do nothing */ }
44
45   /// \brief Revert solution to initial values
46   virtual void undo();
47
48   /// \brief Check the constraint is conflicted with others
49   virtual bool isConflicting(const ConstraintID& theConstraint) const;
50
51   /// \brief Degrees of freedom
52   virtual int dof();
53
54 private:
55   void collectConflicting();
56
57 private:
58   typedef std::map<ConstraintID, std::set<GCSConstraintPtr> > ConstraintMap;
59
60   GCS::VEC_pD                  myParameters;     ///< list of unknowns
61   ConstraintMap                myConstraints;    ///< list of constraints
62
63   std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
64
65   GCS::SET_I                   myConflictingIDs; ///< list of IDs of conflicting constraints
66
67   /// specifies the conflicting constraints are already collected
68   bool                         myConfCollected;
69
70   int                          myDOF;            ///< degrees of freedom
71 };
72
73 #endif