|
26 | 26 | """ |
27 | 27 |
|
28 | 28 |
|
| 29 | +def getCellDimension( mesh: Union[ vtkMultiBlockDataSet, vtkDataSet ] ) -> set[ int ]: |
| 30 | + """Get the set of the different cells dimension of a mesh. |
| 31 | +
|
| 32 | + Args: |
| 33 | + mesh (Union[vtkMultiBlockDataSet, vtkDataSet]): The input mesh with the cells dimension to get. |
| 34 | +
|
| 35 | + Returns: |
| 36 | + set[int]: The set of the different cells dimension in the input mesh. |
| 37 | + """ |
| 38 | + if isinstance( mesh, vtkDataSet ): |
| 39 | + return getCellDimensionDataSet( mesh ) |
| 40 | + elif isinstance( mesh, vtkMultiBlockDataSet ): |
| 41 | + return getCellDimensionMultiBlockDataSet( mesh ) |
| 42 | + else: |
| 43 | + raise TypeError( "The input mesh must be a vtkMultiBlockDataSet or a vtkDataSet." ) |
| 44 | + |
| 45 | + |
| 46 | +def getCellDimensionMultiBlockDataSet( multiBlockDataSet: vtkMultiBlockDataSet ) -> set[ int ]: |
| 47 | + """Get the set of the different cells dimension of a multiBlockDataSet. |
| 48 | +
|
| 49 | + Args: |
| 50 | + multiBlockDataSet (vtkMultiBlockDataSet): The input mesh with the cells dimension to get. |
| 51 | +
|
| 52 | + Returns: |
| 53 | + set[int]: The set of the different cells dimension in the input multiBlockDataSet. |
| 54 | + """ |
| 55 | + cellDim: set[ int ] = set() |
| 56 | + listFlatIdDataSet: list[ int ] = getBlockElementIndexesFlatten( multiBlockDataSet ) |
| 57 | + for flatIdDataSet in listFlatIdDataSet: |
| 58 | + dataSet: vtkDataSet = vtkDataSet.SafeDownCast( multiBlockDataSet.GetDataSet( flatIdDataSet ) ) |
| 59 | + cellDim = cellDim.union( getCellDimensionDataSet( dataSet ) ) |
| 60 | + return cellDim |
| 61 | + |
| 62 | + |
| 63 | +def getCellDimensionDataSet( dataSet: vtkDataSet ) -> set[ int ]: |
| 64 | + """Get the set of the different cells dimension of a dataSet. |
| 65 | +
|
| 66 | + Args: |
| 67 | + dataSet (vtkDataSet): The input mesh with the cells dimension to get. |
| 68 | +
|
| 69 | + Returns: |
| 70 | + set[int]: The set of the different cells dimension in the input dataSet. |
| 71 | + """ |
| 72 | + cellDim: set[ int ] = set() |
| 73 | + cellIter = dataSet.NewCellIterator() |
| 74 | + cellIter.InitTraversal() |
| 75 | + while not cellIter.IsDoneWithTraversal(): |
| 76 | + cellDim.add( cellIter.GetCellDimension() ) |
| 77 | + cellIter.GoToNextCell() |
| 78 | + return cellDim |
| 79 | + |
| 80 | + |
29 | 81 | def computeElementMapping( |
30 | 82 | meshFrom: Union[ vtkDataSet, vtkMultiBlockDataSet ], |
31 | 83 | meshTo: Union[ vtkDataSet, vtkMultiBlockDataSet ], |
|
0 commit comments