File indexing completed on 2025-08-06 08:17:37
0001 #include "GlobalVertexMapv1.h"
0002
0003 #include "GlobalVertex.h"
0004 #include "GlobalVertexMap.h"
0005
0006 #include <utility> // for pair, make_pair
0007
0008 GlobalVertexMapv1::~GlobalVertexMapv1()
0009 {
0010 clear();
0011 }
0012
0013 void GlobalVertexMapv1::identify(std::ostream& os) const
0014 {
0015 os << "GlobalVertexMapv1: size = " << _map.size() << std::endl;
0016 for (auto& m : _map)
0017 {
0018 m.second->identify(os);
0019 }
0020 return;
0021 }
0022
0023 void GlobalVertexMapv1::clear()
0024 {
0025 for (const auto& iter : _map)
0026 {
0027 delete iter.second;
0028 }
0029 _map.clear();
0030 return;
0031 }
0032
0033 const GlobalVertex* GlobalVertexMapv1::get(unsigned int id) const
0034 {
0035 ConstIter iter = _map.find(id);
0036 if (iter == _map.end())
0037 {
0038 return nullptr;
0039 }
0040 return iter->second;
0041 }
0042
0043 GlobalVertex* GlobalVertexMapv1::get(unsigned int id)
0044 {
0045 Iter iter = _map.find(id);
0046 if (iter == _map.end())
0047 {
0048 return nullptr;
0049 }
0050 return iter->second;
0051 }
0052
0053 GlobalVertex* GlobalVertexMapv1::insert(GlobalVertex* clus)
0054 {
0055 unsigned int index = clus->get_id();
0056 _map[index] = clus;
0057 return _map[index];
0058 }
0059
0060 void GlobalVertexMapv1::CopyTo(GlobalVertexMap* to_global)
0061 {
0062 for (auto const& it : _map)
0063 {
0064 GlobalVertex *glvtx = dynamic_cast<GlobalVertex*>(it.second->CloneMe());
0065 glvtx->clear_vtxs();
0066 glvtx->set_id(to_global->size());
0067 for (GlobalVertex::ConstVertexIter iter = it.second->begin_vertexes(); iter != it.second->end_vertexes(); ++iter)
0068 {
0069 for (auto& vertex : iter->second)
0070 {
0071 glvtx->clone_insert_vtx(iter->first, vertex);
0072 to_global->insert(glvtx);
0073 }
0074 }
0075 }
0076 }