1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_Group.h
4 // Created: 27 May 2014
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_Group_H_
8 #define SketchSolver_Group_H_
10 #include <SketchSolver_Constraint.h>
11 #include <SketchSolver_Storage.h>
12 #include <SketchSolver_ISolver.h>
14 #include <SketchPlugin_Constraint.h>
19 typedef std::map<ConstraintPtr, SolverConstraintPtr> ConstraintConstraintMap;
21 /** \class SketchSolver_Group
23 * \brief Keeps the group of constraints which placed in the same sketch
25 class SketchSolver_Group
28 /** \brief New group based on specified workplane.
29 * Throws an exception if theWorkplane is not an object of SketchPlugin_Sketch type
30 * \remark Type of theSketch is not verified inside
32 SketchSolver_Group(const CompositeFeaturePtr& theWorkplane);
34 virtual ~SketchSolver_Group();
36 /// \brief Returns true if the group has no constraints yet
37 inline bool isEmpty() const
39 return myConstraints.empty();
42 /// \brief Check for valid sketch data
43 inline bool isWorkplaneValid() const
45 return mySketch->data() && mySketch->data()->isValid();
48 /** \brief Adds or updates a constraint in the group
49 * \param[in] theConstraint constraint to be changed
50 * \return \c true if the constraint added or updated successfully
52 bool changeConstraint(std::shared_ptr<SketchPlugin_Constraint> theConstraint);
54 /** \brief Updates the data corresponding the specified feature
55 * \param[in] theFeature the feature to be updated
57 bool updateFeature(FeaturePtr theFeature);
59 /** \brief Updates the data corresponding the specified feature moved in GUI.
60 * Additional Fixed constraints are created.
61 * \param[in] theFeature the feature to be updated
62 * \return \c true, if the feature is moved
64 bool moveFeature(FeaturePtr theFeature);
66 /// Returns the current workplane
67 inline const CompositeFeaturePtr& getWorkplane() const
72 /** \brief Searches invalid features and constraints in the group and removes them
73 * \return \c false if the group several constraints were removed
75 void repairConsistency();
77 /** \brief Start solution procedure if necessary and update attributes of features
78 * \return \c false when no need to solve constraints
80 bool resolveConstraints();
82 /// \brief Block or unblock events sent by features in this group
83 void blockEvents(bool isBlocked);
86 /** \brief Removes constraints from the group
87 * \param[in] theConstraint constraint to be removed
89 void removeConstraint(ConstraintPtr theConstraint);
91 /// \brief Remove all temporary constraints after the computation finished
92 void removeTemporaryConstraints();
94 /// \brief Append given constraint to the group of temporary constraints
95 void setTemporary(SolverConstraintPtr theConstraint);
98 CompositeFeaturePtr mySketch; ///< Sketch for this group
99 ConstraintConstraintMap myConstraints; ///< List of constraints
100 std::set<SolverConstraintPtr> myTempConstraints; ///< List of temporary constraints
102 StoragePtr myStorage; ///< Container for the set of SolveSpace constraints and their entities
103 SolverPtr mySketchSolver; ///< Solver for set of equations obtained by constraints
105 /// Result of previous solution of the set of constraints
106 SketchSolver_SolveStatus myPrevResult;
107 std::set<ObjectPtr> myConflictingConstraints; ///< List of conflicting constraints
109 bool myIsEventsBlocked; ///< shows the events are blocked for this group
112 typedef std::shared_ptr<SketchSolver_Group> SketchGroupPtr;