# [vtkusers] is it possible in VTK to sample a function with a non standard grid?

Roberto De Leo deleo at unica.it
Sun Jun 30 13:54:48 EDT 2002

```Hi,
I've been using VTK for 4 years for my geometrical numerical computations.
What I do is basically generating an isosurface in a [0,1]x[0,1]x[0,1] cube
and cut it with several planes [as many as ~10^4 ] to get some curves on
which later I perform some calculation.
I mostly work with a surface that is more or less a sphere centered in the
center of the cube with attached six handles coming out along the x, y
and z axes and cutting the 6 faces of the cube in 6 circles centered in the
centers of the faces.
E.g. you can get such a surface as 0-level of the function
f(x,y,z)=cos(2Pi x)+cos(2Pi y)+cos(2Pi z).

Here is my problem: is it possible in VTK to specify different
resolutions in
different areas of the cube when building an isosurface? In my case for
example
I do not care at all about having a big precision in the construction of
the part of
the surface away from the faces of the cube, that is roughly a sphere,
while
it is critical for me to have as much precision as possible in the
meshes of the
portion of the handles close to the faces.

The way I produce the isosurface is the usual one, through the
vtkSampleFunction
and vtkContourFilter classes.
Until now to increase the precision of my calculations I simply
increased the
"SampleDimensions" [I am using lately 150 as value for all 3 directions]
in the
vtkSampleFunction call, increasing the number of triangles in all single
parts
of the surface [even where I do not need that at all], but of course
this way
I make all my algorithm much slower than needed and lately I reached a
point
at which the code is just too slow to be really useful.

But I am convinced that if it were possible to set different resolutions
in different
areas of the cube, in order to have very few triangles describing the
"inner"
portion of the surface and many triangles describing the portion closest
to the faces,
then my code would speed up very much and finally allow me to procede deeper
in my study.

Therefore I'd be very interested in knowing whether somebody else out there
faced some similar problem and whether any similar feature has been or
will be
implemented soon in VTK.

Thanks a lot,
Roberto De Leo

```