3#include <wmtk/io/ComponentIO.hpp>
6#include <wmtk/Types.hpp>
7#include <wmtk/envelope/Envelope.hpp>
8#include <wmtk/history/History.hpp>
9#include <wmtk/utils/Delaunay.hpp>
11namespace wmtk::components::simwild {
13using ImageData = std::vector<std::vector<std::vector<size_t>>>;
16using PositionKey = std::array<std::array<double, 3>, 3>;
18using FacetSources = std::vector<std::pair<PositionKey, std::vector<uint32_t>>>;
33void delaunay_box_mesh(
35 const MatrixXd& vertices,
36 std::vector<wmtk::delaunay::Point3D>& points,
37 std::vector<wmtk::delaunay::Tetrahedron>& tets,
62 const MatrixXd& V_surface,
63 const MatrixXi& F_surface,
64 const MatrixXd& V_vol,
65 const MatrixXi& T_vol,
68 MatrixXi& F_on_surface,
69 const bool perform_sanity_checks =
false,
70 const std::vector<size_t>& F_input = {},
71 std::vector<std::vector<size_t>>* F_on_surface_inputs =
nullptr,
72 std::vector<std::vector<int>>* F_on_surface_orientations =
nullptr,
73 FacetSources* facet_sources =
nullptr);
95 const std::vector<std::string>& img_filenames,
96 const std::vector<Matrix4d>& img_transform = {},
97 const double tol_rel = -1,
98 const double tol_abs = -1,
99 const bool split_connected_components =
false,
101 const bool record_history =
false);
124 const bool use_exact,
125 const int num_threads = 0,
126 const double boundary_eps = 0);
144 const bool flood_fill =
false,
146 const bool provenance =
false);
153 const MatrixXd& V_emb()
const {
return m_V_emb; }
154 const MatrixXr& V_emb_r()
const {
return m_V_emb_r; }
155 const MatrixXd& V_surface()
const {
return m_V_surface; }
156 const MatrixXi& T_emb()
const {
return m_T_emb; }
157 const MatrixSi& T_tags()
const {
return m_T_tags; }
158 const MatrixXi& F_on_surface()
const {
return m_F_on_surface; }
160 const std::vector<std::vector<size_t>>&
F_tags_surface()
const {
return m_F_tags_surface; }
165 return m_F_tags_surface_orientation;
167 const MatrixXi& F_surface()
const {
return m_F_surface; }
169 const std::vector<size_t>&
F_input()
const {
return m_F_input; }
172 bool m_record_history =
false;
174 FacetSources m_facet_sources;
192 void write_emb_msh(
const std::string& filename)
const;
193 void write_emb_vtu(
const std::string& filename)
const;
195 std::pair<Vector3d, Vector3d> bbox_minmax()
const;
196 std::pair<Vector3d, Vector3d> bbox_surf_minmax()
const;
198 std::vector<Eigen::Vector3d> V_surf_to_vector()
const;
199 std::vector<std::array<size_t, 3>> F_surf_to_vector()
const;
202 void V_surf_from_vector(
const std::vector<Eigen::Vector3d>& verts);
203 void F_surf_from_vector(
const std::vector<std::array<size_t, 3>>& tris);
235 std::vector<std::string> m_img_filenames;
236 std::vector<ImageData> m_img_datas;
239 MatrixXd m_V_surface;
240 MatrixXi m_F_surface;
243 std::vector<size_t> m_F_input;
247 std::vector<std::vector<size_t>> m_F_tags_surface;
249 std::vector<std::vector<int>> m_F_tags_surface_orientation;
251 std::vector<size_t> modified_nonmanifold_v;
258 MatrixXi m_F_on_surface;
261 std::vector<std::set<int64_t>> m_tags;
264 std::vector<MatrixXd> Vs;
265 std::vector<MatrixXi> Fs;
268 bool m_smooth_surface =
false;
269 bool m_perform_sanity_checks =
false;
270 int m_num_threads = 0;
Definition Envelope.hpp:19
Definition EmbedSurface.hpp:79
void consolidate()
Remove unreferenced vertices.
Definition EmbedSurface.cpp:946
void check_tag_surface_invariant(const std::string &how) const
Count where the tagging and the arrangement's surface disagree.
Definition EmbedSurface.cpp:1103
void tag_from_provenance()
Decide the cell tags from the arrangement's surface provenance.
Definition EmbedSurface.cpp:1154
FacetSources & facet_sources()
With record_history, once embedded: the input triangles each surface facet lies on.
Definition EmbedSurface.hpp:110
const std::vector< size_t > & F_input() const
Per row of F_surface(): the input it came from, SIZE_MAX for none.
Definition EmbedSurface.hpp:169
void write_emb_surf_off(const std::string &filename) const
Write embedded surface.
Definition EmbedSurface.cpp:998
const std::vector< std::vector< int > > & F_tags_surface_orientation() const
Definition EmbedSurface.hpp:163
void remove_duplicates(const double eps)
Merge vertices that are closer than eps.
Definition EmbedSurface.cpp:599
void write_surf_off(const std::string &filename) const
Write surface as read from image.
Definition EmbedSurface.cpp:993
void simplify_surface(const double eps, const bool use_exact, const int num_threads=0, const double boundary_eps=0)
Simplify the input surface while staying within the eps envelope.
Definition EmbedSurface.cpp:524
const history::SurfaceHistory & input_history() const
With record_history: the files as read, concatenated, then what became of them on the way to the arra...
Definition EmbedSurface.hpp:108
void tag_from_winding_number()
One binary tag column per input, set where that input's winding number at a tet barycenter is at leas...
Definition EmbedSurface.cpp:1282
const std::vector< std::vector< size_t > > & F_tags_surface() const
Per row of F_on_surface(): the inputs tiling it. Empty unless embed_surface recorded it.
Definition EmbedSurface.hpp:160
bool embed_surface(const bool flood_fill=false, const bool tag_from_winding_number=true, const bool provenance=false)
Run the arrangement and tag the resulting cells.
Definition EmbedSurface.cpp:615
Definition ComponentIO.hpp:15
A complex and the edits it went through, in commit order.
Definition History.hpp:101