29 std::vector<F3> points;
31 float r_outer = radius;
32 float r_inner = radius - thickness;
36 float circumference = 2.0f *
kPi * r_outer;
37 int n_angular = std::ceil(circumference / spacing);
38 int n_vertical = std::ceil(h / spacing);
40 for (
int i = 0; i < n_angular; ++i) {
41 float theta = 2.0f *
kPi * i / n_angular;
42 for (
int j = 0; j <= n_vertical; ++j) {
43 float y = -0.5f * h + h * j / n_vertical;
44 float x = r_outer * std::cos(theta);
45 float z = r_outer * std::sin(theta);
46 points.push_back(
F3{x, y, z});
51 if (thickness > 0.0f) {
52 circumference = 2.0f *
kPi * r_inner;
53 n_angular = std::ceil(circumference / spacing);
54 for (
int i = 0; i < n_angular; ++i) {
55 float theta = 2.0f *
kPi * i / n_angular;
56 for (
int j = 0; j <= n_vertical; ++j) {
57 float y = -0.5f * h + h * j / n_vertical;
58 float x = r_inner * std::cos(theta);
59 float z = r_inner * std::sin(theta);
60 points.push_back(
F3{x, y, z});
67 int n_radial = std::ceil(thickness / dr);
68 for (
int i = 0; i <= n_radial; ++i) {
69 float r = r_inner + (r_outer - r_inner) * i / n_radial;
70 circumference = 2.0f *
kPi * r;
71 n_angular = std::ceil(circumference / spacing);
72 for (
int j = 0; j < n_angular; ++j) {
73 float theta = 2.0f *
kPi * j / n_angular;
74 float x = r * std::cos(theta);
75 float z = r * std::sin(theta);
76 points.push_back(
F3{x, 0.5f * h, z});
77 points.push_back(
F3{x, -0.5f * h, z});
86inline std::vector<F3>
genBoxShell(
float hx,
float hy,
float hz,
float spacing) {
87 std::vector<F3> points;
88 auto nseg = [&](
float half) {
89 int n = (int)std::ceil(2.0f * half / spacing);
92 int nx = nseg(hx), ny = nseg(hy), nz = nseg(hz);
93 auto lin = [](
float half,
int i,
int n) {
return -half + 2.0f * half * (float)i / (
float)n; };
96 for (
int j = 0; j <= ny; ++j)
97 for (
int k = 0; k <= nz; ++k) {
98 float y = lin(hy, j, ny), z = lin(hz, k, nz);
99 points.push_back(
F3{hx, y, z});
100 points.push_back(
F3{-hx, y, z});
103 for (
int i = 0; i <= nx; ++i)
104 for (
int k = 0; k <= nz; ++k) {
105 float x = lin(hx, i, nx), z = lin(hz, k, nz);
106 points.push_back(
F3{x, hy, z});
107 points.push_back(
F3{x, -hy, z});
110 for (
int i = 0; i <= nx; ++i)
111 for (
int j = 0; j <= ny; ++j) {
112 float x = lin(hx, i, nx), y = lin(hy, j, ny);
113 points.push_back(
F3{x, y, hz});
114 points.push_back(
F3{x, y, -hz});