Skip to content

Commit ccb1e18

Browse files
committed
Revert "Fix for PVPythonViewConfigurator to handle new MultiblockDataSet input. Can still crash in some cases and will need separate PR to deal with it."
This reverts commit 183f9a1.
1 parent 183f9a1 commit ccb1e18

File tree

2 files changed

+46
-35
lines changed

2 files changed

+46
-35
lines changed

geos-pv/src/geos/pv/plugins/PVPythonViewConfigurator.py

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
update_paths()
1818

19-
from geos.mesh.utils.multiblockModifiers import mergeBlocks
2019
import geos.pv.utils.paraviewTreatments as pvt
2120
from geos.pv.utils.checkboxFunction import ( # type: ignore[attr-defined]
2221
createModifiedCallback, )
@@ -35,22 +34,14 @@
3534
GetActiveSource, GetActiveView, Render, Show, servermanager,
3635
)
3736
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
38-
smdomain, smproperty,
37+
VTKPythonAlgorithmBase, smdomain, smhint, smproperty, smproxy,
3938
)
4039
from vtkmodules.vtkCommonCore import (
4140
vtkDataArraySelection,
4241
vtkInformation,
42+
vtkInformationVector,
4343
)
4444

45-
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
46-
VTKPythonAlgorithmBase )
47-
48-
from vtkmodules.vtkCommonDataModel import (
49-
vtkDataObject,
50-
vtkMultiBlockDataSet,
51-
)
52-
from geos.pv.utils.details import SISOFilter, FilterCategory
53-
5445
__doc__ = """
5546
PVPythonViewConfigurator is a Paraview plugin that allows to create cross-plots
5647
from input data using the PythonView.
@@ -68,17 +59,18 @@
6859
"""
6960

7061

71-
@SISOFilter( category=FilterCategory.GEOS_UTILS,
72-
decoratedLabel="Python View Configurator",
73-
decoratedType="vtkDataObject" )
62+
@smproxy.filter( name="PVPythonViewConfigurator", label="Python View Configurator" )
63+
@smhint.xml( '<ShowInMenu category="4- Geos Utils"/>' )
64+
@smproperty.input( name="Input" )
65+
@smdomain.datatype( dataTypes=[ "vtkDataObject" ], composite_data_supported=True )
7466
class PVPythonViewConfigurator( VTKPythonAlgorithmBase ):
7567

7668
def __init__( self: Self ) -> None:
7769
"""Paraview plugin to create cross-plots in a Python View.
7870
7971
Input is a vtkDataObject.
8072
"""
81-
# super().__init__( nInputPorts=1, nOutputPorts=1 )
73+
super().__init__( nInputPorts=1, nOutputPorts=1 )
8274
# Python view layout and object.
8375
self.m_layoutName: str = ""
8476
self.m_pythonView: Any
@@ -88,9 +80,6 @@ def __init__( self: Self ) -> None:
8880
# Input source and curve names.
8981
inputSource = GetActiveSource()
9082
dataset = servermanager.Fetch( inputSource )
91-
# Handle vtkMultiBlockDataSet by merging blocks first
92-
if isinstance( dataset, vtkMultiBlockDataSet ):
93-
dataset = mergeBlocks( dataset, keepPartialAttributes=True )
9483
dataframe: pd.DataFrame = pvt.vtkToDataframe( dataset )
9584
self.m_pathPythonViewScript: Path = geos_pv_path / "src/geos/pv/pythonViewUtils/mainPythonView.py"
9685

@@ -817,14 +806,47 @@ def FillInputPortInformation( self: Self, port: int, info: vtkInformation ) -> i
817806
info.Set( self.INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject" )
818807
return 1
819808

820-
def Filter( self, inputMesh: vtkDataObject, outputMesh: vtkDataObject ) -> None:
821-
"""Dummy interface for plugin to fit decorator reqs.
809+
def RequestDataObject(
810+
self: Self,
811+
request: vtkInformation,
812+
inInfoVec: list[ vtkInformationVector ],
813+
outInfoVec: vtkInformationVector,
814+
) -> int:
815+
"""Inherited from VTKPythonAlgorithmBase::RequestDataObject.
816+
817+
Args:
818+
request (vtkInformation): Request.
819+
inInfoVec (list[vtkInformationVector]): Input objects.
820+
outInfoVec (vtkInformationVector): Output objects.
821+
822+
Returns:
823+
int: 1 if calculation successfully ended, 0 otherwise.
824+
"""
825+
inData = self.GetInputData( inInfoVec, 0, 0 )
826+
outData = self.GetOutputData( outInfoVec, 0 )
827+
assert inData is not None
828+
if outData is None or ( not outData.IsA( inData.GetClassName() ) ):
829+
outData = inData.NewInstance()
830+
outInfoVec.GetInformationObject( 0 ).Set( outData.DATA_OBJECT(), outData )
831+
return super().RequestDataObject( request, inInfoVec, outInfoVec ) # type: ignore[no-any-return]
832+
833+
def RequestData(
834+
self: Self,
835+
request: vtkInformation, # noqa: F841
836+
inInfoVec: list[ vtkInformationVector ], # noqa: F841
837+
outInfoVec: vtkInformationVector, # noqa: F841
838+
) -> int:
839+
"""Inherited from VTKPythonAlgorithmBase::RequestData.
822840
823841
Args:
824-
inputMesh : A dummy mesh to transform
825-
outputMesh : A dummy mesh transformed
842+
request (vtkInformation): Request.
843+
inInfoVec (list[vtkInformationVector]): Input objects.
844+
outInfoVec (vtkInformationVector): Output objects.
826845
846+
Returns:
847+
int: 1 if calculation successfully ended, 0 otherwise.
827848
"""
849+
# pythonViewGeneration
828850
assert self.m_pythonView is not None, "No Python View was found."
829851
viewSize = GetActiveView().ViewSize
830852
self.m_userChoices[ "ratio" ] = viewSize[ 0 ] / viewSize[ 1 ]
@@ -833,4 +855,4 @@ def Filter( self, inputMesh: vtkDataObject, outputMesh: vtkDataObject ) -> None:
833855
self.defineCurvesAspect()
834856
self.m_pythonView.Script = self.buildPythonViewScript()
835857
Render()
836-
return
858+
return 1

geos-pv/src/geos/pv/utils/paraviewTreatments.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
vtkTable,
3838
vtkUnstructuredGrid,
3939
)
40-
from vtkmodules.vtkFiltersParallelDIY2 import vtkGenerateGlobalIds
4140

4241
from geos.utils.GeosOutputsConstants import (
4342
ComponentNameEnum,
@@ -123,18 +122,8 @@ def vtkUnstructuredGridCellsToDataframe( grid: vtkUnstructuredGrid ) -> pd.DataF
123122
Returns:
124123
pd.DataFrame: Pandas dataframe.
125124
"""
126-
cellIdAttributeName: str = GeosMeshOutputsEnum.VTK_ORIGINAL_CELL_ID.attributeName
125+
cellIdAttributeName = GeosMeshOutputsEnum.VTK_ORIGINAL_CELL_ID.attributeName
127126
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-
138127
numberCells: int = grid.GetNumberOfCells()
139128
data: dict[ str, Any ] = {}
140129
for i in range( cellData.GetNumberOfArrays() ):

0 commit comments

Comments
 (0)