Multiple Bugs and rewrite of vtkCleanPolyData

Miller, James V (CRD) millerjv at crd.ge.com
Mon Feb 21 10:32:59 EST 2000


If want to send the files, I'll check them in.  Thanks for the great work!

Jim

-----Original Message-----
From: John Biddiscombe [mailto:j.biddiscombe at rl.ac.uk]
Sent: Sunday, February 20, 2000 6:27 AM
To: vtk
Subject: Multiple Bugs and rewrite of vtkCleanPolyData


I'm afraid that whilst examining vtkCleanPolyData I've found several bugs.
At or near line 176 there's a newId instead of cellId which will cause
celldata to be copied incorrectly. Much more seriously - the whole design is
flawed - CellData is copied as below

if ( numNewPts > 1 ) {
  newId = newLines->InsertNextCell(numNewPts,updatedPts);
  outputCD->CopyData (cd, cellId, newId);
}

This is very dubious, because if Verts exist, then newId should continue
from the count left over from the vert cleaning, however InsertNextCell for
the lines will start from zero (because InsertNextCell for the newLines will
return 0,1,2,3 etc etc) , thus the CopyData(...) will copy to the wrong
position.

If polydata contains verts, lines, polys and strips the error will
accumulate with each pass through the loops. I checked this and indeed it
does. If only verts, lines, polys or strips exist then the filter works
fine. The error only appears when mixes exist and cell data exists.

I have rewritten the filter and added some new options
bool ConvertLinesToPoints
bool ConvertPolysToLines
bool ConvertStripsToPolys

So that if a poly is reduced to a line it can be aded to the lines cellarray
(and ensure the celldata is copied correctly!!)
Likewise a line reduced to a point can be added to the verts and a strip
reduced to 3 points becomes a poly, 2 points a line and one point a vert.

The full set is
Line with 1 points -> Vert (if ConvertLinesToPoints=1)
Poly with 2 points -> Line (if ConvertPolysToLines=1)
Poly with 1 points -> Vert (if ConvertPolysToLines && ConvertLinesToPoints)
Strp with 3 points -> Poly (if ConvertStripsToPolys=1)
Strp with 2 points -> Line (if ConvertStripsToPolys && ConvertPolysToLines)
Strp with 1 points -> Vert (if ConvertStripsToPolys && ConvertPolysToLines
&& ConvertLinesToPoints)

I think that explains it OK.

However, the main reason I was examining it was I was creating a
vtkQuantizePolyDataPoints filter which will align (x,y,z components of) all
points to 1,10,100 or 0.5,0.25 etc etc. ie quantize the point locations and
I needed the degenerate lines to become points and polys to become lines - I
wanted to use vtkCleanPolyData as a starting point.

Having fixed vtkCleanPolyData, it becomes easy to simply insert a call to
"QuantizePoint" before inserting the point into the points list, so why not
just insert a virtual function in CleanPolyData which subclasses can
override and it can be used as a basis for deriving new "cleaning" filters.

Therefore I have two classes to submit. One is the improved and fixed
vtkCleanPolyData and the other is a subclass called
vtkQuantizePolyDataPoints which takes parameter called QFactor which can be
any positive value like 0.5,1,2,4,10,20 etc etc

Oh yes, I've also added an option
SetToleranceToAbsolute/SetToleranceToRelative to vtkCleanPolyDataFilter
which controls whether the tolerance is a fixed value like 5 or a fraction
of the dataset bounding box length as previously.

Where should I put the new classes?

Thanks

John B

--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------
--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list