> I use a contour filter, and I need the points found by contouring to display ...
 

Eduard,

This is a COMPLETE kludge, but it will at least give you the idea how to get at this data. I used this code for constructing a single polyline from an orthogonal slice through a convex hull (closed polygon). Once you have a single cell polyline you can utilize e.g. the Evaluate method.

NOTE:  Your polydata must be a closed line for this to work !! This implies a single closed contour. You can modify for open contours. The basic idea is really just to find out the connectivity between the individual line segments. You initialliy get a bunch of two-vertex lines, and what you want (I think) is a single polyline.

If all you want is to plot the line segments separately, this becomes much easier. Just use the list from GetNextCell and copordinates from GetPoint and you can do away with 90% of the kludge below.

Hopefully someone with more experience can point us toward a more elegant solution to the polyline problem.

Regards,

john
 

code snippet follows:

Here the output from "dcut" is the polydata from the slice plane. Replace dcut with whatever you are using to generate the contour polydata.

Once you have the connection list (iline1), you can use GetPoint to get the actual point coordinates.
 

// GET THE POLYLINE CONNECTIVITY
        int numPoints;
        int *lPoints,*icell1,*icell1,icell2,*iline1,*iline2,*itest;
        vtkPoints *pdata;
        vtkCellArray *lines;
        vtkCleanPolyData *dcut;

        dcut->Update();
        pdata = dcut->GetOutput()->GetPoints();
        lines = dcut->GetOutput()->GetLines();
        numPoints = lines->GetNumberOfCells();

        lPoints = new int[numPoints];
        icell1  = new int[numPoints];
        icell2  = new int[numPoints];
        iline1  = new int[numPoints];
        iline2  = new int[numPoints];
        itest   = new int[numPoints];

        lines->InitTraversal();
        for (i=0; i<numPoints; i++) {
          lines->GetNextCell(k,lPoints);
          icell1[i] = lPoints[0];
          icell2[i] = lPoints[1];
        }
 

// HERE FIND THE CONNECTION LIST
//  ILINE1 WILL BE THE LIST OF INDICES ALONG THE POLYLINE
        iline1[0] = icell1[0];
        iline2[0] = icell2[0];
        for (i=1; i<numPoints; i++) {
          i1 = iline2[i-1];
          for (j=0; j<numPoints; j++) {
            if ( ! itest[j] ) {
              j1 = icell1[j];
              j2 = icell2[j];
              if (j1 == i1) {
                iline1[i] = j1;
                iline2[i] = j2;
                itest[j] = 1;
              } else if (j2 == i1) {
                iline1[i] = j2;
                iline2[i] = j1;
                itest[j] = 1;
              }
            }
          }
        }
 

// MAKE A POLYLINE OBJECT - reuse iline2 for connectivity list
        polyLine = vtkUnstructuredGrid::New();
        polyLine->Allocate(numPoints,100);
        points2 = vtkPoints::New();

        for (i=0; i<numPoints; i++) {
          pdata->GetPoint(iline1[i],vector);
          points2->InsertPoint(i,vector);
          iline2[i] = i;
        }

        polyLine->InsertNextCell(VTK_POLYGON, numPoints, iline2);
        polyLine->SetPoints(points2);
  Attachment Converted: "c:\program files\qualcomm\eudora mail\attach\washbourne10.vcf"