|
4 | 4 | from unittest.mock import MagicMock, patch |
5 | 5 |
|
6 | 6 | import pytest |
7 | | -from vtkmodules.vtkCommonCore import vtkFloatArray |
| 7 | +from vtkmodules.vtkCommonCore import reference, vtkFloatArray |
8 | 8 | from vtkmodules.vtkCommonDataModel import vtkPlane, vtkPolyData, vtkUnstructuredGrid |
9 | 9 | from vtkmodules.vtkFiltersCore import vtkAppendPolyData |
10 | 10 | from vtkmodules.vtkFiltersGeometry import vtkGeometryFilter |
|
14 | 14 |
|
15 | 15 | from ansys.visor.viewer.core.visor_colors import VisorColors |
16 | 16 | from ansys.visor.viewer.core.visor_enums import VisorVtkVariableType |
17 | | -from ansys.visor.viewer.vtk.node_pipeline import VtkNodePipeline |
| 17 | +from ansys.visor.viewer.vtk.node_pipeline import PART_POLYGON_OFFSET, VtkNodePipeline |
18 | 18 |
|
19 | 19 |
|
20 | 20 | @pytest.fixture |
@@ -112,6 +112,28 @@ def test_from_dataset_sets_default_color_and_flat_shading(poly_dataset): |
112 | 112 | assert pipe.actor.GetProperty().GetInterpolation() == 0 |
113 | 113 |
|
114 | 114 |
|
| 115 | +def test_from_dataset_pushes_faces_back_with_relative_polygon_offset(poly_dataset): |
| 116 | + """The part's faces are pushed back so that edges and highlights draw in front.""" |
| 117 | + pipe = VtkNodePipeline.from_dataset(poly_dataset) |
| 118 | + factor, units = reference(0.0), reference(0.0) |
| 119 | + |
| 120 | + pipe.mapper.GetRelativeCoincidentTopologyPolygonOffsetParameters(factor, units) |
| 121 | + |
| 122 | + assert (factor, units) == PART_POLYGON_OFFSET |
| 123 | + |
| 124 | + |
| 125 | +def test_from_dataset_servers_relative_polygon_offset(poly_dataset): |
| 126 | + """The offset is in the mapper state, so the wasm client can use when it draws the highlight.""" |
| 127 | + pipe = VtkNodePipeline.from_dataset(poly_dataset) |
| 128 | + mgr = vtkObjectManager() |
| 129 | + mgr.Initialize() |
| 130 | + mgr.RegisterObject(pipe.actor) |
| 131 | + mgr.UpdateStatesFromObjects() |
| 132 | + |
| 133 | + mapper_state = json.loads(mgr.GetState(mgr.GetId(pipe.mapper))) |
| 134 | + assert tuple(mapper_state["RelativeCoincidentTopologyPolygonOffsetParameters"]) == PART_POLYGON_OFFSET |
| 135 | + |
| 136 | + |
115 | 137 | def test_from_dataset_unsupported_type_raises(): |
116 | 138 | with pytest.raises(RuntimeError, match="node type not yet supported"): |
117 | 139 | VtkNodePipeline.from_dataset(object()) |
|
0 commit comments