NetDEM v1.0
Loading...
Searching...
No Matches
gen_wall_box_plate.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "scene.hpp"
4#include "shape_trimesh.hpp"
5#include "wall.hpp"
6
7namespace netdem {
8
17private:
18 TriMesh p_x0, p_y0, p_z0;
19 Wall w_mx, w_px, w_my, w_py, w_mz, w_pz;
20
21public:
32 WallBoxPlate(double len_x, double len_y, double len_z, double center_x,
33 double center_y, double center_z) {
34 double t_factor = 0.1;
35 double len_factor = 1 + 2 * t_factor;
36 double pan_factor = 0.5 * (1 + t_factor);
37
38 p_x0 = GetBox(len_x * t_factor, len_y * len_factor, len_z * len_factor);
39 w_mx = w_px = Wall(&p_x0);
40 w_mx.SetPosition(center_x - pan_factor * len_x, center_y, center_z);
41 w_px.SetPosition(center_x + pan_factor * len_x, center_y, center_z);
42
43 p_y0 = GetBox(len_x * len_factor, len_y * t_factor, len_z * len_factor);
44 w_my = w_py = Wall(&p_y0);
45 w_my.SetPosition(center_x, center_y - pan_factor * len_y, center_z);
46 w_py.SetPosition(center_x, center_y + pan_factor * len_y, center_z);
47
48 p_z0 = GetBox(len_x * len_factor, len_y * len_factor, len_z * t_factor);
49 w_mz = w_pz = Wall(&p_z0);
50 w_mz.SetPosition(center_x, center_y, center_z - pan_factor * len_z);
51 w_pz.SetPosition(center_x, center_y, center_z + pan_factor * len_z);
52 }
53
61 VecXT<Shape *> plate_list;
62 plate_list.emplace_back(&p_x0);
63 plate_list.emplace_back(&p_y0);
64 plate_list.emplace_back(&p_z0);
65 return plate_list;
66 }
67
74 VecXT<Wall *> wall_list;
75 wall_list.emplace_back(&w_mx);
76 wall_list.emplace_back(&w_px);
77 wall_list.emplace_back(&w_my);
78 wall_list.emplace_back(&w_py);
79 wall_list.emplace_back(&w_mz);
80 wall_list.emplace_back(&w_pz);
81 return wall_list;
82 }
83
89 void ImportToScene(Scene *scene) {
90 auto shape_ptr_list_local = GetShapes();
91 auto wall_ptr_list_local = GetWall();
92
93 auto shape_ptr_list = scene->InsertShape(shape_ptr_list_local);
94
95 for (int i = 0; i < 6; i++) {
96 wall_ptr_list_local[i]->SetShape(shape_ptr_list[i / 2]);
97 scene->InsertWall(wall_ptr_list_local[i]);
98 wall_ptr_list_local[i]->SetShape(shape_ptr_list_local[i / 2]);
99 }
100 }
101
102private:
116 TriMesh GetBox(double len_x, double len_y, double len_z) {
117 TriMesh box_ref;
118 box_ref.vertices.resize(8);
119 box_ref.facets.resize(12);
120
121 box_ref.vertices[0][0] = -0.5 * len_x;
122 box_ref.vertices[0][1] = -0.5 * len_y;
123 box_ref.vertices[0][2] = -0.5 * len_z;
124
125 box_ref.vertices[1][0] = -0.5 * len_x;
126 box_ref.vertices[1][1] = 0.5 * len_y;
127 box_ref.vertices[1][2] = -0.5 * len_z;
128
129 box_ref.vertices[2][0] = -0.5 * len_x;
130 box_ref.vertices[2][1] = 0.5 * len_y;
131 box_ref.vertices[2][2] = 0.5 * len_z;
132
133 box_ref.vertices[3][0] = -0.5 * len_x;
134 box_ref.vertices[3][1] = -0.5 * len_y;
135 box_ref.vertices[3][2] = 0.5 * len_z;
136
137 box_ref.vertices[4][0] = 0.5 * len_x;
138 box_ref.vertices[4][1] = -0.5 * len_y;
139 box_ref.vertices[4][2] = -0.5 * len_z;
140
141 box_ref.vertices[5][0] = 0.5 * len_x;
142 box_ref.vertices[5][1] = 0.5 * len_y;
143 box_ref.vertices[5][2] = -0.5 * len_z;
144
145 box_ref.vertices[6][0] = 0.5 * len_x;
146 box_ref.vertices[6][1] = 0.5 * len_y;
147 box_ref.vertices[6][2] = 0.5 * len_z;
148
149 box_ref.vertices[7][0] = 0.5 * len_x;
150 box_ref.vertices[7][1] = -0.5 * len_y;
151 box_ref.vertices[7][2] = 0.5 * len_z;
152
153 box_ref.facets[0][0] = 0;
154 box_ref.facets[0][1] = 3;
155 box_ref.facets[0][2] = 2;
156
157 box_ref.facets[1][0] = 0;
158 box_ref.facets[1][1] = 2;
159 box_ref.facets[1][2] = 1;
160
161 box_ref.facets[2][0] = 4;
162 box_ref.facets[2][1] = 5;
163 box_ref.facets[2][2] = 6;
164
165 box_ref.facets[3][0] = 4;
166 box_ref.facets[3][1] = 6;
167 box_ref.facets[3][2] = 7;
168
169 box_ref.facets[4][0] = 7;
170 box_ref.facets[4][1] = 3;
171 box_ref.facets[4][2] = 0;
172
173 box_ref.facets[5][0] = 7;
174 box_ref.facets[5][1] = 0;
175 box_ref.facets[5][2] = 4;
176
177 box_ref.facets[6][0] = 6;
178 box_ref.facets[6][1] = 5;
179 box_ref.facets[6][2] = 1;
180
181 box_ref.facets[7][0] = 6;
182 box_ref.facets[7][1] = 1;
183 box_ref.facets[7][2] = 2;
184
185 box_ref.facets[8][0] = 0;
186 box_ref.facets[8][1] = 1;
187 box_ref.facets[8][2] = 5;
188
189 box_ref.facets[9][0] = 0;
190 box_ref.facets[9][1] = 5;
191 box_ref.facets[9][2] = 6;
192
193 box_ref.facets[10][0] = 7;
194 box_ref.facets[10][1] = 6;
195 box_ref.facets[10][2] = 2;
196
197 box_ref.facets[11][0] = 7;
198 box_ref.facets[11][1] = 2;
199 box_ref.facets[11][2] = 3;
200
201 box_ref.UpdateShapeProperties();
202
203 return box_ref;
204 }
205};
206} // namespace netdem
A class for managing the elements in a DEM simulation. Scene behaves as a std container:
Definition scene.hpp:56
Shape * InsertShape(const Shape *const s_ptr)
Insert a single shape into this scene.
Definition scene.cpp:19
Wall * InsertWall(const Wall *const w_ptr)
Insert a single wall into this scene.
Definition scene.cpp:194
A class representing a triangular mesh in 3D space.
Definition shape_trimesh.hpp:23
void UpdateShapeProperties() override
Update the shape properties of the TriMesh object.
Definition shape_trimesh.cpp:158
VecXT< Vec3i > facets
The faces (triangles) of the triangular mesh.
Definition shape_trimesh.hpp:33
VecXT< Vec3d > vertices
The vertices of the triangular mesh.
Definition shape_trimesh.hpp:28
A class for generating a box of six walls with plates.
Definition gen_wall_box_plate.hpp:16
VecXT< Shape * > GetShapes()
Gets the list of shapes generated by the wall box.
Definition gen_wall_box_plate.hpp:60
void ImportToScene(Scene *scene)
Imports the shapes and walls generated by the wall box into a scene.
Definition gen_wall_box_plate.hpp:89
WallBoxPlate(double len_x, double len_y, double len_z, double center_x, double center_y, double center_z)
Generates a box of six walls with plates.
Definition gen_wall_box_plate.hpp:32
VecXT< Wall * > GetWall()
Gets the list of walls generated by the wall box.
Definition gen_wall_box_plate.hpp:73
A class representing a wall object in a physics simulation.
Definition wall.hpp:32
void SetShape(Shape *const shape)
Sets the shape of the wall.
Definition wall.cpp:27
void SetPosition(double pos_x, double pos_y, double pos_z)
Sets the position of the wall.
Definition wall.cpp:41
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31