[vtkusers] Calculating the distance between two polyDatas
Robbie Banks
robbie.banks at gmail.com
Thu Feb 3 13:22:31 EST 2011
Hi there,
If you have the polydata and create a vtkDataSet from this, then you can
use the routine below to determine the distance
double cords1[3];
double cords2[3];
double distance = 0.0;
pData->GetPoint(i-1,cords1);
pData->GetPoint(i, cords2);
distance += sqrt(vtkMath::Distance2BetweenPoints(cords1, cords2));
where pData is the vtkDataset created from grabbing the two points of
interest from your vtkPolydata
Cheers
Robbie
-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
Of agerlach
Sent: Thursday, February 03, 2011 9:43 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Calculating the distance between two polyDatas
All,
I have two polyDatas that represent the same "object" (imagine one as a 3D
mesh derived from a 3D CAD model (call this polyData A) and the other as a
3D mesh obtained by 3D scanning a real-world object manufactured from the
CAD model (call this polyData B). Currently I can load both models and align
them, but now I what to visualize the difference between them by rendering
polyData A and then color the surface based on the "difference" between the
polyDatas.
I have seen several example that implement this by taking each point in A
and then searching for the closest point in B and calculating this
difference. However, I would like to specify the point used for calculating
the difference as the point in B closest to the surface normal extended from
the point in A.
Example: take point 1 in A and its surface normal. Then find the cell in B
that intersects with point 1's surface normal. Then approximate the location
on the cell that the normal intersects. This point - point 1 then becomes
the difference used in the visualization. I guess my question is what is the
best way to do this?
It looks like vtkCellLocator::intersectWithLine(...) will work, but I am a
little confused on how that method works. According to the documentation
this can return the cellId as well as a point. Is this point the centroid of
the cell, the 1 of 3 points that define the cell that is closest to the
intersection, or the point of intersection?
Thanks
--
View this message in context:
http://vtk.1045678.n5.nabble.com/Calculating-the-distance-between-two-polyDa
tas-tp3369677p3369677.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list