Skip to content

Commit ecd13f7

Browse files
committed
SISOFilter for all
1 parent 731421c commit ecd13f7

File tree

1 file changed

+10
-58
lines changed

1 file changed

+10
-58
lines changed

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

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@
44
# ruff: noqa: E402 # disable Module level import not at top of file
55
import sys
66
from pathlib import Path
7-
from typing import Union
87

98
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
10-
VTKPythonAlgorithmBase, smdomain, smhint, smproperty, smproxy,
9+
VTKPythonAlgorithmBase,
1110
) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/util/vtkAlgorithm.py
1211
from paraview.detail.loghandler import ( # type: ignore[import-not-found]
1312
VTKHandler,
1413
) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/detail/loghandler.py
1514

1615
from vtkmodules.vtkCommonDataModel import (
17-
vtkMultiBlockDataSet,
18-
vtkUnstructuredGrid,
19-
)
20-
21-
from vtkmodules.vtkCommonCore import (
22-
vtkInformation,
23-
vtkInformationVector,
24-
)
16+
vtkMultiBlockDataSet, )
2517

2618
# update sys.path to load all GEOS Python Package dependencies
2719
geos_pv_path: Path = Path( __file__ ).parent.parent.parent.parent.parent
@@ -30,6 +22,7 @@
3022

3123
update_paths()
3224

25+
from geos.pv.utils.details import SISOFilter, FilterCategory
3326
from geos.mesh.processing.ClipToMainFrame import ClipToMainFrame
3427

3528
__doc__ = """
@@ -43,67 +36,26 @@
4336
"""
4437

4538

46-
@smproxy.filter( name="PVClipToMainFrame", label="Clip to the main frame" )
47-
@smhint.xml( '<ShowInMenu category="4- Geos Utils"/>' )
48-
@smproperty.input( name="Input", port_index=0 )
49-
@smdomain.datatype(
50-
dataTypes=[ "vtkMultiBlockDataSet", "vtkUnstructuredGrid" ],
51-
composite_data_supported=True,
52-
)
39+
@SISOFilter( category=FilterCategory.GEOS_UTILS,
40+
decorated_label="Clip to the main frame",
41+
decorated_type=[ "vtkMultiBlockDataSet", "vtkDataSet" ] )
5342
class PVClipToMainFrame( VTKPythonAlgorithmBase ):
5443

5544
def __init__( self ) -> None:
5645
"""Init motherclass, filter and logger."""
57-
VTKPythonAlgorithmBase.__init__( self,
58-
nInputPorts=1,
59-
nOutputPorts=1,
60-
inputType="vtkDataObject",
61-
outputType="vtkDataObject" )
62-
6346
self._realFilter = ClipToMainFrame( speHandler=True )
6447
if not self._realFilter.logger.hasHandlers():
6548
self._realFilter.SetLoggerHandler( VTKHandler() )
6649

67-
#ensure I/O consistency
68-
def RequestDataObject( self, request: vtkInformation, inInfoVec: list[ vtkInformationVector ],
69-
outInfoVec: vtkInformationVector ) -> int:
70-
"""Inherited from VTKPythonAlgorithmBase::RequestDataObject.
71-
72-
Args:
73-
request (vtkInformation): request
74-
inInfoVec (list[vtkInformationVector]): input objects
75-
outInfoVec (vtkInformationVector): output objects
76-
77-
Returns:
78-
int: 1 if calculation successfully ended, 0 otherwise.
79-
"""
80-
inData = self.GetInputData( inInfoVec, 0, 0 )
81-
outData = self.GetOutputData( outInfoVec, 0 )
82-
assert inData is not None
83-
if outData is None or ( not outData.IsA( inData.GetClassName() ) ):
84-
outData = inData.NewInstance()
85-
outInfoVec.GetInformationObject( 0 ).Set( outData.DATA_OBJECT(), outData )
86-
return super().RequestDataObject( request, inInfoVec, outInfoVec ) # type: ignore[no-any-return]
87-
88-
def RequestData( self, request: vtkInformation, inInfo: list[ vtkInformationVector ],
89-
outInfo: vtkInformationVector ) -> int:
90-
"""Inherited from VTKPythonAlgorithmBase::RequestData. Apply ClipToMainFrame filter.
50+
def Filter( self, inputMesh: vtkMultiBlockDataSet, outputMesh: vtkMultiBlockDataSet ) -> None:
51+
"""Is applying CreateConstantAttributePerRegion filter.
9152
9253
Args:
93-
request (vtkInformation): Request
94-
inInfo (list[vtkInformationVector]): Input objects
95-
outInfo (vtkInformationVector): Output objects
96-
97-
Returns:
98-
int: 1 if calculation successfully ended, 0 otherwise.
54+
inputMesh : a mesh to transform
55+
outputMesh : a mesh transformed
9956
"""
100-
inputMesh: Union[ vtkMultiBlockDataSet, vtkUnstructuredGrid ] = self.GetInputData( inInfo, 0, 0 )
101-
outputMesh: Union[ vtkMultiBlockDataSet, vtkUnstructuredGrid ] = self.GetOutputData( outInfo, 0 )
102-
10357
# struct
10458
self._realFilter.SetInputData( inputMesh )
10559
self._realFilter.ComputeTransform()
10660
self._realFilter.Update()
10761
outputMesh.ShallowCopy( self._realFilter.GetOutputDataObject( 0 ) )
108-
109-
return 1

0 commit comments

Comments
 (0)