mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge remote-tracking branch 'origin/python-black-patches-0vrv2q8' into grid-geometry-extraction
This commit is contained in:
commit
d300869217
@ -14,13 +14,33 @@ rips_instance = Instance.find()
|
||||
grid_geometry_extraction_stub = GridGeometryExtractionStub(rips_instance.channel)
|
||||
|
||||
grid_file_name = None
|
||||
grid_file_name = "D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID"
|
||||
grid_file_name = (
|
||||
"D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID"
|
||||
)
|
||||
|
||||
# Test polylines
|
||||
mocked_model_fence_poly_line_utm_xy = [11.2631, 11.9276, 14.1083, 18.2929, 18.3523, 10.9173]
|
||||
norne_case_fence_poly_line_utm_xy = [456221, 7.32113e+06, 457150, 7.32106e+06, 456885, 7.32176e+06, 457648, 7.3226e+06, 458805, 7.32278e+06]
|
||||
norne_case_single_segment_poly_line_utm_xy = [457150, 7.32106e+06, 456885, 7.32176e+06]
|
||||
norne_case_single_segment_poly_line_gap_utm_xy = [460877, 7.3236e+06, 459279, 7.32477e+06]
|
||||
mocked_model_fence_poly_line_utm_xy = [
|
||||
11.2631,
|
||||
11.9276,
|
||||
14.1083,
|
||||
18.2929,
|
||||
18.3523,
|
||||
10.9173,
|
||||
]
|
||||
norne_case_fence_poly_line_utm_xy = [
|
||||
456221,
|
||||
7.32113e06,
|
||||
457150,
|
||||
7.32106e06,
|
||||
456885,
|
||||
7.32176e06,
|
||||
457648,
|
||||
7.3226e06,
|
||||
458805,
|
||||
7.32278e06,
|
||||
]
|
||||
norne_case_single_segment_poly_line_utm_xy = [457150, 7.32106e06, 456885, 7.32176e06]
|
||||
norne_case_single_segment_poly_line_gap_utm_xy = [460877, 7.3236e06, 459279, 7.32477e06]
|
||||
|
||||
|
||||
fence_poly_line_utm_xy = norne_case_single_segment_poly_line_utm_xy
|
||||
@ -44,7 +64,13 @@ z_start = polygon_vertex_array_org[2]
|
||||
# Subtract x_start, y_start, z_start from all x, y, z coordinates
|
||||
polygon_vertex_array = []
|
||||
for i in range(0, len(polygon_vertex_array_org), 3):
|
||||
polygon_vertex_array.extend([polygon_vertex_array_org[i] - x_start, polygon_vertex_array_org[i + 1] - y_start, polygon_vertex_array_org[i + 2] - z_start])
|
||||
polygon_vertex_array.extend(
|
||||
[
|
||||
polygon_vertex_array_org[i] - x_start,
|
||||
polygon_vertex_array_org[i + 1] - y_start,
|
||||
polygon_vertex_array_org[i + 2] - z_start,
|
||||
]
|
||||
)
|
||||
|
||||
num_vertex_coords = 3 # [x, y, z]
|
||||
|
||||
@ -55,9 +81,9 @@ z_array = []
|
||||
for i in range(0, len(polygon_vertex_array), num_vertex_coords):
|
||||
# vertex array is provided as a single array of x, y, z coordinates
|
||||
# i.e. [x1, y1, z1, x2, y2, z2, x3, y3, z3, ... , xn, yn, zn]
|
||||
x_array.append(polygon_vertex_array[i + 0] )
|
||||
y_array.append(polygon_vertex_array[i + 1] )
|
||||
z_array.append(polygon_vertex_array[i + 2] )
|
||||
x_array.append(polygon_vertex_array[i + 0])
|
||||
y_array.append(polygon_vertex_array[i + 1])
|
||||
z_array.append(polygon_vertex_array[i + 2])
|
||||
|
||||
# Create triangular mesh
|
||||
vertices = np.array(polygon_vertex_array).reshape(-1, 3)
|
||||
@ -78,7 +104,7 @@ triangle_edges_z = []
|
||||
# A quad with vertex [0,1,2,3] will be split into two triangles [0,1,2] and [0,2,3]
|
||||
# A hexagon with vertex [0,1,2,3,4,5] will be split into four triangles [0,1,2], [0,2,3], [0,3,4], [0,4,5]
|
||||
|
||||
polygon_v0_idx = 0 # Index of vertex 0 in the polygon
|
||||
polygon_v0_idx = 0 # Index of vertex 0 in the polygon
|
||||
for vertex_count in vertices_per_polygon:
|
||||
# Must have at least one triangle
|
||||
if vertex_count < 3:
|
||||
@ -100,15 +126,39 @@ for vertex_count in vertices_per_polygon:
|
||||
k.append(triangle_v2_idx)
|
||||
|
||||
# Create edge between vertices in triangle with x,y,z coordinates, coordinates per vertex is 3
|
||||
coordinate_step = 3 # step per vertex
|
||||
coordinate_step = 3 # step per vertex
|
||||
triangle_v0_global_idx = triangle_v0_idx * coordinate_step
|
||||
triangle_v1_global_idx = triangle_v1_idx * coordinate_step
|
||||
triangle_v2_global_idx = triangle_v2_idx * coordinate_step
|
||||
|
||||
# Add x,y,z coordinates for the triangle vertices (closing triangle with 'None')
|
||||
triangle_edges_x.extend([polygon_vertex_array[triangle_v0_global_idx + 0], polygon_vertex_array[triangle_v1_global_idx + 0], polygon_vertex_array[triangle_v2_global_idx + 0], polygon_vertex_array[triangle_v0_global_idx + 0], None])
|
||||
triangle_edges_y.extend([polygon_vertex_array[triangle_v0_global_idx + 1], polygon_vertex_array[triangle_v1_global_idx + 1], polygon_vertex_array[triangle_v2_global_idx + 1], polygon_vertex_array[triangle_v0_global_idx + 1], None])
|
||||
triangle_edges_z.extend([polygon_vertex_array[triangle_v0_global_idx + 2], polygon_vertex_array[triangle_v1_global_idx + 2], polygon_vertex_array[triangle_v2_global_idx + 2], polygon_vertex_array[triangle_v0_global_idx + 2], None])
|
||||
triangle_edges_x.extend(
|
||||
[
|
||||
polygon_vertex_array[triangle_v0_global_idx + 0],
|
||||
polygon_vertex_array[triangle_v1_global_idx + 0],
|
||||
polygon_vertex_array[triangle_v2_global_idx + 0],
|
||||
polygon_vertex_array[triangle_v0_global_idx + 0],
|
||||
None,
|
||||
]
|
||||
)
|
||||
triangle_edges_y.extend(
|
||||
[
|
||||
polygon_vertex_array[triangle_v0_global_idx + 1],
|
||||
polygon_vertex_array[triangle_v1_global_idx + 1],
|
||||
polygon_vertex_array[triangle_v2_global_idx + 1],
|
||||
polygon_vertex_array[triangle_v0_global_idx + 1],
|
||||
None,
|
||||
]
|
||||
)
|
||||
triangle_edges_z.extend(
|
||||
[
|
||||
polygon_vertex_array[triangle_v0_global_idx + 2],
|
||||
polygon_vertex_array[triangle_v1_global_idx + 2],
|
||||
polygon_vertex_array[triangle_v2_global_idx + 2],
|
||||
polygon_vertex_array[triangle_v0_global_idx + 2],
|
||||
None,
|
||||
]
|
||||
)
|
||||
|
||||
# Move to next polygon
|
||||
polygon_v0_idx += vertex_count
|
||||
@ -118,7 +168,7 @@ polygon_edges_x = []
|
||||
polygon_edges_y = []
|
||||
polygon_edges_z = []
|
||||
polygon_global_start_index = 0
|
||||
coordinate_step = 3 # step per vertex
|
||||
coordinate_step = 3 # step per vertex
|
||||
for vertex_count in vertices_per_polygon:
|
||||
# Must have at least a triangle
|
||||
if vertex_count < 3:
|
||||
@ -143,18 +193,19 @@ for vertex_count in vertices_per_polygon:
|
||||
polygon_global_start_index += vertex_count * coordinate_step
|
||||
|
||||
|
||||
|
||||
# Create mesh
|
||||
mesh_3D = go.Mesh3d(x=x, y=y, z=z, i=i, j=j, k=k, opacity=0.8, color='rgba(244,22,100,0.6)')
|
||||
mesh_3D = go.Mesh3d(
|
||||
x=x, y=y, z=z, i=i, j=j, k=k, opacity=0.8, color="rgba(244,22,100,0.6)"
|
||||
)
|
||||
|
||||
# Create edge lines for triangles
|
||||
triangle_edges_3d = go.Scatter3d(
|
||||
x=triangle_edges_x,
|
||||
y=triangle_edges_y,
|
||||
z=triangle_edges_z,
|
||||
mode='lines',
|
||||
name='',
|
||||
line=dict(color= 'rgb(0,0,0)', width=1)
|
||||
mode="lines",
|
||||
name="",
|
||||
line=dict(color="rgb(0,0,0)", width=1),
|
||||
)
|
||||
|
||||
# Create outer edge lines for polygon
|
||||
@ -162,16 +213,16 @@ polygon_edges_3d = go.Scatter3d(
|
||||
x=polygon_edges_x,
|
||||
y=polygon_edges_y,
|
||||
z=polygon_edges_z,
|
||||
mode='lines',
|
||||
name='',
|
||||
line=dict(color= 'rgb(0,0,0)', width=1)
|
||||
mode="lines",
|
||||
name="",
|
||||
line=dict(color="rgb(0,0,0)", width=1),
|
||||
)
|
||||
|
||||
fig = go.Figure(
|
||||
data=[
|
||||
mesh_3D,
|
||||
# triangle_edges_3d,
|
||||
polygon_edges_3d
|
||||
polygon_edges_3d,
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -35,9 +35,9 @@ x_array = []
|
||||
y_array = []
|
||||
z_array = []
|
||||
for i in range(0, len(vertex_array), num_vertex_coords):
|
||||
x_array.append(vertex_array[i + 0] )
|
||||
y_array.append(vertex_array[i + 1] )
|
||||
z_array.append(vertex_array[i + 2] )
|
||||
x_array.append(vertex_array[i + 0])
|
||||
y_array.append(vertex_array[i + 1])
|
||||
z_array.append(vertex_array[i + 2])
|
||||
|
||||
# Create triangular mesh
|
||||
i_array = []
|
||||
@ -50,16 +50,16 @@ for i in range(0, len(x_array), num_vertices_per_triangle):
|
||||
k_array.extend([i + 2])
|
||||
|
||||
mesh_3d = 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"]],
|
||||
)
|
||||
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"]],
|
||||
)
|
||||
|
||||
# Create edges between points in triangles
|
||||
Xe = []
|
||||
@ -67,25 +67,21 @@ Ye = []
|
||||
Ze = []
|
||||
step_per_triangle = num_vertex_coords * num_vertices_per_triangle
|
||||
for i in range(0, len(vertex_array), step_per_triangle):
|
||||
Xe.extend([vertex_array[i + 0], vertex_array[i + 3], vertex_array[i + 6], None]) # x-coordinates of start and end points of the edge
|
||||
Ye.extend([vertex_array[i + 1], vertex_array[i + 4], vertex_array[i + 7], None]) # y-coordinates of start and end points of the edge
|
||||
Ze.extend([vertex_array[i + 2], vertex_array[i + 5], vertex_array[i + 8], None]) # z-coordinates of start and end points of the edge
|
||||
Xe.extend(
|
||||
[vertex_array[i + 0], vertex_array[i + 3], vertex_array[i + 6], None]
|
||||
) # x-coordinates of start and end points of the edge
|
||||
Ye.extend(
|
||||
[vertex_array[i + 1], vertex_array[i + 4], vertex_array[i + 7], None]
|
||||
) # y-coordinates of start and end points of the edge
|
||||
Ze.extend(
|
||||
[vertex_array[i + 2], vertex_array[i + 5], vertex_array[i + 8], None]
|
||||
) # z-coordinates of start and end points of the edge
|
||||
|
||||
edges_3d = go.Scatter3d(
|
||||
x=Xe,
|
||||
y=Ye,
|
||||
z=Ze,
|
||||
mode='lines',
|
||||
name='',
|
||||
line=dict(color= 'rgb(70,70,70)', width=1)
|
||||
x=Xe, y=Ye, z=Ze, mode="lines", name="", line=dict(color="rgb(70,70,70)", width=1)
|
||||
)
|
||||
|
||||
fig = go.Figure(
|
||||
data=[
|
||||
mesh_3d,
|
||||
edges_3d
|
||||
]
|
||||
)
|
||||
fig = go.Figure(data=[mesh_3d, edges_3d])
|
||||
|
||||
print(f"j array: {j_array}")
|
||||
print(f"Number of vertices: {len(vertex_array) / 3}")
|
||||
|
Loading…
Reference in New Issue
Block a user