Salome HOME
Fix incorrect DoF after dump-import loop (issue #1767)
[modules/shaper.git] / src / SketchSolver / SketchSolver_ISolver.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ISolver.h
4 // Created: 30 Nov 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ISolver_H_
8 #define SketchSolver_ISolver_H_
9
10 #include <SketchSolver.h>
11
12 #include <memory>
13
14 /// The result of constraints solution
15 enum SketchSolver_SolveStatus {
16   STATUS_OK,
17   STATUS_INCONSISTENT,
18   STATUS_EMPTYSET,
19   STATUS_FAILED, // set if no one other status is applicable
20   STATUS_UNKNOWN // set for newly created groups
21 };
22
23
24 /**
25  *  Interface providing operations to solve sketches.
26  */
27 class SketchSolver_ISolver
28 {
29 public:
30   virtual ~SketchSolver_ISolver() {}
31
32   /// \brief Changes the ID of the group to solve
33   void setGroup(const GroupID& theGroupID)
34   { myGroup = theGroupID; }
35
36   /// \brief Set or unset the flag which allows to find all failed constraints
37   void calculateFailedConstraints(bool theSic)
38   { myFindFaileds = theSic; }
39
40   /// \brief Prepare for solving. Store initial values of parameters for undo
41   virtual void prepare() = 0;
42
43   /// \brief Solve the set of equations
44   /// \return identifier whether solution succeeded
45   virtual SketchSolver_SolveStatus solve() = 0;
46
47   /// \brief Revert solution to initial values
48   virtual void undo() = 0;
49
50   /// \brief Check the constraint is conflicted with others
51   virtual bool isConflicting(const ConstraintID& theConstraint) const = 0;
52
53   /// \brief Degrees of freedom
54   virtual int dof() const = 0;
55
56 protected:
57   GroupID myGroup;       ///< ID of the group to be solved
58   bool    myFindFaileds; ///< flag to find conflicting or inappropriate constraints
59 };
60
61 typedef std::shared_ptr<SketchSolver_ISolver> SolverPtr;
62
63 #endif