diff --git a/geos-geomechanics/pyproject.toml b/geos-geomechanics/pyproject.toml index be5ca9638..66be4e7f5 100644 --- a/geos-geomechanics/pyproject.toml +++ b/geos-geomechanics/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ ] dependencies=[ "geos-utils", - "vtk >= 9.3", + "vtk >= 9.6", "numpy >= 2.2", "pandas >= 2.2", "typing_extensions >= 4.12", diff --git a/geos-mesh/pyproject.toml b/geos-mesh/pyproject.toml index 06f278e63..d012d0187 100644 --- a/geos-mesh/pyproject.toml +++ b/geos-mesh/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ - "vtk >= 9.3", + "vtk >= 9.6", "networkx >= 2.4", "tqdm >= 4.67", "numpy >= 2.2", diff --git a/geos-mesh/src/geos/mesh/model/CellTypeCounts.py b/geos-mesh/src/geos/mesh/model/CellTypeCounts.py index 708925eff..81696accd 100644 --- a/geos-mesh/src/geos/mesh/model/CellTypeCounts.py +++ b/geos-mesh/src/geos/mesh/model/CellTypeCounts.py @@ -4,7 +4,7 @@ import numpy as np import numpy.typing as npt from typing_extensions import Self -from vtkmodules.vtkCommonDataModel import ( vtkCellTypes, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_VERTEX, VTK_POLYHEDRON, +from vtkmodules.vtkCommonDataModel import ( vtkCellTypeUtilities, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_VERTEX, VTK_POLYHEDRON, VTK_POLYGON, VTK_PYRAMID, VTK_HEXAHEDRON, VTK_WEDGE, VTK_NUMBER_OF_CELL_TYPES ) @@ -116,9 +116,9 @@ def _updateGeneralCounts( self: Self, cellType: int, count: int ) -> None: cellType (int): cell type count (int): count increment """ - if ( cellType != VTK_POLYGON ) and ( vtkCellTypes.GetDimension( cellType ) == 2 ): + if ( cellType != VTK_POLYGON ) and ( vtkCellTypeUtilities.GetDimension( cellType ) == 2 ): self._counts[ VTK_POLYGON ] += count - if ( cellType != VTK_POLYHEDRON ) and ( vtkCellTypes.GetDimension( cellType ) == 3 ): + if ( cellType != VTK_POLYHEDRON ) and ( vtkCellTypeUtilities.GetDimension( cellType ) == 3 ): self._counts[ VTK_POLYHEDRON ] += count def print( self: Self ) -> str: @@ -136,7 +136,7 @@ def print( self: Self ) -> str: card += f"| **Total Number of Cells** | {int(self.getTotalCount()):12} |\n" card += "| - | - |\n" for cellType in ( VTK_TRIANGLE, VTK_QUAD ): - card += f"| **Total Number of {vtkCellTypes.GetClassNameFromTypeId(cellType):<13}** | {int(self._counts[cellType]):12} |\n" + card += f"| **Total Number of {vtkCellTypeUtilities.GetClassNameFromTypeId(cellType):<13}** | {int(self._counts[cellType]):12} |\n" for cellType in ( VTK_TETRA, VTK_PYRAMID, VTK_WEDGE, VTK_HEXAHEDRON ): - card += f"| **Total Number of {vtkCellTypes.GetClassNameFromTypeId(cellType):<13}** | {int(self._counts[cellType]):12} |\n" + card += f"| **Total Number of {vtkCellTypeUtilities.GetClassNameFromTypeId(cellType):<13}** | {int(self._counts[cellType]):12} |\n" return card diff --git a/geos-mesh/src/geos/mesh/model/QualityMetricSummary.py b/geos-mesh/src/geos/mesh/model/QualityMetricSummary.py index e21d86e72..793342b57 100644 --- a/geos-mesh/src/geos/mesh/model/QualityMetricSummary.py +++ b/geos-mesh/src/geos/mesh/model/QualityMetricSummary.py @@ -15,7 +15,7 @@ from matplotlib.axes import Axes from matplotlib.lines import Line2D from matplotlib.patches import Patch -from vtkmodules.vtkCommonDataModel import ( vtkCellTypes, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_PYRAMID, +from vtkmodules.vtkCommonDataModel import ( vtkCellTypeUtilities, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_PYRAMID, VTK_HEXAHEDRON, VTK_WEDGE, VTK_POLYGON, VTK_POLYHEDRON ) from geos.mesh.stats.meshQualityMetricHelpers import ( QUALITY_METRIC_OTHER_START_INDEX, getAllCellTypesExtended, getQualityMeasureNameFromIndex, getQualityMetricFromIndex, @@ -149,7 +149,7 @@ class QualityMetricSummary(): _CELL_TYPES_PLOT: tuple[ int, ...] = ( VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_PYRAMID, VTK_WEDGE, VTK_HEXAHEDRON, VTK_POLYGON, VTK_POLYHEDRON ) _CELL_TYPES_NAME: list[ str ] = [ - vtkCellTypes.GetClassNameFromTypeId( cellType ).removeprefix( "vtk" ) for cellType in _CELL_TYPES_PLOT + vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ).removeprefix( "vtk" ) for cellType in _CELL_TYPES_PLOT ] def __init__( self: Self ) -> None: diff --git a/geos-mesh/src/geos/mesh/stats/meshQualityMetricHelpers.py b/geos-mesh/src/geos/mesh/stats/meshQualityMetricHelpers.py index 7a44ee7a9..8d2aff422 100644 --- a/geos-mesh/src/geos/mesh/stats/meshQualityMetricHelpers.py +++ b/geos-mesh/src/geos/mesh/stats/meshQualityMetricHelpers.py @@ -435,6 +435,8 @@ class VtkCellQualityMetricEnum( CellQualityMetricEnum ): ( False, False, True, True, True, True ), ( None, None, QualityRange( ( 0.0, 0.3 ), ( 0.0, 0.9 ), ( 0.0, 1.0 ) ), None, None, None ) ) + #: the radius of the largest sphere that fits snugly inside it + INRADIUS = ( vtkMeshQuality.QualityMeasureTypes.INRADIUS, "Inradius", ( False, False, True, False, False, False ), ( None, None, None, None, None, None ) ) #: no metric NONE = ( vtkMeshQuality.QualityMeasureTypes.NONE, "None", ( False, False, False, False, False, False ), ( None, None, None, None, None, None ) ) diff --git a/geos-mesh/src/geos/mesh/utils/genericHelpers.py b/geos-mesh/src/geos/mesh/utils/genericHelpers.py index de11a4023..e59d541c1 100644 --- a/geos-mesh/src/geos/mesh/utils/genericHelpers.py +++ b/geos-mesh/src/geos/mesh/utils/genericHelpers.py @@ -43,7 +43,7 @@ def isTriangulate( dataSet: vtkUnstructuredGrid ) -> bool: bool: True if the mesh is triangulate only, False otherwise. """ cellTypes: vtkCellTypes = vtkCellTypes() - dataSet.GetCellTypes( cellTypes ) + dataSet.GetDistinctCellTypes( cellTypes ) return all( cellTypes.GetCellType( cell ) == VTK_TRIANGLE for cell in range( cellTypes.GetNumberOfTypes() ) ) diff --git a/geos-mesh/tests/test_CellTypeCounts.py b/geos-mesh/tests/test_CellTypeCounts.py index b5278ce0f..4352ded81 100644 --- a/geos-mesh/tests/test_CellTypeCounts.py +++ b/geos-mesh/tests/test_CellTypeCounts.py @@ -8,7 +8,7 @@ from geos.mesh.model.CellTypeCounts import CellTypeCounts -from vtkmodules.vtkCommonDataModel import ( vtkCellTypes, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_PYRAMID, +from vtkmodules.vtkCommonDataModel import ( vtkCellTypeUtilities, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_PYRAMID, VTK_HEXAHEDRON, VTK_WEDGE, VTK_VERTEX ) # inputs @@ -77,10 +77,10 @@ def __get_expected_counts( nbTri, nbQuad, ), strict=True ): - countsExp += f"| **Total Number of {vtkCellTypes.GetClassNameFromTypeId(cellType):<13}** | {int(nb):12} |\n" + countsExp += f"| **Total Number of {vtkCellTypeUtilities.GetClassNameFromTypeId(cellType):<13}** | {int(nb):12} |\n" for cellType, nb in zip( ( VTK_TETRA, VTK_PYRAMID, VTK_WEDGE, VTK_HEXAHEDRON ), ( nbTetra, nbPyr, nbWed, nbHexa ), strict=True ): - countsExp += f"| **Total Number of {vtkCellTypes.GetClassNameFromTypeId(cellType):<13}** | {int(nb):12} |\n" + countsExp += f"| **Total Number of {vtkCellTypeUtilities.GetClassNameFromTypeId(cellType):<13}** | {int(nb):12} |\n" return countsExp diff --git a/geos-mesh/tests/test_QualityMetricSummary.py b/geos-mesh/tests/test_QualityMetricSummary.py index 91335f8d5..3aebac26f 100644 --- a/geos-mesh/tests/test_QualityMetricSummary.py +++ b/geos-mesh/tests/test_QualityMetricSummary.py @@ -144,7 +144,7 @@ def test_QualityMetricSummary_init() -> None: stats: QualityMetricSummary = QualityMetricSummary() assert stats.getAllCellStats() is not None, "Stats member is undefined." assert ( stats.getAllCellStats().shape[ 0 ] - == 5 ) and stats.getAllCellStats().shape[ 1 ] == 122, "Stats shape is wrong." + == 5 ) and stats.getAllCellStats().shape[ 1 ] == 123, "Stats shape is wrong." @pytest.mark.parametrize( "test_case", __generate_failed_test_data() ) diff --git a/geos-mesh/tests/test_genericHelpers.py b/geos-mesh/tests/test_genericHelpers.py index 85de45f5c..ce36288c6 100644 --- a/geos-mesh/tests/test_genericHelpers.py +++ b/geos-mesh/tests/test_genericHelpers.py @@ -153,7 +153,7 @@ def test_createMultiCellMesh( test_case: TestCase ) -> None: # check cell types types: vtkCellTypes = vtkCellTypes() - output.GetCellTypes( types ) + output.GetDistinctCellTypes( types ) assert types is not None, "Cell types must be defined" typesArray: npt.NDArray[ np.int64 ] = vtk_to_numpy( types.GetCellTypesArray() ) assert ( typesArray.size == 1 ) and ( typesArray[ 0 ] == test_case.cellTypes[ 0 ] ), "Cell types are wrong" diff --git a/geos-mesh/tests/test_genericHelpers_createSingleCellMesh.py b/geos-mesh/tests/test_genericHelpers_createSingleCellMesh.py index 82a6194d7..40cfe9dad 100644 --- a/geos-mesh/tests/test_genericHelpers_createSingleCellMesh.py +++ b/geos-mesh/tests/test_genericHelpers_createSingleCellMesh.py @@ -13,7 +13,7 @@ from vtkmodules.util.numpy_support import vtk_to_numpy -from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellArray, vtkCellTypes, VTK_TRIANGLE, VTK_QUAD, +from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellArray, vtkCellTypeUtilities, vtkCellTypes, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_HEXAHEDRON, VTK_PYRAMID ) from vtkmodules.vtkCommonCore import ( @@ -50,7 +50,7 @@ def __generate_test_data() -> Iterator[ TestCase ]: yield TestCase( cellType, cell ) -ids: list[ str ] = [ vtkCellTypes.GetClassNameFromTypeId( cellType ) for cellType in cell_type_all ] +ids: list[ str ] = [ vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ) for cellType in cell_type_all ] @pytest.mark.parametrize( "test_case", __generate_test_data(), ids=ids ) @@ -60,7 +60,7 @@ def test_createSingleCellMesh( test_case: TestCase ) -> None: Args: test_case (TestCase): test case """ - cellTypeName: str = vtkCellTypes.GetClassNameFromTypeId( test_case.cellType ) + cellTypeName: str = vtkCellTypeUtilities.GetClassNameFromTypeId( test_case.cellType ) output: vtkUnstructuredGrid = createSingleCellMesh( test_case.cellType, test_case.cellPoints ) assert output is not None, "Output mesh is undefined." @@ -78,7 +78,7 @@ def test_createSingleCellMesh( test_case: TestCase ) -> None: assert cellsOut.GetNumberOfCells() == 1, "Number of cells is expected to be 1." # check cell types types: vtkCellTypes = vtkCellTypes() - output.GetCellTypes( types ) + output.GetDistinctCellTypes( types ) assert types is not None, "Cell types must be defined" typesArray: npt.NDArray[ np.int64 ] = vtk_to_numpy( types.GetCellTypesArray() ) diff --git a/geos-mesh/tests/test_meshQualityHelpers.py b/geos-mesh/tests/test_meshQualityHelpers.py index 2b077d96f..22ac33768 100644 --- a/geos-mesh/tests/test_meshQualityHelpers.py +++ b/geos-mesh/tests/test_meshQualityHelpers.py @@ -77,6 +77,7 @@ vtkMeshQuality.QualityMeasureTypes.EDGE_RATIO, vtkMeshQuality.QualityMeasureTypes.EQUIANGLE_SKEW, vtkMeshQuality.QualityMeasureTypes.EQUIVOLUME_SKEW, + vtkMeshQuality.QualityMeasureTypes.INRADIUS, vtkMeshQuality.QualityMeasureTypes.JACOBIAN, vtkMeshQuality.QualityMeasureTypes.MEAN_RATIO, vtkMeshQuality.QualityMeasureTypes.MIN_ANGLE, @@ -167,6 +168,7 @@ def __generate_test_data() -> Iterator[ TestCase ]: def test_CellQualityMetricEnum_Order() -> None: """Test VtkCellQualityMetricEnum ordering is correct.""" for i, metric in enumerate( list( VtkCellQualityMetricEnum ) ): + print(metric.metricIndex) assert metric.metricIndex == i diff --git a/geos-processing/pyproject.toml b/geos-processing/pyproject.toml index 13391180b..e1737a446 100644 --- a/geos-processing/pyproject.toml +++ b/geos-processing/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "geos-geomechanics", "geos-utils", "geos-mesh", - "vtk >= 9.3", + "vtk >= 9.6", "numpy >= 2.2", "typing_extensions >= 4.12", ] diff --git a/geos-processing/src/geos/processing/generic_processing_tools/SplitMesh.py b/geos-processing/src/geos/processing/generic_processing_tools/SplitMesh.py index bad8002ce..3e8acc7cc 100644 --- a/geos-processing/src/geos/processing/generic_processing_tools/SplitMesh.py +++ b/geos-processing/src/geos/processing/generic_processing_tools/SplitMesh.py @@ -7,7 +7,7 @@ from typing_extensions import Self from vtkmodules.vtkCommonCore import vtkPoints, vtkIdTypeArray, vtkDataArray -from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellArray, vtkCellData, vtkCell, vtkCellTypes, +from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellArray, vtkCellData, vtkCell, vtkCellTypeUtilities, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_HEXAHEDRON, VTK_PYRAMID, VTK_WEDGE, VTK_POLYHEDRON, VTK_POLYGON ) from vtkmodules.util.numpy_support import numpy_to_vtk, vtk_to_numpy @@ -156,7 +156,7 @@ def applyFilter( self: Self ) -> None: if splitMethod is not None: splitMethod( cell, c ) else: - raise TypeError( f"Cell type { vtkCellTypes.GetClassNameFromTypeId( cellType ) } is not supported." ) + raise TypeError( f"Cell type { vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ) } is not supported." ) # Add points and cells self.outputMesh.SetPoints( self.points ) diff --git a/geos-processing/src/geos/processing/pre_processing/CellTypeCounterEnhanced.py b/geos-processing/src/geos/processing/pre_processing/CellTypeCounterEnhanced.py index 3938a5978..d0f1665e1 100644 --- a/geos-processing/src/geos/processing/pre_processing/CellTypeCounterEnhanced.py +++ b/geos-processing/src/geos/processing/pre_processing/CellTypeCounterEnhanced.py @@ -5,7 +5,7 @@ from typing_extensions import Self from vtkmodules.vtkCommonCore import vtkIntArray -from vtkmodules.vtkCommonDataModel import vtkUnstructuredGrid, vtkCell, vtkTable, vtkCellTypes, VTK_VERTEX +from vtkmodules.vtkCommonDataModel import vtkUnstructuredGrid, vtkCell, vtkTable, vtkCellTypeUtilities, VTK_VERTEX from geos.mesh.model.CellTypeCounts import CellTypeCounts from geos.mesh.stats.meshQualityMetricHelpers import getAllCellTypes @@ -116,7 +116,7 @@ def applyFilter( self: Self ) -> None: # Create columns per types for cellType in getAllCellTypes(): array: vtkIntArray = vtkIntArray() - array.SetName( vtkCellTypes.GetClassNameFromTypeId( cellType ) ) + array.SetName( vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ) ) array.SetNumberOfComponents( 1 ) array.SetNumberOfValues( 1 ) array.SetValue( 0, self._counts.getTypeCount( cellType ) ) diff --git a/geos-processing/src/geos/processing/pre_processing/MeshQualityEnhanced.py b/geos-processing/src/geos/processing/pre_processing/MeshQualityEnhanced.py index 930c64c41..44e6a5415 100644 --- a/geos-processing/src/geos/processing/pre_processing/MeshQualityEnhanced.py +++ b/geos-processing/src/geos/processing/pre_processing/MeshQualityEnhanced.py @@ -11,7 +11,7 @@ from vtkmodules.vtkCommonCore import ( vtkIdList, vtkPoints, vtkDataArray, vtkIntArray, vtkDoubleArray, vtkIdTypeArray, vtkMath ) from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkPolyData, vtkCellData, vtkPointData, vtkFieldData, - vtkCell, vtkCell3D, vtkTetra, vtkCellTypes, vtkPolygon, VTK_TRIANGLE, + vtkCell, vtkCell3D, vtkTetra, vtkCellTypeUtilities, vtkPolygon, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_PYRAMID, VTK_HEXAHEDRON, VTK_WEDGE, VTK_POLYGON, VTK_POLYHEDRON ) from vtkmodules.util.numpy_support import vtk_to_numpy, numpy_to_vtk @@ -605,7 +605,7 @@ def _createFieldDataStatsSummary( self: Self ) -> None: count: int = self._qualityMetricSummary.getCellTypeCountsOfCellType( cellType ) metrics: Optional[ set[ int ] ] = self.getComputedMetricsFromCellType( cellType ) # Create count array - name = "_".join( ( vtkCellTypes.GetClassNameFromTypeId( cellType ), StatTypes.COUNT.getString() ) ) + name = "_".join( ( vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ), StatTypes.COUNT.getString() ) ) countArray: vtkIntArray = vtkIntArray() countArray.SetName( name ) countArray.SetNumberOfValues( 1 ) @@ -641,7 +641,7 @@ def _createArrayName( self: Self, cellType: int, metricIndex: int, statType: Sta Returns: str: Array name """ - return "_".join( ( vtkCellTypes.GetClassNameFromTypeId( cellType ), + return "_".join( ( vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ), getQualityMeasureNameFromIndex( metricIndex ).replace( " ", "" ), statType.getString() ) ) def _computeAdditionalMetricsCell( self: Self, metricIndex: int, cell: vtkCell ) -> float: diff --git a/geos-processing/tests/test_CellTypeCounterEnhanced.py b/geos-processing/tests/test_CellTypeCounterEnhanced.py index 7883592c7..bdc8a78f9 100644 --- a/geos-processing/tests/test_CellTypeCounterEnhanced.py +++ b/geos-processing/tests/test_CellTypeCounterEnhanced.py @@ -12,7 +12,7 @@ from geos.processing.pre_processing.CellTypeCounterEnhanced import CellTypeCounterEnhanced from geos.mesh.model.CellTypeCounts import CellTypeCounts -from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellTypes, vtkCell, VTK_TRIANGLE, VTK_QUAD, +from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellTypeUtilities, vtkCell, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_VERTEX, VTK_POLYHEDRON, VTK_POLYGON, VTK_PYRAMID, VTK_HEXAHEDRON, VTK_WEDGE ) @@ -49,7 +49,7 @@ def __generate_test_data_single_cell() -> Iterator[ TestCase ]: yield TestCase( mesh ) -ids: list[ str ] = [ vtkCellTypes.GetClassNameFromTypeId( cellType ) for cellType in cellType_all ] +ids: list[ str ] = [ vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ) for cellType in cellType_all ] @pytest.mark.parametrize( "test_case", __generate_test_data_single_cell(), ids=ids ) @@ -78,7 +78,7 @@ def test_CellTypeCounterEnhanced_single( test_case: TestCase ) -> None: for i, elementType in enumerate( elementTypes ): assert int( countsObs.getTypeCount( elementType ) - ) == counts[ i ], f"The number of {vtkCellTypes.GetClassNameFromTypeId(elementType)} should be {counts[i]}." + ) == counts[ i ], f"The number of {vtkCellTypeUtilities.GetClassNameFromTypeId(elementType)} should be {counts[i]}." nbPolygon: int = counts[ 0 ] + counts[ 1 ] nbPolyhedra: int = np.sum( counts[ 2: ], dtype=int ) @@ -136,7 +136,7 @@ def test_CellTypeCounterEnhanced_multi( test_case: TestCase ) -> None: for i, elementType in enumerate( elementTypes ): assert int( countsObs.getTypeCount( elementType ) - ) == counts[ i ], f"The number of {vtkCellTypes.GetClassNameFromTypeId(elementType)} should be {counts[i]}." + ) == counts[ i ], f"The number of {vtkCellTypeUtilities.GetClassNameFromTypeId(elementType)} should be {counts[i]}." nbPolygon: int = counts[ 0 ] + counts[ 1 ] nbPolyhedra: int = np.sum( counts[ 2: ], dtype=int ) diff --git a/geos-processing/tests/test_MeshQualityEnhanced.py b/geos-processing/tests/test_MeshQualityEnhanced.py index 6b3cb6784..149d11fac 100644 --- a/geos-processing/tests/test_MeshQualityEnhanced.py +++ b/geos-processing/tests/test_MeshQualityEnhanced.py @@ -16,7 +16,7 @@ from geos.mesh.model.QualityMetricSummary import QualityMetricSummary from vtkmodules.vtkFiltersVerdict import vtkMeshQuality -from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellData, vtkFieldData, vtkCellTypes, VTK_TRIANGLE, +from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellData, vtkFieldData, vtkCellTypeUtilities, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_PYRAMID, VTK_WEDGE, VTK_HEXAHEDRON ) from vtkmodules.vtkIOXML import vtkXMLUnstructuredGridReader @@ -148,7 +148,7 @@ def test_MeshQualityEnhanced( test_case: TestCase ) -> None: for i, cellType in enumerate( getAllCellTypesExtended() ): metrics: Optional[ set[ int ] ] = meshQualityEnhancedFilter.getComputedMetricsFromCellType( cellType ) if test_case.cellTypeCounts[ i ] > 0: - assert metrics is not None, f"Metrics from {vtkCellTypes.GetClassNameFromTypeId(cellType)} cells is undefined." + assert metrics is not None, f"Metrics from {vtkCellTypeUtilities.GetClassNameFromTypeId(cellType)} cells is undefined." # test attributes outputMesh: vtkUnstructuredGrid = meshQualityEnhancedFilter.getOutput() @@ -176,7 +176,7 @@ def test_MeshQualityEnhanced( test_case: TestCase ) -> None: for i, cellType in enumerate( getAllCellTypesExtended() ): # test Counts assert stats.getCellTypeCountsOfCellType( cellType ) == test_case.cellTypeCounts[ - i ], f"Number of {vtkCellTypes.GetClassNameFromTypeId(cellType)} cells is expected to be {test_case.cellTypeCounts[i]}" + i ], f"Number of {vtkCellTypeUtilities.GetClassNameFromTypeId(cellType)} cells is expected to be {test_case.cellTypeCounts[i]}" if stats.getCellTypeCountsOfCellType( cellType ) == 0: continue diff --git a/geos-processing/tests/test_SplitMesh.py b/geos-processing/tests/test_SplitMesh.py index c97f24be2..a609e1432 100644 --- a/geos-processing/tests/test_SplitMesh.py +++ b/geos-processing/tests/test_SplitMesh.py @@ -8,7 +8,7 @@ import pytest from typing import Iterator from vtkmodules.util.numpy_support import vtk_to_numpy -from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellArray, vtkCellData, vtkCellTypes, VTK_TRIANGLE, +from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkCellArray, vtkCellData, vtkCellTypes, vtkCellTypeUtilities, VTK_TRIANGLE, VTK_QUAD, VTK_TETRA, VTK_HEXAHEDRON, VTK_PYRAMID ) from vtkmodules.vtkCommonCore import vtkPoints, vtkIdList, vtkDataArray from geos.mesh.io.vtkIO import readUnstructuredGrid @@ -131,7 +131,7 @@ def __generate_split_mesh_test_data() -> Iterator[ TestCase ]: yield TestCase( cellType, mesh, pointsExp, cellsExp ) -ids = [ vtkCellTypes.GetClassNameFromTypeId( cellType ) for cellType in cell_types_all ] +ids = [ vtkCellTypeUtilities.GetClassNameFromTypeId( cellType ) for cellType in cell_types_all ] @pytest.mark.parametrize( "test_case", __generate_split_mesh_test_data(), ids=ids ) @@ -141,7 +141,7 @@ def test_single_cell_split( test_case: TestCase ) -> None: Args: test_case (TestCase): test case """ - cellTypeName: str = vtkCellTypes.GetClassNameFromTypeId( test_case.cellType ) + cellTypeName: str = vtkCellTypeUtilities.GetClassNameFromTypeId( test_case.cellType ) splitMeshFilter: SplitMesh = SplitMesh( test_case.mesh ) splitMeshFilter.applyFilter() output: vtkUnstructuredGrid = splitMeshFilter.getOutput() @@ -160,7 +160,7 @@ def test_single_cell_split( test_case: TestCase ) -> None: test_case.cellsExp ), f"Number of cells is expected to be {len(test_case.cellsExp)}." # check cell types types: vtkCellTypes = vtkCellTypes() - output.GetCellTypes( types ) + output.GetDistinctCellTypes( types ) assert types is not None, "Cell types must be defined" typesArray: npt.NDArray[ np.int64 ] = vtk_to_numpy( types.GetCellTypesArray() ) diff --git a/mesh-doctor/src/geos/mesh_doctor/actions/supportedElements.py b/mesh-doctor/src/geos/mesh_doctor/actions/supportedElements.py index 23c6a28c1..fa07bb0c0 100644 --- a/mesh-doctor/src/geos/mesh_doctor/actions/supportedElements.py +++ b/mesh-doctor/src/geos/mesh_doctor/actions/supportedElements.py @@ -9,7 +9,7 @@ from typing import Iterable, Mapping, Optional from vtkmodules.util.numpy_support import vtk_to_numpy from vtkmodules.vtkCommonCore import vtkIdList -from vtkmodules.vtkCommonDataModel import ( vtkCellTypes, vtkUnstructuredGrid, VTK_HEXAGONAL_PRISM, VTK_HEXAHEDRON, +from vtkmodules.vtkCommonDataModel import ( vtkCellTypeUtilities, vtkUnstructuredGrid, VTK_HEXAGONAL_PRISM, VTK_HEXAHEDRON, VTK_LINE, VTK_PENTAGONAL_PRISM, VTK_POLYGON, VTK_POLYHEDRON, VTK_PYRAMID, VTK_QUAD, VTK_TETRA, VTK_TRIANGLE, VTK_VERTEX, VTK_VOXEL, VTK_WEDGE ) from geos.mesh_doctor.actions.vtkPolyhedron import buildFaceToFaceConnectivityThroughEdges, FaceStream @@ -140,11 +140,11 @@ def findUnsupportedStdElementsTypes( mesh: vtkUnstructuredGrid ) -> list[ str ]: if hasattr( mesh, "GetDistinctCellTypesArray" ): # For more recent versions of vtk. uniqueCellTypes = set( vtk_to_numpy( mesh.GetDistinctCellTypesArray() ) ) else: - _vtkCellTypes = vtkCellTypes() - mesh.GetCellTypes( _vtkCellTypes ) - uniqueCellTypes = set( vtkIter( _vtkCellTypes ) ) + _vtkCellTypeUtilities = vtkCellTypeUtilities() + mesh.GetCellTypes( _vtkCellTypeUtilities ) + uniqueCellTypes = set( vtkIter( _vtkCellTypeUtilities ) ) resultValues: set[ int ] = uniqueCellTypes - supportedCellTypes - results = [ f"Type {i}: {vtkCellTypes.GetClassNameFromTypeId( i )}" for i in frozenset( resultValues ) ] + results = [ f"Type {i}: {vtkCellTypeUtilities.GetClassNameFromTypeId( i )}" for i in frozenset( resultValues ) ] return results