23 std::vector<F3> points;
25 float r_outer = radius;
26 float r_inner = radius - thickness;
30 float circumference = 2.0f * M_PI * r_outer;
31 int n_angular = std::ceil(circumference / spacing);
32 int n_vertical = std::ceil(h / spacing);
34 for (
int i = 0; i < n_angular; ++i) {
35 float theta = 2.0f * M_PI * i / n_angular;
36 for (
int j = 0; j <= n_vertical; ++j) {
37 float y = -0.5f * h + h * j / n_vertical;
38 float x = r_outer * std::cos(theta);
39 float z = r_outer * std::sin(theta);
40 points.push_back(
F3{x, y, z});
45 if (thickness > 0.0f) {
46 circumference = 2.0f * M_PI * r_inner;
47 n_angular = std::ceil(circumference / spacing);
48 for (
int i = 0; i < n_angular; ++i) {
49 float theta = 2.0f * M_PI * i / n_angular;
50 for (
int j = 0; j <= n_vertical; ++j) {
51 float y = -0.5f * h + h * j / n_vertical;
52 float x = r_inner * std::cos(theta);
53 float z = r_inner * std::sin(theta);
54 points.push_back(
F3{x, y, z});
61 int n_radial = std::ceil(thickness / dr);
62 for (
int i = 0; i <= n_radial; ++i) {
63 float r = r_inner + (r_outer - r_inner) * i / n_radial;
64 circumference = 2.0f * M_PI * r;
65 n_angular = std::ceil(circumference / spacing);
66 for (
int j = 0; j < n_angular; ++j) {
67 float theta = 2.0f * M_PI * j / n_angular;
68 float x = r * std::cos(theta);
69 float z = r * std::sin(theta);
70 points.push_back(
F3{x, 0.5f * h, z});
71 points.push_back(
F3{x, -0.5f * h, z});
80inline std::vector<F3>
genBoxShell(
float hx,
float hy,
float hz,
float spacing) {
81 std::vector<F3> points;
82 auto nseg = [&](
float half) {
83 int n = (int)std::ceil(2.0f * half / spacing);
86 int nx = nseg(hx), ny = nseg(hy), nz = nseg(hz);
87 auto lin = [](
float half,
int i,
int n) {
return -half + 2.0f * half * (float)i / (
float)n; };
90 for (
int j = 0; j <= ny; ++j)
91 for (
int k = 0; k <= nz; ++k) {
92 float y = lin(hy, j, ny), z = lin(hz, k, nz);
93 points.push_back(
F3{hx, y, z});
94 points.push_back(
F3{-hx, y, z});
97 for (
int i = 0; i <= nx; ++i)
98 for (
int k = 0; k <= nz; ++k) {
99 float x = lin(hx, i, nx), z = lin(hz, k, nz);
100 points.push_back(
F3{x, hy, z});
101 points.push_back(
F3{x, -hy, z});
104 for (
int i = 0; i <= nx; ++i)
105 for (
int j = 0; j <= ny; ++j) {
106 float x = lin(hx, i, nx), y = lin(hy, j, ny);
107 points.push_back(
F3{x, y, hz});
108 points.push_back(
F3{x, y, -hz});