<div dir="ltr">Hi ,<br><div class="gmail_quote"><div dir="ltr"><div><br></div><div>I am having problem with VTK's setCell for creating unstructured grid from a numpy array. I used following two methods to create cells:</div>
<div> - using numpy_to_vtkIdTypeArray, which result in cell</div><div> - using vtkCellArray and filling it with individual cell's poit list. Results stored in cells2 in the code</div><div>But both method return following error:</div>
<div><br></div><div> # Create points</div><div> grid_array = ...</div><div> grid_array = grid_array.reshape(8*Nz*Ny*Nx,3)</div><div><div> vtk_points = vtk.vtkPoints()</div>
<div> grid = vtk.vtkUnstructuredGrid()</div><div> points = VN.numpy_to_vtk(grid_array, deep=True)</div><div> vtk_points.SetData(points)</div><div> grid.SetPoints(vtk_points)</div></div><div>
<br></div><div><br></div><div><div> # Create cells</div><div> cell_ids = np.arange(0,8*Nx*Ny*Nz, dtype=np.int64).reshape(Nx*Ny*Nz, 8)</div><div> cells = VN.numpy_to_vtkIdTypeArray(cell_ids, deep=True) </div>
<div> cells2 = vtk.vtkCellArray()</div><div> for cell in cell_ids:</div><div> pids = vtk.vtkIdList()</div><div> for p in cell:</div><div> pids.InsertNextId(p)</div><div>
cells2.InsertNextCell(pids)</div>
<div> print cells</div><div> print cells2</div><div> # Assign cells to grid and create unstructured grid. Error comes after this:</div><div> grid.setCells(vtk.VTK_HEXAHEDRON, cells2) # 12==vtk.VTK_HEXAHEDRON</div>
<div><br></div><div>AttributeError: setCells</div><div><br></div><div><br></div><div>I really appriciate your help. I spent 2 days on this problem googled it but couldn't find anything useful.</div>
<div><br></div><div>Regards,</div><div><br></div><div>Aso</div></div></div>
</div><br></div>