[vtkusers] vtkPolyDataConnectivityFilter

Randy Heiland heiland at ncsa.uiuc.edu
Tue Jul 10 14:34:21 EDT 2001


On Jul 10,  1:51pm, Martins D Innus wrote:
> Subject: [vtkusers] vtkPolyDataConnectivityFilter
> Hi,
> 	I dug through the archives and saw that this question has been
> asked before, but I haven't found any answers.  Is there a way to get the
> "n" biggest regions from vtkPolyDataConnectivityFilter ?  Thanks.
>
> Martins


How about using vtkMassProperties() to compute the area of each region and then
you select the N biggest?

--Randy

modifying graphics/examplesPython/polyConnColorRegions.py  as follows:

(unfortunately, it seems the version of vtkMassProperties::GetSurfaceArea that
I'm using returns a NaN from any region that has ill-defined triangles)

...
#conn.SetExtractionModeToAllRegions()
#conn.Update()

#-----------------
conn.SetExtractionModeToSpecifiedRegions()
conn.InitializeSpecifiedRegionList()
conn.AddSpecifiedRegion(0)
conn.Update()

tris = vtkTriangleFilter()
tris.SetInput(conn.GetOutput())
tris.Update()

mp = vtkMassProperties()
#mp.SetInput(conn.GetOutput())
mp.SetInput(tris.GetOutput())
print 'surf area(0) = ', mp.GetSurfaceArea()

maxRegion = 20
maxRegion = 15
for idx in range(1,maxRegion):
  conn.DeleteSpecifiedRegion(idx-1)
  conn.AddSpecifiedRegion(idx)
  conn.Update()
  print 'surf area ', idx,mp.GetSurfaceArea()

...




More information about the vtkusers mailing list