Commit 2c3d6986 authored by T.J. Corona's avatar T.J. Corona

smtk::mesh::ExtractTessellation: use hash map for point id lookup

The method smtk::mesh::PointSet::find is extremely slow, and should be
used only as a last resort. This commit replaces a call to find()
within a tight loop with the construction and repeated query of a hash
map.

NOTE: with this update, the mesh session now loads large datasets as
quickly as the VTK session.
parent 040b7ee9
......@@ -341,6 +341,15 @@ void extractTessellationInternal(
addCellLen = detail::smtkToVTKConn;
}
//construct a map to better search for point ids
std::unordered_map<std::int64_t, std::size_t> pointMap;
auto it = smtk::mesh::rangeElementsBegin(ps.range());
auto end = smtk::mesh::rangeElementsEnd(ps.range());
for (std::size_t counter = 0; it != end; ++it, ++counter)
{
pointMap[*it] = counter;
}
int numPts = 0;
const smtk::mesh::Handle* pointIds;
std::size_t conn_index = 0;
......@@ -375,11 +384,10 @@ void extractTessellationInternal(
for (int i = 0; i < numPts; ++i)
{
//call find on the pointset to determine the proper index for the
//point id. the point id value is based off the global point id, and
//we need to transform it to a relative id based of the pointset
//that was passed in
tess.m_connectivity[conn_index + i] = ps.find(pointIds[i]);
//determine the proper index for the point id. the point id value is
//based off the global point id, and we need to transform it to a
//relative id based of the pointset that was passed in
tess.m_connectivity[conn_index + i] = pointMap[pointIds[i]];
}
tess.m_cellTypes[index] = convertCellTypeFunction(ctype);
......@@ -393,11 +401,10 @@ void extractTessellationInternal(
for (int i = 0; i < numPts; ++i)
{
//call find on the pointset to determine the proper index for the
//point id. the point id value is based off the global point id, and
//we need to transform it to a relative id based of the pointset
//that was passed in
tess.m_connectivity[conn_index + i] = ps.find(pointIds[i]);
//determine the proper index for the point id. the point id value is
//based off the global point id, and we need to transform it to a
//relative id based of the pointset that was passed in
tess.m_connectivity[conn_index + i] = pointMap[pointIds[i]];
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment