2727
2828#include < geode/basic/attribute.hpp>
2929#include < geode/basic/attribute_manager.hpp>
30+ #include < geode/basic/logger.hpp>
3031#include < geode/basic/pimpl_impl.hpp>
3132
3233#include < geode/mesh/core/edged_curve.hpp>
@@ -78,12 +79,17 @@ namespace geode
7879 }
7980
8081 index_t identify_elements ()
82+ {
83+ return identify_elements ( identification_.size () );
84+ }
85+
86+ index_t identify_elements ( index_t nb_max_elements )
8187 {
8288 for ( const auto p : Indices{ identification_ } )
8389 {
8490 if ( identifier ( p ) == NO_ID )
8591 {
86- propagate ( p, nb_components_ );
92+ propagate ( p, nb_components_, nb_max_elements );
8793 nb_components_++;
8894 }
8995 }
@@ -114,11 +120,13 @@ namespace geode
114120 }
115121
116122 private:
117- void propagate ( index_t element_from, index_t tag_id )
123+ void propagate (
124+ index_t element_from, index_t tag_id, index_t nb_max_elements )
118125 {
126+ index_t counter{ 0 };
119127 std::queue< index_t > queue;
120128 queue.emplace ( element_from );
121- while ( !queue.empty () )
129+ while ( !queue.empty () && counter < nb_max_elements )
122130 {
123131 const auto cur_el = queue.front ();
124132 queue.pop ();
@@ -127,6 +135,7 @@ namespace geode
127135 continue ;
128136 }
129137 identification_[cur_el] = tag_id;
138+ counter++;
130139 add_adjacents ( cur_el, queue );
131140 }
132141 }
@@ -176,6 +185,11 @@ namespace geode
176185 return impl_->identify_elements ();
177186 }
178187
188+ index_t GraphIdentifier::identify_vertices ( index_t nb_max_vertices )
189+ {
190+ return impl_->identify_elements ( nb_max_vertices );
191+ }
192+
179193 index_t GraphIdentifier::vertex_identifier ( index_t vertex_id ) const
180194 {
181195 return impl_->identifier ( vertex_id );
0 commit comments