]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
Salome HOME
SketchSolver Refactoring: Eliminate SolveSpace as a sketch solver.
[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 list of unknowns
33   void setParameters(const GCS::VEC_pD& theParams)
34   { myParameters = theParams; }
35
36   /// \brief Solve the set of equations
37   /// \return identifier whether solution succeeded
38   virtual SketchSolver_SolveStatus solve() override;
39
40   /// \brief Prepare for solving. Store initial values of parameters for undo
41   virtual void prepare() override
42   { /* do nothing */ }
43
44   /// \brief Revert solution to initial values
45   virtual void undo() override;
46
47   /// \brief Check the constraint is conflicted with others
48   virtual bool isConflicting(const ConstraintID& theConstraint) const override;
49
50   /// \brief Degrees of freedom
51   virtual int dof() const override;
52
53 private:
54   void collectConflicting();
55
56 private:
57   GCS::VEC_pD                  myParameters;     ///< list of unknowns
58   std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
59
60   GCS::SET_I                   myConflictingIDs; ///< list of IDs of conflicting constraints
61
62   /// specifies the conflicting constraints are already collected
63   bool                         myConfCollected;
64
65   /// lists of parameters used in the Equal constraints (to avoid multiple equalities)
66   std::list<GCS::SET_pD>       myEqualParameters;
67   /// lists of the Equal constraints
68   std::map<ConstraintID, std::set<GCSConstraintPtr> > myEqualConstraints;
69 };
70
71 #endif