<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma" bgColor=#ffffff>
<DIV><FONT face=Arial>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&nbsp;(or vice versa). 
You will only have to check for intersections&nbsp;between those&nbsp;line 
segments that simultaneously&nbsp;intersect your sweep line - i.e. you maintain 
a subset of&nbsp;candidates, dynamically discarding some and 
appending&nbsp;others&nbsp;as&nbsp;the sweep line proceeds&nbsp;through the 
sorted events (events = beginnings and ends of line segments). It's a 
simple&nbsp;concept but can be difficult to implement - especially in cases like 
yours where considerable book-keeping&nbsp;would be&nbsp;required to insert new 
points&nbsp;correctly into existing polylines. Is this&nbsp;something you'll 
have to&nbsp;do often or just a one-off?</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial>HTH</FONT><BR>Malcolm Drummond<BR></DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=Ron.Chapman@rwdi.com href="mailto:Ron.Chapman@rwdi.com">Ron 
  Chapman</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=vtkusers@vtk.org 
  href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, February 16, 2006 1:38 
  AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [vtkusers] 3D Visualization of 
  Map Data</DIV>
  <DIV><BR></DIV>
  <DIV>Malcolm,</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>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&nbsp;2D&nbsp;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:</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>create an empty 2d polydata set -&gt; call this NEW</DIV>
  <DIV>for each 2d line segment in my&nbsp; 2d polydata</DIV>
  <DIV>&nbsp;&nbsp;&nbsp; for each line in 3d mesh</DIV>
  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if intersection</DIV>
  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; create 
  new line segment</DIV>
  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; add 
  new line segment to NEW</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Then use NEW with the pipeline below insead of Shape2D:</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>// get the evalation scalars</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;float bounds[6];<BR>&nbsp;Mesh3D-&gt;GetBounds(bounds);</DIV>
  <DIV>&nbsp;vtkElevationFilter *Elevation = 
  vtkElevationFilter::New();<BR>&nbsp;Elevation-&gt;SetInput(Mesh3D);<BR>&nbsp;Elevation-&gt;SetLowPoint(0,0,bounds[4]);<BR>&nbsp;Elevation-&gt;SetHighPoint(0,0,bounds[5]);<BR>&nbsp;Elevation-&gt;SetScalarRange(bounds[4], 
  bounds[5]);<BR>&nbsp;Elevation-&gt;Update();</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp;// convert our 3d mesh to 2d</DIV>
  <DIV><BR>&nbsp;vtkTransform *Transform = 
  vtkTransform::New();<BR>&nbsp;Transform-&gt;Scale(1.0,1.0,0.0);</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;vtkTransformPolyDataFilter *transFilter = 
  vtkTransformPolyDataFilter::New();<BR>&nbsp;transFilter-&gt;SetInput((vtkPolyData 
  *) 
  Elevation-&gt;GetOutput());<BR>&nbsp;transFilter-&gt;SetTransform(Transform);<BR>&nbsp;transFilter-&gt;Update();<BR>&nbsp;<BR>&nbsp;//&nbsp;probe 
  2d mesh with shape data</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;vtkProbeFilter *Probe = 
  vtkProbeFilter::New();<BR>&nbsp;Probe-&gt;SetInput(Shape2D);<BR>&nbsp;Probe-&gt;SetSource(transFilter-&gt;GetOutput());<BR>&nbsp;Probe-&gt;Update();</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;//&nbsp;apply the sampled elevation to the overlay</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;vtkWarpScalar *Warp = 
  vtkWarpScalar::New();<BR>&nbsp;Warp-&gt;SetInput(Probe-&gt;GetPolyDataOutput());<BR>&nbsp;Warp-&gt;SetScaleFactor(1.0);<BR>&nbsp;Warp-&gt;Update();<BR></DIV>
  <DIV>Ron</DIV>
  <DIV>&nbsp;</DIV>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>This is the private 
  VTK discussion list. <BR>Please keep messages on-topic. Check the FAQ at: 
  http://www.vtk.org/Wiki/VTK_FAQ<BR>Follow this link to 
  subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers<BR></BLOCKQUOTE></BODY></HTML>