NetDEM v1.0
Loading...
Searching...
No Matches
sdf_calculator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "stl_model.hpp"
4#include "utils_math.hpp"
5#include <Eigen/Dense>
6#include <igl/signed_distance.h>
7
8namespace netdem {
9
21public:
29
40 void InitFromSTL(const VecXT<Vec3d> &vv, const VecXT<Vec3i> &ff);
41
51 void InitFromSTL(STLModel const &stl_model);
52
61 void Init();
62
73 double SignedDistance(Vec3d const &pos) const;
74
84 Vec3d SurfacePoint(Vec3d const &pos) const;
85
94 int ClosestFacet(Vec3d const &pos) const;
95
96private:
97 double max_distance{0.0};
98
99 Eigen::MatrixXd vertices;
100 Eigen::MatrixXi facets;
101
102 Eigen::MatrixXi T;
103
104 // AABB tree used to accelerate SDF computation.
105 igl::AABB<Eigen::MatrixXd, 3> tree;
106
107 Eigen::MatrixXd FN, VN, EN;
109 Eigen::MatrixXi E;
110 Eigen::VectorXi EMAP;
111};
112
113} // namespace netdem
Class for computing signed distance fields from triangle meshes.
Definition sdf_calculator.hpp:20
Vec3d SurfacePoint(Vec3d const &pos) const
Find the surface point on the mesh closest to a given point.
Definition sdf_calculator.cpp:250
int ClosestFacet(Vec3d const &pos) const
Find the closest facet on the mesh to a given point.
Definition sdf_calculator.cpp:271
SDFCalculator()
Default constructor.
Definition sdf_calculator.cpp:194
void InitFromSTL(const VecXT< Vec3d > &vv, const VecXT< Vec3i > &ff)
Initialize from a set of vertices and faces.
Definition sdf_calculator.cpp:196
double SignedDistance(Vec3d const &pos) const
Compute the signed distance at a point in space.
Definition sdf_calculator.cpp:229
void Init()
Initialize the SDFCalculator.
Definition sdf_calculator.cpp:208
Class for working with STL models.
Definition stl_model.hpp:17
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