diff --git a/requirements.txt b/requirements.txt index 43950ad6..9108a15f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -63,4 +63,3 @@ wslink==1.12.4 yarl>=1 # via aiohttp -opengeodeweb-microservice==1.*,>=1.2.0rc1 diff --git a/src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py b/src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py index b9b3720c..5a21fc20 100644 --- a/src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py +++ b/src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py @@ -121,14 +121,12 @@ def displayAttributeOnVertices( pipeline = self.get_vtk_pipeline(data_id) pipeline.reader.GetOutputAsDataSet().GetPointData().SetActiveScalars(name) pipeline.filter.Update() - active_ds = pipeline.mapper.GetInputDataObject(0, 0) - if active_ds: + if active_ds := pipeline.mapper.GetInputDataObject(0, 0): active_ds.GetPointData().SetActiveScalars(name) - mapper = pipeline.mapper - mapper.ScalarVisibilityOn() - mapper.SetScalarModeToUsePointData() - mapper.SetArrayComponent(item) - self.setupColorMap(data_id, color_map, minimum, maximum) + pipeline.mapper.ScalarVisibilityOn() + pipeline.mapper.SetScalarModeToUsePointData() + pipeline.mapper.ColorByArrayComponent(name, item) + self.setupColorMap(data_id, color_map, minimum, maximum, item) def displayAttributeOnCells( self, @@ -142,14 +140,12 @@ def displayAttributeOnCells( pipeline = self.get_vtk_pipeline(data_id) pipeline.reader.GetOutputAsDataSet().GetCellData().SetActiveScalars(name) pipeline.filter.Update() - active_ds = pipeline.mapper.GetInputDataObject(0, 0) - if active_ds: + if active_ds := pipeline.mapper.GetInputDataObject(0, 0): active_ds.GetCellData().SetActiveScalars(name) - mapper = pipeline.mapper - mapper.ScalarVisibilityOn() - mapper.SetScalarModeToUseCellData() - mapper.SetArrayComponent(item) - self.setupColorMap(data_id, color_map, minimum, maximum) + pipeline.mapper.ScalarVisibilityOn() + pipeline.mapper.SetScalarModeToUseCellData() + pipeline.mapper.ColorByArrayComponent(name, item) + self.setupColorMap(data_id, color_map, minimum, maximum, item) def displayScalarRange(self, data_id: str, minimum: float, maximum: float) -> None: print( @@ -161,10 +157,17 @@ def displayScalarRange(self, data_id: str, minimum: float, maximum: float) -> No data.mapper.SetUseLookupTableScalarRange(False) def setupColorMap( - self, data_id: str, points: list[float], minimum: float, maximum: float + self, + data_id: str, + points: list[float], + minimum: float, + maximum: float, + item: int = 0, ) -> None: data = self.get_vtk_pipeline(data_id) lut = vtkColorTransferFunction() + lut.SetVectorModeToComponent() + lut.SetVectorComponent(item) data.mapper.SetLookupTable(lut) if not points: diff --git a/src/opengeodeweb_viewer/vtk_pipeline.py b/src/opengeodeweb_viewer/vtk_pipeline.py index 2723aa99..db15b7f2 100644 --- a/src/opengeodeweb_viewer/vtk_pipeline.py +++ b/src/opengeodeweb_viewer/vtk_pipeline.py @@ -136,19 +136,25 @@ def update_block_colors(self, block_id: int) -> None: block.GetPointData().SetActiveScalars("") block.GetCellData().SetActiveScalars("") return - field_data = ( - block.GetPointData() - if style["attribute_location"] == "point" - else block.GetCellData() - ) + is_point = style["attribute_location"] == "point" + field_data = block.GetPointData() if is_point else block.GetCellData() + other_field_data = block.GetCellData() if is_point else block.GetPointData() + scalar_array = field_data.GetArray(style["name"]) if not scalar_array: return - lut = vtkColorTransferFunction() - points = style["points"] + field_data.SetActiveScalars(style["name"]) + other_field_data.SetActiveScalars("") + + item = style.get("item", 0) minimum = style["minimum"] maximum = style["maximum"] + points = style["points"] + lut = vtkColorTransferFunction() + lut.SetVectorModeToComponent() + lut.SetVectorComponent(item) + lut.SetRange(minimum, maximum) if points: x_min, x_max = points[0], points[-4] span = x_max - x_min @@ -164,27 +170,19 @@ def update_block_colors(self, block_id: int) -> None: lut.AddRGBPoint(minimum, 0, 0, 0) lut.AddRGBPoint(maximum, 1, 1, 1) - lut.SetRange(minimum, maximum) - rgba_colors = lut.MapScalars(scalar_array, 0, style.get("item", 0)) - rgba_colors.SetName(f"__colors_{style['name']}") - - field_data.AddArray(rgba_colors) - field_data.SetActiveScalars(rgba_colors.GetName()) - - other_field_data = ( - block.GetCellData() - if style["attribute_location"] == "point" - else block.GetPointData() - ) - other_field_data.SetActiveScalars("") - if isinstance(self.mapper, vtkCompositePolyDataMapper): - attributes = self.mapper.GetCompositeDataDisplayAttributes() - if attributes: + if attributes := self.mapper.GetCompositeDataDisplayAttributes(): attributes.RemoveBlockColor(block) self.mapper.ScalarVisibilityOn() - self.mapper.SetColorModeToDirectScalars() - self.mapper.SetScalarModeToDefault() + self.mapper.SetLookupTable(lut) + self.mapper.SetScalarRange(minimum, maximum) + self.mapper.SetColorModeToMapScalars() + if is_point: + self.mapper.SetScalarModeToUsePointData() + else: + self.mapper.SetScalarModeToUseCellData() + self.mapper.ColorByArrayComponent(style["name"], item) + self.mapper.InterpolateScalarsBeforeMappingOn() self.mapper.Modified() def sync_block_display_attributes( diff --git a/tests/data/images/mesh/cells/cell_color_map_item.jpeg b/tests/data/images/mesh/cells/cell_color_map_item.jpeg new file mode 100644 index 00000000..edec8f28 Binary files /dev/null and b/tests/data/images/mesh/cells/cell_color_map_item.jpeg differ diff --git a/tests/data/images/mesh/cells/vertex_attribute_item.jpeg b/tests/data/images/mesh/cells/vertex_attribute_item.jpeg new file mode 100644 index 00000000..c87c17bd Binary files /dev/null and b/tests/data/images/mesh/cells/vertex_attribute_item.jpeg differ diff --git a/tests/data/images/mesh/edges/edge_attribute_item.jpeg b/tests/data/images/mesh/edges/edge_attribute_item.jpeg new file mode 100644 index 00000000..1051848d Binary files /dev/null and b/tests/data/images/mesh/edges/edge_attribute_item.jpeg differ diff --git a/tests/data/images/mesh/edges/vertex_attribute_item.jpeg b/tests/data/images/mesh/edges/vertex_attribute_item.jpeg new file mode 100644 index 00000000..ce7f7293 Binary files /dev/null and b/tests/data/images/mesh/edges/vertex_attribute_item.jpeg differ diff --git a/tests/data/images/mesh/points/vertex_attribute_item.jpeg b/tests/data/images/mesh/points/vertex_attribute_item.jpeg new file mode 100644 index 00000000..f19f36cd Binary files /dev/null and b/tests/data/images/mesh/points/vertex_attribute_item.jpeg differ diff --git a/tests/data/images/mesh/polygons/polygon_attribute_item.jpeg b/tests/data/images/mesh/polygons/polygon_attribute_item.jpeg new file mode 100644 index 00000000..8ed15a69 Binary files /dev/null and b/tests/data/images/mesh/polygons/polygon_attribute_item.jpeg differ diff --git a/tests/data/images/mesh/polygons/vertex_attribute_item.jpeg b/tests/data/images/mesh/polygons/vertex_attribute_item.jpeg new file mode 100644 index 00000000..f19f36cd Binary files /dev/null and b/tests/data/images/mesh/polygons/vertex_attribute_item.jpeg differ diff --git a/tests/data/images/mesh/polyhedra/polyhedron_attribute_item.jpeg b/tests/data/images/mesh/polyhedra/polyhedron_attribute_item.jpeg new file mode 100644 index 00000000..d269244b Binary files /dev/null and b/tests/data/images/mesh/polyhedra/polyhedron_attribute_item.jpeg differ diff --git a/tests/data/images/mesh/polyhedra/vertex_attribute_item.jpeg b/tests/data/images/mesh/polyhedra/vertex_attribute_item.jpeg new file mode 100644 index 00000000..9981c86b Binary files /dev/null and b/tests/data/images/mesh/polyhedra/vertex_attribute_item.jpeg differ diff --git a/tests/data/images/model/blocks/updated_vertex_color_map.jpeg b/tests/data/images/model/blocks/updated_vertex_color_map.jpeg index 7e3dc1b7..a3707530 100644 Binary files a/tests/data/images/model/blocks/updated_vertex_color_map.jpeg and b/tests/data/images/model/blocks/updated_vertex_color_map.jpeg differ diff --git a/tests/data/images/model/blocks/vertex_attribute_item.jpeg b/tests/data/images/model/blocks/vertex_attribute_item.jpeg new file mode 100644 index 00000000..25dc7669 Binary files /dev/null and b/tests/data/images/model/blocks/vertex_attribute_item.jpeg differ diff --git a/tests/data/images/model/blocks/vertex_color_map.jpeg b/tests/data/images/model/blocks/vertex_color_map.jpeg index 900c4453..3032eed9 100644 Binary files a/tests/data/images/model/blocks/vertex_color_map.jpeg and b/tests/data/images/model/blocks/vertex_color_map.jpeg differ diff --git a/tests/data/images/model/blocks/vertex_color_map_rainbow.jpeg b/tests/data/images/model/blocks/vertex_color_map_rainbow.jpeg index 2ffcc4c6..740f3f08 100644 Binary files a/tests/data/images/model/blocks/vertex_color_map_rainbow.jpeg and b/tests/data/images/model/blocks/vertex_color_map_rainbow.jpeg differ diff --git a/tests/data/images/model/blocks/vertex_color_map_rainbow_initial.jpeg b/tests/data/images/model/blocks/vertex_color_map_rainbow_initial.jpeg index 3d1f7d07..40d2c3fd 100644 Binary files a/tests/data/images/model/blocks/vertex_color_map_rainbow_initial.jpeg and b/tests/data/images/model/blocks/vertex_color_map_rainbow_initial.jpeg differ diff --git a/tests/data/images/model/corners/vertex_color_map.jpeg b/tests/data/images/model/corners/vertex_color_map.jpeg index 0053b15b..7fae14d6 100644 Binary files a/tests/data/images/model/corners/vertex_color_map.jpeg and b/tests/data/images/model/corners/vertex_color_map.jpeg differ diff --git a/tests/data/images/model/corners/vertex_color_map_rainbow_initial.jpeg b/tests/data/images/model/corners/vertex_color_map_rainbow_initial.jpeg index 70413509..d0f37ee9 100644 Binary files a/tests/data/images/model/corners/vertex_color_map_rainbow_initial.jpeg and b/tests/data/images/model/corners/vertex_color_map_rainbow_initial.jpeg differ diff --git a/tests/data/images/model/edges/visibility.jpeg b/tests/data/images/model/edges/visibility.jpeg index 275131ae..60f37f04 100644 Binary files a/tests/data/images/model/edges/visibility.jpeg and b/tests/data/images/model/edges/visibility.jpeg differ diff --git a/tests/data/images/model/lines/updated_vertex_color_map.jpeg b/tests/data/images/model/lines/updated_vertex_color_map.jpeg index a7301c1e..e99c4343 100644 Binary files a/tests/data/images/model/lines/updated_vertex_color_map.jpeg and b/tests/data/images/model/lines/updated_vertex_color_map.jpeg differ diff --git a/tests/data/images/model/lines/vertex_attribute.jpeg b/tests/data/images/model/lines/vertex_attribute.jpeg index 25e0de5d..24cd1d57 100644 Binary files a/tests/data/images/model/lines/vertex_attribute.jpeg and b/tests/data/images/model/lines/vertex_attribute.jpeg differ diff --git a/tests/data/images/model/lines/vertex_color_map.jpeg b/tests/data/images/model/lines/vertex_color_map.jpeg index e50e4369..73d0f527 100644 Binary files a/tests/data/images/model/lines/vertex_color_map.jpeg and b/tests/data/images/model/lines/vertex_color_map.jpeg differ diff --git a/tests/data/images/model/lines/vertex_color_map_rainbow.jpeg b/tests/data/images/model/lines/vertex_color_map_rainbow.jpeg index 8c8319f1..d3ec0879 100644 Binary files a/tests/data/images/model/lines/vertex_color_map_rainbow.jpeg and b/tests/data/images/model/lines/vertex_color_map_rainbow.jpeg differ diff --git a/tests/data/images/model/lines/vertex_color_map_rainbow_initial.jpeg b/tests/data/images/model/lines/vertex_color_map_rainbow_initial.jpeg index b038df49..eae4408b 100644 Binary files a/tests/data/images/model/lines/vertex_color_map_rainbow_initial.jpeg and b/tests/data/images/model/lines/vertex_color_map_rainbow_initial.jpeg differ diff --git a/tests/data/images/model/lines/vertex_color_map_red_shift.jpeg b/tests/data/images/model/lines/vertex_color_map_red_shift.jpeg index 64d1db6f..f6354c92 100644 Binary files a/tests/data/images/model/lines/vertex_color_map_red_shift.jpeg and b/tests/data/images/model/lines/vertex_color_map_red_shift.jpeg differ diff --git a/tests/data/images/model/lines/visibility.jpeg b/tests/data/images/model/lines/visibility.jpeg index 12b6fc0c..68b64815 100644 Binary files a/tests/data/images/model/lines/visibility.jpeg and b/tests/data/images/model/lines/visibility.jpeg differ diff --git a/tests/data/images/model/points/size.jpeg b/tests/data/images/model/points/size.jpeg index fa5189eb..123cedb9 100644 Binary files a/tests/data/images/model/points/size.jpeg and b/tests/data/images/model/points/size.jpeg differ diff --git a/tests/data/images/model/points/visibility.jpeg b/tests/data/images/model/points/visibility.jpeg index 150626cd..e5d0e635 100644 Binary files a/tests/data/images/model/points/visibility.jpeg and b/tests/data/images/model/points/visibility.jpeg differ diff --git a/tests/data/images/model/register.jpeg b/tests/data/images/model/register.jpeg index 53d4b593..d26591b4 100644 Binary files a/tests/data/images/model/register.jpeg and b/tests/data/images/model/register.jpeg differ diff --git a/tests/data/images/model/surfaces/color.jpeg b/tests/data/images/model/surfaces/color.jpeg index c9f855c5..1976bf06 100644 Binary files a/tests/data/images/model/surfaces/color.jpeg and b/tests/data/images/model/surfaces/color.jpeg differ diff --git a/tests/data/images/model/surfaces/updated_vertex_color_map.jpeg b/tests/data/images/model/surfaces/updated_vertex_color_map.jpeg index 4165289b..4a0a7cfe 100644 Binary files a/tests/data/images/model/surfaces/updated_vertex_color_map.jpeg and b/tests/data/images/model/surfaces/updated_vertex_color_map.jpeg differ diff --git a/tests/data/images/model/surfaces/vertex_attribute_item.jpeg b/tests/data/images/model/surfaces/vertex_attribute_item.jpeg new file mode 100644 index 00000000..25dc7669 Binary files /dev/null and b/tests/data/images/model/surfaces/vertex_attribute_item.jpeg differ diff --git a/tests/data/images/model/surfaces/vertex_color_map.jpeg b/tests/data/images/model/surfaces/vertex_color_map.jpeg index 25dc7669..64a5be4a 100644 Binary files a/tests/data/images/model/surfaces/vertex_color_map.jpeg and b/tests/data/images/model/surfaces/vertex_color_map.jpeg differ diff --git a/tests/data/images/model/surfaces/vertex_color_map_rainbow.jpeg b/tests/data/images/model/surfaces/vertex_color_map_rainbow.jpeg index 2ffcc4c6..740f3f08 100644 Binary files a/tests/data/images/model/surfaces/vertex_color_map_rainbow.jpeg and b/tests/data/images/model/surfaces/vertex_color_map_rainbow.jpeg differ diff --git a/tests/data/images/model/surfaces/vertex_color_map_rainbow_initial.jpeg b/tests/data/images/model/surfaces/vertex_color_map_rainbow_initial.jpeg index 3d1f7d07..40d2c3fd 100644 Binary files a/tests/data/images/model/surfaces/vertex_color_map_rainbow_initial.jpeg and b/tests/data/images/model/surfaces/vertex_color_map_rainbow_initial.jpeg differ diff --git a/tests/mesh/cells/attribute/cell/test_cells_attribute_cell_protocols.py b/tests/mesh/cells/attribute/cell/test_cells_attribute_cell_protocols.py index ecc1133e..45049b5f 100644 --- a/tests/mesh/cells/attribute/cell/test_cells_attribute_cell_protocols.py +++ b/tests/mesh/cells/attribute/cell/test_cells_attribute_cell_protocols.py @@ -305,3 +305,38 @@ def test_cells_cell_color_map_rainbow( ) assert server.compare_image("mesh/cells/cell_color_map_rainbow.jpeg") == True + + +def test_cells_cell_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register(server, dataset_factory) + + server.call( + VtkMeshCellsAttributeCellView.mesh_cells_attribute_cell_prefix + + VtkMeshCellsAttributeCellView.mesh_cells_attribute_cell_schemas_dict[ + "attribute" + ]["rpc"], + [ + { + "id": mesh_id, + "name": "RGB_data", + "item": 1, + "points": [ + 0.0, + 0, + 0, + 1.0, + 255.0, + 1.0, + 0, + 0, + ], + "minimum": 0.0, + "maximum": 255.0, + } + ], + ) + + assert server.compare_image("mesh/cells/cell_color_map_item.jpeg") == True diff --git a/tests/mesh/cells/attribute/vertex/test_cells_attribute_vertex_protocols.py b/tests/mesh/cells/attribute/vertex/test_cells_attribute_vertex_protocols.py index 7a9baa69..aea2a28e 100644 --- a/tests/mesh/cells/attribute/vertex/test_cells_attribute_vertex_protocols.py +++ b/tests/mesh/cells/attribute/vertex/test_cells_attribute_vertex_protocols.py @@ -307,7 +307,7 @@ def test_cells_vertex_color_map_rainbow( assert server.compare_image("mesh/cells/vertex_color_map_rainbow.jpeg") == True -def test_cells_vertex_vector_component( +def test_cells_vertex_attribute_item( server: ServerMonitor, dataset_factory: Callable[..., str] ) -> None: test_register(server, dataset_factory) @@ -339,10 +339,4 @@ def test_cells_vertex_vector_component( ], ) - # Render and assert we receive non-empty image bytes (no backend crashes) - server.call("opengeodeweb_viewer.viewer.render") - while True: - response = server.ws.recv() - if isinstance(response, bytes): - assert len(response) > 0 - break + assert server.compare_image("mesh/cells/vertex_attribute_item.jpeg") == True diff --git a/tests/mesh/edges/attribute/edge/test_edges_attribute_edge_protocols.py b/tests/mesh/edges/attribute/edge/test_edges_attribute_edge_protocols.py index 92a20c72..871bc858 100644 --- a/tests/mesh/edges/attribute/edge/test_edges_attribute_edge_protocols.py +++ b/tests/mesh/edges/attribute/edge/test_edges_attribute_edge_protocols.py @@ -242,3 +242,38 @@ def test_edges_edge_color_map_rainbow( ) assert server.compare_image("mesh/edges/edge_color_map_rainbow.jpeg") == True + + +def test_edges_edge_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register(server, dataset_factory) + + server.call( + VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix + + VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict[ + "attribute" + ]["rpc"], + [ + { + "id": mesh_id, + "name": "cycle_id", + "item": 1, + "points": [ + 0.0, + 0, + 0, + 1.0, + 8.0, + 1.0, + 0, + 0, + ], + "minimum": 0.0, + "maximum": 8.0, + } + ], + ) + + assert server.compare_image("mesh/edges/edge_attribute_item.jpeg") == True diff --git a/tests/mesh/edges/attribute/vertex/test_edges_attribute_vertex_protocols.py b/tests/mesh/edges/attribute/vertex/test_edges_attribute_vertex_protocols.py index 5de92b82..1a80e485 100644 --- a/tests/mesh/edges/attribute/vertex/test_edges_attribute_vertex_protocols.py +++ b/tests/mesh/edges/attribute/vertex/test_edges_attribute_vertex_protocols.py @@ -307,3 +307,38 @@ def test_edges_vertex_color_map_rainbow( ) assert server.compare_image("mesh/edges/vertex_color_map_rainbow.jpeg") == True + + +def test_edges_vertex_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register(server, dataset_factory) + + server.call( + VtkMeshEdgesAttributeVertexView.mesh_edges_attribute_vertex_prefix + + VtkMeshEdgesAttributeVertexView.mesh_edges_attribute_vertex_schemas_dict[ + "attribute" + ]["rpc"], + [ + { + "id": mesh_id, + "name": "points", + "item": 1, + "points": [ + 0.0, + 0, + 0, + 1.0, + 50.0, + 1.0, + 0, + 0, + ], + "minimum": 0.0, + "maximum": 50.0, + } + ], + ) + + assert server.compare_image("mesh/edges/vertex_attribute_item.jpeg") == True diff --git a/tests/mesh/points/attribute/vertex/test_points_attribute_vertex_protocols.py b/tests/mesh/points/attribute/vertex/test_points_attribute_vertex_protocols.py index 91f74233..b8ddcc85 100644 --- a/tests/mesh/points/attribute/vertex/test_points_attribute_vertex_protocols.py +++ b/tests/mesh/points/attribute/vertex/test_points_attribute_vertex_protocols.py @@ -299,3 +299,37 @@ def test_points_vertex_color_map_rainbow( ) assert server.compare_image("mesh/points/vertex_color_map_rainbow.jpeg") == True + + +def test_points_vertex_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register(server, dataset_factory) + + server.call( + VtkMeshPointsAttributeVertexView.mesh_points_attribute_vertex_prefix + + VtkMeshPointsAttributeVertexView.mesh_points_attribute_vertex_schemas_dict[ + "attribute" + ]["rpc"], + [ + { + "id": mesh_id, + "name": "points", + "item": 1, + "points": [ + 2.0, + 0, + 0, + 1.0, + 498.0, + 1.0, + 0, + 0, + ], + "minimum": 2.0, + "maximum": 498.0, + } + ], + ) + assert server.compare_image("mesh/points/vertex_attribute_item.jpeg") == True diff --git a/tests/mesh/polygons/attribute/polygon/test_polygons_attribute_polygon_protocols.py b/tests/mesh/polygons/attribute/polygon/test_polygons_attribute_polygon_protocols.py index aa161317..eb32d5bc 100644 --- a/tests/mesh/polygons/attribute/polygon/test_polygons_attribute_polygon_protocols.py +++ b/tests/mesh/polygons/attribute/polygon/test_polygons_attribute_polygon_protocols.py @@ -327,3 +327,40 @@ def test_polygons_polygon_color_map_rainbow( ) assert server.compare_image("mesh/polygons/polygon_color_map_rainbow.jpeg") == True + + +def test_polygons_polygon_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register(server, dataset_factory) + + server.call( + VtkMeshPolygonsAttributePolygonView.mesh_polygons_attribute_polygon_prefix + + VtkMeshPolygonsAttributePolygonView.mesh_polygons_attribute_polygon_schemas_dict[ + "attribute" + ][ + "rpc" + ], + [ + { + "id": mesh_id, + "name": "triangle_vertices", + "item": 1, + "points": [ + 0.0, + 0, + 0, + 1.0, + 50.0, + 1.0, + 0, + 0, + ], + "minimum": 0.0, + "maximum": 50.0, + } + ], + ) + + assert server.compare_image("mesh/polygons/polygon_attribute_item.jpeg") == True diff --git a/tests/mesh/polygons/attribute/vertex/test_polygons_attribute_vertex_protocols.py b/tests/mesh/polygons/attribute/vertex/test_polygons_attribute_vertex_protocols.py index 2ec8c4bf..fb1bb914 100644 --- a/tests/mesh/polygons/attribute/vertex/test_polygons_attribute_vertex_protocols.py +++ b/tests/mesh/polygons/attribute/vertex/test_polygons_attribute_vertex_protocols.py @@ -322,3 +322,39 @@ def test_polygons_vertex_color_map_rainbow( ) assert server.compare_image("mesh/polygons/vertex_color_map_rainbow.jpeg") == True + + +def test_polygons_vertex_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_register(server, dataset_factory) + + server.call( + VtkMeshPolygonsAttributeVertexView.mesh_polygons_attribute_vertex_prefix + + VtkMeshPolygonsAttributeVertexView.mesh_polygons_attribute_vertex_schemas_dict[ + "attribute" + ][ + "rpc" + ], + [ + { + "id": mesh_id, + "name": "points", + "item": 1, + "points": [ + 2.0, + 0, + 0, + 1.0, + 498.0, + 1.0, + 0, + 0, + ], + "minimum": 2.0, + "maximum": 498.0, + } + ], + ) + + assert server.compare_image("mesh/polygons/vertex_attribute_item.jpeg") == True diff --git a/tests/mesh/polyhedra/attribute/polyhedron/test_polyhedra_attribute_polyhedron_protocols.py b/tests/mesh/polyhedra/attribute/polyhedron/test_polyhedra_attribute_polyhedron_protocols.py index f60da143..e60f198a 100644 --- a/tests/mesh/polyhedra/attribute/polyhedron/test_polyhedra_attribute_polyhedron_protocols.py +++ b/tests/mesh/polyhedra/attribute/polyhedron/test_polyhedra_attribute_polyhedron_protocols.py @@ -330,3 +330,40 @@ def test_polyhedra_polyhedron_color_map_rainbow( assert ( server.compare_image("mesh/polyhedra/polyhedron_color_map_rainbow.jpeg") == True ) + + +def test_polyhedra_polyhedron_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register(server, dataset_factory) + + server.call( + VtkMeshPolyhedraAttributePolyhedronView.mesh_polyhedra_attribute_polyhedron_prefix + + VtkMeshPolyhedraAttributePolyhedronView.mesh_polyhedra_attribute_polyhedron_schemas_dict[ + "attribute" + ][ + "rpc" + ], + [ + { + "id": mesh_id, + "name": "toto_on_polyhedra", + "item": 1, + "points": [ + 3.0, + 0, + 0, + 1.0, + 6.0, + 1.0, + 0, + 0, + ], + "minimum": 3.0, + "maximum": 6.0, + } + ], + ) + + assert server.compare_image("mesh/polyhedra/polyhedron_attribute_item.jpeg") == True diff --git a/tests/mesh/polyhedra/attribute/vertex/test_polyhedra_attribute_vertex_protocols.py b/tests/mesh/polyhedra/attribute/vertex/test_polyhedra_attribute_vertex_protocols.py index 1412c18f..29fc9eb8 100644 --- a/tests/mesh/polyhedra/attribute/vertex/test_polyhedra_attribute_vertex_protocols.py +++ b/tests/mesh/polyhedra/attribute/vertex/test_polyhedra_attribute_vertex_protocols.py @@ -327,3 +327,40 @@ def test_polyhedra_vertex_color_map_rainbow( ) assert server.compare_image("mesh/polyhedra/vertex_color_map_rainbow.jpeg") == True + + +def test_polyhedra_vertex_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register(server, dataset_factory) + + server.call( + VtkMeshPolyhedraAttributeVertexView.mesh_polyhedra_attribute_vertex_prefix + + VtkMeshPolyhedraAttributeVertexView.mesh_polyhedra_attribute_vertex_schemas_dict[ + "attribute" + ][ + "rpc" + ], + [ + { + "id": mesh_id, + "name": "points", + "item": 1, + "points": [ + 0.0, + 0, + 0, + 1.0, + 10.0, + 1.0, + 0, + 0, + ], + "minimum": 0.0, + "maximum": 10.0, + } + ], + ) + + assert server.compare_image("mesh/polyhedra/vertex_attribute_item.jpeg") == True diff --git a/tests/model/blocks/attribute/vertex/test_model_blocks_attribute_vertex_protocols.py b/tests/model/blocks/attribute/vertex/test_model_blocks_attribute_vertex_protocols.py index 3b899a3b..67de8409 100644 --- a/tests/model/blocks/attribute/vertex/test_model_blocks_attribute_vertex_protocols.py +++ b/tests/model/blocks/attribute/vertex/test_model_blocks_attribute_vertex_protocols.py @@ -404,3 +404,51 @@ def test_blocks_vertex_color_map_rainbow( ) assert server.compare_image("model/blocks/vertex_color_map_rainbow.jpeg") == True + + +def test_blocks_vertex_attribute_item( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + + test_register_model_cube(server, dataset_factory) + + # Hide all blocks to ensure visibility of blocks + server.call( + VtkModelBlocksView.model_blocks_prefix + + VtkModelBlocksView.model_blocks_schemas_dict["visibility"]["rpc"], + [{"id": model_id, "block_ids": list(range(1, 50)), "visibility": False}], + ) + # Show only blocks + server.call( + VtkModelBlocksView.model_blocks_prefix + + VtkModelBlocksView.model_blocks_schemas_dict["visibility"]["rpc"], + [{"id": model_id, "block_ids": list(range(48, 50)), "visibility": True}], + ) + + server.call( + VtkModelBlocksAttributeVertexView.model_blocks_attribute_vertex_prefix + + VtkModelBlocksAttributeVertexView.model_blocks_attribute_vertex_schemas_dict[ + "attribute" + ]["rpc"], + [ + { + "id": model_id, + "block_ids": list(range(48, 50)), + "name": "unique vertices", + "item": 1, + "points": [ + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + 0.0, + 0.0, + ], + "minimum": 0.0, + "maximum": 1.0, + } + ], + ) + assert server.compare_image("model/blocks/vertex_attribute_item.jpeg") == True diff --git a/tests/model/surfaces/attribute/vertex/test_model_surfaces_attribute_vertex_protocols.py b/tests/model/surfaces/attribute/vertex/test_model_surfaces_attribute_vertex_protocols.py index 5d1b5e6b..270cdbe9 100644 --- a/tests/model/surfaces/attribute/vertex/test_model_surfaces_attribute_vertex_protocols.py +++ b/tests/model/surfaces/attribute/vertex/test_model_surfaces_attribute_vertex_protocols.py @@ -422,7 +422,7 @@ def test_surfaces_vertex_color_map_rainbow( assert server.compare_image("model/surfaces/vertex_color_map_rainbow.jpeg") == True -def test_surfaces_vertex_vector_component( +def test_surfaces_vertex_attribute_item( server: ServerMonitor, dataset_factory: Callable[..., str] ) -> None: test_register_model_cube(server, dataset_factory) @@ -453,7 +453,7 @@ def test_surfaces_vertex_vector_component( "id": model_id, "block_ids": list(range(36, 47)), "name": "unique vertices", - "item": 0, + "item": 1, "points": [ 0.0, 0.0, @@ -470,10 +470,4 @@ def test_surfaces_vertex_vector_component( ], ) - # Render and assert we receive non-empty image bytes (no backend crashes) - server.call("opengeodeweb_viewer.viewer.render") - while True: - response = server.ws.recv() - if isinstance(response, bytes): - assert len(response) > 0 - break + assert server.compare_image("model/surfaces/vertex_attribute_item.jpeg") == True