Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_UpdateCoincidence.h
1 // Copyright (C) 2017-20xx CEA/DEN, EDF R&D
2
3 // File:    PlaneGCSSolver_UpdateCoincidence.h
4 // Created: 17 Feb 2017
5 // Author:  Artem ZHIDKOV
6
7 #ifndef PlaneGCSSolver_UpdateCoincidence_H_
8 #define PlaneGCSSolver_UpdateCoincidence_H_
9
10 #include <PlaneGCSSolver_Update.h>
11 #include <SketchSolver_IEntityWrapper.h>
12
13 #include <map>
14
15 /** \class   PlaneGCSSolver_UpdateCoincidence
16  *  \ingroup Plugins
17  *  \brief   Send events to listeners about changing a constraint
18  */
19 class PlaneGCSSolver_UpdateCoincidence : public PlaneGCSSolver_Update
20 {
21 public:
22   PlaneGCSSolver_UpdateCoincidence(UpdaterPtr theNext = UpdaterPtr())
23     : PlaneGCSSolver_Update(theNext)
24   {}
25
26   virtual ~PlaneGCSSolver_UpdateCoincidence() {}
27
28   /// \brief Group of entities, processed by this kind of updater
29   static const std::string& GROUP()
30   {
31     static const std::string TYPE("Coincidence");
32     return TYPE;
33   }
34
35   /// \brief Attach listener
36   /// \param theObserver [in]  object which want to receive notifications
37   /// \param theType     [in]  receive notifications about changing objects
38   ///                          of theType and their derivatives
39   virtual void attach(SketchSolver_Constraint* theObserver, const std::string& theType);
40
41   /// \brief Send notification about update of the feature to all interested
42   virtual void update(const FeaturePtr& theFeature);
43
44   /// \brief Verifies the entities are not coincident yet
45   /// \return \c true if the entities does not coincident
46   bool checkCoincidence(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2);
47
48 private:
49   /// \brief Container for collecting and operating coincident entities
50   class CoincidentEntities
51   {
52   public:
53     CoincidentEntities(const EntityWrapperPtr& theEntity1,
54                        const EntityWrapperPtr& theEntity2);
55
56     /// Verify the entity is already in the list
57     bool isExist(const EntityWrapperPtr& theEntity) const;
58     /// Check the coincidence is not in list yet
59     bool isNewCoincidence(const EntityWrapperPtr& theEntityExist,
60                           const EntityWrapperPtr& theOtherEntity);
61     bool isNewCoincidence(const EntityWrapperPtr& theEntityExist,
62                           const CoincidentEntities& theOtherGroup,
63                           const EntityWrapperPtr& theEntityInOtherGroup);
64
65   private:
66     bool hasExternal() const;
67
68   private:
69     /// external entity and set of entities connected to it
70     std::map<EntityWrapperPtr, std::set<EntityWrapperPtr> > myExternalAndConnected;
71   };
72
73   std::list<CoincidentEntities> myCoincident; ///< list of coincidences
74 };
75
76 #endif