NetDEM v1.0
Loading...
Searching...
No Matches
shape_polybezier.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "shape.hpp"
4#include "stl_model.hpp"
5#include "stl_reader.hpp"
6#include <iostream>
7#include <string>
8
9namespace netdem {
10
21class Polybezier : public Shape {
22public:
23 // num_patches have to be even
24 int num_patches{30}, order{2}; // only second order implemented for now
25
26 // [num of faces] by num of knots (e.g., 6 for 2nd order) by 3
28
29 // [num of faces] by 3 vertices by 3
31
32 // [num of faces*3/2] by num of knots (e.g., 6 for 2nd order) by 3
34
35 // [num of faces] by 3, used to find the edge patches for a face patch
37
38 // [6*num_cells^2] by [num of patches]
40 int num_cells{4};
41
45 Polybezier();
46
55 nlohmann::json PackJson() override;
56
65 void InitFromJson(nlohmann::json const &js) override;
66
74 Shape *Clone() const override;
75
82 void InitByRandom();
83
93 void InitFromKernelSTL(std::string const &file);
94
103 void InitFromKernelSTL(STLModel const &stl_model);
104
111 void Init();
112
119 void UpdateShapeProperties() override;
120
129 void SetSize(double d) override;
130
141 STLModel GetSTLModel(int num_nodes = 200) override;
142
156 STLModel GetSTLModel_v2(int num_nodes = 200);
157
166 void SaveNormalPatchesSpherical(std::string const &file);
167
176 void SaveNormalPatchesCubic(std::string const &file);
177
190 Vec3d SupportPoint(Vec3d const &dir) override;
191
204 VecXT<Vec3d> SupportPoints(Vec3d const &dir) override;
205
212 void Print() override;
213
214private:
221 void AlignAxes();
222
230 void UpdateLinkedPatches();
231
232 VecXT<VecNT<Vec3d, 3>> mat_du_list, mat_dv_list;
233
240 void UpdataMatDuDv();
241
253 Vec3d GetEdgeKnot(Vec3d const &v0, Vec3d const &v1, Vec3d const &n01);
254
265 void GetUniqueEdges(VecXT<Vec2i> *const edges,
266 VecXT<Vec3i> *const linked_list,
267 STLModel const &stl_model);
268
280 Vec3d GetPatchNormal(Vec3d const &v0, Vec3d const &v1, Vec3d const &v2);
281
290 void SortNormalPatchVertices(VecXT<Vec3d> *const normals);
291
301 VecXT<Vec3d> GetCartesianProject(const VecXT<Vec3d> &normals);
302
314 VecXT<Vec3d> GetCartesianProject(Vec3d const &v1, Vec3d const &v2);
315
328 bool ContainCorner(Vec3d const &corner, const VecXT<Vec3d> &normals);
329
341 STLModel GetSTLModel(const VecXT<Vec3d> &knots, int num_nodes_each);
342
353 int GetSupportPatchID(Vec3d const &dir);
354};
355
356} // namespace netdem
A class representing a polybezier with variable orders and patches.
Definition shape_polybezier.hpp:21
int order
Definition shape_polybezier.hpp:24
STLModel GetSTLModel(int num_nodes=200) override
Generate an STL model for the Polybezier object.
Definition shape_polybezier.cpp:251
Polybezier()
Default constructor.
Definition shape_polybezier.cpp:16
Shape * Clone() const override
Clone the Polybezier object.
Definition shape_polybezier.cpp:249
VecXT< VecXT< Vec3d > > face_patch_normals_list
Definition shape_polybezier.hpp:30
void UpdateShapeProperties() override
Update the shape properties of the Polybezier object.
Definition shape_polybezier.cpp:182
void SaveNormalPatchesSpherical(std::string const &file)
Save normal patches as a spherical mesh.
Definition shape_polybezier.cpp:304
Vec3d SupportPoint(Vec3d const &dir) override
Compute the support point of the Polybezier object in a given direction.
Definition shape_polybezier.cpp:378
void Init()
Initialize the Polybezier object.
Definition shape_polybezier.cpp:175
VecXT< VecXT< int > > linked_patches_list
Definition shape_polybezier.hpp:39
int num_patches
Definition shape_polybezier.hpp:24
void SaveNormalPatchesCubic(std::string const &file)
Save normal patches as a cubic mesh.
Definition shape_polybezier.cpp:332
STLModel GetSTLModel_v2(int num_nodes=200)
Generate an alternate version of the STL model for the Polybezier object.
Definition shape_polybezier.cpp:266
void InitFromJson(nlohmann::json const &js) override
Initialize the Polybezier object from a JSON structure.
Definition shape_polybezier.cpp:31
void Print() override
Print information about the Polybezier object.
Definition shape_polybezier.cpp:532
VecXT< Vec3i > linked_edges_list
Definition shape_polybezier.hpp:36
VecXT< VecXT< Vec3d > > edge_patch_knots_list
Definition shape_polybezier.hpp:33
VecXT< Vec3d > SupportPoints(Vec3d const &dir) override
Compute the support points of the Polybezier object in a given direction.
Definition shape_polybezier.cpp:418
VecXT< VecXT< Vec3d > > face_patch_knots_list
Definition shape_polybezier.hpp:27
void InitFromKernelSTL(std::string const &file)
Initialize the Polybezier object from a kernel STL model read from file.
nlohmann::json PackJson() override
Pack the Polybezier object into a JSON structure.
Definition shape_polybezier.cpp:21
int num_cells
Definition shape_polybezier.hpp:40
void SetSize(double d) override
Set the size of the Polybezier object.
Definition shape_polybezier.cpp:225
void InitByRandom()
Initialize the Polybezier object randomly.
Definition shape_polybezier.cpp:46
Class for working with STL models.
Definition stl_model.hpp:17
This class represents different types of shapes and performs various calculations on them.
Definition shape.hpp:15
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31
std::array< double, 3 > Vec3d
Definition utils_macros.hpp:18