NetDEM v1.0
Loading...
Searching...
No Matches
04_demo_normal_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;
STLModel GetKernelPolyhedron();
void DemoNormalPatches(int argc, char **argv) {
int num_particles = atof(argv[2]);
filesystem::create_directories("local/polybezier_model/demo_normal_patches");
for (int i = 0; i < num_particles; i++) {
auto kernel_stl = GetKernelPolyhedron();
kernel_stl.SaveAsSTL(
"local/polybezier_model/demo_normal_patches/kernel_stl_" +
to_string(i) + ".stl");
Polybezier polybezier;
polybezier.InitFromKernelSTL(kernel_stl);
"local/polybezier_model/demo_normal_patches/polybezier_normal_" +
to_string(i) + ".stl");
TriMesh trimesh;
trimesh.use_linked_patches = true;
trimesh.InitFromSTL(polybezier.GetSTLModel(500));
trimesh.SaveAsSTL("local/polybezier_model/demo_normal_patches/mesh_stl_" +
to_string(i) + ".stl");
"local/polybezier_model/demo_normal_patches/mesh_normal_" +
to_string(i) + ".stl");
}
}
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
void SaveNormalPatchesCubic(std::string const &file)
Save normal patches as a cubic mesh.
Definition shape_polybezier.cpp:332
void InitFromKernelSTL(std::string const &file)
Initialize the Polybezier object from a kernel STL model read from file.
Class for working with STL models.
Definition stl_model.hpp:17
virtual void SaveAsSTL(std::string const &filename)
Saves the shape instance as an STL file.
Definition shape.cpp:353
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.
void SaveNormalPatchesCubic(std::string const &file)
Save cubic normal patches for the TriMesh object to a file.
Definition shape_trimesh.cpp:588
bool use_linked_patches
Flag indicating whether to use the linked-patches algorithm for support point calculation.
Definition shape_trimesh.hpp:45
Definition bond_entry.hpp:7