1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef PlaneGCSSolver_UpdateCoincidence_H_
22 #define PlaneGCSSolver_UpdateCoincidence_H_
24 #include <PlaneGCSSolver_Update.h>
25 #include <PlaneGCSSolver_EntityWrapper.h>
31 /** \class PlaneGCSSolver_UpdateCoincidence
33 * \brief Send events to listeners about changing a constraint
35 class PlaneGCSSolver_UpdateCoincidence : public PlaneGCSSolver_Update
38 PlaneGCSSolver_UpdateCoincidence(UpdaterPtr theNext = UpdaterPtr())
39 : PlaneGCSSolver_Update(theNext)
42 virtual ~PlaneGCSSolver_UpdateCoincidence() {}
44 /// \brief Group of entities, processed by this kind of updater
45 static const std::string& GROUP()
47 static const std::string TYPE("Coincidence");
51 /// \brief Attach listener
52 /// \param theObserver [in] object which want to receive notifications
53 /// \param theType [in] receive notifications about changing objects
54 /// of theType and their derivatives
55 virtual void attach(SketchSolver_Constraint* theObserver, const std::string& theType);
57 /// \brief Send notification about update of the feature to all interested
58 virtual void update(const FeaturePtr& theFeature);
60 /// \brief Set coincidence between two given entities
61 /// \return \c true if the entities does not coincident yet
62 bool addCoincidence(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2);
64 /// \brief Verifies the point is coincident to the feature
65 /// \return \c true if the point is on the feature
66 bool isPointOnEntity(const EntityWrapperPtr& thePoint, const EntityWrapperPtr& theEntity);
69 /// \brief Container for collecting and operating coincident entities
70 class CoincidentEntities
73 CoincidentEntities(const EntityWrapperPtr& theEntity1,
74 const EntityWrapperPtr& theEntity2);
76 /// Verify the entity is already in the list
77 bool isExist(const EntityWrapperPtr& theEntity) const;
78 /// Verify the point is already in the list
79 bool isExist(const GCS::Point& thePoint) const;
81 /// Add entity to group
82 bool add(const EntityWrapperPtr& theEntity);
84 /// Remove entity from group
85 void remove(const EntityWrapperPtr& theEntity);
88 void merge(const CoincidentEntities& theOther);
90 /// Returns any of external points
91 EntityWrapperPtr externalPoint() const;
94 std::set<EntityWrapperPtr> myPoints; ///< coincident points
95 std::set<EntityWrapperPtr> myExternalPoints; //< external points coincident to other points
96 std::set<EntityWrapperPtr> myFeatures; ///< other entities containing points
99 /// \brief Search the group of coincidences containing given entity.
100 /// Searches points only.
101 std::list<CoincidentEntities>::iterator findGroupOfCoincidence(const EntityWrapperPtr& theEntity);
103 /// \brief Add entity to group of coincidences
104 /// \reutrn \c true if the entity is added, thus the coincidence is new
105 bool addToGroupOfCoincidence(CoincidentEntities& theGroup, const EntityWrapperPtr& theEntity);
108 std::list<CoincidentEntities> myCoincident; ///< list of coincidences