@@ -579,22 +579,31 @@ void ImageSimulationMesh::resolve_intersections(const std::vector<CellTag>& inte
579579 m_envelope.reset ();
580580}
581581
582- void ImageSimulationMesh::replace_tags (const std::vector<CellTag>& tags_in, const CellTag& tag_out)
582+ void ImageSimulationMesh::replace_tags (
583+ const std::vector<CellTag>& tags_in,
584+ const std::vector<CellTag>& tags_out)
583585{
584586 for (const Tuple& t : get_tets ()) {
585587 CellTag& tags = m_tet_attribute[t.tid (*this )].tags ;
586- bool found_some = false ;
587- for (const CellTag& tag : tags_in) {
588- if (set_includes (tags, tag)) {
589- found_some = true ;
590- // remove tag from tags
591- for (const size_t t : tag) {
592- tags.erase (t);
588+ std::vector<bool > found_tags (tags_in.size (), false );
589+ for (size_t i = 0 ; i < tags_in.size (); ++i) {
590+ if (set_includes (tags, tags_in[i])) {
591+ found_tags[i] = true ;
592+ }
593+ }
594+ // remove "tags_in" from tags
595+ for (size_t i = 0 ; i < tags_in.size (); ++i) {
596+ if (found_tags[i]) {
597+ for (const int64_t tt : tags_in[i]) {
598+ tags.erase (tt);
593599 }
594600 }
595601 }
596- if (found_some) {
597- tags.insert (tag_out.begin (), tag_out.end ());
602+ // add "tags_out" to tags
603+ for (size_t i = 0 ; i < tags_out.size (); ++i) {
604+ if (found_tags[i]) {
605+ tags.insert (tags_out[i].begin (), tags_out[i].end ());
606+ }
598607 }
599608 }
600609
0 commit comments