28 MeshType =
itk.Mesh[PixelType, Dimension]
34 for point_id
in range(number_of_points):
35 point = [float(point_id), np.log(float(point_id) + np.finfo(float).eps)]
36 mesh.SetPoint(point_id, point)
38 number_of_cells = number_of_points - 1
41 cells_array = np.zeros([number_of_cells, 2], dtype=np.uint64)
43 for cell_id
in range(number_of_cells):
44 cells_array[cell_id][0] = cell_id
45 cells_array[cell_id][1] = cell_id + 1
47 cells_vector = itk.vector_container_from_array(cells_array.flatten())
50 mesh.SetCellsArray(cells_vector, itk.CommonEnums.CellGeometry_LINE_CELL)
52 print(
"Points = ", mesh.GetNumberOfPoints())
53 print(
"Cells = ", mesh.GetNumberOfCells())
59 for cell_id
in range(number_of_cells):
60 mesh.SetCellData(cell_id, cell_id * cell_id)
64 cell_data = mesh.GetCellData()
67 cell_data_np = itk.array_from_vector_container(cell_data)
69 for cell_id
in range(number_of_cells):
73 print(
"Cell ", cell_id,
" = ", cell_data.GetElement(cell_id))
75 temp = cell_data_np[cell_id]
76 print(
"Cell ", cell_id,
" = ", cell_data_np[cell_id])