<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">
<DIV>Malcolm,</DIV>
<DIV> </DIV>
<DIV>I was thinking that my naive approach would be costly so I did some research and found some papers referencing sweep algorithm that you suggested. The sweep algorithm looks promissing and I have to do some more investigation to figure out how to implement it properly. This is something we'll have to do often so it's worth it to write a proper class. Unfortunately this project is a "Proof of concept" and am performing the investigation in my spare time so it may take me a bit to get the sweep algorithm coded. I will let you know how it works out.</DIV>
<DIV> </DIV>
<DIV>Ron</DIV>
<DIV> </DIV>
<DIV>The naive approach will work but you can drastically reduce the number of intersection tests by running a sweep algorithm (many computational geometry textbooks cover this). Basically you sweep a vertical line through a horizontally sorted set of line segments (or vice versa). You will only have to check for intersections between those line segments that simultaneously intersect your sweep line - i.e. you maintain a subset of candidates, dynamically discarding some and appending others as the sweep line proceeds through the sorted events (events = beginnings and ends of line segments). It's a simple concept but can be difficult to implement - especially in cases like yours where considerable book-keeping would be required to insert new points correctly into existing polylines. Is this something you'll have to do often or just a one-off?<BR><BR>HTH<BR>Malcolm Drummond<BR><BR> ----- Original Message ----- <BR> From: Ron Chapman <BR> To: <A href="http://www.vtk.org/mailman/listinfo/vtkusers">vtkusers at vtk.org</A> <BR> Sent: Thursday, February 16, 2006 1:38 AM<BR> Subject: [vtkusers] 3D Visualization of Map Data<BR><BR><BR> Malcolm,<BR><BR> Thanks for your help, once I figured out some basic vtk'isms your suggestion worked well, albeit roads are sometimes elevated, and/or disappear through my surface (see the below pipeline). Now I need to figure out how to split my road (line segments) into polylines that intersect with my 2D mesh so that the probing produces better results. Does anyone have some hints on how to do this? I was naively thinking of the following:<BR><BR> create an empty 2d polydata set -> call this NEW<BR> for each 2d line segment in my 2d polydata<BR> for each line in 3d mesh<BR> if intersection<BR> create new line segment<BR> add new line segment to NEW<BR><BR> Then use NEW with the pipeline below insead of Shape2D:<BR><BR> // get the evalation scalars<BR><BR> float bounds[6];<BR> Mesh3D->GetBounds(bounds);<BR> vtkElevationFilter *Elevation = vtkElevationFilter::New();<BR> Elevation->SetInput(Mesh3D);<BR> Elevation->SetLowPoint(0,0,bounds[4]);<BR> Elevation->SetHighPoint(0,0,bounds[5]);<BR> Elevation->SetScalarRange(bounds[4], bounds[5]);<BR> Elevation->Update();<BR><BR> // convert our 3d mesh to 2d<BR><BR> vtkTransform *Transform = vtkTransform::New();<BR> Transform->Scale(1.0,1.0,0.0);<BR><BR> vtkTransformPolyDataFilter *transFilter = vtkTransformPolyDataFilter::New();<BR> transFilter->SetInput((vtkPolyData *) Elevation->GetOutput());<BR> transFilter->SetTransform(Transform);<BR> transFilter->Update();<BR> <BR> // probe 2d mesh with shape data<BR><BR> vtkProbeFilter *Probe = vtkProbeFilter::New();<BR> Probe->SetInput(Shape2D);<BR> Probe->SetSource(transFilter->GetOutput());<BR> Probe->Update();<BR><BR> // apply the sampled elevation to the overlay<BR><BR> vtkWarpScalar *Warp = vtkWarpScalar::New();<BR> Warp->SetInput(Probe->GetPolyDataOutput());<BR> Warp->SetScaleFactor(1.0);<BR> Warp->Update();<BR><BR> Ron<BR><BR></DIV></BODY></HTML>