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 wmtk {
15{
16public:
17 virtual ~Envelope() = default;
18 virtual void init(
19 const std::vector<Eigen::Vector3d>& m_ver,
20 const std::vector<Eigen::Vector3i>& m_faces,
21 const double) {};
22 virtual bool is_outside(const std::array<Eigen::Vector3d, 3>& tris) const { return false; };
23 virtual bool is_outside(const Eigen::Vector3d& pts) const { return false; };
24};
25
26class ExactEnvelope : public Envelope, public fastEnvelope::FastEnvelope
27{
28public:
30 : fastEnvelope::FastEnvelope::FastEnvelope() {};
31 ~ExactEnvelope() {};
32 void init(
33 const std::vector<Eigen::Vector3d>& m_ver,
34 const std::vector<Eigen::Vector3i>& m_faces,
35 const double eps)
36 {
37 fastEnvelope::FastEnvelope::init(m_ver, m_faces, eps);
38 }
39 bool is_outside(const std::array<Eigen::Vector3d, 3>& tris) const
40 {
41 return fastEnvelope::FastEnvelope::is_outside(tris);
42 }
43 bool is_outside(const Eigen::Vector3d& pts) const
44 {
45 return fastEnvelope::FastEnvelope::is_outside(pts);
46 }
47};
48
49
51{
52public:
53 SampleEnvelope(bool exact = false)
54 : use_exact(exact) {};
55 double eps2 = 1e-6;
56 double sampling_dist = 1e-3;
57 bool use_exact = false;
58 void init(
59 const std::vector<Eigen::Vector3d>& m_ver,
60 const std::vector<Eigen::Vector3i>& m_faces,
61 const double);
62 void init(
63 const std::vector<Eigen::Vector3d>& m_ver,
64 const std::vector<Eigen::Vector2i>& m_edges,
65 const double);
66 void init(
67 const std::vector<Eigen::Vector2d>& m_ver,
68 const std::vector<Eigen::Vector2i>& m_edges,
69 const double);
70 bool is_outside(const std::array<Eigen::Vector3d, 3>& tris) const;
71 bool is_outside(const std::array<Eigen::Vector3d, 2>& edge) const;
72 bool is_outside(const std::array<Eigen::Vector2d, 2>& edge) const;
73 bool is_outside(const Eigen::Vector3d& pts) const;
74 bool is_outside(const Eigen::Vector2d& pts) const;
75 double nearest_point(const Eigen::Vector3d& pts, Eigen::Vector3d& result) const;
76 double nearest_point(const Eigen::Vector2d& pts, Eigen::Vector2d& result) const;
77 bool initialized() { return m_bvh != nullptr; };
78
79 double squared_distance(const Eigen::Vector3d& p) const;
80 double squared_distance(const Eigen::Vector2d& p) const;
81
82private:
83 std::vector<int> geo_vertex_ind;
84 std::vector<int> geo_face_ind;
85 std::shared_ptr<SimpleBVH::BVH> m_bvh;
86
87private:
88 fastEnvelope::FastEnvelope exact_envelope;
89};
90} // namespace wmtk
Definition Envelope.hpp:15
Definition Envelope.hpp:27
Definition Envelope.hpp:51