Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9c2aca1
fix(colorbar): simplifying attribute protocols
MaxNumerique Jan 29, 2026
13eec4a
fixing tests with workflow
MaxNumerique Jan 29, 2026
b6be71c
Apply prepare changes
MaxNumerique Jan 29, 2026
69083aa
rm comments
MaxNumerique Jan 29, 2026
3086f1a
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Jan 29, 2026
2510cfc
rm com
MaxNumerique Jan 29, 2026
16a8fe8
test scalar_range comparison
MaxNumerique Jan 30, 2026
6eaa40a
coms
MaxNumerique Jan 30, 2026
ac8183b
update mesh color map schemas to use flattened point arrays and remov…
MaxNumerique Jan 30, 2026
bbffeb3
Apply prepare changes
MaxNumerique Jan 30, 2026
4f09594
refacto scalar range and color map setup by integrating lookup table
MaxNumerique Jan 30, 2026
0afbe7e
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Jan 30, 2026
540e4ca
minimum adn maximum added to setupColorMap
MaxNumerique Jan 30, 2026
7460325
Apply prepare changes
MaxNumerique Jan 30, 2026
d89007a
fixed schemas
MaxNumerique Jan 30, 2026
5abce2a
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Jan 30, 2026
3411729
Apply prepare changes
MaxNumerique Jan 30, 2026
89fe79b
missed this one
MaxNumerique Jan 30, 2026
a36e482
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Jan 30, 2026
9b90ac5
Apply prepare changes
MaxNumerique Jan 30, 2026
dea10d7
removedAllPoints not needed
MaxNumerique Jan 30, 2026
e9d071d
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Jan 30, 2026
421fc92
new architecture
MaxNumerique Feb 3, 2026
04a8862
Apply prepare changes
MaxNumerique Feb 3, 2026
66ad44c
new architecture for attributes
MaxNumerique Feb 4, 2026
4f6cd7c
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Feb 4, 2026
f1500af
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Feb 4, 2026
dfc7831
Apply prepare changes
MaxNumerique Feb 4, 2026
ddf89cb
rm this ?
MaxNumerique Feb 4, 2026
59413a5
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Feb 4, 2026
53c3800
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Feb 4, 2026
f4273b8
Apply prepare changes
MaxNumerique Feb 4, 2026
4619214
rm unecessary rpcs from cells_protocols
MaxNumerique Feb 4, 2026
5aa1435
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
MaxNumerique Feb 4, 2026
65a335a
tests cells
MaxNumerique Feb 4, 2026
3cc448b
new architecture for tests
MaxNumerique Feb 4, 2026
aeddd92
pyproject.toml
MaxNumerique Feb 4, 2026
0c1272e
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
JulienChampagnol Feb 12, 2026
8f59dac
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
JulienChampagnol Feb 12, 2026
842e3fd
Apply prepare changes
JulienChampagnol Feb 12, 2026
775ff21
tests okay
JulienChampagnol Feb 13, 2026
9bd6766
Merge branch 'feat/color-bar' of https://github.com/Geode-solutions/O…
JulienChampagnol Feb 13, 2026
202839a
Apply prepare changes
JulienChampagnol Feb 13, 2026
cb336b5
test
JulienChampagnol Feb 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ wslink==1.12.4
yarl>=1
# via aiohttp

opengeodeweb-microservice==1.*,>=1.0.13rc1
40 changes: 20 additions & 20 deletions src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py
Comment thread
MaxNumerique marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def displayAttributeOnVertices(self, data_id: str, name: str) -> None:
mapper = self.get_object(data_id).mapper
mapper.ScalarVisibilityOn()
mapper.SetScalarModeToUsePointData()
mapper.SetScalarRange(points.GetScalars().GetRange())
# mapper.SetScalarRange(points.GetScalars().GetRange())

def displayAttributeOnCells(self, data_id: str, name: str) -> None:
reader = self.get_object(data_id).reader
Expand All @@ -150,31 +150,31 @@ def displayAttributeOnCells(self, data_id: str, name: str) -> None:
mapper = self.get_object(data_id).mapper
mapper.ScalarVisibilityOn()
mapper.SetScalarModeToUseCellData()
mapper.SetScalarRange(cells.GetScalars().GetRange())
# mapper.SetScalarRange(cells.GetScalars().GetRange())

def displayScalarRange(self, data_id: str, minimum: float, maximum: float) -> None:
Comment thread
MaxNumerique marked this conversation as resolved.
data = self.get_object(data_id)
data.mapper.SetScalarRange(minimum, maximum)
if hasattr(data, "color_map_points") and data.color_map_points:
lut = vtkColorTransferFunction()
for ratio, red, green, blue in data.color_map_points:
scalar_value = minimum + ratio * (maximum - minimum)
lut.AddRGBPoint(scalar_value, red / 255, green / 255, blue / 255)
data.mapper.SetLookupTable(lut)

def setupColorMap(self, data_id: str, points: list[list[float]]) -> None:
data = self.get_object(data_id)
sorted_points = sorted(points, key=lambda x: x[0])
points_min = sorted_points[0][0]
points_max = sorted_points[-1][0]
points_range = points_max - points_min if points_max != points_min else 1.0

data.color_map_points = []
for point in sorted_points:
ratio = (point[0] - points_min) / points_range
data.color_map_points.append([ratio, *point[1:]])

# sorted_points = sorted(points, key=lambda x: x[0])
# points_min = sorted_points[0][0]
# points_max = sorted_points[-1][0]
# points_range = points_max - points_min if points_max != points_min else 1.0

# data.color_map_points = []
# for point in points:
# # ratio = (point[0] - points_min) / points_range
# data.color_map_points.append(point)

lut = vtkColorTransferFunction()
for ratio, red, green, blue in points:
# scalar_value = minimum + ratio * (maximum - minimum)
# lut.AddRGBPoint(scalar_value, red / 255, green / 255, blue / 255)
lut.AddRGBPoint(ratio, red, green, blue)
data.mapper.SetLookupTable(lut)
data.mapper.InterpolateScalarsBeforeMappingOn()

minimum, maximum = data.mapper.GetScalarRange()
self.displayScalarRange(data_id, minimum, maximum)
# minimum, maximum = data.mapper.GetScalarRange()
# self.displayScalarRange(data_id, minimum, maximum)
2 changes: 1 addition & 1 deletion src/opengeodeweb_viewer/vtk_protocol.py
Comment thread
MaxNumerique marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class vtkData:
max_dimension: Literal["points", "edges", "polygons", "polyhedra", "default"] = (
"default"
)
color_map_points: list[list[float]] = field(default_factory=list)
# color_map_points: list[list[float]] = field(default_factory=list)


class VtkTypingMixin:
Expand Down
162 changes: 134 additions & 28 deletions tests/mesh/cells/test_mesh_cells_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def test_cells_vertex_attribute(
+ VtkMeshCellsView.mesh_cells_schemas_dict["vertex_attribute"]["rpc"],
[{"id": mesh_id, "name": "points"}],
)
server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["vertex_scalar_range"]["rpc"],
[{"id": mesh_id, "minimum": 2, "maximum": 498}],
)
assert server.compare_image("mesh/cells/vertex_attribute.jpeg") == True

server.call(
Expand All @@ -84,6 +89,11 @@ def test_cells_cell_attribute(
+ VtkMeshCellsView.mesh_cells_schemas_dict["cell_attribute"]["rpc"],
[{"id": mesh_id, "name": "RGB_data"}],
)
server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["cell_scalar_range"]["rpc"],
[{"id": mesh_id, "minimum": 0, "maximum": 255}],
)
assert server.compare_image("mesh/cells/cell_attribute.jpeg") == True

server.call(
Expand Down Expand Up @@ -122,8 +132,8 @@ def test_cells_vertex_color_map(
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 255],
[1.0, 255, 0, 0],
[2.0, 0, 0, 1.0],
Comment thread
MaxNumerique marked this conversation as resolved.
Outdated
[498.0, 1.0, 0, 0],
],
}
],
Expand Down Expand Up @@ -153,8 +163,8 @@ def test_cells_vertex_color_map_range_update(
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 255],
[1.0, 255, 0, 0],
[2.0, 0, 0, 1.0],
[498.0, 1.0, 0, 0],
],
}
],
Expand All @@ -169,6 +179,20 @@ def test_cells_vertex_color_map_range_update(
[{"id": mesh_id, "minimum": 200.0, "maximum": 300.0}],
)

server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["vertex_color_map"]["rpc"],
[
{
"id": mesh_id,
"points": [
[200.0, 0, 0, 1.0],
[300.0, 1.0, 0, 0],
],
}
],
)

assert server.compare_image("mesh/cells/vertex_color_map_range_update.jpeg") == True


Expand All @@ -193,8 +217,8 @@ def test_cells_vertex_color_map_red_shift(
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 255],
[1.0, 255, 0, 0],
[2.0, 0, 0, 1.0],
[498.0, 1.0, 0, 0],
],
}
],
Expand All @@ -209,6 +233,20 @@ def test_cells_vertex_color_map_red_shift(
[{"id": mesh_id, "minimum": 0.0, "maximum": 50.0}],
)

server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["vertex_color_map"]["rpc"],
[
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 1.0],
[50.0, 1.0, 0, 0],
],
}
],
)

assert server.compare_image("mesh/cells/vertex_color_map_red_shift.jpeg") == True


Expand All @@ -233,14 +271,14 @@ def test_cells_vertex_color_map_rainbow(
{
"id": mesh_id,
"points": [
[0.0, 71, 71, 219],
[0.143, 0, 0, 92],
[0.285, 0, 255, 255],
[0.429, 0, 128, 0],
[0.571, 255, 255, 0],
[0.714, 255, 97, 0],
[0.857, 107, 0, 0],
[1.0, 224, 77, 77],
[2 + 0.0 * 496, 71 / 255, 71 / 255, 219 / 255],
[2 + 0.143 * 496, 0, 0, 92 / 255],
[2 + 0.285 * 496, 0, 255 / 255, 255 / 255],
[2 + 0.429 * 496, 0, 128 / 255, 0],
[2 + 0.571 * 496, 255 / 255, 255 / 255, 0],
[2 + 0.714 * 496, 255 / 255, 97 / 255, 0],
[2 + 0.857 * 496, 107 / 255, 0, 0],
[2 + 1.0 * 496, 224 / 255, 77 / 255, 77 / 255],
],
}
],
Expand All @@ -257,6 +295,26 @@ def test_cells_vertex_color_map_rainbow(
[{"id": mesh_id, "minimum": 50.0, "maximum": 200.0}],
)

server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["vertex_color_map"]["rpc"],
[
{
"id": mesh_id,
"points": [
[50 + 0.0 * 150, 71 / 255, 71 / 255, 219 / 255],
[50 + 0.143 * 150, 0, 0, 92 / 255],
[50 + 0.285 * 150, 0, 255 / 255, 255 / 255],
[50 + 0.429 * 150, 0, 128 / 255, 0],
[50 + 0.571 * 150, 255 / 255, 255 / 255, 0],
[50 + 0.714 * 150, 255 / 255, 97 / 255, 0],
[50 + 0.857 * 150, 107 / 255, 0, 0],
[50 + 1.0 * 150, 224 / 255, 77 / 255, 77 / 255],
],
}
],
)

assert server.compare_image("mesh/cells/vertex_color_map_rainbow.jpeg") == True


Expand Down Expand Up @@ -288,8 +346,8 @@ def test_cells_cell_color_map(
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 255],
[1.0, 255, 0, 0],
[0.0, 0, 0, 1.0],
[255.0, 1.0, 0, 0],
],
}
],
Expand Down Expand Up @@ -319,8 +377,8 @@ def test_cells_cell_color_map_range_update(
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 255],
[1.0, 255, 0, 0],
[0.0, 0, 0, 1.0],
[255.0, 1.0, 0, 0],
],
}
],
Expand All @@ -335,6 +393,20 @@ def test_cells_cell_color_map_range_update(
[{"id": mesh_id, "minimum": 100.0, "maximum": 150.0}],
)

server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["cell_color_map"]["rpc"],
[
{
"id": mesh_id,
"points": [
[100.0, 0, 0, 1.0],
[150.0, 1.0, 0, 0],
],
}
],
)

assert server.compare_image("mesh/cells/cell_color_map_range_update.jpeg") == True


Expand All @@ -359,8 +431,8 @@ def test_cells_cell_color_map_red_shift(
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 255],
[1.0, 255, 0, 0],
[0.0, 0, 0, 1.0],
[255.0, 1.0, 0, 0],
],
}
],
Expand All @@ -375,6 +447,20 @@ def test_cells_cell_color_map_red_shift(
[{"id": mesh_id, "minimum": 0.0, "maximum": 20.0}],
)

server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["cell_color_map"]["rpc"],
[
{
"id": mesh_id,
"points": [
[0.0, 0, 0, 1.0],
[20.0, 1.0, 0, 0],
],
}
],
)

assert server.compare_image("mesh/cells/cell_color_map_red_shift.jpeg") == True


Expand All @@ -399,14 +485,14 @@ def test_cells_cell_color_map_rainbow(
{
"id": mesh_id,
"points": [
[0.0, 71, 71, 219],
[0.143, 0, 0, 92],
[0.285, 0, 255, 255],
[0.429, 0, 128, 0],
[0.571, 255, 255, 0],
[0.714, 255, 97, 0],
[0.857, 107, 0, 0],
[1.0, 224, 77, 77],
[0.0 * 255, 71 / 255, 71 / 255, 219 / 255],
[0.143 * 255, 0, 0, 92 / 255],
[0.285 * 255, 0, 255 / 255, 255 / 255],
[0.429 * 255, 0, 128 / 255, 0],
[0.571 * 255, 255 / 255, 255 / 255, 0],
[0.714 * 255, 255 / 255, 97 / 255, 0],
[0.857 * 255, 107 / 255, 0, 0],
[1.0 * 255, 224 / 255, 77 / 255, 77 / 255],
],
}
],
Expand All @@ -423,4 +509,24 @@ def test_cells_cell_color_map_rainbow(
[{"id": mesh_id, "minimum": 50.0, "maximum": 100.0}],
)

server.call(
VtkMeshCellsView.mesh_cells_prefix
+ VtkMeshCellsView.mesh_cells_schemas_dict["cell_color_map"]["rpc"],
[
{
"id": mesh_id,
"points": [
[50 + 0.0 * 50, 71 / 255, 71 / 255, 219 / 255],
[50 + 0.143 * 50, 0, 0, 92 / 255],
[50 + 0.285 * 50, 0, 255 / 255, 255 / 255],
[50 + 0.429 * 50, 0, 128 / 255, 0],
[50 + 0.571 * 50, 255 / 255, 255 / 255, 0],
[50 + 0.714 * 50, 255 / 255, 97 / 255, 0],
[50 + 0.857 * 50, 107 / 255, 0, 0],
[50 + 1.0 * 50, 224 / 255, 77 / 255, 77 / 255],
],
}
],
)

assert server.compare_image("mesh/cells/cell_color_map_rainbow.jpeg") == True
Loading
Loading