<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>&nbsp;</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.&nbsp; The sweep algorithm looks promissing and I have to do some more investigation to figure out how to implement it properly.&nbsp; This is something we'll have to do often so it's worth it to write a proper class.&nbsp; 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.&nbsp; I will let you know how it works out.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Ron</DIV>
<DIV>&nbsp;</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>&nbsp; ----- Original Message ----- <BR>&nbsp; From: Ron Chapman <BR>&nbsp; To: <A href="http://www.vtk.org/mailman/listinfo/vtkusers">vtkusers at vtk.org</A> <BR>&nbsp; Sent: Thursday, February 16, 2006 1:38 AM<BR>&nbsp; Subject: [vtkusers] 3D Visualization of Map Data<BR><BR><BR>&nbsp; Malcolm,<BR><BR>&nbsp; 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).&nbsp; 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.&nbsp; Does anyone have some hints on how to do this?&nbsp; I was naively thinking of the following:<BR><BR>&nbsp; create an empty 2d polydata set -&gt; call this NEW<BR>&nbsp; for each 2d line segment in my&nbsp; 2d polydata<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for each line in 3d mesh<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if intersection<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; create new line segment<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; add new line segment to NEW<BR><BR>&nbsp; Then use NEW with the pipeline below insead of Shape2D:<BR><BR>&nbsp; // get the evalation scalars<BR><BR>&nbsp;&nbsp; float bounds[6];<BR>&nbsp;&nbsp; Mesh3D-&gt;GetBounds(bounds);<BR>&nbsp;&nbsp; vtkElevationFilter *Elevation = vtkElevationFilter::New();<BR>&nbsp;&nbsp; Elevation-&gt;SetInput(Mesh3D);<BR>&nbsp;&nbsp; Elevation-&gt;SetLowPoint(0,0,bounds[4]);<BR>&nbsp;&nbsp; Elevation-&gt;SetHighPoint(0,0,bounds[5]);<BR>&nbsp;&nbsp; Elevation-&gt;SetScalarRange(bounds[4], bounds[5]);<BR>&nbsp;&nbsp; Elevation-&gt;Update();<BR><BR>&nbsp;&nbsp;&nbsp; // convert our 3d mesh to 2d<BR><BR>&nbsp;&nbsp; vtkTransform *Transform = vtkTransform::New();<BR>&nbsp;&nbsp; Transform-&gt;Scale(1.0,1.0,0.0);<BR><BR>&nbsp;&nbsp; vtkTransformPolyDataFilter *transFilter = vtkTransformPolyDataFilter::New();<BR>&nbsp;&nbsp; transFilter-&gt;SetInput((vtkPolyData *) Elevation-&gt;GetOutput());<BR>&nbsp;&nbsp; transFilter-&gt;SetTransform(Transform);<BR>&nbsp;&nbsp; transFilter-&gt;Update();<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; // probe 2d mesh with shape data<BR><BR>&nbsp;&nbsp; vtkProbeFilter *Probe = vtkProbeFilter::New();<BR>&nbsp;&nbsp; Probe-&gt;SetInput(Shape2D);<BR>&nbsp;&nbsp; Probe-&gt;SetSource(transFilter-&gt;GetOutput());<BR>&nbsp;&nbsp; Probe-&gt;Update();<BR><BR>&nbsp;&nbsp; // apply the sampled elevation to the overlay<BR><BR>&nbsp;&nbsp; vtkWarpScalar *Warp = vtkWarpScalar::New();<BR>&nbsp;&nbsp; Warp-&gt;SetInput(Probe-&gt;GetPolyDataOutput());<BR>&nbsp;&nbsp; Warp-&gt;SetScaleFactor(1.0);<BR>&nbsp;&nbsp; Warp-&gt;Update();<BR><BR>&nbsp; Ron<BR><BR></DIV></BODY></HTML>