[vtkusers] vtkMergeCells/corrupt k-d tree

Katie Grayshan kgrayshan at hotmail.com
Tue Jun 27 14:47:13 EDT 2006


I'm trying to implement vtkMergeCells to merge several structured grids into one
unstructured grid, and it isn't working for some cases. I've created a simplified
version of my problem below. The error I keep getting  is:

     " ERROR: In \cygwin\...\Vtk\Graphics\vtkKdTree.cxx, line 1860 vtkKdTree [00E14DC0]:
       vtkKdTree:: BuildMapForDuplicatePoints corrupt k-d tree"

The sample case I've created below for Python uses the Numeric module. If it would
be easier, I can generate an additional case without this module- just let me know.

Any help/suggestions/ideas  would be GREATLY appreciated. If there is anything I can
do to make it easier for you to help me, let me know.

Have I missed something?

Thank you,
Katelyn Grayshan
VTK/Python Newbie

import Numeric as N
import vtk

n = 16

a = -1. + ( 2. /( n-1.0 ) )*N.arange( 0, n )
A = N.multiply.outer( N.ones( ( n, ), typecode = N.Float64 ), a )
B = N.multiply.outer( a, N.ones( ( n, ), typecode = N.Float64 ) )
C = N.array( [ [ 1. ]*n ]*n )

R = N.sqrt( A**2 + B**2 + C**2 )
x, y, z = ( A/R, B/R, C/R )

xyz = N.zeros( ( n*n, 3 ), N.Float64 )
xyz[ :,0 ] = x.flat
xyz[ :,1 ] = y.flat
xyz[ :,2 ] = z.flat

vtk_xyz = vtk.vtkDoubleArray( )
vtk_xyz.SetNumberOfTuples( n*n )
vtk_xyz.SetNumberOfComponents( 3 )
vtk_xyz.SetVoidArray( xyz, n*n*3, 1 )

vtk_pts = vtk.vtkPoints( )
vtk_pts.SetNumberOfPoints( n*n )
vtk_pts.SetDataTypeToDouble( )
vtk_pts.SetData( vtk_xyz )
vtk_pts.Modified( )

vtk_z = vtk.vtkDoubleArray( )
vtk_z.SetNumberOfComponents( 1 )
vtk_z.SetNumberOfTuples( n*n )
vtk_z.SetVoidArray( z, n*n, 1 )

vtk_SGrid = vtk.vtkStructuredGrid( )
vtk_SGrid.SetDimensions( n, n, 1 )
vtk_SGrid.SetPoints( vtk_pts )
vtk_SGrid.GetPointData( ).SetScalars( vtk_z )

vtk_lut = vtk.vtkLookupTable( )
vtk_lut.SetHueRange( 0.667, 0.0 )

vtk_USGrid = vtk.vtkUnstructuredGrid( )
vtk_merge = vtk.vtkMergeCells( )
vtk_merge.SetUnstructuredGrid( vtk_USGrid ) 
vtk_merge.PointMergeTolerance = 10e-4
vtk_merge.MergeDuplicatePointsOn( )
vtk_merge.SetTotalNumberOfPoints( n**2 )
vtk_merge.SetTotalNumberOfCells( ( n-1 )**2 )
vtk_merge.SetTotalNumberOfDataSets( 1 )
vtk_merge.MergeDataSet( vtk_SGrid )
vtk_merge.Finish( )

dmin,dmax = vtk_USGrid.GetScalarRange( )

vtk_gridFilter = vtk.vtkContourGrid( )
vtk_gridFilter.SetInput( vtk_USGrid )
vtk_gridFilter.GenerateValues( 11, dmin, dmax )
vtk_gridFilter.Modified( )

vtk_mapper = vtk.vtkPolyDataMapper( )
vtk_mapper.SetLookupTable( vtk_lut )
vtk_mapper.SetInput( vtk_gridFilter.GetOutput( ) )

vtk_actor = vtk.vtkActor( )
vtk_actor.SetMapper( vtk_mapper )

vtk_ren = vtk.vtkRenderer( )
vtk_ren.AddActor( vtk_actor )

vtk_win = vtk.vtkRenderWindow( )
vtk_win.AddRenderer( vtk_ren )
vtk_win.SetSize( 600, 600 )

vtk_iren = vtk.vtkRenderWindowInteractor( )
vtk_iren.SetRenderWindow( vtk_win )
vtk_iren.Initialize( )

print 'n=%d n=%d' % ( n, n, )
vtk_win.Render( )
vtk_iren.Start( )


_________________________________________________________________
Add photos, news, and blogs about the World Cup to your Live.com homepage!
http://www.live.com/getstarted


More information about the vtkusers mailing list