<!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 (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?</FONT></DIV>
<DIV><FONT face=Arial></FONT> </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> </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). 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:</DIV>
<DIV> </DIV>
<DIV>create an empty 2d polydata set -> call this NEW</DIV>
<DIV>for each 2d line segment in my 2d polydata</DIV>
<DIV> for each line in 3d mesh</DIV>
<DIV> if intersection</DIV>
<DIV> create
new line segment</DIV>
<DIV> add
new line segment to NEW</DIV>
<DIV> </DIV>
<DIV>Then use NEW with the pipeline below insead of Shape2D:</DIV>
<DIV> </DIV>
<DIV>// get the evalation scalars</DIV>
<DIV> </DIV>
<DIV> float bounds[6];<BR> Mesh3D->GetBounds(bounds);</DIV>
<DIV> 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();</DIV>
<DIV> </DIV>
<DIV> // convert our 3d mesh to 2d</DIV>
<DIV><BR> vtkTransform *Transform =
vtkTransform::New();<BR> Transform->Scale(1.0,1.0,0.0);</DIV>
<DIV> </DIV>
<DIV> 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</DIV>
<DIV> </DIV>
<DIV> vtkProbeFilter *Probe =
vtkProbeFilter::New();<BR> Probe->SetInput(Shape2D);<BR> Probe->SetSource(transFilter->GetOutput());<BR> Probe->Update();</DIV>
<DIV> </DIV>
<DIV> // apply the sampled elevation to the overlay</DIV>
<DIV> </DIV>
<DIV> vtkWarpScalar *Warp =
vtkWarpScalar::New();<BR> Warp->SetInput(Probe->GetPolyDataOutput());<BR> Warp->SetScaleFactor(1.0);<BR> Warp->Update();<BR></DIV>
<DIV>Ron</DIV>
<DIV> </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>