Skip to content

Commit 358a45f

Browse files
committed
some more constraints
1 parent e943d4c commit 358a45f

File tree

6 files changed

+61
-55
lines changed

6 files changed

+61
-55
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,16 @@
1818

1919
import vtkmodules.util.numpy_support as vnp
2020

21-
2221
from vtkmodules.vtkCommonDataModel import (
23-
vtkDataSet,
24-
)
22+
vtkDataSet, )
2523

2624
# update sys.path to load all GEOS Python Package dependencies
2725
geos_pv_path: Path = Path( __file__ ).parent.parent.parent.parent.parent
2826
sys.path.insert( 0, str( geos_pv_path / "src" ) )
29-
from geos.pv.utils.config import update_paths
3027

3128
from geos.mesh.processing.CreateConstantAttributePerRegion import ( CreateConstantAttributePerRegion )
3229

3330
from geos.pv.utils.details import SISOFilter, FilterCategory
34-
from geos.mesh.processing.CreateConstantAttributePerRegion import CreateConstantAttributePerRegion
3531

3632
__doc__ = """
3733
PVCreateConstantAttributePerRegion is a Paraview plugin that allows to create an attribute
@@ -53,10 +49,12 @@
5349
* Apply.
5450
5551
"""
52+
53+
5654
@SISOFilter( category=FilterCategory.GEOS_PROP,
5755
decoratedLabel="Create Constant Attribute Per Region",
58-
decoratedType=[ "vtkMultiBlockDataSet", "vtkDataSet" ])
59-
class PVCreateConstantAttributePerRegion(VTKPythonAlgorithmBase):
56+
decoratedType=[ "vtkMultiBlockDataSet", "vtkDataSet" ] )
57+
class PVCreateConstantAttributePerRegion( VTKPythonAlgorithmBase ):
6058

6159
def __init__( self: Self ) -> None:
6260
"""Create an attribute with constant value per region."""
@@ -275,12 +273,12 @@ def groupNewAttributeSettingsWidgets( self: Self ) -> None:
275273
"""Group the widgets to set the settings of the new attribute."""
276274
self.Modified()
277275

278-
def Filter(self, inputMesh: vtkDataSet , outputMesh: vtkDataSet) -> None:
276+
def Filter( self, inputMesh: vtkDataSet, outputMesh: vtkDataSet ) -> None:
279277
"""Is applying CreateConstantAttributePerRegion filter.
280-
outputMesh : A mesh transformed.
278+
281279
Args:
282280
inputMesh : A mesh to transform
283-
outputMesh : A mesh transformed
281+
outputMesh : A mesh transformed.
284282
"""
285283
filter: CreateConstantAttributePerRegion = CreateConstantAttributePerRegion(
286284
outputMesh,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
@SISOFilter( category=FilterCategory.GEOS_UTILS,
4747
decoratedLabel="Fill Partial Arrays",
4848
decoratedType="vtkMultiBlockDataSet" )
49-
class PVFillPartialArrays(VTKPythonAlgorithmBase):
49+
class PVFillPartialArrays( VTKPythonAlgorithmBase ):
5050

5151
def __init__( self: Self, ) -> None:
5252
"""Fill a partial attribute with constant value per component."""
@@ -90,7 +90,7 @@ def setDictAttributesValues( self: Self, attributeName: str, values: str ) -> No
9090
if values is not None:
9191
self.dictAttributesValues[ attributeName ] = list( values.split( "," ) )
9292
else:
93-
self.dictAttributesValues[ attributeName ] = None # ignore : type[unreachable]
93+
self.dictAttributesValues[ attributeName ] = None #ignore : type[unreachable]
9494

9595
self.Modified()
9696

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
from typing_extensions import Self, Optional
88

99
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
10-
VTKPythonAlgorithmBase, smdomain, smproperty,
10+
VTKPythonAlgorithmBase, smdomain, smproperty,
1111
)
1212
from vtkmodules.vtkCommonCore import (
13-
vtkDataArraySelection,
14-
)
13+
vtkDataArraySelection, )
1514
from vtkmodules.vtkCommonDataModel import (
1615
vtkUnstructuredGrid, )
1716

@@ -65,10 +64,12 @@
6564
.. IMPORTANT::
6665
Please refer to the `Verdict Manual <https://visit-sphinx-github-user-manual.readthedocs.io/en/v3.4.0/_downloads/9d944264b44b411aeb4a867a1c9b1ed5/VerdictManual-revA.pdf>`_ for metrics and range definitions.
6766
"""
67+
68+
6869
@SISOFilter( category=FilterCategory.GEOS_QC,
6970
decoratedLabel="Mesh Quality Enhanced",
70-
decoratedType="vtkUnstructuredGrid")
71-
class PVMeshQualityEnhanced(VTKPythonAlgorithmBase):
71+
decoratedType="vtkUnstructuredGrid" )
72+
class PVMeshQualityEnhanced( VTKPythonAlgorithmBase ):
7273

7374
def __init__( self: Self ) -> None:
7475
"""Merge collocated points."""
@@ -164,7 +165,7 @@ def b01SetSaveToFile( self: Self, saveToFile: bool ) -> None:
164165
"""
165166
if self._saveToFile != saveToFile:
166167
self._saveToFile = saveToFile
167-
PVMeshQualityEnhanced.Modified(self)
168+
PVMeshQualityEnhanced.Modified( self )
168169

169170
@smproperty.stringvector( name="FilePath", label="File Path" )
170171
@smdomain.xml( """
@@ -183,7 +184,7 @@ def b02SetFileName( self: Self, fname: str ) -> None:
183184
"""
184185
if self._filename != fname:
185186
self._filename = fname
186-
PVMeshQualityEnhanced.Modified(self)
187+
PVMeshQualityEnhanced.Modified( self )
187188

188189
@smproperty.xml( """
189190
<PropertyGroup
@@ -199,12 +200,12 @@ def b02SetFileName( self: Self, fname: str ) -> None:
199200
""" )
200201
def b03GroupAdvancedOutputParameters( self: Self ) -> None:
201202
"""Organize groups."""
202-
PVMeshQualityEnhanced.Modified(self)
203+
PVMeshQualityEnhanced.Modified( self )
203204

204205
def Modified( self: Self ) -> None:
205206
"""Overload Modified method to reset _blockIndex."""
206207
self._blockIndex = 0
207-
VTKPythonAlgorithmBase.Modified(self)
208+
VTKPythonAlgorithmBase.Modified( self )
208209

209210
def _getQualityMetricsToUse( self: Self, selection: vtkDataArraySelection ) -> set[ int ]:
210211
"""Get mesh quality metric indexes from user selection.
@@ -215,7 +216,7 @@ def _getQualityMetricsToUse( self: Self, selection: vtkDataArraySelection ) -> s
215216
metricsNames: set[ str ] = getArrayChoices( selection )
216217
return { getQualityMeasureIndexFromName( name ) for name in metricsNames }
217218

218-
def Filter(self, inputMesh: vtkUnstructuredGrid, outputMesh:vtkUnstructuredGrid) -> None:
219+
def Filter( self, inputMesh: vtkUnstructuredGrid, outputMesh: vtkUnstructuredGrid ) -> None:
219220
"""Is applying MeshQualityEnhanced to the input Mesh.
220221
221222
Args:

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
vtkInformation,
4242
)
4343

44+
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
45+
VTKPythonAlgorithmBase )
46+
4447
from vtkmodules.vtkCommonDataModel import vtkDataObject
4548
from geos.pv.utils.details import SISOFilter, FilterCategory
4649

@@ -59,10 +62,12 @@
5962
* Search and Apply PVPythonViewConfigurator Filter.
6063
6164
"""
65+
66+
6267
@SISOFilter( category=FilterCategory.GEOS_UTILS,
6368
decoratedLabel="Python View Configurator",
64-
decoratedType="vtkDataObject")
65-
class PVPythonViewConfigurator:
69+
decoratedType="vtkDataObject" )
70+
class PVPythonViewConfigurator( VTKPythonAlgorithmBase ):
6671

6772
def __init__( self: Self ) -> None:
6873
"""Paraview plugin to create cross-plots in a Python View.
@@ -805,7 +810,7 @@ def FillInputPortInformation( self: Self, port: int, info: vtkInformation ) -> i
805810
info.Set( self.INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject" )
806811
return 1
807812

808-
def Filter(self, inputMesh : vtkDataObject, outputMesh : vtkDataObject) -> None:
813+
def Filter( self, inputMesh: vtkDataObject, outputMesh: vtkDataObject ) -> None:
809814
"""Dummy interface for plugin to fit decorator reqs.
810815
811816
Args:

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from typing_extensions import Self
88

99
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
10-
VTKPythonAlgorithmBase
11-
)
10+
VTKPythonAlgorithmBase )
1211

1312
from vtkmodules.vtkCommonDataModel import (
1413
vtkPointSet, )
@@ -22,6 +21,7 @@
2221

2322
from geos.mesh.processing.SplitMesh import SplitMesh
2423
from geos.pv.utils.details import SISOFilter, FilterCategory
24+
2525
__doc__ = """
2626
Split each cell of input mesh to smaller cells.
2727
@@ -36,20 +36,14 @@
3636
"""
3737

3838

39-
@SISOFilter( category=FilterCategory.GEOS_UTILS,
40-
decoratedLabel="Split Mesh",
41-
decoratedType="vtkPointSet")
42-
class PVSplitMesh(VTKPythonAlgorithmBase):
39+
@SISOFilter( category=FilterCategory.GEOS_UTILS, decoratedLabel="Split Mesh", decoratedType="vtkPointSet" )
40+
class PVSplitMesh( VTKPythonAlgorithmBase ):
4341

4442
def __init__( self: Self ) -> None:
4543
"""Split mesh cells."""
4644
pass
4745

48-
def Filter(
49-
self: Self,
50-
inputMesh: vtkPointSet,
51-
outputMesh:vtkPointSet
52-
) -> None:
46+
def Filter( self: Self, inputMesh: vtkPointSet, outputMesh: vtkPointSet ) -> None:
5347
"""Apply vtk filter.
5448
5549
Args:

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
from abc import abstractmethod
1212
from enum import Enum
1313

14-
1514
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
1615
VTKPythonAlgorithmBase, smdomain, smhint, smproperty, smproxy,
1716
) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/util/vtkAlgorithm.py
1817

1918
from vtkmodules.vtkCommonDataModel import (
20-
vtkMultiBlockDataSet, )
19+
vtkMultiBlockDataSet,
20+
vtkDataObject,
21+
)
2122

2223
from vtkmodules.vtkCommonCore import (
2324
vtkInformation,
@@ -43,6 +44,8 @@ class PVMyFilter:
4344
...
4445
4546
"""
47+
48+
4649
# Enum for filter categories
4750
class FilterCategory( str, Enum ):
4851
"""String Enum to sort into category in PV task bar under Plugins."""
@@ -55,15 +58,17 @@ class FilterCategory( str, Enum ):
5558
# Add more as needed
5659

5760

58-
U = TypeVar('U')
61+
U = TypeVar( 'U', bound='vtkDataObject' )
62+
63+
5964
@runtime_checkable
60-
class IsSISOFilter( Protocol[U] ):
65+
class IsSISOFilter( Protocol[ U ] ):
6166
"""Protocol to ensure that the wrapped filter defines the correct Filter core function."""
6267

6368
@abstractmethod
6469
def Filter(
6570
self,
66-
inputMesh: U,
71+
inputMesh: U,
6772
outputMesh: U,
6873
) -> None:
6974
"""Define filter here.
@@ -75,12 +80,14 @@ def Filter(
7580
"""
7681
raise NotImplementedError
7782

83+
7884
T = TypeVar( 'T', bound='IsSISOFilter' )
7985

8086

8187
def SISOFilter( category: FilterCategory, decoratedLabel: str,
82-
decoratedType: Union[str,list] ) -> Callable[ [ Type[ T ] ], Type[ T ] ]:
88+
decoratedType: Union[ str, list ] ) -> Callable[ [ Type[ T ] ], Type[ T ] ]:
8389
"""Decorate Single Input Single Output (SISO) filter."""
90+
8491
def decoratedClass( cls: Type[ T ] ) -> Type[ T ]:
8592
"""Outer wrapper function. All is in the WrappingClass below."""
8693
originalInit = cls.__init__
@@ -94,11 +101,12 @@ def __init__( self, *ar: Any, **kw: Any ) -> None:
94101
ar : Fowarded arguments
95102
kw : Forwarded keywords args
96103
"""
97-
VTKPythonAlgorithmBase.__init__( self,
98-
nInputPorts=1,
99-
nOutputPorts=1,
100-
inputType=decoratedType if isinstance(decoratedType,str) else "vtkDataObject",
101-
outputType=decoratedType if isinstance(decoratedType,str) else "vtkDataObject")
104+
VTKPythonAlgorithmBase.__init__(
105+
self,
106+
nInputPorts=1,
107+
nOutputPorts=1,
108+
inputType=decoratedType if isinstance( decoratedType, str ) else "vtkDataObject",
109+
outputType=decoratedType if isinstance( decoratedType, str ) else "vtkDataObject" )
102110

103111
#If wrapped class has more to init there it is applied
104112
#avoid the overwritten init by decorator taking place of the cls
@@ -155,16 +163,16 @@ def RequestData(
155163

156164
cls.Filter( self, inputMesh, outputMesh )
157165
return 1
158-
166+
159167
# Copy all methods and attributes from cls, including decorator metadata
160-
for attrName in dir(cls):
161-
if attrName.startswith('_'):
168+
for attrName in dir( cls ):
169+
if attrName.startswith( '_' ):
162170
continue # Skip private/magic methods (already handled or inherited)
163-
164-
attr = getattr(cls, attrName)
171+
172+
attr = getattr( cls, attrName )
165173
# Copy methods with their decorators
166-
if callable(attr) and attrName not in WrappingClass.__dict__:
167-
setattr(WrappingClass,attrName,attr)
174+
if callable( attr ) and attrName not in WrappingClass.__dict__:
175+
setattr( WrappingClass, attrName, attr )
168176

169177
# Copy metadata
170178
WrappingClass.__name__ = cls.__name__
@@ -175,7 +183,7 @@ def RequestData(
175183

176184
#decorate it old fashion way
177185
WrappingClass = smdomain.datatype(
178-
dataTypes=[ decoratedType ] if isinstance(decoratedType,str) else decoratedType,
186+
dataTypes=[ decoratedType ] if isinstance( decoratedType, str ) else decoratedType,
179187
composite_data_supported=True,
180188
)( WrappingClass )
181189
WrappingClass = smproperty.input( name="Input", port_index=0 )( WrappingClass )

0 commit comments

Comments
 (0)