-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial testing of GetGridSurface with mocked data
- Loading branch information
1 parent
a8e1c8e
commit 9eec4e6
Showing
15 changed files
with
396 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,76 @@ | ||
syntax = "proto3"; | ||
|
||
import "Grid.proto"; | ||
import "VectorDefines.proto"; | ||
|
||
// Will this work if we import only part of the protos? | ||
package rips; | ||
|
||
service GridGeometryExtraction | ||
{ | ||
rpc GetGridSurface(GetGridSurfaceRequest) returns (GetGridSurfaceResponse); | ||
rpc CutAlongPolyline(CutAlongPolylineRequest) returns (CutAlongPolylineResponse); | ||
} | ||
|
||
message IJKIndexFilter | ||
{ | ||
int32 iMin = 1; | ||
int32 iMax = 2; | ||
int32 jMin = 3; | ||
int32 jMax = 4; | ||
int32 kMin = 5; | ||
int32 kMax = 6; | ||
} | ||
|
||
message CellIndexFilter | ||
{ | ||
repeated fixed32 cellIndicesArr = 1; | ||
} | ||
|
||
message PropertyFilter | ||
{ | ||
// Timestep ?? | ||
string propertyFilename = 1; | ||
float valueMin = 2; | ||
float valueMax = 3; | ||
} | ||
|
||
message GetGridSurfaceRequest | ||
{ | ||
string gridFilename = 1; | ||
IJKIndexFilter ijkIndexFilter = 2; | ||
CellIndexFilter cellIndexFilter = 3; | ||
PropertyFilter propertyFilter = 4; | ||
} | ||
|
||
message GetGridSurfaceResponse | ||
{ | ||
repeated float vertexArray = 1; | ||
repeated fixed32 quadIndicesArr = 2; // 4*NumQuads long | ||
repeated fixed32 sourceCellIndicesArr = 3; // The originating cell index per quad, longnumQuads long | ||
GridDimensions gridDimensions = 5; | ||
Vec3d originUtm = 6; | ||
} | ||
|
||
message CutAlongPolylineRequest | ||
{ | ||
string gridFilename = 1; | ||
repeated double fencePolylineUtmXY = 2; | ||
} | ||
|
||
message FenceMeshSection | ||
{ | ||
// U-axis defined by vector from start to end, Z is global Z | ||
repeated float vertexArrayUZ = 1; | ||
repeated fixed32 polyIndicesArr = 2; | ||
repeated fixed32 verticesPerPolygonArr = 3; // Number of vertices per polygon, numPolygons long | ||
repeated fixed32 sourceCellIndicesArr = 4; // The originating cell index per polygon, numPolygons long | ||
Vec2d startUtmXY = 6; | ||
Vec2d endUtmXY = 7; | ||
} | ||
|
||
message CutAlongPolylineResponse | ||
{ | ||
repeated FenceMeshSection feceMeshSections = 1; | ||
GridDimensions gridDimensions = 2; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
syntax = "proto3"; | ||
|
||
import "Definitions.proto"; | ||
import "VectorDefines.proto"; | ||
|
||
package rips; | ||
|
||
|
This file contains 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,22 @@ | ||
syntax = "proto3"; | ||
|
||
package rips; | ||
|
||
message Vec3i { | ||
int32 i = 1; | ||
int32 j = 2; | ||
int32 k = 3; | ||
} | ||
|
||
message Vec2d | ||
{ | ||
double x = 1; | ||
double y = 2; | ||
} | ||
|
||
message Vec3d | ||
{ | ||
double x = 1; | ||
double y = 2; | ||
double z = 3; | ||
} |
65 changes: 65 additions & 0 deletions
65
GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_TEST.py
This file contains 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,65 @@ | ||
import sys | ||
import os | ||
|
||
import numpy as np | ||
|
||
import plotly.graph_objects as go | ||
|
||
sys.path.insert(1, os.path.join(sys.path[0], "../")) | ||
|
||
from rips.instance import * | ||
from rips.generated.GridGeometryExtraction_pb2_grpc import * | ||
from rips.generated.GridGeometryExtraction_pb2 import * | ||
|
||
rips_instance = Instance.find() | ||
grid_geometry_extraction_stub = GridGeometryExtractionStub(rips_instance.channel) | ||
|
||
get_grid_surface_request = GridGeometryExtraction__pb2.GetGridSurfaceRequest(gridFilename=None, ijkIndexFilter=None,cellIndexFilter=None,propertyFilter=None) | ||
get_grid_surface_response: GridGeometryExtraction__pb2.GetGridSurfaceResponse = grid_geometry_extraction_stub.GetGridSurface(get_grid_surface_request) | ||
|
||
get_grid_surface_response.gridDimensions | ||
vertex_array = get_grid_surface_response.vertexArray | ||
quad_indices_array = get_grid_surface_response.quadIndicesArr | ||
|
||
num_vertex_coords = 3 # [x, y, z] | ||
num_vertices_per_quad = 4 # [v1, v2, v3, v4] | ||
num_quads = len(vertex_array) /(num_vertex_coords * num_vertices_per_quad) | ||
|
||
x_array = [] | ||
y_array = [] | ||
z_array = [] | ||
|
||
# Create x-, y-, and z-arrays | ||
for i in range(0, len(vertex_array), num_vertex_coords): | ||
x_array.append(vertex_array[i]) | ||
y_array.append(vertex_array[i+1]) | ||
z_array.append(vertex_array[i+2]) | ||
|
||
# Create triangular mesh | ||
i_array = [] | ||
j_array = [] | ||
k_array = [] | ||
for i in range(0, len(quad_indices_array), num_vertices_per_quad): | ||
# Set the indices of the vertices of the triangles | ||
i_array.extend([i, i]) | ||
j_array.extend([i+1, i+2]) | ||
k_array.extend([i+2, i+3]) | ||
|
||
|
||
|
||
fig = go.Figure(data=[go.Mesh3d( | ||
x=x_array, | ||
y=y_array, | ||
z=z_array, | ||
i=i_array, | ||
j=j_array, | ||
k=k_array, | ||
intensity = np.linspace(-5, 5, 1000, endpoint=True), | ||
showscale=True, | ||
colorscale=[[0, 'gold'],[0.5, 'mediumturquoise'],[1.0, 'magenta']] | ||
)]) | ||
|
||
print(fig.data) | ||
|
||
fig.show() | ||
|
This file contains 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
Oops, something went wrong.