NetDEM v1.0
Loading...
Searching...
No Matches
shape_level_set.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "igl_wrapper.hpp"
5#include "sdf_calculator.hpp"
6#include "shape.hpp"
7#include "stl_model.hpp"
8#include "stl_reader.hpp"
9#include <iostream>
10#include <string>
11
12namespace netdem {
13
25class LevelSet : public LevelSetFunction, public Shape {
26public:
30 LevelSet();
31
40 nlohmann::json PackJson() override;
41
50 void InitFromJson(nlohmann::json const &js) override;
51
62 void InitFromSTL(std::string const &file, int mesh_res = 40);
63
74 void InitFromSTL(STLModel const &stl_model, int mesh_res = 40);
75
91 void InitFromDistanceMap(double c_0, double c_1, double c_2, double sp,
92 const VecXT<VecXT<VecXT<double>>> &dist_map);
93
100 void Init();
101
108 void AlignAxes();
109
116 void UpdateSurfaceNodes() override;
117
124 void UpdateShapeProperties() override;
125
134 void SetSize(double d) override;
135
143 Shape *Clone() const override;
144
155 STLModel GetSTLModel(int num_nodes = 200) override;
156
168 double SignedDistance(Vec3d const &pos) const override;
169
183 Vec3d SurfacePoint(Vec3d const &pos) override;
184
191 void Print() override;
192};
193
194} // namespace netdem
Class for representing a level set function on a regular grid.
Definition level_set_function.hpp:17
A class for representing a level set function as a Shape object.
Definition shape_level_set.hpp:25
nlohmann::json PackJson() override
Pack the LevelSet object into a JSON structure.
Definition shape_level_set.cpp:13
void Init()
Initialize the LevelSet object.
Definition shape_level_set.cpp:124
void InitFromSTL(std::string const &file, int mesh_res=40)
Initialize the LevelSet object from an STL file.
Vec3d SurfacePoint(Vec3d const &pos) override
Compute the surface point closest to a given position on the LevelSet object.
Definition shape_level_set.cpp:255
void SetSize(double d) override
Set the size of the LevelSet object.
Definition shape_level_set.cpp:218
void InitFromJson(nlohmann::json const &js) override
Initialize the LevelSet object from a JSON structure.
Definition shape_level_set.cpp:25
void UpdateShapeProperties() override
Update the shape properties of the LevelSet object.
Definition shape_level_set.cpp:172
Shape * Clone() const override
Clone the LevelSet object.
Definition shape_level_set.cpp:238
STLModel GetSTLModel(int num_nodes=200) override
Generate an STL model of the LevelSet object.
Definition shape_level_set.cpp:240
void InitFromDistanceMap(double c_0, double c_1, double c_2, double sp, const VecXT< VecXT< VecXT< double > > > &dist_map)
Initialize the LevelSet object from a distance map.
Definition shape_level_set.cpp:101
double SignedDistance(Vec3d const &pos) const override
Compute the signed distance from a given position to the surface of the LevelSet object.
Definition shape_level_set.cpp:251
void UpdateSurfaceNodes() override
Update the surface nodes of the LevelSet object.
Definition shape_level_set.cpp:149
LevelSet()
Default constructor.
Definition shape_level_set.cpp:8
void AlignAxes()
Align the axes of the LevelSet object.
Definition shape_level_set.cpp:135
void Print() override
Print information about the LevelSet object.
Definition shape_level_set.cpp:321
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
pos
Definition json_serilization.hpp:19
std::array< double, 3 > Vec3d
Definition utils_macros.hpp:18