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>
17 * The main class that performs the high-level operations for connection to the PlaneGCS.
19 class PlaneGCSSolver_Solver : public SketchSolver_ISolver
22 PlaneGCSSolver_Solver();
23 ~PlaneGCSSolver_Solver();
25 /// \brief Clear system of equations
28 /// \brief Add constraint to the system of equations
29 void addConstraint(GCSConstraintPtr theConstraint,
30 const SketchSolver_ConstraintType theType);
32 /// \brief Remove constraint from the system of equations
33 void removeConstraint(GCSConstraintPtr theConstraint);
35 /// \brief Initialize list of unknowns
36 void setParameters(const GCS::VEC_pD& theParams)
37 { myParameters = theParams; }
39 /// \brief Set list of IDs of tangent constraints
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; }
46 /** \brief Solve the set of equations
47 * \return identifier whether solution succeeded
49 virtual SketchSolver_SolveStatus solve();
51 /// \brief Prepare for solving. Store initial values of parameters for undo
52 virtual void prepare()
55 /// \brief Revert solution to initial values
58 /// \brief Check the constraint is conflicted with others
59 virtual bool isConflicting(const ConstraintID& theConstraint) const;
61 /// \brief Degrees of freedom
62 virtual int dof() const;
65 void collectConflicting();
67 /// \brief Remove constraint from the system of equations
68 void removeConstraint(GCS::Constraint* theConstraint);
70 /// \brief Remove redundant tangent constraints and try to solve the system again
71 GCS::SolveStatus solveWithoutTangent();
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;
79 typedef std::map<GCS::Constraint*, SketchSolver_ConstraintType> ConstraintMap;
81 GCS::VEC_pD myParameters; ///< list of unknowns
82 ConstraintMap myConstraints; ///< list of constraints already processed by the system
83 std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
85 GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints
86 bool myConfCollected; ///< specifies the conflicting constraints are already collected
88 GCS::SET_I myTangent; ///< list of tangent IDs to check incorrect redundant constraints