I'm gonna cry soon if I don't get this done. > <<div><br></div><div>I have a .txt file of points and connectivity data. How do I read this in as an unstructuredGrid? </div><div>How do I use vtkCellArray?</div>
<div><br></div><div>At the moment, I have this:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">with open('C:\\Qt\\SimLCM\\Default\\Data_Input_Geometry.txt', 'r') as f:<br>
#with open('C:\\Qt\\SimLCM\\Default\\Data_Input_Geometry_trial2.txt', 'r') as f:<br> <br> meshPoints = vtk.vtkPoints()<br> # Can't use voxels, because they specify corners that are perpendicular<br>
<br> # Get number of points<br> no_points = f.readline()<br> no_points = int(no_points)<br> print no_points # Check reading<br> <br> # Set number of points in mesh<br> meshPoints.SetNumberOfPoints(no_points)<br>
<br> for i in range(no_points):<br> # Get coord info for each point<br> point_info = f.readline().split() # I need to split, before I assign to point_coord<br> # else the whole thing is split into single numbers<br>
#print point_info # Check reading<br> <br> point_ID = (int(point_info[0])-1) # -1 because the IDs need to start with 0.<br> point_x = float(point_info[1])<br> point_y = float(point_info[2])<br>
point_z = float(point_info[3])<br> print point_ID, point_x, point_y, point_z<br> # Set coord info in mesh<br> meshPoints.InsertPoint(point_ID, point_x, point_y, point_z)<br> <br># Don't need the input file anymore. Get on with the display<br>
aMeshGrid = vtk.vtkUnstructuredGrid()<br>aMeshGrid.Allocate(180,1)<br><br>cellTypes = vtk.vtkCellTypes()<br>aMeshGrid.InsertNextCell(cellTypes,[1,2,13])<br>aMeshGrid.SetPoints(meshPoints)</blockquote><div><br></div><div>
etc...</div>
<div><br></div><div>But this second last line gives an error saying: TypeError: An Integer is required. </div><div><br></div><div>PLEASE help! Please...<br>-- <br>Helvin <br><br>"Though the world may promise me more, I'm just made to be filled with the Lord."<br>
</div>