1 // Copyright (C) 2017-20xx CEA/DEN, EDF R&D
3 // File: PlaneGCSSolver_UpdateCoincidence.h
4 // Created: 17 Feb 2017
5 // Author: Artem ZHIDKOV
7 #ifndef PlaneGCSSolver_UpdateCoincidence_H_
8 #define PlaneGCSSolver_UpdateCoincidence_H_
10 #include <PlaneGCSSolver_Update.h>
11 #include <PlaneGCSSolver_EntityWrapper.h>
17 /** \class PlaneGCSSolver_UpdateCoincidence
19 * \brief Send events to listeners about changing a constraint
21 class PlaneGCSSolver_UpdateCoincidence : public PlaneGCSSolver_Update
24 PlaneGCSSolver_UpdateCoincidence(UpdaterPtr theNext = UpdaterPtr())
25 : PlaneGCSSolver_Update(theNext)
28 virtual ~PlaneGCSSolver_UpdateCoincidence() {}
30 /// \brief Group of entities, processed by this kind of updater
31 static const std::string& GROUP()
33 static const std::string TYPE("Coincidence");
37 /// \brief Attach listener
38 /// \param theObserver [in] object which want to receive notifications
39 /// \param theType [in] receive notifications about changing objects
40 /// of theType and their derivatives
41 virtual void attach(SketchSolver_Constraint* theObserver, const std::string& theType);
43 /// \brief Send notification about update of the feature to all interested
44 virtual void update(const FeaturePtr& theFeature);
46 /// \brief Set coincidence between two given entities
47 /// \return \c true if the entities does not coincident yet
48 bool addCoincidence(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2);
50 /// \brief Verifies the point is coincident to the feature
51 /// \return \c true if the point is on the feature
52 bool isPointOnEntity(const EntityWrapperPtr& thePoint, const EntityWrapperPtr& theEntity);
55 /// \brief Container for collecting and operating coincident entities
56 class CoincidentEntities
59 CoincidentEntities(const EntityWrapperPtr& theEntity1,
60 const EntityWrapperPtr& theEntity2);
62 /// Verify the entity is already in the list
63 bool isExist(const EntityWrapperPtr& theEntity) const;
64 /// Verify the point is already in the list
65 bool isExist(const GCS::Point& thePoint) const;
67 /// Add entity to group
68 bool add(const EntityWrapperPtr& theEntity);
70 /// Remove entity from group
71 void remove(const EntityWrapperPtr& theEntity);
74 void merge(const CoincidentEntities& theOther);
77 std::set<EntityWrapperPtr> myPoints; ///< coincident points
78 std::set<EntityWrapperPtr> myExternalPoints; //< external points coincident to other points
79 std::set<EntityWrapperPtr> myFeatures; ///< other entities containing points
82 /// \brief Search the group of coincidences containing given entity.
83 /// Searches points only.
84 std::list<CoincidentEntities>::iterator findGroupOfCoincidence(const EntityWrapperPtr& theEntity);
86 /// \brief Add entity to group of coincidences
87 /// \reutrn \c true if the entity is added, thus the coincidence is new
88 bool addToGroupOfCoincidence(CoincidentEntities& theGroup, const EntityWrapperPtr& theEntity);
91 std::list<CoincidentEntities> myCoincident; ///< list of coincidences