[vtkusers] 3D Visualization of Map Data
Malcolm Drummond
malcolm at geode.co.za
Thu Feb 16 08:39:24 EST 2006
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?
HTH
Malcolm Drummond
----- Original Message -----
From: Ron Chapman
To: vtkusers at vtk.org
Sent: Thursday, February 16, 2006 1:38 AM
Subject: [vtkusers] 3D Visualization of Map Data
Malcolm,
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:
create an empty 2d polydata set -> call this NEW
for each 2d line segment in my 2d polydata
for each line in 3d mesh
if intersection
create new line segment
add new line segment to NEW
Then use NEW with the pipeline below insead of Shape2D:
// get the evalation scalars
float bounds[6];
Mesh3D->GetBounds(bounds);
vtkElevationFilter *Elevation = vtkElevationFilter::New();
Elevation->SetInput(Mesh3D);
Elevation->SetLowPoint(0,0,bounds[4]);
Elevation->SetHighPoint(0,0,bounds[5]);
Elevation->SetScalarRange(bounds[4], bounds[5]);
Elevation->Update();
// convert our 3d mesh to 2d
vtkTransform *Transform = vtkTransform::New();
Transform->Scale(1.0,1.0,0.0);
vtkTransformPolyDataFilter *transFilter = vtkTransformPolyDataFilter::New();
transFilter->SetInput((vtkPolyData *) Elevation->GetOutput());
transFilter->SetTransform(Transform);
transFilter->Update();
// probe 2d mesh with shape data
vtkProbeFilter *Probe = vtkProbeFilter::New();
Probe->SetInput(Shape2D);
Probe->SetSource(transFilter->GetOutput());
Probe->Update();
// apply the sampled elevation to the overlay
vtkWarpScalar *Warp = vtkWarpScalar::New();
Warp->SetInput(Probe->GetPolyDataOutput());
Warp->SetScaleFactor(1.0);
Warp->Update();
Ron
------------------------------------------------------------------------------
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060216/6799a71c/attachment.htm>
More information about the vtkusers
mailing list