This is a python friendly wrapper of a vtkUnstructuredGrid that defines a few useful properties.
| 1408 | Polygons = property(GetPolygons, None, None, "This property returns the connectivity of polygons.") |
| 1409 | |
| 1410 | class UnstructuredGrid(PointSet): |
| 1411 | """This is a python friendly wrapper of a vtkUnstructuredGrid that defines |
| 1412 | a few useful properties.""" |
| 1413 | |
| 1414 | def GetCellTypes(self): |
| 1415 | """Returns the cell types as a VTKArray instance.""" |
| 1416 | if not self.VTKObject.GetCellTypes(): |
| 1417 | return None |
| 1418 | return vtkDataArrayToVTKArray( |
| 1419 | self.VTKObject.GetCellTypes(), self) |
| 1420 | |
| 1421 | def GetCellLocations(self): |
| 1422 | """Returns the cell locations as a VTKArray instance.""" |
| 1423 | if not self.VTKObject.GetCellLocationsArray(): |
| 1424 | return None |
| 1425 | return vtkDataArrayToVTKArray( |
| 1426 | self.VTKObject.GetCellLocationsArray(), self) |
| 1427 | |
| 1428 | def GetCells(self): |
| 1429 | """Returns the cells as a VTKArray instance.""" |
| 1430 | if not self.VTKObject.GetCells(): |
| 1431 | return None |
| 1432 | return vtkDataArrayToVTKArray( |
| 1433 | self.VTKObject.GetCells().GetData(), self) |
| 1434 | |
| 1435 | def SetCells(self, cellTypes, cellLocations, cells): |
| 1436 | """Given cellTypes, cellLocations, cells as VTKArrays, |
| 1437 | populates the unstructured grid data structures.""" |
| 1438 | from ..util.vtkConstants import VTK_ID_TYPE |
| 1439 | from ..vtkCommonDataModel import vtkCellArray |
| 1440 | cellTypes = numpyTovtkDataArray(cellTypes) |
| 1441 | cellLocations = numpyTovtkDataArray(cellLocations, array_type=VTK_ID_TYPE) |
| 1442 | cells = numpyTovtkDataArray(cells, array_type=VTK_ID_TYPE) |
| 1443 | ca = vtkCellArray() |
| 1444 | ca.SetCells(cellTypes.GetNumberOfTuples(), cells) |
| 1445 | self.VTKObject.SetCells(cellTypes, cellLocations, ca) |
| 1446 | |
| 1447 | CellTypes = property(GetCellTypes, None, None, "This property returns the types of cells.") |
| 1448 | CellLocations = property(GetCellLocations, None, None, "This property returns the locations of cells.") |
| 1449 | Cells = property(GetCells, None, None, "This property returns the connectivity of cells.") |
| 1450 | |
| 1451 | class Graph(DataObject): |
| 1452 | """This is a python friendly wrapper of a vtkGraph that defines |