Salome HOME
Updated copyright comment
[modules/shaper.git] / src / SketchSolver / SolveSpaceSolver / SolveSpaceSolver_Storage.h
index 7136648b11cba963a8f4f98a505f00d044cd644a..a48631b3b16e0ad79dbc4d4b7dc56b0db0cabf04 100644 (file)
@@ -1,8 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    SolveSpaceSolver_Storage.h
-// Created: 18 Mar 2015
-// Author:  Artem ZHIDKOV
+// Copyright (C) 2014-2024  CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #ifndef SolveSpaceSolver_Storage_H_
 #define SolveSpaceSolver_Storage_H_
 #include <set>
 #include <vector>
 
-typedef std::map<EntityWrapperPtr, std::set<EntityWrapperPtr> > CoincidentPointsMap;
 typedef std::list< std::set<ConstraintWrapperPtr> >             SameConstraintMap;
 
 /** \class   SolveSpaceSolver_Storage
  *  \ingroup Plugins
- *  \brief   Contains all necessary data in SolveSpace format to solve a single group of constraints
+ *  \brief   Contains all necessary data in SolveSpace format to solve a single 
+ *  group of constraints
  */
 class SolveSpaceSolver_Storage : public SketchSolver_Storage
 {
@@ -31,24 +44,13 @@ public:
 
   /// \brief Update constraint's data
   /// \return \c true if any value is updated
-  virtual bool update(ConstraintWrapperPtr& theConstraint);
+  virtual bool update(ConstraintWrapperPtr theConstraint);
   /// \brief Update entity's data
   /// \return \c true if any value is updated
-  virtual bool update(EntityWrapperPtr& theEntity);
+  virtual bool update(EntityWrapperPtr theEntity);
   /// \brief Update parameter's data
   /// \return \c true if the value of parameter is updated
-  virtual bool update(ParameterWrapperPtr& theParameter);
-
-  /// \brief Removes constraint from the storage
-  /// \return \c true if the constraint and all its parameters are remove successfully
-  virtual bool removeConstraint(ConstraintPtr theConstraint);
-  /// \brief Removes feature from the storage
-  /// \return \c true if the feature and its attributes are removed successfully;
-  ///         \c false if the feature or any it attribute is used by remaining constraints.
-  virtual bool removeEntity(FeaturePtr theFeature);
-  /// \brief Removes attribute from the storage
-  /// \return \c true if the attribute is not used by remaining features and constraints
-  virtual bool removeEntity(AttributePtr theAttribute);
+  virtual bool update(ParameterWrapperPtr theParameter);
 
   /// \brief Update SketchPlugin features after resolving constraints
   /// \param theFixedOnly [in]  if \c true the fixed points will be updated only
@@ -121,35 +123,12 @@ public:
    *  \return \c true if the entity was successfully removed
    */
   bool removeEntity(const Slvs_hEntity& theEntityID);
-  /** \brief Remove all entities, which are not used in constraints
-   */
-  void removeUnusedEntities();
   /// \brief Returns the entity by its ID
   const Slvs_Entity& getEntity(const Slvs_hEntity& theEntityID) const;
-  /// \brief Makes a full copy of the given entity
-  Slvs_hEntity copyEntity(const Slvs_hEntity& theCopied);
-  /// \brief Copy one entity to another
-  void copyEntity(const Slvs_hEntity& theFrom, const Slvs_hEntity& theTo);
-  /// \brief Check the entity is used in constraints
-  bool isUsedByConstraints(const Slvs_hEntity& theEntityID) const;
   /// \brief Returns maximal ID of entities in this storage
   const Slvs_hEntity& entityMaxID() const
   { return myEntityMaxID; }
 
-  /// \brief Verifies the current point or another coincident one is fixed
-  /// \param[in]  thePointID  entity to be checked fixed
-  /// \param[out] theFixed    ID of constraint
-  /// \param[in]  theAccurate if \c true, the calculation will be made for all type of constraints,
-  ///                         if \c false, only the point is verified
-  /// \return \c true if the point is fixed
-  bool isPointFixed(const Slvs_hEntity& thePointID, Slvs_hConstraint& theFixed, bool theAccurate = false) const;
-  /// \brief Verifies the current entity is fully fixed (may not be changed by constraints)
-  /// \param[in] theEntityID entity to be checked fixed
-  /// \param[in] theAccurate if \c true, the calculation will be made for all type of constraints,
-  ///                        if \c false, only points are verified
-  /// \return \c true if the entity is fixed
-  bool isEntityFixed(const Slvs_hEntity& theEntityID, bool theAccurate = false) const;
-
   /** \brief Add new constraint to the current group
    *  \param[in] theConstraint   SolveSpace's constraint
    *  \return the ID of added constraint
@@ -169,31 +148,10 @@ public:
   bool removeConstraint(const Slvs_hConstraint& theConstraintID);
   /// \brief Returns the constraint by its ID
   const Slvs_Constraint& getConstraint(const Slvs_hConstraint& theConstraintID) const;
-  /// \brief Returns list of constraints of specified type
-  std::list<Slvs_Constraint> getConstraintsByType(int theConstraintType) const;
   /// \brief Returns quantity of constraints in this storage
   size_t nbConstraints() const
   { return myConstraints.size(); }
 
-  /// \brief Attach constraint SLVS_C_WHERE_DRAGGED to this storage. It need to make precise calculations
-  void addConstraintWhereDragged(const Slvs_hConstraint& theConstraintID);
-
-  /// \brief Add transient constraint
-  void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID);
-  /// \brief Mark specified constraint as temporary
-  virtual void setTemporary(ConstraintPtr theConstraint);
-  /// \brief Remove all transient constraints
-  void removeAllTemporary();
-  /// \brief Remove temporary constraint s. Preferable to remove the points under Point-on-Line constraint
-  /// \param theNbConstraints [in]  number of temporary constraints to be deleted
-  /// \return Number of remaining temporary constraints
-  virtual size_t removeTemporary(size_t theNbConstraints);
-  /// \brief Checks the constraint is temporary
-  bool isTemporary(const Slvs_hConstraint& theConstraintID) const;
-  /// \brief Number of temporary constraints
-  virtual size_t nbTemporary() const
-  { return myTemporaryConstraints.size(); }
-
   /// \brief Shows the storage has the same constraint twice
   virtual bool hasDuplicatedConstraint() const
   { return myDuplicatedConstraint; }
@@ -201,50 +159,10 @@ public:
   /// \brief Initialize constraint solver by the entities collected by current storage
   virtual void initializeSolver(SolverPtr theSolver);
 
-public:
-  /// \brief Check two points are coincident or have same coordinates
-  bool isEqual(const Slvs_hEntity& thePoint1, const Slvs_hEntity& thePoint2) const;
-
-  /// \brief Check the entity is horizontal of vertical
-  bool isAxisParallel(const Slvs_hEntity& theEntity) const;
-
-  /// \brief Verifies the entity is used in any equal constraint
-  /// \param[in]  theEntity entity to be found
-  /// \param[out] theEqual  constraint, which uses the entity
-  /// \return \c true, if the Equal constrait is found
-  bool isUsedInEqual(const Slvs_hEntity& theEntity, Slvs_Constraint& theEqual) const;
-
-  /// \brief Fixes specified entity
-  /// \param theEntity  ID of the entity to be fixed
-  /// \return List of created constraints
-  std::vector<Slvs_hConstraint> fixEntity(const Slvs_hEntity& theEntity);
-
 private:
-  /// \brief Fixes specified point
-  /// \param [in]  thePoint    point to be fixed
-  /// \param [out] theCreated  list of the Fixed constraints created
-  void fixPoint(const Slvs_Entity& thePoint, std::vector<Slvs_hConstraint>& theCreated);
-  /// \brief Fixes specified line
-  /// \param [in]  theLine     line to be fixed
-  /// \param [out] theCreated  list of the Fixed constraints created
-  void fixLine(const Slvs_Entity& theLine, std::vector<Slvs_hConstraint>& theCreated);
-  /// \brief Fixes specified circle
-  /// \param [in]  theCircle   circle to be fixed
-  /// \param [out] theCreated  list of the Fixed constraints created
-  void fixCircle(const Slvs_Entity& theCircle, std::vector<Slvs_hConstraint>& theCreated);
-  /// \brief Fixes specified arc
-  /// \param [in]  theArc      arc to be fixed
-  /// \param [out] theCreated  list of the Fixed constraints created
-  void fixArc(const Slvs_Entity& theArc, std::vector<Slvs_hConstraint>& theCreated);
-
   /// \brief Update arc points to be on circle sharp.
   void adjustArc(const Slvs_Entity& theArc);
 
-  /// \brief Verify the feature or any its attribute is used by constraint
-  bool isUsed(FeaturePtr theFeature) const;
-  /// \brief Verify the attribute is used by constraint
-  bool isUsed(AttributePtr theAttirubute) const;
-
   /// \brief Replace sub-entity theSource in all features by theDest
   void replaceInFeatures(EntityWrapperPtr theSource, EntityWrapperPtr theDest);
   /// \brief Replace constrained entity theSource by theDest in all constraints;
@@ -254,25 +172,32 @@ private:
   ///
   ///        These constraints may be different and become the same after the substitution
   ///        of point coincidence.
-  void addSameConstraints(ConstraintWrapperPtr theConstraint1, ConstraintWrapperPtr theConstraint2);
+  void addSameConstraints(ConstraintWrapperPtr theConstraint1,
+                          ConstraintWrapperPtr theConstraint2);
+
+  /// \brief Search constraint equal to the given in terms of SolveSpace notation
+  bool findSameConstraint(ConstraintWrapperPtr theConstraint);
 
 private:
   Slvs_hEntity myWorkplaneID; ///< identifier of workplane
 
-  Slvs_hParam myParamMaxID; ///< current parameter index (may differs with the number of parameters)
-  std::vector<Slvs_Param> myParameters; ///< list of parameters used in the current group of constraints (sorted by the identifier)
+  /// current parameter index (may differs with the number of parameters)
+  Slvs_hParam myParamMaxID;
+
+  /// list of parameters used in the current group of constraints (sorted by the identifier)
+  std::vector<Slvs_Param> myParameters;
   Slvs_hEntity myEntityMaxID; ///< current entity index (may differs with the number of entities)
-  std::vector<Slvs_Entity> myEntities; ///< list of entities used in the current group of constraints (sorted by the identifier)
-  Slvs_hConstraint myConstrMaxID; ///< current constraint index (may differs with the number of constraints)
-  std::vector<Slvs_Constraint> myConstraints; ///< list of constraints used in the current group (sorted by the identifier)
 
-  CoincidentPointsMap myCoincidentPoints; ///< lists of coincident points (first is a master point, second is a set of slaves)
-  Slvs_hConstraint myFixed; ///< identifier of one of temporary constraints to fix separate point
+  /// list of entities used in the current group of constraints (sorted by the identifier)
+  std::vector<Slvs_Entity> myEntities;
 
-  bool myDuplicatedConstraint; ///< shows the storage has same constraint twice
+  /// current constraint index (may differs with the number of constraints)
+  Slvs_hConstraint myConstrMaxID;
 
-  std::set<Slvs_hConstraint> myTemporaryConstraints; ///< list of transient constraints
-  std::set<Slvs_hParam> myUpdatedParameters; ///< list of just updated parameters (cleared when isNeedToResolve() called)
+  /// list of constraints used in the current group (sorted by the identifier)
+  std::vector<Slvs_Constraint> myConstraints;
+
+  bool myDuplicatedConstraint; ///< shows the storage has same constraint twice
 
   SameConstraintMap myEqualConstraints; ///< list of groups of equal constraints
 };