Follow-up from "[DataExplorer] Include Vtu2Grid"
The following discussion from !4651 (merged) should be addressed:
-
@TomFischer started a discussion: (+3 comments)
Reuse functions to estimate expected voxel.
Also extract this part:
std::array<std::size_t, 3> const dims =
VoxelGridFromMesh::getNumberOfVoxelPerDimension(ranges, cellsize);
std::unique_ptr<MeshLib::Mesh> grid(
generateRegularHexMesh(dims[0], dims[1], dims[2], cellsize[0],
cellsize[1], cellsize[2], min, "grid"));
if (grid == nullptr)
{
OGS_FATAL(
"Could not generate regular hex mesh. With parameters dims={} {} "
"{}, "
"cellsize={} {} {}",
dims[0], dims[1], dims[2], cellsize[0], cellsize[1], cellsize[2]);
}
std::vector<int>* cell_ids =
grid->getProperties().createNewPropertyVector<int>(
VoxelGridFromMesh::cell_id_name, MeshLib::MeshItemType::Cell, 1);
if (cell_ids == nullptr)
{
OGS_FATAL("Could not create cell ids.");
}
*cell_ids = VoxelGridFromMesh::assignCellIds(mesh, min, dims, cellsize);
if (!VoxelGridFromMesh::removeUnusedGridCells(mesh, grid))
{
return;
}
VoxelGridFromMesh::mapMeshArraysOntoGrid(mesh, grid);
if (grid == nullptr)
{
OGSError::box("No voxelgrid could be created from the mesh.");
return;
}
to a new function called generateVoxelGrid
Edited by Julian Heinze