Wildmeshing Toolkit
Loading...
Searching...
No Matches
CDT.cpp
Go to the documentation of this file.
1#include "CDT.hpp"
2
3#include <wmtk/Mesh.hpp>
4#include <wmtk/TetMesh.hpp>
5#include <wmtk/TriMesh.hpp>
6
7// #include <wmtk/components/multimesh_from_tag/internal/MultiMeshFromTag.hpp>
9
10#include "internal/CDT.hpp"
11// #include "internal/CDTOptions.hpp"
12
13namespace wmtk {
14namespace components {
15
16using namespace internal;
17
18std::shared_ptr<Mesh> CDT(const TriMesh& trimesh, const bool inner_only, const bool rational_output)
19{
20 constexpr static PrimitiveType PV = PrimitiveType::Vertex;
21 constexpr static PrimitiveType PE = PrimitiveType::Edge;
22 constexpr static PrimitiveType PF = PrimitiveType::Triangle;
24
25 std::vector<std::array<bool, 4>> local_f_on_input;
26
27 wmtk::logger().info("start CDT ...");
28
29 std::shared_ptr<TetMesh> tm =
30 CDT_internal(trimesh, local_f_on_input, inner_only, rational_output);
31
32 wmtk::logger().info("finished CDT");
33
34 // auto surface_handle = tm->register_attribute<int64_t>("surface", PrimitiveType::Triangle, 1);
35 // auto surface_accessor = tm->create_accessor<int64_t>(surface_handle);
36
37 // const auto& tets = tm->get_all(PrimitiveType::Tetrahedron);
38
39 // for (int64_t i = 0; i < tets.size(); ++i) {
40 // const auto& t = tets[i];
41 // std::array<Tuple, 4> fs = {
42 // {tm->Mesh::switch_tuples(t, {PV, PE, PF}),
43 // tm->Mesh::switch_tuples(t, {PE, PF}),
44 // t,
45 // tm->Mesh::switch_tuples(t, {PF})}};
46
47 // for (int64_t k = 0; k < 4; ++k) {
48 // if (local_f_on_input[i][k]) {
49 // surface_accessor.scalar_attribute(fs[k]) = 1;
50 // } else {
51 // surface_accessor.scalar_attribute(fs[k]) = 0;
52 // }
53 // }
54 // }
55
56 // std::shared_ptr<Mesh> surface_mesh;
57 // internal::MultiMeshFromTag mmft(*tm, surface_handle, 1);
58 // mmft.compute_substructure_mesh();
59 // surface_mesh = tm->get_child_meshes().back();
60 // mmft.remove_soup();
61
62 // wmtk::logger().info("registered surface child mesh to tetmesh {}", options.output);
63
64 // // propagate position to all child meshes
65 // auto pt_attribute = tm->get_attribute_handle<Rational>("vertices", PrimitiveType::Vertex);
66
67 // for (auto child : tm->get_child_meshes()) {
68 // auto child_position_handle = child->register_attribute<Rational>(
69 // "vertices",
70 // PrimitiveType::Vertex,
71 // tm->get_attribute_dimension(pt_attribute.as<Rational>()));
72
73 // auto propagate_to_child_position =
74 // [](const Eigen::MatrixX<Rational>& P) -> Eigen::VectorX<Rational> { return P; };
75 // auto update_child_positon =
76 // std::make_shared<wmtk::operations::SingleAttributeTransferStrategy<Rational,
77 // Rational>>(
78 // child_position_handle,
79 // pt_attribute,
80 // propagate_to_child_position);
81 // update_child_positon->run_on_all();
82 // }
83
84 return tm;
85}
86
87} // namespace components
88} // namespace wmtk
constexpr wmtk::PrimitiveType PT
constexpr wmtk::PrimitiveType PF
std::shared_ptr< wmtk::TetMesh > CDT_internal(const wmtk::TriMesh &m, std::vector< std::array< bool, 4 > > &local_f_on_input, bool inner_only, bool rational_output)
Definition CDT.cpp:18
std::shared_ptr< Mesh > CDT(const TriMesh &trimesh, const bool inner_only, const bool rational_output)
Definition CDT.cpp:18
constexpr PrimitiveType PE
spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:58
constexpr PrimitiveType PV