Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.12"
- name: Test
run: |
pip install pytest pytest-xprocess
pip install https://www.vtk.org/files/release/9.3/vtk_osmesa-9.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip install https://www.vtk.org/files/release/9.3/vtk_osmesa-9.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip install -e .
pytest

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "OpenGeodeWeb-Viewer"
version = "1.9.0"
version = "1.9.1-rc.1"
dynamic = ["dependencies"]
authors = [
{ name="Geode-solutions", email="[email protected]" },
Expand Down
30 changes: 23 additions & 7 deletions src/opengeodeweb_viewer/object/object_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,35 @@ def SetColor(self, id, red, green, blue):

def SetEdgesVisibility(self, id, visibility):
actor = self.get_object(id)["actor"]
actor.GetProperty().SetEdgeVisibility(visibility)
max_dimension = self.get_object(id)["max_dimension"]
if max_dimension == "edges":
self.SetVisibility(id, visibility)
else:
actor.GetProperty().SetEdgeVisibility(visibility)
self.render()

def SetEdgesSize(self, id, size):
def SetEdgesWidth(self, id, width):
actor = self.get_object(id)["actor"]
actor.GetProperty().SetEdgeWidth(size)
actor.GetProperty().SetEdgeWidth(width)
self.render()

def SetEdgesColor(self, id, red, green, blue):
actor = self.get_object(id)["actor"]
actor.GetProperty().SetEdgeColor([red / 255, green / 255, blue / 255])
max_dimension = self.get_object(id)["max_dimension"]
if max_dimension == "edges":
self.SetColor(id, red, green, blue)
else:
actor.GetProperty().SetEdgeColor([red / 255, green / 255, blue / 255])
self.render()

def SetPointsVisibility(self, id, visibility):
actor = self.get_object(id)["actor"]
actor.GetProperty().SetVertexVisibility(visibility)
actor.GetProperty().SetEdgeVisibility(visibility)
max_dimension = self.get_object(id)["max_dimension"]
if max_dimension == "points":
self.SetVisibility(id, visibility)
else:
actor.GetProperty().SetVertexVisibility(visibility)
actor.GetProperty().SetEdgeVisibility(visibility)
self.render()

def SetPointsSize(self, id, size):
Expand All @@ -134,7 +146,11 @@ def SetPointsSize(self, id, size):

def SetPointsColor(self, id, red, green, blue):
actor = self.get_object(id)["actor"]
actor.GetProperty().SetVertexColor([red / 255, green / 255, blue / 255])
max_dimension = self.get_object(id)["max_dimension"]
if max_dimension == "points":
self.SetColor(id, red, green, blue)
else:
actor.GetProperty().SetVertexColor([red / 255, green / 255, blue / 255])
self.render()

def SetBlocksVisibility(self, id, block_ids, visibility):
Expand Down
10 changes: 5 additions & 5 deletions src/opengeodeweb_viewer/rpc/mesh/edges/mesh_edges_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def setMeshEdgesColor(self, params):
)
self.SetEdgesColor(id, red, green, blue)

@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["size"]["rpc"])
def setMeshEdgesSize(self, params):
@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["width"]["rpc"])
def setMeshEdgesWidth(self, params):
validate_schema(
params, self.mesh_edges_schemas_dict["size"], self.mesh_edges_prefix
params, self.mesh_edges_schemas_dict["width"], self.mesh_edges_prefix
)
id, size = params["id"], params["size"]
self.SetEdgesSize(id, size)
id, size = params["id"], params["width"]
self.SetEdgesWidth(id, width)
18 changes: 18 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/edges/schemas/width.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"rpc": "size",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"width": {
"type": "number"
}
},
"required": [
"id",
"width"
],
"additionalProperties": false
}
21 changes: 21 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ def registerMesh(self, params):
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(reader.GetOutputPort())
self.registerObject(id, file_name, reader, filter, mapper)

data_object = reader.GetOutput()
data_set = vtk.vtkDataSet.SafeDownCast(data_object)
cell_types = vtk.vtkCellTypes()
data_set.GetCellTypes(cell_types)
cell_data = cell_types.GetCellTypesArray()
max_id = -1
for t in range(cell_data.GetSize()):
t_id = cell_data.GetValue(t)
max_id = max(max_id, t_id)
print(f"{max_id=}", flush=True)
max_dimension = ""
if max_id < 3:
max_dimension = "points"
elif max_id < 5:
max_dimension = "edges"
elif max_id < 7:
max_dimension = "polygons"
elif max_id >= 7:
max_dimension = "polyhedra"
self.get_data_base()[id]["max_dimension"] = max_dimension
except Exception as e:
print("error : ", str(e), flush=True)

Expand Down
1 change: 1 addition & 0 deletions src/opengeodeweb_viewer/rpc/model/model_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def registerModel(self, params):
attributes = vtkCompositeDataDisplayAttributes()
mapper.SetCompositeDataDisplayAttributes(attributes)
self.registerObject(id, file_name, reader, filter, mapper)
self.get_object(id)["max_dimension"] = "default"
except Exception as e:
print("error : ", str(e), flush=True)

Expand Down
12 changes: 6 additions & 6 deletions src/opengeodeweb_viewer/vtkw_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
from .rpc.mesh.polygons.polygons_protocols import VtkMeshPolygonsView
from .rpc.mesh.polyhedra.polyhedra_protocols import VtkMeshPolyhedraView
from .rpc.model.model_protocols import VtkModelView
from .rpc.model.edges.edges_protocols import (
from .rpc.model.edges.model_edges_protocols import (
VtkModelEdgesView,
)
from .rpc.model.points.points_protocols import (
from .rpc.model.points.model_points_protocols import (
VtkModelPointsView,
)
from .rpc.model.corners.corners_protocols import (
from .rpc.model.corners.model_corners_protocols import (
VtkModelCornersView,
)
from .rpc.model.lines.lines_protocols import (
from .rpc.model.lines.model_lines_protocols import (
VtkModelLinesView,
)
from .rpc.model.surfaces.surfaces_protocols import (
from .rpc.model.surfaces.model_surfaces_protocols import (
VtkModelSurfacesView,
)
from .rpc.model.blocks.blocks_protocols import (
from .rpc.model.blocks.model_blocks_protocols import (
VtkModelBlocksView,
)
from .rpc.generic.generic_protocols import VtkGenericView
Expand Down
20 changes: 20 additions & 0 deletions src/tests/data/edged_curve.vtp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<VTKFile type="PolyData" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<PolyData>
<Piece NumberOfPoints="4" NumberOfLines="4">
<PointData>
<DataArray type="Float64" Name="points" format="ascii" NumberOfComponents="3" RangeMin="0.100000001" RangeMax="9.39999962">0.1 0.2 0.3 2.1 9.4 6.7 7.5 5.2 6.3 8.7 1.4 4.7 </DataArray>
</PointData>
<Points>
<DataArray type="Float64" Name="Points" format="ascii" NumberOfComponents="3" RangeMin="0.10000000000000001" RangeMax="9.4000000000000004">0.1 0.2 0.3 2.1 9.4 6.7 7.5 5.2 6.3 8.7 1.4 4.7 </DataArray>
</Points>
<CellData>
<DataArray type="Float64" Name="edges" format="ascii" NumberOfComponents="2" RangeMin="0" RangeMax="3">0 1 0 2 3 2 1 2 </DataArray>
</CellData>
<Lines>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="3">0 1 0 2 3 2 1 2 </DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="0" RangeMax="4">2 4 6 8 </DataArray>
</Lines>
</Piece>
</PolyData>
</VTKFile>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/tests/data/points.vtp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<VTKFile type="PolyData" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<PolyData>
<Piece NumberOfPoints="24" NumberOfVerts="24">
<PointData>
<DataArray type="Float64" Name="geode_implicit_value" format="ascii" NumberOfComponents="1" RangeMin="0" RangeMax="1">0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 </DataArray>
<DataArray type="Float64" Name="points" format="ascii" NumberOfComponents="3" RangeMin="0.5" RangeMax="39.0999985">0.5 1 2 20 2 12 1.5 19 12.3 39.1 1.5 7 1.5 39.1 8.5 37.5 38.2 11.1 17.8 35.5 15 13.9 15.1 17 25.9 14 17.5 22 25 25 15 29 20 27 28 22 1 0.5 21 19 1.5 27 1.3 17 29.5 38.7 2.1 25 1.2 37.8 30 38.1 37.7 26.8 17.5 36.2 31 14.2 14.9 29.5 26.5 15 29.5 21.2 23.4 35.5 14.5 28.7 33 26.3 25.7 34 </DataArray>
<DataArray type="Float64" Name="geode_implicit_weight" format="ascii" NumberOfComponents="1" RangeMin="10" RangeMax="10">10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 </DataArray>
</PointData>
<Points>
<DataArray type="Float64" Name="Points" format="ascii" NumberOfComponents="3" RangeMin="0.5" RangeMax="39.100000000000001">0.5 1 2 20 2 12 1.5 19 12.3 39.1 1.5 7 1.5 39.1 8.5 37.5 38.2 11.1 17.8 35.5 15 13.9 15.1 17 25.9 14 17.5 22 25 25 15 29 20 27 28 22 1 0.5 21 19 1.5 27 1.3 17 29.5 38.7 2.1 25 1.2 37.8 30 38.1 37.7 26.8 17.5 36.2 31 14.2 14.9 29.5 26.5 15 29.5 21.2 23.4 35.5 14.5 28.7 33 26.3 25.7 34 </DataArray>
</Points>
<Verts>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="23">0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 </DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="0" RangeMax="24">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 </DataArray>
</Verts>
</Piece>
</PolyData>
</VTKFile>
Binary file modified src/tests/data/take_screenshot_with_background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/tests/data/take_screenshot_with_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/tests/data/take_screenshot_without_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 0 additions & 31 deletions src/tests/mesh/edges/test_edges_protocols.py

This file was deleted.

55 changes: 55 additions & 0 deletions src/tests/mesh/edges/test_mesh_edges_protocols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Standard library imports

# Third party imports
from src.opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
from src.opengeodeweb_viewer.rpc.mesh.edges.mesh_edges_protocols import VtkMeshEdgesView

# Local application imports
from src.tests.mesh.test_mesh_protocols import test_register_mesh


def test_edges_visibility(server):

test_register_mesh(server)

server.call(
VtkMeshEdgesView.mesh_edges_prefix
+ VtkMeshEdgesView.mesh_edges_schemas_dict["visibility"]["rpc"],
[{"id": "123456789", "visibility": True}],
)
assert server.compare_image(3, "mesh/edges/visibility.jpeg") == True


def test_edges_color(server):

test_edges_visibility(server)

server.call(
VtkMeshEdgesView.mesh_edges_prefix
+ VtkMeshEdgesView.mesh_edges_schemas_dict["color"]["rpc"],
[{"id": "123456789", "color": {"r": 255, "g": 0, "b": 0}}],
)
assert server.compare_image(3, "mesh/edges/color.jpeg") == True


def test_edges_with_edged_curve(server):

server.call(
VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["register"]["rpc"],
[{"id": "123456789", "file_name": "edged_curve.vtp"}],
)
assert server.compare_image(3, "mesh/edges/register_edged_curve.jpeg") == True

server.call(
VtkMeshEdgesView.mesh_edges_prefix
+ VtkMeshEdgesView.mesh_edges_schemas_dict["color"]["rpc"],
[{"id": "123456789", "color": {"r": 255, "g": 0, "b": 0}}],
)
assert server.compare_image(3, "mesh/edges/edged_curve_color.jpeg") == True

server.call(
VtkMeshEdgesView.mesh_edges_prefix
+ VtkMeshEdgesView.mesh_edges_schemas_dict["visibility"]["rpc"],
[{"id": "123456789", "visibility": False}],
)
assert server.compare_image(3, "mesh/edges/edged_curve_visibility.jpeg") == True
31 changes: 31 additions & 0 deletions src/tests/mesh/points/test_mesh_points_protocols.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Standard library imports

# Third party imports
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
from opengeodeweb_viewer.rpc.mesh.points.mesh_points_protocols import VtkMeshPointsView

# Local application imports
Expand Down Expand Up @@ -41,3 +42,33 @@ def test_points_color(server):
[{"id": "123456789", "color": {"r": 255, "g": 0, "b": 0}}],
)
assert server.compare_image(3, "mesh/points/color.jpeg") == True


def test_points_with_point_set(server):

server.call(
VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["register"]["rpc"],
[{"id": "123456789", "file_name": "points.vtp"}],
)
assert server.compare_image(3, "mesh/points/register_point_set.jpeg") == True

server.call(
VtkMeshPointsView.mesh_points_prefix
+ VtkMeshPointsView.mesh_points_schemas_dict["size"]["rpc"],
[{"id": "123456789", "size": 10}],
)
assert server.compare_image(3, "mesh/points/point_set_size.jpeg") == True

server.call(
VtkMeshPointsView.mesh_points_prefix
+ VtkMeshPointsView.mesh_points_schemas_dict["color"]["rpc"],
[{"id": "123456789", "color": {"r": 255, "g": 0, "b": 0}}],
)
assert server.compare_image(3, "mesh/points/point_set_color.jpeg") == True

server.call(
VtkMeshPointsView.mesh_points_prefix
+ VtkMeshPointsView.mesh_points_schemas_dict["visibility"]["rpc"],
[{"id": "123456789", "visibility": False}],
)
assert server.compare_image(3, "mesh/points/point_set_visibility.jpeg") == True
2 changes: 1 addition & 1 deletion src/tests/model/blocks/test_model_blocks_protocols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard library imports

# Third party imports
from opengeodeweb_viewer.rpc.model.blocks.blocks_protocols import (
from opengeodeweb_viewer.rpc.model.blocks.model_blocks_protocols import (
VtkModelBlocksView,
)

Expand Down
2 changes: 1 addition & 1 deletion src/tests/model/corners/test_model_corners_protocols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard library imports

# Third party imports
from opengeodeweb_viewer.rpc.model.corners.corners_protocols import (
from opengeodeweb_viewer.rpc.model.corners.model_corners_protocols import (
VtkModelCornersView,
)

Expand Down
2 changes: 1 addition & 1 deletion src/tests/model/edges/test_model_edges_protocols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard library imports

# Third party imports
from opengeodeweb_viewer.rpc.model.edges.edges_protocols import (
from opengeodeweb_viewer.rpc.model.edges.model_edges_protocols import (
VtkModelEdgesView,
)

Expand Down
2 changes: 1 addition & 1 deletion src/tests/model/lines/test_model_lines_protocols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard library imports

# Third party imports
from opengeodeweb_viewer.rpc.model.lines.lines_protocols import (
from opengeodeweb_viewer.rpc.model.lines.model_lines_protocols import (
VtkModelLinesView,
)

Expand Down
2 changes: 1 addition & 1 deletion src/tests/model/points/test_model_points_protocols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard library imports

# Third party imports
from opengeodeweb_viewer.rpc.model.points.points_protocols import (
from opengeodeweb_viewer.rpc.model.points.model_points_protocols import (
VtkModelPointsView,
)

Expand Down
Loading