[vtkusers] Checking on whether or not a bug in vtkTriangleFilter has been fixed...

Renny Werner rendawg at plinet.com
Mon Jul 10 11:41:24 EDT 2000


Back in August of last year, I was informed of an error in vtkTriangleFilter
that popped up when it tried to triangulate complex polygons that had
concave edges.

For example, if you take the following code snippet...

/* begin code snippet */
    vtkPoints* pPoints = vtkPoints::New();
    vtkCellArray* pCells = vtkCellArray::New();
    vtkPolyData* pGeoData   =    vtkPolyData::New();
    vtkGeometryFilter* pGeoFilter =    vtkGeometryFilter::New();
    vtkPolyDataMapper* pGeoMapper =    vtkPolyDataMapper::New();
    vtkActor* pGeoActor  =    vtkActor::New();

    static float x1[12][3]={{15,15,0}, {29.7,15,0}, {29.7,48.5,0},
{115.6,48.5,0},
                            {115.6,15,0}, {130.3,15,0}, {130.3,96.8,0},
{115.6,96.8,0},
                            {115.6,63.3,0}, {29.7,63.3,0}, {29.7,96.8,0},
{15, 96.8, 0}};
    static int pts[12] = {0,1,2,3,4,5,6,7,8,9,10,11};

    for( int i = 0; i < 12; i++ )
       pPoints->InsertPoint( i, x1[i] );
    pCells->InsertNextCell( 12, pts );

    pGeoData->SetPoints( pPoints );
    pPoints->Delete();
    pGeoData->SetPolys( pCells );
    pCells->Delete();

    pGeoFilter->SetInput(pGeoData);
    pGeoMapper->SetInput(pGeoFilter->GetOutput());
    pGeoActor->SetMapper(pGeoMapper);
    pRenderer->AddActor( pGeoActor );
/* end code snippet */

The points listed should give an "H-shape" polygon.  If you map them out on
paper that is what you will get.  This doesn't seem to happen when you try
to do it through vtk, however.

I have tried vtkTriangleFilter and got similarly unacceptable results even
though the documentation in the User's Guide states that the Triangulate
method of vtkPolygon handles such a shape, but all I seem to get through the
vtkTriangleFilter is one vertical portion of the "H".

The fellow that got back in touch with me on this back then (Will Schroeder,
I believe) informed me that it was most likely a bug that he was working on
that might be fixed shortly.  He did give me a new vtkPolygon.cxx to try
out, but it was to no avail.  I am just wondering if this problem has been
addressed now and if I should get the latest update (of which my next
question would most likely be the best way to do that, use the nightlies or
some other method).

By the way, I did manage to bypass the problem by creating a vtkPlaneSource
object with a high resolution that was larger than the desired polygon. Then
I created a vtkSelectPolyData with the vertices of the final desired polygon
shape and turned on the generation of selection scalars.  Then I fed the
vtkSelectPolygon output into a vtkClipPolyData object to clip out the
selected complex polygon shape and put the output into an vtkAppendPolyData
so that the complex polygon would be with the other non-complex polygons
that I wanted to group together.  While this did work for all of my complex
polygons, the memory needed to perform this quickly went beyond normal
machines (like, needing a 750 MB swapfile size in order to have the memory
to compute all of the data and render it on the screen).

So, for now I have the original vtkTriangleFilter method in place for
everything and if the user wants to, he can select to have it do the
"multiple cells per component clipping" method if they have a complex
polygon to render, but I would really like to not have to do this as most of
the users are unable to use that method anyways due to the memory
constraints.

Any ideas or other ways to perform this if the vtkTriangleFilter is still
not fixed?

Thank in advance,
Lawrence "Renny" Werner
20324 North Turkey Creek Rd, Morrison, CO 80465
voice : (303) 697-7656
email :   rendawg at plinet.com





More information about the vtkusers mailing list