-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPVClipToMainFrame.py
More file actions
67 lines (50 loc) · 2.57 KB
/
PVClipToMainFrame.py
File metadata and controls
67 lines (50 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
# SPDX-FileContributor: Jacques Franc
# ruff: noqa: E402 # disable Module level import not at top of file
import sys
import logging
from pathlib import Path
from paraview.util.vtkAlgorithm import VTKPythonAlgorithmBase # type: ignore[import-not-found]
# source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/util/vtkAlgorithm.py
from paraview.detail.loghandler import VTKHandler # type: ignore[import-not-found]
# source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/detail/loghandler.py
from vtkmodules.vtkCommonDataModel import vtkMultiBlockDataSet
# update sys.path to load all GEOS Python Package dependencies
geos_pv_path: Path = Path( __file__ ).parent.parent.parent.parent.parent.parent
sys.path.insert( 0, str( geos_pv_path / "src" ) )
from geos.pv.utils.config import update_paths
update_paths()
from geos.pv.utils.details import ( SISOFilter, FilterCategory )
from geos.processing.generic_processing_tools.ClipToMainFrame import ClipToMainFrame
from geos.utils.Logger import isHandlerInLogger
__doc__ = f"""
Clip the input mesh to the main frame applying the correct LandmarkTransform
To use it:
* Load the plugin in Paraview: Tools > Manage Plugins ... > Load New ... > .../geosPythonPackages/geos-pv/src/geos/pv/plugins/generic_processing/PVClipToMainFrame
* Select the mesh to process
* Select the filter: Filters > { FilterCategory.GENERIC_PROCESSING.value } > Clip to the main frame
* Apply
"""
HANDLER: logging.Handler = VTKHandler()
@SISOFilter( category=FilterCategory.GENERIC_PROCESSING,
decoratedLabel="Clip to the main frame",
decoratedType=[ "vtkMultiBlockDataSet", "vtkDataSet" ] )
class PVClipToMainFrame( VTKPythonAlgorithmBase ):
def __init__( self ) -> None:
"""Init motherclass, filter and logger."""
self._realFilter = ClipToMainFrame( speHandler=True )
if not isHandlerInLogger( HANDLER, self._realFilter.logger ):
self._realFilter.SetLoggerHandler( HANDLER )
def ApplyFilter( self, inputMesh: vtkMultiBlockDataSet, outputMesh: vtkMultiBlockDataSet ) -> None:
"""Is applying clipToMainFrame filter.
Args:
inputMesh : A mesh to transform.
outputMesh : A mesh transformed.
"""
# struct
self._realFilter.SetInputData( inputMesh )
self._realFilter.ComputeTransform()
self._realFilter.Update()
outputMesh.ShallowCopy( self._realFilter.GetOutputDataObject( 0 ) )
return