This is an example of how to use the netdem library.
#include <iostream>
#include <unordered_map>
using namespace std;
void EvaluateMorphology(int argc, char **argv) {
int num_particles = atof(argv[2]);
int num_patches = atof(argv[3]);
stringbuf buf;
ostream os(&buf);
int os_width = 24;
os.setf(ios::scientific);
os.precision(15);
for (int i = 0; i < num_particles; i++) {
tmp_stl.
InitFromSTL(
"local/polybezier_model/random_generation/n" +
to_string(num_patches) + "/p" + to_string(i) + ".stl");
cout << "local/polybezier_model/n" + to_string(num_patches) + "/p" +
to_string(i) + ".stl"
<< endl;
auto bound_len = bound_max - bound_min;
auto len_max = max(bound_len[0], max(bound_len[1], bound_len[2]));
auto len_min = min(bound_len[0], min(bound_len[1], bound_len[2]));
auto len_mid =
bound_len[0] + bound_len[1] + bound_len[2] - len_max - len_min;
auto flatness = len_min / len_mid;
auto elongation = len_mid / len_max;
auto sphericity =
1.0 / 3.0) /
os.width(os_width);
os << flatness << ", ";
os.width(os_width);
os << elongation << ", ";
os.width(os_width);
os << sphericity << endl;
}
ofstream outfile;
auto filename = "local/polybezier_model/random_generation/n" +
to_string(num_patches) + ".txt";
outfile.open(filename);
if (!outfile) {
cout << "cannot open file: " << filename << endl;
}
outfile << buf.str();
outfile.close();
cout << "data saved to: " << filename << endl;
}
Class for working with STL models.
Definition stl_model.hpp:17
std::tuple< Vec3d, Vec3d > GetBoundAABB() const
Get the axis-aligned bounding box of the model.
Definition stl_model.cpp:453
double GetVolume() const
Get the volume of the model.
Definition stl_model.cpp:476
double GetSurfaceArea() const
Get the surface area of the model.
Definition stl_model.cpp:472
void Standardize()
Standardize the model.
Definition stl_model.cpp:290
void InitFromSTL(std::string const &file)
Initialize the model from an STL file.
Definition stl_model.cpp:25
Definition bond_entry.hpp:7