SV: [vtkusers] Distances between polydata surfaces

Tron Darvann trd at
Tue Jul 4 04:48:03 EDT 2006

Hello Steve,
You can use vtkCellLocator with FindClosestPoint to find distance from a point in space to a surface.  If you wish to know the distance from all points in a polydata, you can go through all points in that polydata and find closest point on other surface.  It is quite efficient, although there exists other non-vtk implementations that are even faster.
I attach 3 examples in c++ (note that tcl does not have the method FindClosestPoint available, you would have to wrap it yourself).
Example 1.  closestp_curve2surface.cxx
Given an ASCII file of xyz coordinates for any number of points (e.g. along a line you wish to "project" down to the surface) and a target polydata surface file in .vtk format, output an ASCII file of modified xyz coordinates.
Example 2.  closestpoint_diff_unsigned.cxx
Compute ditance between two surfaces and output distances between them.  The distance is computed for each VERTEX CENTER.  If you want per vertex (point on the surface), please modify.
Example 3.  closestpoint_diff_signed.cxx  
Same as example 2, but with signed distance (sign depending on whether one surface inside or outside of the other, determined by the direction of the surface normal).
Tron Darvann
Research Engineer, PhD, 3D-Laboratory
Tel: (+45) 35 32 67 58 (lab) / (+45) 28 20 03 12 (mobile)
E-mail: trd at
Skype: tron.darvann
Fax: (+45) 35 32 67 60
Mailing and Visiting Address:
3D-Lab, School of Dentistry
University of Copenhagen
Nørre Alle 20
DK-2200 Copenhagen N


Fra: at på vegne af Steven Boyd
Sendt: ti 04-07-2006 03:57
Til: vtk
Emne: [vtkusers] Distances between polydata surfaces


I want to calculate the distance from one polydata surface to another.
Does anybody have a suggestion for this?  I don't see a class that seems
to be suited.



Steven Boyd

PhD, PEng
Assistant Professor
Department of Mechanical and Manufacturing Engineering
University of Calgary
2500 University Drive, N.W.
Calgary, Alberta, Canada, T2N 1N4

tel. 1.403.220.4173  fax. 1.403.282.8406  skboyd at
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
Follow this link to subscribe/unsubscribe:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: closestp_curve2surface.cxx
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: closestpoint_diff_signed.cxx
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: closestpoint_diff_unsigned.cxx
URL: <>

More information about the vtkusers mailing list