[vtkusers] Extracting cell connectivity from a vtk file

Eric Mark (CISD/CIV) emark at arl.army.mil
Fri Sep 25 13:57:59 EDT 2009


I did try that and just tried it again and it still doesn't allow me to 
use GetCell or GetNextCell. These are the only methods available:

What Can I Do With Cells? : ['AddObserver', 'Allocate', 'BreakOnError', 
'DebugOff', 'DebugOn', 'DeepCopy', 'EstimateSize', 'FastDelete', 
'GetActualMemorySize', 'GetAddressAsString', 'GetClassName', 'GetData', 
'GetDebug', 'GetGlobalWarningDisplay', 'GetInsertLocation', 'GetMTime', 
'GetMaxCellSize', 'GetNumberOfCells', 'GetNumberOfConnectivityEntries', 
'GetReferenceCount', 'GetSize', 'GetTraversalLocation', 
'GlobalWarningDisplayOff', 'GlobalWarningDisplayOn', 'HasObserver', 
'InitTraversal', 'Initialize', 'InsertCellPoint', 'InsertNextCell', 
'InvokeEvent', 'IsA', 'IsTypeOf', 'Modified', 'NewInstance', 
'PrintRevisions', 'Register', 'RemoveAllObservers', 'RemoveObserver', 
'RemoveObservers', 'Reset', 'ReverseCell', 'SafeDownCast', 'SetCells', 
'SetDebug', 'SetGlobalWarningDisplay', 'SetNumberOfCells', 
'SetReferenceCount', 'SetTraversalLocation', 'Squeeze', 'UnRegister', 
'UpdateCellCount']

Thanks,

Eric

Yang, Jinzhong wrote:
> You need to call InitTraversal() before you can use GetCell() or
> GetNextCell()
>
>
>
> -----Original Message-----
> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
> Of Eric Mark (CISD/CIV)
> Sent: Friday, September 25, 2009 10:37 AM
> To: vtkusers at vtk.org
> Subject: [vtkusers] Extracting cell connectivity from a vtk file
>
> Hello all,
>
> I'm using python with vtk 5.2.1 and am trying to read the connectivity 
> list from a vtk file and write it back out in a different format.    I'm 
> able to read the point data but I'm not having any success in reading 
> the connectivity data.    I would like to be able to print out a 
> connectivity list in the same manner that I'm using below to print the 
> points.  However it seems that GetCell or GetNextCell methods are not 
> available from Python.  Am I doing something wrong or is there an 
> alternate way of doing this?
>
> Thanks,
>
> Eric
>
> Here's the code:
>
> fn = "test.vtk"
> r = vtkUnstructuredGridReader()
>
> r.SetFileName(fn)
> r.Update()
> points = r.GetOutput().GetPoints()
>
> print "Number of Points: " ,  points.GetNumberOfPoints()
> i = 0
> while(i < points.GetNumberOfPoints()) :
>      print "Next Point : %d, %s " % (i + 1, points.GetPoint(i))
>      i = i + 1
>
> numcells = r.GetOutput().GetNumberOfCells()
> print "Number Of Cells: ", numcells
> cells = r.GetOutput().GetCells()
> print "Cells Var contains: ", cells
> print "Cells.GetSize : ", cells.GetSize()
> print "Cells.GetSize : ", cells.GetNumberOfConnectivityEntries()
> print "What Can I Do With Cells? :", dir(cells)
> j = 0
> cells.SetTraversalLocation(j)
> print "NextCell", cells.GetOutput().GetCell(j)
> #print "Check Array: ",  r.GetOutput().GetCells()
> while(j < cells ):
>      #print " %d, %s " % (j + 1, cells.GetNextCell())
>      j = j + 1
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>   




More information about the vtkusers mailing list