1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PlaneGCSSolver_Solver.h
4 // Created: 14 Dec 2014
5 // Author: Artem ZHIDKOV
7 #ifndef PlaneGCSSolver_Solver_H_
8 #define PlaneGCSSolver_Solver_H_
10 #include <SketchSolver_ISolver.h>
11 #include <PlaneGCSSolver_Defs.h>
16 * The main class that performs the high-level operations for connection to the PlaneGCS.
18 class PlaneGCSSolver_Solver : public SketchSolver_ISolver
21 PlaneGCSSolver_Solver() {}
22 ~PlaneGCSSolver_Solver();
24 /// \brief Clear system of equations
27 /// \brief Add constraint to the system of equations
28 void addConstraint(GCSConstraintPtr theConstraint);
30 /// \brief Remove constraint from the system of equations
31 void removeConstraint(GCSConstraintPtr theConstraint);
33 /// \brief Initialize list of unknowns
34 void setParameters(const GCS::VEC_pD& theParams)
35 { myParameters = theParams; }
37 /// \brief Set list of IDs of tangent constraints
39 /// Workaround to avoid incorrect report about redundant constraints
40 /// if an arc is already smoothly connected to a line.
41 void setTangent(const GCS::SET_I& theTangentIDs)
42 { myTangent = theTangentIDs; }
44 /** \brief Solve the set of equations
45 * \return identifier whether solution succeeded
47 virtual SketchSolver_SolveStatus solve();
49 /// \brief Prepare for solving. Store initial values of parameters for undo
50 virtual void prepare()
53 /// \brief Revert solution to initial values
56 /// \brief Check the constraint is conflicted with others
57 virtual bool isConflicting(const ConstraintID& theConstraint) const;
59 /// \brief Degrees of freedom
60 virtual int dof() const;
63 void collectConflicting();
65 /// \brief Remove constraint from the system of equations
66 void removeConstraint(GCS::Constraint* theConstraint);
68 /// \brief Remove redundant tangent constraints and try to solve the system again
69 SketchSolver_SolveStatus solveWithoutTangent();
72 GCS::VEC_pD myParameters; ///< list of unknowns
73 std::set<GCS::Constraint*> myConstraints; ///< list of constraints already processed by the system
74 GCS::System myEquationSystem; ///< set of equations for solving in FreeGCS
76 GCS::VEC_I myConflictingIDs; ///< list of IDs of conflicting constraints
77 bool myConfCollected; ///< specifies the conflicting constraints are already collected
79 GCS::SET_I myTangent; ///< list of tangent IDs to check incorrect redundant constraints