[vtkusers] How to extact the geometry within a bounding box from a vtkPolyData ? Please Help !!!!!

David E DeMarle dave.demarle at kitware.com
Tue Mar 14 13:54:48 EST 2006


I'm not sure if 4.2 has all of the following classes and I'm not sure if 
the code under vtkExtractPolyDataGeometry will be any faster than doing 
the equivalent directly with the scalars in your data yourself, but this 
is where I would start:

vtkSOMEREADER reader
 reader SetFileName "afile"
 reader Update

# create an implicit function to evaluate inside/outside with, start as
# 000 to 111
vtkImageData id
  id SetDimensions 1 1 1
  id SetOrigin 0 0 0
  id SetSpacing 1 1 1
vtkFloatArray pfa
 pfa SetNumberOfComponents 1
 pfa InsertNextValue -1
 pfa InsertNextValue -1
 pfa InsertNextValue -1
 pfa InsertNextValue -1
 pfa InsertNextValue -1
 pfa InsertNextValue -1
 pfa InsertNextValue -1
 pfa InsertNextValue -1
[id GetPointData] SetScalars pfa
vtkImplicitVolume impVol
 impVol SetVolume id
 impVol SetOutValue 1
#TODO:
#assign a vtkAbstractTransform  to impVol to translate, scale and
#rotate the sample volume as you need, without one this example will
#return geometry beween 000 and 111

#At long last, extract the portion of the reader's output that is
#inside the volume.
vtkExtractPolyDataGeometry extractor
 extractor SetInputConnection [reader GetOutputPort]
 extractor SetImplicitFunction impVol
 extractor ExtractInsideOn

#etc, the usual rendering stuff would follow to show extractor's output



More information about the vtkusers mailing list