File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1616
1717update_paths ()
1818
19+ from geos .mesh .utils .multiblockModifiers import mergeBlocks
1920import geos .pv .utils .paraviewTreatments as pvt
2021from geos .pv .utils .checkboxFunction import ( # type: ignore[attr-defined]
2122 createModifiedCallback , )
4445from paraview .util .vtkAlgorithm import ( # type: ignore[import-not-found]
4546 VTKPythonAlgorithmBase )
4647
47- from vtkmodules .vtkCommonDataModel import vtkDataObject
48+ from vtkmodules .vtkCommonDataModel import (
49+ vtkDataObject ,
50+ vtkMultiBlockDataSet ,
51+ )
4852from geos .pv .utils .details import SISOFilter , FilterCategory
4953
5054__doc__ = """
@@ -84,6 +88,9 @@ def __init__( self: Self ) -> None:
8488 # Input source and curve names.
8589 inputSource = GetActiveSource ()
8690 dataset = servermanager .Fetch ( inputSource )
91+ # Handle vtkMultiBlockDataSet by merging blocks first
92+ if isinstance ( dataset , vtkMultiBlockDataSet ):
93+ dataset = mergeBlocks ( dataset , keepPartialAttributes = True )
8794 dataframe : pd .DataFrame = pvt .vtkToDataframe ( dataset )
8895 self .m_pathPythonViewScript : Path = geos_pv_path / "src/geos/pv/pythonViewUtils/mainPythonView.py"
8996
Original file line number Diff line number Diff line change 3737 vtkTable ,
3838 vtkUnstructuredGrid ,
3939)
40+ from vtkmodules .vtkFiltersParallelDIY2 import vtkGenerateGlobalIds
4041
4142from geos .utils .GeosOutputsConstants import (
4243 ComponentNameEnum ,
@@ -122,8 +123,18 @@ def vtkUnstructuredGridCellsToDataframe( grid: vtkUnstructuredGrid ) -> pd.DataF
122123 Returns:
123124 pd.DataFrame: Pandas dataframe.
124125 """
125- cellIdAttributeName = GeosMeshOutputsEnum .VTK_ORIGINAL_CELL_ID .attributeName
126+ cellIdAttributeName : str = GeosMeshOutputsEnum .VTK_ORIGINAL_CELL_ID .attributeName
126127 cellData = grid .GetCellData ()
128+ if not cellData .HasArray ( GeosMeshOutputsEnum .VTK_ORIGINAL_CELL_ID .attributeName ):
129+ print ( "We have to create global ids." )
130+ idFilter = vtkGenerateGlobalIds ()
131+ idFilter .SetInputData ( grid )
132+ idFilter .Update ()
133+ grid = idFilter .GetOutput ()
134+ cellData = grid .GetCellData () # Update cellData to point to the new grid's cell data
135+ cellIdAttributeName = "GlobalCellIds"
136+ assert cellData .HasArray (cellIdAttributeName ), "Invalid global ids array name selected."
137+
127138 numberCells : int = grid .GetNumberOfCells ()
128139 data : dict [ str , Any ] = {}
129140 for i in range ( cellData .GetNumberOfArrays () ):
You can’t perform that action at this time.
0 commit comments