1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef PlaneGCSSolver_UpdateCoincidence_H_
21 #define PlaneGCSSolver_UpdateCoincidence_H_
23 #include <PlaneGCSSolver_Update.h>
24 #include <PlaneGCSSolver_EntityWrapper.h>
30 /** \class PlaneGCSSolver_UpdateCoincidence
32 * \brief Send events to listeners about changing a constraint
34 class PlaneGCSSolver_UpdateCoincidence : public PlaneGCSSolver_Update
37 PlaneGCSSolver_UpdateCoincidence(UpdaterPtr theNext = UpdaterPtr())
38 : PlaneGCSSolver_Update(theNext)
41 virtual ~PlaneGCSSolver_UpdateCoincidence() {}
43 /// \brief Group of entities, processed by this kind of updater
44 static const std::string& GROUP()
46 static const std::string TYPE("Coincidence");
50 /// \brief Attach listener
51 /// \param theObserver [in] object which want to receive notifications
52 /// \param theType [in] receive notifications about changing objects
53 /// of theType and their derivatives
54 virtual void attach(SketchSolver_Constraint* theObserver, const std::string& theType);
56 /// \brief Send notification about update of the feature to all interested
57 virtual void update(const FeaturePtr& theFeature);
59 /// \brief Set coincidence between two given entities
60 /// \return \c true if the entities does not coincident yet
61 bool addCoincidence(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2);
63 /// \brief Verifies the point is coincident to the feature
64 /// \return \c true if the point is on the feature
65 bool isPointOnEntity(const EntityWrapperPtr& thePoint, const EntityWrapperPtr& theEntity);
68 /// \brief Container for collecting and operating coincident entities
69 class CoincidentEntities
72 CoincidentEntities(const EntityWrapperPtr& theEntity1,
73 const EntityWrapperPtr& theEntity2);
75 /// Verify the entity is already in the list
76 bool isExist(const EntityWrapperPtr& theEntity) const;
77 /// Verify the point is already in the list
78 bool isExist(const GCS::Point& thePoint) const;
80 /// Add entity to group
81 bool add(const EntityWrapperPtr& theEntity);
83 /// Remove entity from group
84 void remove(const EntityWrapperPtr& theEntity);
87 void merge(const CoincidentEntities& theOther);
89 /// Returns any of external points
90 EntityWrapperPtr externalPoint() const;
93 std::set<EntityWrapperPtr> myPoints; ///< coincident points
94 std::set<EntityWrapperPtr> myExternalPoints; //< external points coincident to other points
95 std::set<EntityWrapperPtr> myFeatures; ///< other entities containing points
98 /// \brief Search the group of coincidences containing given entity.
99 /// Searches points only.
100 std::list<CoincidentEntities>::iterator findGroupOfCoincidence(const EntityWrapperPtr& theEntity);
102 /// \brief Add entity to group of coincidences
103 /// \reutrn \c true if the entity is added, thus the coincidence is new
104 bool addToGroupOfCoincidence(CoincidentEntities& theGroup, const EntityWrapperPtr& theEntity);
107 std::list<CoincidentEntities> myCoincident; ///< list of coincidences