[vtkusers] resent - cells given a point [was: postprocessing vtkDelaunay2D/3D]

David, John john.david at uconn.edu
Tue Mar 4 08:06:23 EST 2008


Last night the VTK website went down around the time that I got a bounce notice from the vtk-users list.  So, I am resending it.  For any who receives this twice, please accept my apologies.

----------------

Thank you Amy,

> You can accomplish item #1 below using the GetPointCells method on the
> output of your Delaunay triangulation filter (vtkPolyData for
> vtkDelaunay2D, vtkUnstructuredGrid for vtkDelaunay3D).

Thanks to your suggestion I was able to traverse through the list of points and cells:


  vtkDelaunay2D *d2d = vtkDelaunay2D::New();
    d2d->SetInput (usg);

  vtkPolyData *tOut = d2d->GetOutput();
    tOut->GetPointData()->SetScalars(scalars);
    tOut->Update();

  vtkIdList *cellIds  = vtkIdList::New();
  vtkIdList *pointIds = vtkIdList::New();

  for(i=0; i<poi->GetNumberOfPoints(); i++)
   {
       tOut->GetPointCells (i, cellIds);

       int sz = cellIds->GetNumberOfIds();
       cout << "  # of cells using pointId[" << i << "] = " << sz << "\n";
       for (j=0; j<sz; j++)
          cout << "     pointId[" << cellIds->GetId(j) << "]\n";
   }

  for(i=0; i<tOut->GetNumberOfPolys();i++)
  {
     tOut->GetCellPoints (i, pointIds);

     int sz = pointIds->GetNumberOfIds();
     if (3!=sz)
     {
         cerr << "Error! found something that is not a triangle...\n";
         cerr << "  cellId = " << i << "\n";
         continue;
     }
     cout << "  # points using cellId[" << i << "]\n";
     for (j=0; j<sz; j++)
         cout << "     cellId[" << pointIds->GetId(j) << "]\n";
  }


I think I must be doing the traversal incorrectly as there are some methods for traversing the cell arrays similar to the following, but I'm not getting it to work consistently.

  vtkCellArray* verts = tOut->GetVerts();
  vtkCellArray* cells = tOut->GetPolys();
  vtkCellArray* lines = tOut->GetLines();

  h=cells->GetNumberOfCells();
  cells->InitTraversal();

  while (1)
   {
     h=cells->GetNextCell(npts,pts);
     if (0 == h) break;

     ....
    }

My concern is that the pointId and the index of the point array probably are not guaranteed to be the same, but vtkPoints does not provide a traversal method (although maybe I simply did not look deep enough into the inheritance tree).  Is the best method to get a list of the pointId's and manually spin through the list?

Thanks again,


  EBo --




-----Original Message-----
From: Amy Squillacote [mailto:ahs at cfdrc.com]
Sent: Mon 3/3/2008 2:56 PM
To: David, John
Cc: vtkusers
Subject: Re: [vtkusers] postprocessing vtkDelaunay2D/3D

You can accomplish item #1 below using the GetPointCells method on the
output of your Delaunay triangulation filter (vtkPolyData for
vtkDelaunay2D, vtkUnstructuredGrid for vtkDelaunay3D).

You could probably use vtkExtractEdges filter
(http://www.vtk.org/doc/nightly/html/classvtkExtractEdges.html) as part
of a solution for item #2.

- Amy

David, John wrote:
> Hello,
>
> I need to postprocess a Delaunay triangulation and have the following questions that I have not been able to track down:
>
>   1) given a vertex/point from the point list, is there an easy way to get a list of all triangles/tertahedra that reference that point as a vertex?
>
>   2) is there any classes which take a Delaunay triangulation and return a unique edge list?
>
>
> Thanks and best regards,
>
>   EBo --
> _______________________________________________
> 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
>
>
>  

--
Amy Squillacote                    Phone: (256) 726-4839
Computer Scientist                 Fax: (256) 726-4806
CFD Research Corporation           Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL  35805





More information about the vtkusers mailing list