MCPcopy Create free account
hub / github.com/Kitware/VTK / CompositeDataSet

Class CompositeDataSet

Wrapping/Python/vtkmodules/numpy_interface/dataset_adapter.py:1242–1350  ·  view source on GitHub ↗

A wrapper for vtkCompositeData and subclasses that makes it easier to access Point/Cell/Field data as VTKCompositeDataArrays. It also provides a Python type iterator.

Source from the content-addressed store, hash-verified

1240 CellData = property(GetCellData, None, None, "This property returns the cell data of the hypertree grid.")
1241
1242class CompositeDataSet(DataObject):
1243 """A wrapper for vtkCompositeData and subclasses that makes it easier
1244 to access Point/Cell/Field data as VTKCompositeDataArrays. It also
1245 provides a Python type iterator."""
1246
1247 def __init__(self, vtkobject):
1248 DataObject.__init__(self, vtkobject)
1249 self._PointData = None
1250 self._CellData = None
1251 self._FieldData = None
1252 self._GlobalData = None
1253 self._Points = None
1254
1255 def __iter__(self):
1256 "Creates an iterator for the contained datasets."
1257 return CompositeDataIterator(self)
1258
1259 def GetNumberOfElements(self, assoc):
1260 """Returns the total number of cells or points depending
1261 on the value of assoc which can be ArrayAssociation.POINT or
1262 ArrayAssociation.CELL."""
1263 result = 0
1264 for dataset in self:
1265 result += dataset.GetNumberOfElements(assoc)
1266 return int(result)
1267
1268 def GetNumberOfPoints(self):
1269 """Returns the total number of points of all datasets
1270 in the composite dataset. Note that this traverses the
1271 whole composite dataset every time and should not be
1272 called repeatedly for large composite datasets."""
1273 return self.GetNumberOfElements(ArrayAssociation.POINT)
1274
1275 def GetNumberOfCells(self):
1276 """Returns the total number of cells of all datasets
1277 in the composite dataset. Note that this traverses the
1278 whole composite dataset every time and should not be
1279 called repeatedly for large composite datasets."""
1280 return self.GetNumberOfElements(ArrayAssociation.CELL)
1281
1282 def GetAttributes(self, type):
1283 """Returns the attributes specified by the type as a
1284 CompositeDataSetAttributes instance."""
1285 return CompositeDataSetAttributes(self, type)
1286
1287 def HasAttributes(self, type):
1288 "Returns true if every leaves of current composite object support this attributes type"
1289 for dataset in self:
1290 if not dataset.HasAttributes(type):
1291 return False
1292
1293 return True
1294
1295 def GetPointData(self):
1296 "Returns the point data as a CompositeDataSetAttributes instance."
1297 if self._PointData is None or self._PointData() is None:
1298 pdata = self.GetAttributes(ArrayAssociation.POINT)
1299 self._PointData = weakref.ref(pdata)

Callers 1

WrapDataObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected