Salome HOME
Remove extra files
[modules/shaper.git] / src / SketchSolver / SketchSolver_Group.h
index e75accd08dd53a53b0c370b13ec4dd804c0e9ec2..9312c6a5a0a43eb5bedfd788fd0c70d4f2f37347 100644 (file)
 #include "SketchSolver.h"
 #include <SketchSolver_Constraint.h>
 #include <SketchSolver_Storage.h>
-#include <SketchSolver_FeatureStorage.h>
-#include <SketchSolver_Solver.h>
+#include <SketchSolver_ISolver.h>
 
 #include <SketchPlugin_Constraint.h>
-#include <ModelAPI_Data.h>
 #include <ModelAPI_Feature.h>
-#include <ModelAPI_AttributeRefList.h>
 
 #include <memory>
 #include <list>
 #include <map>
-#include <vector>
 #include <set>
 
 typedef std::map<ConstraintPtr, SolverConstraintPtr> ConstraintConstraintMap;
@@ -42,22 +38,17 @@ class SketchSolver_Group
   ~SketchSolver_Group();
 
   /// \brief Returns group's unique identifier
-  inline const Slvs_hGroup& getId() const
+  inline const GroupID& getId() const
   {
     return myID;
   }
 
   /// \brief Returns identifier of the workplane
-  inline const Slvs_hEntity& getWorkplaneId() const
+  inline const EntityID& getWorkplaneId() const
   {
     return myWorkplaneID;
   }
 
-  /// \brief Find the identifier of the feature, if it already exists in the group
-  Slvs_hEntity getFeatureId(FeaturePtr theFeature) const;
-  /// \brief Find the identifier of the attribute, if it already exists in the group
-  Slvs_hEntity getAttributeId(AttributePtr theAttribute) const;
-
   /// \brief Returns true if the group has no constraints yet
   inline bool isEmpty() const
   {
@@ -70,8 +61,11 @@ class SketchSolver_Group
     return mySketch->data() && mySketch->data()->isValid();
   }
 
-  /// \brief Verifies the constraint is complex, i.e. it needs another constraints to be created before
-  static bool isComplexConstraint(FeaturePtr theConstraint);
+  /// \brief Check the group has conflicting constraints
+  inline bool isFailed() const
+  {
+    return !myConflictingConstraints.empty();
+  }
 
   /** \brief Adds or updates a constraint in the group
    *  \param[in] theConstraint constraint to be changed
@@ -82,19 +76,20 @@ class SketchSolver_Group
   /** \brief Updates the data corresponding the specified feature
    *  \param[in] theFeature the feature to be updated
    */
-  bool updateFeature(std::shared_ptr<SketchPlugin_Feature> theFeature);
+  bool updateFeature(FeaturePtr theFeature);
 
   /** \brief Updates the data corresponding the specified feature moved in GUI.
    *         Additional Fixed constraints are created.
    *  \param[in] theFeature the feature to be updated
+   *  \return \c true, if the feature is moved
    */
-  void moveFeature(std::shared_ptr<SketchPlugin_Feature> theFeature);
+  bool moveFeature(FeaturePtr theFeature);
 
   /** \brief Verifies the feature attributes are used in this group
    *  \param[in] theFeature constraint or any other object for verification of interaction
    *  \return \c true if some of attributes are used in current group
    */
-  bool isInteract(std::shared_ptr<SketchPlugin_Feature> theFeature) const;
+  bool isInteract(FeaturePtr theFeature) const;
 
   /** \brief Verifies the specified feature is equal to the base workplane for this group
    *  \param[in] theWorkplane the feature to be compared with base workplane
@@ -109,7 +104,8 @@ class SketchSolver_Group
   }
 
   /** \brief Update parameters of workplane. Should be called when Update event is coming.
-   *  \return \c true if workplane updated successfully, \c false if workplane parameters are not consistent
+   *  \return \c true if workplane updated successfully, 
+   *  \c false if workplane parameters are not consistent
    */
   bool updateWorkplane();
 
@@ -123,25 +119,30 @@ class SketchSolver_Group
    */
   void mergeGroups(const SketchSolver_Group& theGroup);
 
-  /** \brief Cut from the group several subgroups, which are not connected to the current one by any constraint
+  /** \brief Cut from the group several subgroups, which are not connected to 
+   * the current one by any constraint
    *  \param[out] theCuts enlarge this list by newly created groups
    */
-  void splitGroup(std::vector<SketchSolver_Group*>& theCuts);
+  void splitGroup(std::list<SketchSolver_Group*>& theCuts);
 
   /** \brief Start solution procedure if necessary and update attributes of features
    *  \return \c false when no need to solve constraints
    */
   bool resolveConstraints();
 
+  /** \brief Collect all features applicable for the sketch
+   *  \param theObjects  list of features
+   *  \return list of bolted and sorted features
+   */
+  static std::list<FeaturePtr> selectApplicableFeatures(const std::set<ObjectPtr>& theObjects);
+
 protected:
   /** \brief Removes constraints from the group
    *  \param[in] theConstraint constraint to be removed
    */
   void removeConstraint(ConstraintPtr theConstraint);
 
-  /** \brief Remove all temporary constraint after computation finished
-   *  \param[in] theRemoved  indexes of constraints to be removed. If empty, all temporary constraints should be deleted
-   */
+  /// \brief Remove all temporary constraint after computation finished
   void removeTemporaryConstraints();
 
 private:
@@ -151,28 +152,33 @@ private:
    */
   bool addWorkplane(CompositeFeaturePtr theSketch);
 
-  /// \brief Apply temporary rigid constraints for the list of features
-  void fixFeaturesList(AttributeRefListPtr theList);
-
-  /// \brief Append given constraint to th group of temporary constraints
+  /// \brief Append given constraint to the group of temporary constraints
   void setTemporary(SolverConstraintPtr theConstraint);
 
   /// \brief Verifies is the feature valid
   bool checkFeatureValidity(FeaturePtr theFeature);
 
+  /// \brief Notify all interested constraints that coincidence appears or removed
+  /// \param[in] theCoincidence  coincidence constraint
+  void notifyCoincidenceChanged(SolverConstraintPtr theCoincidence);
+
 private:
-  Slvs_hGroup myID; ///< Index of the group
-  Slvs_hEntity myWorkplaneID; ///< Index of workplane, the group is based on
+  GroupID  myID; ///< Index of the group
+  EntityID myWorkplaneID; ///< Index of workplane, the group is based on
   CompositeFeaturePtr mySketch; ///< Sketch is equivalent to workplane
   ConstraintConstraintMap myConstraints; ///< List of constraints
   std::set<SolverConstraintPtr> myTempConstraints; ///< List of temporary constraints
 
+  /// List of parametric constraints
+  std::map<AttributePtr, SolverConstraintPtr> myParametricConstraints; 
+
   StoragePtr myStorage; ///< Container for the set of SolveSpace constraints and their entities
-  FeatureStoragePtr myFeatureStorage; ///< Container for the set of SketchPlugin features and their dependencies
 
-  SketchSolver_Solver myConstrSolver;  ///< Solver for set of equations obtained by constraints
+  SolverPtr mySketchSolver;  ///< Solver for set of equations obtained by constraints
 
-  bool myPrevSolved; ///< Indicates that previous solving was done correctly
+  /// Result of previous solution of the set of constraints
+  SketchSolver_SolveStatus myPrevResult; 
+  std::set<ObjectPtr>      myConflictingConstraints; ///< List of conflicting constraints
 };
 
 #endif