Salome HOME
Update copyrights
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_UpdateCoincidence.h
index 44f36c4653289d989b2bc9d5fe20cf1b096d6804..29247709f45053988ffbcf07bfa5091a09a0c45c 100644 (file)
@@ -1,14 +1,31 @@
-// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
-
-// File:    PlaneGCSSolver_UpdateCoincidence.h
-// Created: 17 Feb 2017
-// Author:  Artem ZHIDKOV
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+//
+// 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 PlaneGCSSolver_UpdateCoincidence_H_
 #define PlaneGCSSolver_UpdateCoincidence_H_
 
 #include <PlaneGCSSolver_Update.h>
-#include <SketchSolver_IEntityWrapper.h>
+#include <PlaneGCSSolver_EntityWrapper.h>
+
+#include <GCS.h>
+
+#include <map>
 
 /** \class   PlaneGCSSolver_UpdateCoincidence
  *  \ingroup Plugins
@@ -39,12 +56,55 @@ public:
   /// \brief Send notification about update of the feature to all interested
   virtual void update(const FeaturePtr& theFeature);
 
-  /// \brief Verifies the entities are not coincident yet
-  /// \return \c true if the entities does not coincident
-  bool checkCoincidence(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2);
+  /// \brief Set coincidence between two given entities
+  /// \return \c true if the entities does not coincident yet
+  bool addCoincidence(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2);
+
+  /// \brief Verifies the point is coincident to the feature
+  /// \return \c true if the point is on the feature
+  bool isPointOnEntity(const EntityWrapperPtr& thePoint, const EntityWrapperPtr& theEntity);
+
+private:
+  /// \brief Container for collecting and operating coincident entities
+  class CoincidentEntities
+  {
+  public:
+    CoincidentEntities(const EntityWrapperPtr& theEntity1,
+                       const EntityWrapperPtr& theEntity2);
+
+    /// Verify the entity is already in the list
+    bool isExist(const EntityWrapperPtr& theEntity) const;
+    /// Verify the point is already in the list
+    bool isExist(const GCS::Point& thePoint) const;
+
+    /// Add entity to group
+    bool add(const EntityWrapperPtr& theEntity);
+
+    /// Remove entity from group
+    void remove(const EntityWrapperPtr& theEntity);
+
+    /// Merge two groups
+    void merge(const CoincidentEntities& theOther);
+
+    /// Returns any of external points
+    EntityWrapperPtr externalPoint() const;
+
+  private:
+    std::set<EntityWrapperPtr> myPoints; ///< coincident points
+    std::set<EntityWrapperPtr> myExternalPoints; //< external points coincident to other points
+    std::set<EntityWrapperPtr> myFeatures; ///< other entities containing points
+  };
+
+  /// \brief Search the group of coincidences containing given entity.
+  ///        Searches points only.
+  std::list<CoincidentEntities>::iterator findGroupOfCoincidence(const EntityWrapperPtr& theEntity);
+
+  /// \brief Add entity to group of coincidences
+  /// \reutrn \c true if the entity is added, thus the coincidence is new
+  bool addToGroupOfCoincidence(CoincidentEntities& theGroup, const EntityWrapperPtr& theEntity);
 
 private:
-  std::list<std::set<EntityWrapperPtr> > myCoincident; ///< list of coincidences
+  std::list<CoincidentEntities> myCoincident; ///< list of coincidences
 };
 
 #endif