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 <SketchSolver_IConstraintWrapper.h>
12 #include <PlaneGCSSolver_Defs.h>
16 typedef std::map<GCS::Constraint*, SketchSolver_ConstraintType> ConstraintMap;
19 * The main class that performs the high-level operations for connection to the PlaneGCS.
21 class PlaneGCSSolver_Solver : public SketchSolver_ISolver
24 PlaneGCSSolver_Solver();
25 ~PlaneGCSSolver_Solver();
27 /// \brief Clear system of equations
30 /// \brief Add constraint to the system of equations
31 void addConstraint(GCSConstraintPtr theConstraint,
32 const SketchSolver_ConstraintType theType);
34 /// \brief Remove constraint from the system of equations
35 void removeConstraint(GCSConstraintPtr theConstraint);
37 /// \brief Initialize list of unknowns
38 void setParameters(const GCS::VEC_pD& theParams)
39 { myParameters = theParams; }
41 /// \brief Set list of IDs of tangent constraints
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; }
48 /** \brief Solve the set of equations
49 * \return identifier whether solution succeeded
51 virtual SketchSolver_SolveStatus solve();
53 /// \brief Prepare for solving. Store initial values of parameters for undo
54 virtual void prepare()
57 /// \brief Revert solution to initial values
60 /// \brief Check the constraint is conflicted with others
61 virtual bool isConflicting(const ConstraintID& theConstraint) const;
63 /// \brief Degrees of freedom
64 virtual int dof() const;
67 void collectConflicting();
69 /// \brief Remove constraint from the system of equations
70 void removeConstraint(GCS::Constraint* theConstraint);
72 /// \brief Remove redundant tangent constraints and try to solve the system again
73 GCS::SolveStatus solveWithoutTangent();
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;
81 GCS::VEC_pD myParameters; ///< list of unknowns
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
87 GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints
89 /// specifies the conflicting constraints are already collected
92 /// list of tangent IDs to check incorrect redundant constraints