vtk单元类型:https://blog.csdn.net/calmreason/article/details/124268501
新的填充方式相对于,创建单元对象的方式效率更高,比绑定单元的方式更灵活。
vtk新的填充单元方式(非多面体)
vtkNew<vtkUnstructuredGrid> unstruct;
std::vector<std::vector>cells;//单元和点id
unstruct->Allocate(cells.size());//初始化单元大小
for (int i = 0 ;i< cells.size();i++)
{
vtkNew<vtkIdList> cellIDdList;//填充单元点id数据
for (int curri = 0; curri < cells[i].size(); curri++)
{
cellIDdList->InsertNextId(cells[i][curri]);
}
unstruct->InsertNextCell(VTK_POLYGON, cellIDdList->GetNumberOfIds(), cellIDdList->GetPointer(0));//填充单元,1.单元类型,2.单元点数,3数据指针
}
vtk新的填充单元方式(多面体)
多面体单元数据需要面和点,点构成面,面构成体。
vtkNew<vtkUnstructuredGrid> unstruct;
std::vector<std::vector<vtkIdType>> cells;//每个单元的面id数据
std::vector<std::vector<vtkIdType>> faces;//每个面的点id数据
unstruct->Allocate(cells.size());//初始化单元大小
for (int i = 0; i < cells.size();i++)
{
const auto& cell = cells[i];
vtkNew<vtkIdList> polyhedron;
for (auto& aFaceIndex : cell )
{
const auto& aFace = faces[aFaceIndex];
const auto faceSize = static_cast<vtkIdType>(aFace.size());//每个面点数
polyhedron->InsertNextId(faceSize);
for (auto& aVertexIndex : aFace)
{
polyhedron->InsertNextId(aVertexIndex);//填充点id数据
}
}
unstruct->InsertNextCell(VTK_POLYHEDRON, cell .size(), polyhedron->GetPointer(0));//填充单元数据,2.面的数量,单元数据指针。
}
网友评论