Skip to content

Commit 584c88e

Browse files
committed
Add vtk to mock imports
1 parent f4a9ca2 commit 584c88e

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
]
4949

5050
autoclass_content = 'both'
51-
autodoc_mock_imports = [ "ats", "h5py", "lxml", "paraview", "pygeosx", "pylvarray", "meshio", "mpi4py", "scipy", "xmlschema", "colorcet", "xsdata" ]
51+
autodoc_mock_imports = [ "ats", "colorcet", "h5py", "lxml", "meshio", "mpi4py", "scipy", "paraview", "pygeosx", "pylvarray", "vtk", "xmlschema", "xsdata" ]
5252
autodoc_typehints = 'none'
5353
autodoc_typehints_format = 'short'
5454
suppress_warnings = [ "autodoc.mocked_object" ]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
3+
# SPDX-FileContributor: Lionel Untereiner
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
3+
# SPDX-FileContributor: Lionel Untereiner
4+
from typing_extensions import Self
5+
6+
from paraview.util.vtkAlgorithm import smdomain, smhint, smproperty, smproxy
7+
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
8+
from vtkmodules.vtkCommonCore import vtkInformation, vtkInformationVector
9+
from vtkmodules.vtkCommonDataModel import vtkPartitionedDataSetCollection
10+
11+
paraview_plugin_version = "0.1.0"
12+
13+
14+
@smproxy.reader(
15+
name="PythonGeosDeckReader",
16+
label="Python-based Deck Reader for GEOS",
17+
extensions="xml",
18+
file_description="XML files",
19+
)
20+
class PVGeosDeckReader( VTKPythonAlgorithmBase ):
21+
22+
def __init__( self: Self ) -> Self:
23+
"""Constructor of the reader."""
24+
VTKPythonAlgorithmBase.__init__(
25+
self,
26+
nInputPorts=0,
27+
nOutputPorts=1,
28+
outputType="vtkPartitionedDataSetCollection",
29+
) # type: ignore
30+
self.__filename: str
31+
from geos_xml_viewer.filters.geosDeckReader import GeosDeckReader
32+
33+
self.__realAlgorithm = GeosDeckReader()
34+
35+
@smproperty.stringvector( name="FileName" ) # type: ignore
36+
@smdomain.filelist() # type: ignore
37+
@smhint.filechooser( extensions="xml", file_description="GEOS XML files" ) # type: ignore
38+
def SetFileName( self: Self, name: str ) -> None:
39+
"""Specify filename for the file to read.
40+
41+
Args:
42+
name (str): filename
43+
"""
44+
if self.__filename != name:
45+
self.__filename = name
46+
self.__realAlgorithm.SetFileName( self.__filename )
47+
self.__realAlgorithm.Update()
48+
self.Modified()
49+
50+
def RequestData(
51+
self: Self,
52+
request: vtkInformation,
53+
inInfoVec: list[ vtkInformationVector ],
54+
outInfoVec: vtkInformationVector,
55+
) -> int:
56+
"""RequestData function of the vtk pipeline.
57+
58+
Args:
59+
request (vtkInformation): information about the request
60+
inInfoVec (list[vtkInformationVector]): input information vector
61+
outInfoVec (vtkInformationVector): output information vector
62+
63+
Raises:
64+
RuntimeError: Raises an error if no filename is specified
65+
66+
Returns:
67+
int: Returns 1 if the pipeline is successful
68+
"""
69+
if self.__filename is None:
70+
raise RuntimeError( "No filename specified" )
71+
72+
output = vtkPartitionedDataSetCollection.GetData( inInfoVec, 0 )
73+
output.ShallowCopy( self.__realAlgorithm.GetOutputDataObject( 0 ) )
74+
return 1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
3+
# SPDX-FileContributor: Lionel Untereiner
4+
5+
import os
6+
import sys
7+
8+
sys.path.append( os.path.dirname( __file__ ) )

geos-xml-viewer/src/PVPlugins/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)