]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
Salome HOME
Issue #1834: Fix length of lines
[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 /**
17  * The main class that performs the high-level operations for connection to the PlaneGCS.
18  */
19 class PlaneGCSSolver_Solver : public SketchSolver_ISolver
20 {
21 public:
22   PlaneGCSSolver_Solver();
23   ~PlaneGCSSolver_Solver();
24
25   /// \brief Clear system of equations
26   void clear();
27
28   /// \brief Add constraint to the system of equations
29   void addConstraint(GCSConstraintPtr theConstraint,
30                      const SketchSolver_ConstraintType theType);
31
32   /// \brief Remove constraint from the system of equations
33   void removeConstraint(GCSConstraintPtr theConstraint);
34
35   /// \brief Initialize list of unknowns
36   void setParameters(const GCS::VEC_pD& theParams)
37   { myParameters = theParams; }
38
39   /// \brief Set list of IDs of tangent constraints
40   ///
41   /// Workaround to avoid incorrect report about redundant constraints
42   /// if an arc is already smoothly connected to a line.
43   void setTangent(const GCS::SET_I& theTangentIDs)
44   { myTangent = theTangentIDs; }
45
46   /** \brief Solve the set of equations
47    *  \return identifier whether solution succeeded
48    */
49   virtual SketchSolver_SolveStatus solve();
50
51   /// \brief Prepare for solving. Store initial values of parameters for undo
52   virtual void prepare()
53   { /* do nothing */ }
54
55   /// \brief Revert solution to initial values
56   virtual void undo();
57
58   /// \brief Check the constraint is conflicted with others
59   virtual bool isConflicting(const ConstraintID& theConstraint) const;
60
61   /// \brief Degrees of freedom
62   virtual int dof() const;
63
64 private:
65   void collectConflicting();
66
67   /// \brief Remove constraint from the system of equations
68   void removeConstraint(GCS::Constraint* theConstraint);
69
70   /// \brief Remove redundant tangent constraints and try to solve the system again
71   GCS::SolveStatus solveWithoutTangent();
72
73   /// \brief Check the entities under the tangent constraint are smoothly connected
74   bool isTangentTruth(int theTagID) const;
75   /// \brief Check the entities under the tangent constraint are smoothly connected
76   bool isTangentTruth(GCS::Constraint* theTangent) const;
77
78 private:
79   typedef std::map<GCS::Constraint*, SketchSolver_ConstraintType> ConstraintMap;
80
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