Wildmeshing Toolkit
Loading...
Searching...
No Matches
Envelope.hpp
1#pragma once
2
3#include <Eigen/Core>
4#include <memory>
5
6// clang-format off
7#include <wmtk/utils/DisableWarnings.hpp>
8#include <fastenvelope/FastEnvelope.h>
9#include <SimpleBVH/BVH.hpp>
10#include <wmtk/utils/EnableWarnings.hpp>
11// clang-format on
12
13namespace GEO {
14class MeshFacetsAABBWithEps;
15class Mesh;
16} // namespace GEO
17
18namespace wmtk {
20{
21public:
22 virtual ~Envelope() = default;
23 virtual void init(
24 const std::vector<Eigen::Vector3d>& m_ver,
25 const std::vector<Eigen::Vector3i>& m_faces,
26 const double) {};
27 virtual bool is_outside(const std::array<Eigen::Vector3d, 3>& tris) const { return false; };
28 virtual bool is_outside(const Eigen::Vector3d& pts) const { return false; };
29};
30
31class ExactEnvelope : public Envelope, public fastEnvelope::FastEnvelope
32{
33public:
35 : fastEnvelope::FastEnvelope::FastEnvelope() {};
36 ~ExactEnvelope() {};
37 void init(
38 const std::vector<Eigen::Vector3d>& m_ver,
39 const std::vector<Eigen::Vector3i>& m_faces,
40 const double eps)
41 {
42 fastEnvelope::FastEnvelope::init(m_ver, m_faces, eps);
43 }
44 bool is_outside(const std::array<Eigen::Vector3d, 3>& tris) const
45 {
46 return fastEnvelope::FastEnvelope::is_outside(tris);
47 }
48 bool is_outside(const Eigen::Vector3d& pts) const
49 {
50 return fastEnvelope::FastEnvelope::is_outside(pts);
51 }
52};
53
54
56{
57public:
58 SampleEnvelope(bool exact = false)
59 : use_exact(exact) {};
60 double eps2 = 1e-6;
61 double sampling_dist = 1e-3;
62 bool use_exact = false;
63 void init(
64 const std::vector<Eigen::Vector3d>& m_ver,
65 const std::vector<Eigen::Vector3i>& m_faces,
66 const double);
67 void init(
68 const std::vector<Eigen::Vector3d>& m_ver,
69 const std::vector<Eigen::Vector2i>& m_edges,
70 const double);
71 bool is_outside(const std::array<Eigen::Vector3d, 3>& tris) const;
72 bool is_outside(const std::array<Eigen::Vector3d, 2>& edge) const;
73 bool is_outside(const Eigen::Vector3d& pts) const;
74 double nearest_point(const Eigen::Vector3d& pts, Eigen::Vector3d& result) const;
75 bool initialized() { return m_bvh != nullptr; };
76
77 double squared_distance(const Eigen::Vector3d& p) const;
78
79private:
80 std::vector<int> geo_vertex_ind;
81 std::vector<int> geo_face_ind;
82 std::shared_ptr<SimpleBVH::BVH> m_bvh;
83
84private:
85 fastEnvelope::FastEnvelope exact_envelope;
86};
87} // namespace wmtk
Definition Envelope.hpp:20
Definition Envelope.hpp:32
Definition Envelope.hpp:56