[vtkusers] vrkCellLocator intersectWithLine() seldomly outputing wrong values
sebastien MARAUX
maraux at ondim.fr
Tue Dec 31 09:26:56 EST 2002
hello, happy new year !
(sorry for 12kb attached pieces, it can help understand my problem)
I saw in the mailing list archive a bug with vtkCellLocator
IntersectWithLine.
has it been fixed ? (cf
http://public.kitware.com/pipermail/vtkusers/2001-September/007757.html )
I got some strange output with it but really seldomly.
I am using vtkCellLocator to find height of a specific
point on a triangulated digital elevation model.
So I build cellLocator with the DEM polyData as input
(DEM is imported in VRML format, so I named it vrmlPolyData):
//-------------------------------------------snip
begins-----------------------------------------------
float a0[3], a1[3], x[3], pcoords[3];
// pour trouver selon (x,y) une coordonnée z du mnt trianguler
vtkCellLocator *cellLocator = vtkCellLocator::New();
cellLocator->SetDataSet(vrmlPolyData);
cellLocator->CacheCellBoundsOn();
cellLocator->SetTolerance(0.0);
cellLocator->AutomaticOn();
cellLocator->BuildLocator();
//----------------------------------------snip
ends--------------------------------------------------
Then I loop for each point of a poly I want to map on DEM,
retrieving each point height data with interscetwithline()
//--------------------------------------snip
begins---------------------------------------------------
vtkPoints *validHeightedPoints = vtkPoints::New();
// add height component to points of poly
for (i=0;i<mp_PolyData->GetNumberOfPoints();i++) {
mp_PolyData->GetPoint(i,myPoint);
// recherche de l'altitude y :
float t;
int subId;
// in VRML file y = height
a0[0]=myPoint[0];
a0[1]=myPoint[1];
a0[2]=FLT_MIN;
a1[0]=myPoint[0];
a1[1]=myPoint[1];
a1[2]=FLT_MAX;
// ray cast to get height of MNT back in this point
// in polydata z=height
cellLocator->IntersectWithLine(a0,a1,0.0,t,x,pcoords,subId);
myPoint[2]=x[2];
mp_PolyData->GetPoints()->SetPoint(i,myPoint);
validHeightedPoints->InsertNextPoint(myPoint);
}
mp_PolyData->SetPoints(validHeightedPoints);
file://----------------------------------snip
ends----------------------------------------------------
Surprisingly, this does not output always the height of the DEM,
even if tolerance is set to 0.
Have you any idea about that?
Take a look at the 2 screenshots representing my terrain, and the poly
which should be mapped on it. (polygon data has been zoomed)
If main heights of poygon data is OK (kind of V form for the main object,
because it is almost on 2 DEM faces only)
you can see some weird up and down foldings. in the middle of the object,
which are not from initial DEM.
Thank you
Seb
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polygon_data.jpg
Type: image/jpeg
Size: 4038 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20021231/8fbe1b18/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DEM_data.gif
Type: image/gif
Size: 8144 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20021231/8fbe1b18/attachment.gif>
More information about the vtkusers
mailing list