Skip to content

Commit 1a57322

Browse files
committed
wip
1 parent 8081656 commit 1a57322

File tree

2 files changed

+98
-18
lines changed

2 files changed

+98
-18
lines changed

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
update_paths()
3131

3232
from geos.mesh.processing.FillPartialArrays import FillPartialArrays
33-
33+
import geos.pv.utils.details
3434
__doc__ = """
3535
Fill partial arrays of input mesh.
3636
@@ -47,21 +47,22 @@
4747
"""
4848

4949

50-
@smproxy.filter( name="PVFillPartialArrays", label="Fill Partial Arrays" )
51-
@smhint.xml( '<ShowInMenu category="4- Geos Utils"/>' )
52-
@smproperty.input( name="Input", port_index=0 )
53-
@smdomain.datatype(
54-
dataTypes=[ "vtkMultiBlockDataSet" ],
55-
composite_data_supported=True,
56-
)
57-
class PVFillPartialArrays( VTKPythonAlgorithmBase ):
50+
# @smproxy.filter( name="PVFillPartialArrays", label="Fill Partial Arrays" )
51+
# @smhint.xml( '<ShowInMenu category="4- Geos Utils"/>' )
52+
# @smproperty.input( name="Input", port_index=0 )
53+
# @smdomain.datatype(
54+
# dataTypes=[ "vtkMultiBlockDataSet" ],
55+
# composite_data_supported=True,
56+
# )
57+
@geos.pv.utils.details.SISOFilter(decorated_name="PVFillPartialArrays", decorated_label="Fill Partial Arrays",decorated_type="vtkMultiBlockDataSet")
58+
class PVFillPartialArrays:
5859

5960
def __init__( self: Self, ) -> None:
6061
"""Fill a partial attribute with constant value per component."""
61-
super().__init__( nInputPorts=1,
62-
nOutputPorts=1,
63-
inputType="vtkMultiBlockDataSet",
64-
outputType="vtkMultiBlockDataSet" )
62+
# super().__init__( nInputPorts=1,
63+
# nOutputPorts=1,
64+
# inputType="vtkMultiBlockDataSet",
65+
# outputType="vtkMultiBlockDataSet" )
6566

6667
self.clearDictAttributesValues: bool = True
6768
self.dictAttributesValues: dict[ str, Union[ list[ Any ], None ] ] = {}
@@ -99,13 +100,13 @@ def _setDictAttributesValues( self: Self, attributeName: str, values: str ) -> N
99100
if self.clearDictAttributesValues:
100101
self.dictAttributesValues = {}
101102
self.clearDictAttributesValues = False
102-
103+
103104
if attributeName is not None:
104105
if values is not None :
105106
self.dictAttributesValues[ attributeName ] = list( values.split( "," ) )
106107
else:
107108
self.dictAttributesValues[ attributeName ] = None
108-
109+
109110
self.Modified()
110111

111112
def RequestDataObject(
@@ -156,13 +157,13 @@ def RequestData(
156157
outputMesh.ShallowCopy( inputMesh )
157158

158159
filter: FillPartialArrays = FillPartialArrays( outputMesh,
159-
self.dictAttributesValues,
160+
self.dictAttributesValues,
160161
True,
161162
)
162-
163+
163164
if not filter.logger.hasHandlers():
164165
filter.setLoggerHandler( VTKHandler() )
165-
166+
166167
filter.applyFilter()
167168

168169
self.clearDictAttributesValues = True
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
3+
# SPDX-FileContributor: Martin Lemay, Romain Baville
4+
# ruff: noqa: E402 # disable Module level import not at top of file
5+
import sys
6+
from pathlib import Path
7+
from typing import Union, Any
8+
from typing_extensions import Self
9+
10+
# from functools import wraps
11+
# from dataclasses import dataclass
12+
13+
from paraview.util.vtkAlgorithm import ( # type: ignore[import-not-found]
14+
VTKPythonAlgorithmBase, smdomain, smhint, smproperty, smproxy,
15+
) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/util/vtkAlgorithm.py
16+
from paraview.detail.loghandler import ( # type: ignore[import-not-found]
17+
VTKHandler,
18+
) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/detail/loghandler.py
19+
20+
from vtkmodules.vtkCommonDataModel import (
21+
vtkMultiBlockDataSet, )
22+
23+
from vtkmodules.vtkCommonCore import (
24+
vtkInformation,
25+
vtkInformationVector,
26+
)
27+
28+
# update sys.path to load all GEOS Python Package dependencies
29+
geos_pv_path: Path = Path( __file__ ).parent.parent.parent.parent.parent
30+
sys.path.insert( 0, str( geos_pv_path / "src" ) )
31+
from geos.pv.utils.config import update_paths
32+
33+
update_paths()
34+
35+
__doc__ = """
36+
Set of decorators that allow:
37+
- quicker generation of MultiBlockDataSet to MultiBlockDataSet filters
38+
- more stable logger strategy
39+
40+
Usage is:
41+
42+
@SISO(name='MyFilter',label='This is my filter',dtype='vtkMultiBlockDataSet')
43+
class PVMyFilter:
44+
...
45+
def __hidden_layer(self):
46+
47+
48+
"""
49+
50+
def SISOFilter(decorated_name, decorated_label, decorated_type):
51+
"""
52+
Decorate single input single output filter
53+
"""
54+
def decorated_class(cls):
55+
@smproxy.filter( name=decorated_name, label=decorated_label )
56+
@smhint.xml( '<ShowInMenu category="4- Geos Utils"/>' )
57+
@smproperty.input( name="Input", port_index=0 )
58+
@smdomain.datatype(
59+
dataTypes=[ decorated_type ],
60+
composite_data_supported=True,
61+
)
62+
# @dataclass
63+
# class WrappingClass(cls):
64+
class WrappingClass(cls,VTKPythonAlgorithmBase):
65+
66+
def __init__(self,*ar,**kw):
67+
VTKPythonAlgorithmBase.__init__(self, nInputPorts=1,
68+
nOutputPorts=1,
69+
inputType=decorated_type,
70+
outputType=decorated_type )
71+
cls.___init__(self,*ar,**kw)
72+
WrappingClass.__name__ = cls.__name__
73+
WrappingClass.__module__ = cls.__module__
74+
75+
return WrappingClass
76+
return decorated_class
77+
78+
79+

0 commit comments

Comments
 (0)