NetDEM v1.0
Loading...
Searching...
No Matches
gen_wall_box_plane.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "scene.hpp"
4#include "shape_plane.hpp"
5#include "wall.hpp"
6
7namespace netdem {
8
24private:
25 Plane p_mx, p_px, p_my, p_py, p_mz, p_pz;
26 Wall w_mx, w_px, w_my, w_py, w_mz, w_pz;
27
28public:
39 WallBoxPlane(double len_x, double len_y, double len_z, double center_x,
40 double center_y, double center_z) {
41 p_mx = Plane(center_x - 0.5 * len_x, center_y, center_z, 1, 0, 0);
42 p_px = Plane(center_x + 0.5 * len_x, center_y, center_z, -1, 0, 0);
43 p_my = Plane(center_x, center_y - 0.5 * len_y, center_z, 0, 1, 0);
44 p_py = Plane(center_x, center_y + 0.5 * len_y, center_z, 0, -1, 0);
45 p_mz = Plane(center_x, center_y, center_z - 0.5 * len_z, 0, 0, 1);
46 p_pz = Plane(center_x, center_y, center_z + 0.5 * len_z, 0, 0, -1);
47
48 double sqrt_2_by_2 = 2.0 * std::sqrt(2.0);
49 p_mx.SetExtent(std::max(len_y, len_z) * sqrt_2_by_2);
50 p_px.SetExtent(std::max(len_y, len_z) * sqrt_2_by_2);
51 p_my.SetExtent(std::max(len_x, len_z) * sqrt_2_by_2);
52 p_py.SetExtent(std::max(len_x, len_z) * sqrt_2_by_2);
53 p_mz.SetExtent(std::max(len_x, len_y) * sqrt_2_by_2);
54 p_pz.SetExtent(std::max(len_x, len_y) * sqrt_2_by_2);
55
56 w_mx = Wall(&p_mx);
57 w_px = Wall(&p_px);
58 w_my = Wall(&p_my);
59 w_py = Wall(&p_py);
60 w_mz = Wall(&p_mz);
61 w_pz = Wall(&p_pz);
62 }
63
71 VecXT<Shape *> plane_list;
72 plane_list.emplace_back(&p_mx);
73 plane_list.emplace_back(&p_px);
74 plane_list.emplace_back(&p_my);
75 plane_list.emplace_back(&p_py);
76 plane_list.emplace_back(&p_mz);
77 plane_list.emplace_back(&p_pz);
78 return plane_list;
79 }
80
87 VecXT<Wall *> wall_list;
88 wall_list.emplace_back(&w_mx);
89 wall_list.emplace_back(&w_px);
90 wall_list.emplace_back(&w_my);
91 wall_list.emplace_back(&w_py);
92 wall_list.emplace_back(&w_mz);
93 wall_list.emplace_back(&w_pz);
94 return wall_list;
95 }
96
102 void ImportToScene(Scene *scene) {
103 auto shape_ptr_list_local = GetShapes();
104 auto wall_ptr_list_local = GetWall();
105
106 auto shape_ptr_list = scene->InsertShape(shape_ptr_list_local);
107
108 for (int i = 0; i < 6; i++) {
109 wall_ptr_list_local[i]->SetShape(shape_ptr_list[i]);
110 scene->InsertWall(wall_ptr_list_local[i]);
111 wall_ptr_list_local[i]->SetShape(shape_ptr_list_local[i]);
112 }
113 }
114};
115
116} // namespace netdem
A class for representing a plane with a center point and normal vector.
Definition shape_plane.hpp:22
void SetExtent(double e)
Set the extent of the Plane object.
Definition shape_plane.cpp:119
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 for generating a box of six walls.
Definition gen_wall_box_plane.hpp:23
WallBoxPlane(double len_x, double len_y, double len_z, double center_x, double center_y, double center_z)
Generates a box of six walls.
Definition gen_wall_box_plane.hpp:39
void ImportToScene(Scene *scene)
Imports the shapes and walls generated by the wall box into a scene.
Definition gen_wall_box_plane.hpp:102
VecXT< Wall * > GetWall()
Gets the list of walls generated by the wall box.
Definition gen_wall_box_plane.hpp:86
VecXT< Shape * > GetShapes()
Gets the list of shapes generated by the wall box.
Definition gen_wall_box_plane.hpp:70
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
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31