Salome HOME
Workaround to check false-positive conflicting constraints during fillet operation...
[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 typedef std::map<GCS::Constraint*, SketchSolver_ConstraintType> ConstraintMap;
17
18 /**
19  * The main class that performs the high-level operations for connection to the PlaneGCS.
20  */
21 class PlaneGCSSolver_Solver : public SketchSolver_ISolver
22 {
23 public:
24   PlaneGCSSolver_Solver();
25   ~PlaneGCSSolver_Solver();
26
27   /// \brief Clear system of equations
28   void clear();
29
30   /// \brief Add constraint to the system of equations
31   void addConstraint(GCSConstraintPtr theConstraint,
32                      const SketchSolver_ConstraintType theType);
33
34   /// \brief Remove constraint from the system of equations
35   void removeConstraint(GCSConstraintPtr theConstraint);
36
37   /// \brief Initialize list of unknowns
38   void setParameters(const GCS::VEC_pD& theParams)
39   { myParameters = theParams; }
40
41   /// \brief Set list of IDs of tangent constraints
42   ///
43   /// Workaround to avoid incorrect report about redundant constraints
44   /// if an arc is already smoothly connected to a line.
45   void setTangent(const GCS::SET_I& theTangentIDs)
46   { myTangent = theTangentIDs; }
47
48   /** \brief Solve the set of equations
49    *  \return identifier whether solution succeeded
50    */
51   virtual SketchSolver_SolveStatus solve();
52
53   /// \brief Prepare for solving. Store initial values of parameters for undo
54   virtual void prepare()
55   { /* do nothing */ }
56
57   /// \brief Revert solution to initial values
58   virtual void undo();
59
60   /// \brief Check the constraint is conflicted with others
61   virtual bool isConflicting(const ConstraintID& theConstraint) const;
62
63   /// \brief Degrees of freedom
64   virtual int dof() const;
65
66 private:
67   void collectConflicting();
68
69   /// \brief Remove constraint from the system of equations
70   void removeConstraint(GCS::Constraint* theConstraint);
71
72   /// \brief Remove redundant tangent constraints and try to solve the system again
73   GCS::SolveStatus solveWithoutTangent();
74
75   /// \brief Check the entities under the tangent constraint are smoothly connected
76   bool isTangentTruth(int theTagID) const;
77   /// \brief Check the entities under the tangent constraint are smoothly connected
78   bool isTangentTruth(GCS::Constraint* theTangent) const;
79
80 private:
81   GCS::VEC_pD                  myParameters;     ///< list of unknowns
82
83   /// list of constraints already processed by the system
84   ConstraintMap                myConstraints;
85   std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
86
87   GCS::SET_I                   myConflictingIDs; ///< list of IDs of conflicting constraints
88
89   /// specifies the conflicting constraints are already collected
90   bool                         myConfCollected;
91
92   /// list of tangent IDs to check incorrect redundant constraints
93   GCS::SET_I                   myTangent;
94 };
95
96 #endif