NetDEM v1.0
Loading...
Searching...
No Matches
05_ave_num_linked_patches.cpp

This is an example of how to use the netdem library.

#include "data_dumper.hpp"
#include "gen_pack.hpp"
#include "gravity.hpp"
#include "shape_sphere.hpp"
#include "simulation.hpp"
#include <filesystem>
#include <iostream>
#include <unordered_map>
using namespace netdem;
using namespace std;
void AveNumLinkedPatches(int argc, char **argv) {
int num_particles = atof(argv[2]);
filesystem::create_directories("local/polybezier_model/demo_normal_patches");
for (int i = 1; i < 10; i++) {
STLModel kernel_stl;
kernel_stl.InitFromSTL(
"local/polybezier_model/demo_normal_patches/kernel_stl_1.stl");
Polybezier polybezier;
polybezier.num_cells = i;
polybezier.InitFromKernelSTL(kernel_stl);
double ave_num{0};
for (auto cell : polybezier.linked_patches_list) {
ave_num += cell.size();
}
cout << i << ", " << ave_num / polybezier.linked_patches_list.size()
<< ", ";
TriMesh trimesh;
trimesh.num_cells = i;
trimesh.use_linked_patches = true;
trimesh.InitFromSTL(polybezier.GetSTLModel(500));
ave_num = 0;
for (auto cell : trimesh.linked_vertices) {
ave_num += cell.size();
}
cout << ave_num / trimesh.linked_vertices.size() << endl;
}
}
A class representing a polybezier with variable orders and patches.
Definition shape_polybezier.hpp:21
STLModel GetSTLModel(int num_nodes=200) override
Generate an STL model for the Polybezier object.
Definition shape_polybezier.cpp:251
VecXT< VecXT< int > > linked_patches_list
Definition shape_polybezier.hpp:39
void InitFromKernelSTL(std::string const &file)
Initialize the Polybezier object from a kernel STL model read from file.
int num_cells
Definition shape_polybezier.hpp:40
Class for working with STL models.
Definition stl_model.hpp:17
void InitFromSTL(std::string const &file)
Initialize the model from an STL file.
Definition stl_model.cpp:25
A class representing a triangular mesh in 3D space.
Definition shape_trimesh.hpp:23
void InitFromSTL(std::string const &file)
Initialize the TriMesh object from an STL file.
bool use_linked_patches
Flag indicating whether to use the linked-patches algorithm for support point calculation.
Definition shape_trimesh.hpp:45
int num_cells
The number of cells for the linked-patches algorithm (should be even).
Definition shape_trimesh.hpp:51
VecXT< VecXT< int > > linked_vertices
The vertices in each cell for the linked-patches algorithm.
Definition shape_trimesh.hpp:56
Definition bond_entry.hpp:7