-
Notifications
You must be signed in to change notification settings - Fork 0
feat(protocols): new polyhedrons protocols #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
391642c
new data with polyhedrons
JulienChampagnol e3bf44c
export schemas
JulienChampagnol 62acea9
register protocols
JulienChampagnol 2984d13
wip test protocols
JulienChampagnol 15b35fc
feat(polyhedrons): color protocol
JulienChampagnol 8e64ed0
color methods harmonization
JulienChampagnol 15f0678
data with vertices & polyhedra attribute
JulienChampagnol 4136e1d
rename mesh functions
JulienChampagnol 655a3ab
protocols & tests
JulienChampagnol 4be5438
cleanup
JulienChampagnol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/opengeodeweb_viewer/rpc/mesh/polyhedrons/polyhedrons_protocols.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Standard library imports | ||
| import os | ||
|
|
||
| # Third party imports | ||
| from wslink import register as exportRpc | ||
|
|
||
| # Local application imports | ||
| from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema | ||
| from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView | ||
|
|
||
| class VtkMeshPolyhedronsView(VtkMeshView): | ||
| mesh_polyhedrons_prefix = "opengeodeweb_viewer.mesh.polyhedrons." | ||
| mesh_polyhedrons_schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas")) | ||
|
|
||
| def __init__(self): | ||
| super().__init__() | ||
|
|
||
| # @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["visibility"]["rpc"]) | ||
JulienChampagnol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # def setMeshPolyhedronsVisibility(self, params): | ||
| # print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["visibility"]["rpc"], f"{params=}", flush=True) | ||
| # validate_schema(params, self.mesh_polyhedrons_schemas_dict["visibility"]) | ||
| # id = params["id"] | ||
| # visibility = bool(params["visibility"]) | ||
| # self.SetPolyhedronsVisibility(id, visibility) | ||
|
|
||
| @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["color"]["rpc"]) | ||
| def setMeshPolyhedronsColor(self, params): | ||
| print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["color"]["rpc"], f"{params=}", flush=True) | ||
| validate_schema(params, self.mesh_polyhedrons_schemas_dict["color"]) | ||
| print("id", params["id"], flush=True) | ||
| id = params["id"] | ||
| print("color", params["color"], flush=True) | ||
| red, green, blue = params["color"]["r"]/255, params["color"]["g"]/255, params["color"]["b"]/255 | ||
| self.SetColor(id, red, green, blue) | ||
|
|
||
| # @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["vertex_attribute"]["rpc"]) | ||
| # def setMeshPolyhedronsVertexAttribute(self, params): | ||
| # print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["vertex_attribute"]["rpc"], f"{params=}", flush=True) | ||
| # validate_schema(params, self.mesh_polyhedrons_schemas_dict["vertex_attribute"]) | ||
| # id = params["id"] | ||
| # name = str(params["name"]) | ||
| # self.setMeshVertexAttribute(id, name) | ||
|
|
||
| # @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["polygon_attribute"]["rpc"]) | ||
| # def setMeshPolyhedronsPolygonAttribute(self, params): | ||
| # print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["polygon_attribute"]["rpc"], f"{params=}", flush=True) | ||
| # validate_schema(params, self.mesh_polyhedrons_schemas_dict["polygon_attribute"]) | ||
| # id = params["id"] | ||
| # name = str(params["name"]) | ||
| # self.setMeshPolygonAttribute(id, name) | ||
46 changes: 46 additions & 0 deletions
46
src/opengeodeweb_viewer/rpc/mesh/polyhedrons/schemas/color.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| { | ||
| "rpc": "color", | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string" | ||
| }, | ||
| "color": { | ||
| "type": "object", | ||
| "properties": { | ||
| "r": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "maximum": 255 | ||
| }, | ||
| "g": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "maximum": 255 | ||
| }, | ||
| "b": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "maximum": 255 | ||
| }, | ||
| "a": { | ||
| "type": "number", | ||
| "minimum": 0, | ||
| "maximum": 1, | ||
| "default": 1 | ||
| } | ||
| }, | ||
| "required": [ | ||
| "r", | ||
| "g", | ||
| "b" | ||
| ], | ||
| "additionalProperties": false | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "color" | ||
| ], | ||
| "additionalProperties": false | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/opengeodeweb_viewer/rpc/mesh/polyhedrons/schemas/polygon_attribute.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "rpc": "polygon_attribute", | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string" | ||
| }, | ||
| "name": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "name" | ||
| ], | ||
| "additionalProperties": false | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/opengeodeweb_viewer/rpc/mesh/polyhedrons/schemas/vertex_attribute.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "rpc": "vertex_attribute", | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string" | ||
| }, | ||
| "name": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "name" | ||
| ], | ||
| "additionalProperties": false | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/opengeodeweb_viewer/rpc/mesh/polyhedrons/schemas/visibility.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "rpc": "visibility", | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string" | ||
| }, | ||
| "visibility": { | ||
| "type": "boolean" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "visibility" | ||
| ], | ||
| "additionalProperties": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?xml version="1.0"?> | ||
| <VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor"> | ||
| <UnstructuredGrid> | ||
| <Piece NumberOfPoints="11" NumberOfCells="4"> | ||
| <PointData> | ||
| <DataArray type="Float64" Name="points" format="ascii" NumberOfComponents="3" RangeMin="0" RangeMax="2">0 0 0 1 0 0 2 1 0 1 2 0 0 2 0 0 0 1 1 0 1 2 1 1 1 2 1 0 2 1 1 1 2 </DataArray> | ||
| </PointData> | ||
| <Points> | ||
| <DataArray type="Float64" Name="Points" format="ascii" NumberOfComponents="3" RangeMin="0" RangeMax="2">0 0 0 1 0 0 2 1 0 1 2 0 0 2 0 0 0 1 1 0 1 2 1 1 1 2 1 0 2 1 1 1 2 </DataArray> | ||
| </Points> | ||
| <CellData /> | ||
| <Cells> | ||
| <DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="10">0 1 3 4 5 6 8 9 1 2 3 6 7 8 5 6 8 9 10 6 7 8 10 </DataArray> | ||
| <DataArray type="Int64" Name="offsets" format="ascii" RangeMin="0" RangeMax="11">8 14 19 23 </DataArray> | ||
| <DataArray type="UInt8" Name="types" format="ascii" RangeMin="1" RangeMax="42">12 13 14 10 </DataArray> | ||
| </Cells> | ||
| </Piece> | ||
| </UnstructuredGrid> | ||
| </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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Standard library imports | ||
|
|
||
| # Third party imports | ||
| from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView | ||
| from opengeodeweb_viewer.rpc.mesh.polyhedrons.polyhedrons_protocols import VtkMeshPolyhedronsView | ||
|
|
||
| # Local application imports | ||
|
|
||
|
|
||
| def test_register_mesh(server): | ||
|
|
||
| server.call(VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["register"]["rpc"], [{"id": "123456789", "file_name": "hybrid_solid.vtu"}]) | ||
| assert server.compare_image(3, "mesh/polyhedrons/register.jpeg") == True | ||
|
|
||
| def test_polyhedrons_color(server): | ||
|
|
||
| test_register_mesh(server) | ||
|
|
||
| server.call(VtkMeshPolyhedronsView.mesh_polyhedrons_prefix + VtkMeshPolyhedronsView.mesh_polyhedrons_schemas_dict["color"]["rpc"], [{"id": "123456789", "color": {"r": 255, "g": 0, "b": 0}}]) | ||
| assert server.compare_image(3, "mesh/polyhedrons/color.jpeg") == True |
JulienChampagnol marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.