Size-dependent time cost of Delaunay3D filter

Hi,

I’m facing size (or unit)-dependent time costs when using Delaunay3D filter on a discrete scalar field, and do not understand those.

I’m actually working on the distance field to some sphere, for gridpoints on a structured (regular here) grid. Using the exact same number of gridpoints, but different grid spacing and sphere radii, I have completely different time costs of the Delaunay3D filter.

The behavior is illustrated by the following Python code (I launched it with IPython 5.5.0 / Python 2.7.17 on Ubuntu 18.04):

# writing in a structured grid the distance field to a sphere of some radius, and testing size-dependance of treatment costs
import time,vtk
radVal = [0.001,0.1] # considered sphere radius values
def distToSph(point,radius):
    '''Returns the signed distance between a [x,y,z] point and a sphere of some radius'''
    return (point[0]**2+point[1]**2+point[2]**2)**0.5 - radius

for rad in radVal: # considering the 2 radius values
    sgrid = vtk.vtkStructuredGrid() # a 23*23*23 grid enclosing the sphere of radius rad in both cases
    sgrid.SetDimensions([23,23,23])
    gridPts = vtk.vtkPoints()
    gridPts.Allocate(23**3)
    distField = vtk.vtkDoubleArray() # the scalar field stored on the grid: shortest distance to the sphere of radius rad
    distField.SetNumberOfComponents(1)
    for k in range(23):
        for j in range(23):
            for i in range(23):
                gp = [(-1.1+i/10.)*rad,(-1.1+j/10.)*rad,(-1.1+k/10.)*rad]
                gridPts.InsertNextPoint(gp)
                distField.InsertNextValue(distToSph(gp,rad))
                sgrid.SetPoints(gridPts)
                sgrid.GetPointData().SetScalars(distField)
    # Delaunay filter to the data:
    t1 = time.time()
    delaunay = vtk.vtkDelaunay3D()
    delaunay.SetInputData(sgrid)
    delaunay.Update()
    t2 = time.time()
    print 'For radius =',rad,'Delaunay filter took',t2-t1,'s'

On my machine, I get as an output:

For radius = 0.001 Delaunay filter took 0.00500893592834 s
For radius = 0.1 Delaunay filter took 2.61835503578 s

The time difference surprises (and annoys…) me since there is exactly the same amount of data to process in both cases…

Hence the question: Is there a dimensional argument to the Delaunay3D filter I should use to avoid such a difference ? (more general explanations would also be welcome)

(As background information, I’m applying this filter before extracting the zero-contour and the sphere surface, which is my final goal – for more complex shapes than spheres. By the way, I know Delaunay triangulation may not be suitable for such structured mesh, but that is the best method I found for now…)