[vtkusers] 3D Visualization of Map Data

Ron Chapman Ron.Chapman at rwdi.com
Thu Feb 16 09:14:35 EST 2006


Malcolm,
 
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.
 
Ron
 
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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060216/b5470aa5/attachment.htm>


More information about the vtkusers mailing list