<div dir="ltr"><div dir="ltr">Hello list,<div><br></div><div>    I m trying to create a very, very simple 2D unstructured grid but every time I run my script - no matter what modifications I do - Python crashes hard with a Windows message "Python has stopped working...".</div><div><br></div><div>A simplified version of my grid is in the picture below (done in Excel, sorry...):</div><div><br></div><div><div><img src="cid:ii_jmj8jtx30" alt="image.png" width="481" height="289"><br></div></div><div><br></div><div>I attach a copy of my script below. Could anyone offer some suggestions on what I am doing wrong? I am using VTK 7.1.0 on Windows 7 64 bit, Python 2.7 64 bit - VTK comes from Christophe Gohlke very useful Python binary wheels.</div><div><br></div><div>Thank you in advance for your help.</div><div><br></div><div>Andrea.</div><div><br></div><div><br></div><div># -- BEGIN CODE -- #</div><div><br></div><div><div>import numpy</div><div>import vtk</div><div><br></div><div>import vtk.util.numpy_support as numpy_support</div><div><br></div><div># X, Y coordinates of a simple grid - Z is zero</div><div><br></div><div>X = [600.4957421, 600.5, 600.5, 600.4957421, 600.4913048, 600.5,</div><div>     600.5, 600.4957421, 600.4913048, 600.4868674, 600.5, 600.5,</div><div>     600.4913048, 600.4868674, 600.4824301, 600.5, 600.5, 600.4868674,</div><div>     600.4824301, 600.4779928, 600.5, 600.5, 600.4824301, 600.4779928,</div><div>     600.4735554, 600.5, 600.5, 600.4779928, 600.4735554]</div><div><br></div><div>Y = [2940.5, 2940.5, 2940.404044, 2940.5, 2940.6, 2940.6, 2940.5,</div><div>     2940.5, 2940.6, 2940.7, 2940.7, 2940.6, 2940.6, 2940.7, 2940.8,</div><div>     2940.8, 2940.7, 2940.7, 2940.8, 2940.9, 2940.9, 2940.8, 2940.8,</div><div>     2940.9, 2941, 2941, 2940.9, 2940.9, 2941]</div><div><br></div><div># First face is triangular, everything else is a 4-sided polygon</div><div>IDS = [range(4)]</div><div>IDS += numpy.split(numpy.arange(4, len(X)), 5)</div><div><br></div><div>npoints = len(X)</div><div>matrix = numpy.zeros((npoints, 3), numpy.float32)</div><div><br></div><div>matrix[:, 0] = X</div><div>matrix[:, 1] = Y</div><div><br></div><div># Create the grid points</div><div>vtk_pts = vtk.vtkPoints()</div><div>vtk_pts.SetData(numpy_support.numpy_to_vtk(matrix, deep=1))</div><div><br></div><div># Create the unstructured grid</div><div>grid = vtk.vtkUnstructuredGrid()</div><div>grid.SetPoints(vtk_pts)</div><div><br></div><div># Allocate space for the cells in the grid</div><div>nc = len(IDS)</div><div>grid.Allocate(nc)</div><div><br></div><div># Loop through all cells</div><div>for i in xrange(nc):</div><div>    cell_ids = IDS[i]</div><div>    ncoords = len(cell_ids)</div><div>    grid.InsertNextCell(vtk.VTK_POLYGON, ncoords, cell_ids)</div><div><br></div><div>print grid.GetNumberOfCells(), nc</div><div><br></div><div>mapper = vtk.vtkDataSetMapper()</div><div>mapper.SetInputData(grid)</div><div><br></div><div>actor = vtk.vtkActor()</div><div>actor.SetMapper(mapper)</div><div><br></div><div>ren = vtk.vtkRenderer()</div><div>renWin = vtk.vtkRenderWindow()</div><div>renWin.AddRenderer(ren)</div><div>iren = vtk.vtkRenderWindowInteractor()</div><div>iren.SetRenderWindow(renWin)</div><div><br></div><div># Add the actors to the renderer, set the background and size</div><div>ren.AddActor(actor)</div><div>ren.SetBackground(0, 0, 0)</div><div><br></div><div># This allows the interactor to initalize itself. It has to be</div><div># called before an event loop.</div><div>iren.Initialize()</div><div><br></div><div>ren.ResetCamera()</div><div>renWin.Render()</div><div><br></div><div># Start the event loop.</div><div>iren.Start()</div></div><div><br></div><div><br></div></div></div>