|
4 | 4 | # ruff: noqa: E402 # disable Module level import not at top of file |
5 | 5 | import sys |
6 | 6 | from pathlib import Path |
7 | | -from typing import Union |
8 | 7 |
|
9 | 8 | from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found] |
10 | | - VTKPythonAlgorithmBase, smdomain, smhint, smproperty, smproxy, |
| 9 | + VTKPythonAlgorithmBase, |
11 | 10 | ) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/util/vtkAlgorithm.py |
12 | 11 | from paraview.detail.loghandler import ( # type: ignore[import-not-found] |
13 | 12 | VTKHandler, |
14 | 13 | ) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/detail/loghandler.py |
15 | 14 |
|
16 | 15 | from vtkmodules.vtkCommonDataModel import ( |
17 | | - vtkMultiBlockDataSet, |
18 | | - vtkUnstructuredGrid, |
19 | | -) |
20 | | - |
21 | | -from vtkmodules.vtkCommonCore import ( |
22 | | - vtkInformation, |
23 | | - vtkInformationVector, |
24 | | -) |
| 16 | + vtkMultiBlockDataSet, ) |
25 | 17 |
|
26 | 18 | # update sys.path to load all GEOS Python Package dependencies |
27 | 19 | geos_pv_path: Path = Path( __file__ ).parent.parent.parent.parent.parent |
|
30 | 22 |
|
31 | 23 | update_paths() |
32 | 24 |
|
| 25 | +from geos.pv.utils.details import SISOFilter, FilterCategory |
33 | 26 | from geos.mesh.processing.ClipToMainFrame import ClipToMainFrame |
34 | 27 |
|
35 | 28 | __doc__ = """ |
|
43 | 36 | """ |
44 | 37 |
|
45 | 38 |
|
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" ] ) |
53 | 42 | class PVClipToMainFrame( VTKPythonAlgorithmBase ): |
54 | 43 |
|
55 | 44 | def __init__( self ) -> None: |
56 | 45 | """Init motherclass, filter and logger.""" |
57 | | - VTKPythonAlgorithmBase.__init__( self, |
58 | | - nInputPorts=1, |
59 | | - nOutputPorts=1, |
60 | | - inputType="vtkDataObject", |
61 | | - outputType="vtkDataObject" ) |
62 | | - |
63 | 46 | self._realFilter = ClipToMainFrame( speHandler=True ) |
64 | 47 | if not self._realFilter.logger.hasHandlers(): |
65 | 48 | self._realFilter.SetLoggerHandler( VTKHandler() ) |
66 | 49 |
|
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. |
91 | 52 |
|
92 | 53 | 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 |
99 | 56 | """ |
100 | | - inputMesh: Union[ vtkMultiBlockDataSet, vtkUnstructuredGrid ] = self.GetInputData( inInfo, 0, 0 ) |
101 | | - outputMesh: Union[ vtkMultiBlockDataSet, vtkUnstructuredGrid ] = self.GetOutputData( outInfo, 0 ) |
102 | | - |
103 | 57 | # struct |
104 | 58 | self._realFilter.SetInputData( inputMesh ) |
105 | 59 | self._realFilter.ComputeTransform() |
106 | 60 | self._realFilter.Update() |
107 | 61 | outputMesh.ShallowCopy( self._realFilter.GetOutputDataObject( 0 ) ) |
108 | | - |
109 | | - return 1 |
0 commit comments