|
13 | 13 | from abc import ABC, abstractmethod |
14 | 14 |
|
15 | 15 | import numpy as np |
16 | | -from geoapps_utils.modelling.plates import PlateModel, inside_plate |
17 | | -from geoapps_utils.utils.transformations import ( |
18 | | - rotate_points, |
19 | | - rotate_xyz, |
20 | | - x_rotation_matrix, |
21 | | - z_rotation_matrix, |
22 | | -) |
23 | 16 | from geoh5py.objects import Octree, Surface |
24 | | -from geoh5py.shared.utils import fetch_active_workspace |
25 | | -from geoh5py.workspace import Workspace |
26 | 17 | from trimesh import Trimesh |
27 | 18 | from trimesh.proximity import ProximityQuery |
28 | 19 |
|
29 | | -from simpeg_drivers.plate_simulation.models.options import PlateOptions |
30 | 20 | from simpeg_drivers.utils.utils import active_from_xyz |
31 | 21 |
|
32 | 22 |
|
@@ -57,121 +47,121 @@ def mask(self, mesh: Octree) -> np.ndarray: |
57 | 47 | """ |
58 | 48 |
|
59 | 49 |
|
60 | | -class Plate(Parametric): |
61 | | - """ |
62 | | - Define a rotated rectangular block in 3D space |
63 | | -
|
64 | | - :param params: Parameters describing the plate. |
65 | | - :param surface: Surface object representing the plate. |
66 | | - """ |
67 | | - |
68 | | - def __init__( |
69 | | - self, |
70 | | - params: PlateOptions, |
71 | | - workspace: Workspace | None = None, |
72 | | - ): |
73 | | - self.params = params |
74 | | - self._workspace = workspace |
75 | | - super().__init__(self._create_surface()) |
76 | | - |
77 | | - def _create_surface(self) -> Surface: |
78 | | - """ |
79 | | - Create a surface object from a plate object. |
80 | | -
|
81 | | - :param workspace: Workspace object to create the surface in. |
82 | | - :param out_group: Output group to store the surface. |
83 | | - """ |
84 | | - with fetch_active_workspace(self.workspace) as ws: |
85 | | - surface = Surface.create( |
86 | | - ws, |
87 | | - vertices=self.vertices, |
88 | | - cells=self.triangles, |
89 | | - name=self.params.name, |
90 | | - ) |
91 | | - |
92 | | - return surface |
93 | | - |
94 | | - @property |
95 | | - def surface(self): |
96 | | - """ |
97 | | - A surface object representing the plate. |
98 | | - """ |
99 | | - return self._surface |
100 | | - |
101 | | - @property |
102 | | - def triangles(self) -> np.ndarray: |
103 | | - """Triangulation of the block.""" |
104 | | - return np.vstack( |
105 | | - [ |
106 | | - [0, 2, 1], |
107 | | - [1, 2, 3], |
108 | | - [0, 1, 4], |
109 | | - [4, 1, 5], |
110 | | - [1, 3, 5], |
111 | | - [5, 3, 7], |
112 | | - [2, 6, 3], |
113 | | - [3, 6, 7], |
114 | | - [0, 4, 2], |
115 | | - [2, 4, 6], |
116 | | - [4, 5, 6], |
117 | | - [6, 5, 7], |
118 | | - ] |
119 | | - ) |
120 | | - |
121 | | - @property |
122 | | - def vertices(self) -> np.ndarray: |
123 | | - """Vertices for triangulation of a rectangular prism in 3D space.""" |
124 | | - |
125 | | - u_1 = self.params.geometry.origin[0] - ( |
126 | | - self.params.geometry.strike_length / 2.0 |
127 | | - ) |
128 | | - u_2 = self.params.geometry.origin[0] + ( |
129 | | - self.params.geometry.strike_length / 2.0 |
130 | | - ) |
131 | | - v_1 = self.params.geometry.origin[1] - (self.params.geometry.dip_length / 2.0) |
132 | | - v_2 = self.params.geometry.origin[1] + (self.params.geometry.dip_length / 2.0) |
133 | | - w_1 = self.params.geometry.origin[2] - (self.params.geometry.width / 2.0) |
134 | | - w_2 = self.params.geometry.origin[2] + (self.params.geometry.width / 2.0) |
135 | | - |
136 | | - vertices = np.array( |
137 | | - [ |
138 | | - [u_1, v_1, w_1], |
139 | | - [u_2, v_1, w_1], |
140 | | - [u_1, v_2, w_1], |
141 | | - [u_2, v_2, w_1], |
142 | | - [u_1, v_1, w_2], |
143 | | - [u_2, v_1, w_2], |
144 | | - [u_1, v_2, w_2], |
145 | | - [u_2, v_2, w_2], |
146 | | - ] |
147 | | - ) |
148 | | - |
149 | | - return self._rotate(vertices) |
150 | | - |
151 | | - @property |
152 | | - def workspace(self) -> Workspace: |
153 | | - if self._workspace is None: |
154 | | - self._workspace = Workspace() |
155 | | - |
156 | | - return self._workspace |
157 | | - |
158 | | - def _rotate(self, vertices: np.ndarray) -> np.ndarray: |
159 | | - """Rotate vertices and adjust for reference point.""" |
160 | | - theta = -1 * self.params.geometry.direction |
161 | | - phi = -1 * self.params.geometry.dip |
162 | | - rotated_vertices = rotate_xyz(vertices, self.params.geometry.origin, theta, phi) |
163 | | - |
164 | | - return rotated_vertices |
165 | | - |
166 | | - def mask(self, mesh: Octree) -> np.ndarray: |
167 | | - rotations = [ |
168 | | - z_rotation_matrix(np.deg2rad(self.params.geometry.direction)), |
169 | | - x_rotation_matrix(np.deg2rad(self.params.geometry.dip)), |
170 | | - ] |
171 | | - rotated_centers = rotate_points( |
172 | | - mesh.centroids, origin=self.params.geometry.origin, rotations=rotations |
173 | | - ) |
174 | | - return inside_plate(rotated_centers, self.params.geometry) |
| 50 | +# class Plate(Parametric): |
| 51 | +# """ |
| 52 | +# Define a rotated rectangular block in 3D space |
| 53 | +# |
| 54 | +# :param params: Parameters describing the plate. |
| 55 | +# :param surface: Surface object representing the plate. |
| 56 | +# """ |
| 57 | +# |
| 58 | +# def __init__( |
| 59 | +# self, |
| 60 | +# params: PlateOptions, |
| 61 | +# workspace: Workspace | None = None, |
| 62 | +# ): |
| 63 | +# self.params = params |
| 64 | +# self._workspace = workspace |
| 65 | +# super().__init__(self._create_surface()) |
| 66 | +# |
| 67 | +# def _create_surface(self) -> Surface: |
| 68 | +# """ |
| 69 | +# Create a surface object from a plate object. |
| 70 | +# |
| 71 | +# :param workspace: Workspace object to create the surface in. |
| 72 | +# :param out_group: Output group to store the surface. |
| 73 | +# """ |
| 74 | +# with fetch_active_workspace(self.workspace) as ws: |
| 75 | +# surface = Surface.create( |
| 76 | +# ws, |
| 77 | +# vertices=self.vertices, |
| 78 | +# cells=self.triangles, |
| 79 | +# name=self.params.name, |
| 80 | +# ) |
| 81 | +# |
| 82 | +# return surface |
| 83 | +# |
| 84 | +# @property |
| 85 | +# def surface(self): |
| 86 | +# """ |
| 87 | +# A surface object representing the plate. |
| 88 | +# """ |
| 89 | +# return self._surface |
| 90 | +# |
| 91 | +# @property |
| 92 | +# def triangles(self) -> np.ndarray: |
| 93 | +# """Triangulation of the block.""" |
| 94 | +# return np.vstack( |
| 95 | +# [ |
| 96 | +# [0, 2, 1], |
| 97 | +# [1, 2, 3], |
| 98 | +# [0, 1, 4], |
| 99 | +# [4, 1, 5], |
| 100 | +# [1, 3, 5], |
| 101 | +# [5, 3, 7], |
| 102 | +# [2, 6, 3], |
| 103 | +# [3, 6, 7], |
| 104 | +# [0, 4, 2], |
| 105 | +# [2, 4, 6], |
| 106 | +# [4, 5, 6], |
| 107 | +# [6, 5, 7], |
| 108 | +# ] |
| 109 | +# ) |
| 110 | +# |
| 111 | +# @property |
| 112 | +# def vertices(self) -> np.ndarray: |
| 113 | +# """Vertices for triangulation of a rectangular prism in 3D space.""" |
| 114 | +# |
| 115 | +# u_1 = self.params.geometry.origin[0] - ( |
| 116 | +# self.params.geometry.strike_length / 2.0 |
| 117 | +# ) |
| 118 | +# u_2 = self.params.geometry.origin[0] + ( |
| 119 | +# self.params.geometry.strike_length / 2.0 |
| 120 | +# ) |
| 121 | +# v_1 = self.params.geometry.origin[1] - (self.params.geometry.dip_length / 2.0) |
| 122 | +# v_2 = self.params.geometry.origin[1] + (self.params.geometry.dip_length / 2.0) |
| 123 | +# w_1 = self.params.geometry.origin[2] - (self.params.geometry.width / 2.0) |
| 124 | +# w_2 = self.params.geometry.origin[2] + (self.params.geometry.width / 2.0) |
| 125 | +# |
| 126 | +# vertices = np.array( |
| 127 | +# [ |
| 128 | +# [u_1, v_1, w_1], |
| 129 | +# [u_2, v_1, w_1], |
| 130 | +# [u_1, v_2, w_1], |
| 131 | +# [u_2, v_2, w_1], |
| 132 | +# [u_1, v_1, w_2], |
| 133 | +# [u_2, v_1, w_2], |
| 134 | +# [u_1, v_2, w_2], |
| 135 | +# [u_2, v_2, w_2], |
| 136 | +# ] |
| 137 | +# ) |
| 138 | +# |
| 139 | +# return self._rotate(vertices) |
| 140 | +# |
| 141 | +# @property |
| 142 | +# def workspace(self) -> Workspace: |
| 143 | +# if self._workspace is None: |
| 144 | +# self._workspace = Workspace() |
| 145 | +# |
| 146 | +# return self._workspace |
| 147 | +# |
| 148 | +# def _rotate(self, vertices: np.ndarray) -> np.ndarray: |
| 149 | +# """Rotate vertices and adjust for reference point.""" |
| 150 | +# theta = -1 * self.params.geometry.direction |
| 151 | +# phi = -1 * self.params.geometry.dip |
| 152 | +# rotated_vertices = rotate_xyz(vertices, self.params.geometry.origin, theta, phi) |
| 153 | +# |
| 154 | +# return rotated_vertices |
| 155 | +# |
| 156 | +# def mask(self, mesh: Octree) -> np.ndarray: |
| 157 | +# rotations = [ |
| 158 | +# z_rotation_matrix(np.deg2rad(self.params.geometry.direction)), |
| 159 | +# x_rotation_matrix(np.deg2rad(self.params.geometry.dip)), |
| 160 | +# ] |
| 161 | +# rotated_centers = rotate_points( |
| 162 | +# mesh.centroids, origin=self.params.geometry.origin, rotations=rotations |
| 163 | +# ) |
| 164 | +# return inside_plate(rotated_centers, self.params.geometry) |
175 | 165 |
|
176 | 166 |
|
177 | 167 | class Body(Parametric): |
|
0 commit comments