30 const attribute::MeshAttributeHandle& attribute,
33 :
m_accessor(m.create_accessor<int64_t>(attribute))
44 const std::vector<attribute::MeshAttributeHandle>& label_attributes,
46 const std::vector<attribute::MeshAttributeHandle>& pass_through_attributes)
48 , m_label_attributes(label_attributes)
50 , m_pass_through_attributes(pass_through_attributes)
55 using namespace operations;
57 std::vector<attribute::MeshAttributeHandle> todo_handles;
61 todo_handles.emplace_back(todo_handle);
64 std::deque<TagAttribute> tag_attributes;
66 tag_attributes.emplace_back(
74 for (
size_t i = 0; i < tag_attributes.size(); ++i) {
78 "the top simplex type up to vertex.");
84 for (
size_t attr_it = 0; attr_it < tag_attributes.size() - 1; ++attr_it) {
87 if (ta.m_accessor.const_scalar_attribute(t) != ta.m_val) {
105 if (!generate_simplicial_embedding) {
111 const auto pos_handle =
117 logger().error(
"Mesh is not inversion free BEFORE simplicial embedding!");
123 for (
size_t attr_it = 0; attr_it < tag_attributes.size() - 1;) {
129 int64_t count_todos = 0;
131 if (ta.m_accessor.const_scalar_attribute(t) == ta.m_val) {
142 const TagAttribute& face_ta = tag_attributes[attr_it + 1];
144 bool all_faces_are_tagged =
true;
147 if (face_ta.m_accessor.const_scalar_attribute(f) != face_ta.m_val) {
148 all_faces_are_tagged =
false;
153 if (all_faces_are_tagged) {
154 todo_acc.scalar_attribute(t) = 1;
161 int64_t count_done = 0;
162 switch (ta.m_ptype) {
173 SplitBasicStrategy::None,
174 SplitRibBasicStrategy::None);
180 SplitBasicStrategy::Copy,
181 SplitRibBasicStrategy::None);
188 logger().info(
"split {} edges", count_todos);
192 if (stats.number_of_successful_operations() == 0) {
209 SplitBasicStrategy::None,
210 SplitRibBasicStrategy::None);
217 SplitBasicStrategy::Copy,
218 SplitRibBasicStrategy::None);
226 CollapseBasicStrategy::None);
230 logger().info(
"split {} faces", count_todos);
234 if (stats.number_of_successful_operations() == 0) {
251 SplitBasicStrategy::None,
252 SplitRibBasicStrategy::None);
259 SplitBasicStrategy::Copy,
260 SplitRibBasicStrategy::None);
268 CollapseBasicStrategy::None);
271 logger().info(
"split {} tetrahedra", count_todos);
275 if (stats.number_of_successful_operations() == 0) {
285 if (count_done == count_todos) {
289 "{} remain. Regularize same primitive type once more.",
290 count_todos - count_done);
296 const auto pos_handle =
304 logger().error(
"Mesh is not inversion free after simplicial embedding!");
attribute::MeshAttributeHandle register_attribute(const std::string &name, PrimitiveType type, int64_t size, bool replace=false, T default_value=T(0))
attribute::MeshAttributeHandle get_attribute_handle(const std::string &name, const PrimitiveType ptype) const
std::vector< Tuple > get_all(PrimitiveType type) const
Generate a vector of Tuples from global vertex/edge/triangle/tetrahedron index.
bool has_attribute(const std::string &name, const PrimitiveType ptype) const
int64_t top_cell_dimension() const
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
PrimitiveType top_simplex_type() const
SchedulerStats run_operation_on_all(operations::Operation &op)
int64_t number_of_successful_operations() const
Returns the number of successful operations performed by the scheduler.
bool after(const std::vector< Tuple > &, const std::vector< Tuple > &top_dimension_tuples_after) const override
we assume with local vid order (v0,v1,v2,v3) has positive volume (orient3d(v0,v1,v2,...
T & scalar_attribute(const ArgType &t)
SimplicialEmbedding(Mesh &mesh, const std::vector< attribute::MeshAttributeHandle > &label_attributes, const int64_t &value, const std::vector< attribute::MeshAttributeHandle > &pass_through_attributes)
std::vector< attribute::MeshAttributeHandle > m_pass_through_attributes
void regularize_tags(bool generate_simplicial_embedding=true)
Regularize tags in mesh.
std::vector< attribute::MeshAttributeHandle > m_label_attributes
wmtk::attribute::Accessor< int64_t > m_accessor
TagAttribute(Mesh &m, const attribute::MeshAttributeHandle &attribute, PrimitiveType ptype, int64_t val)
void set_new_attribute_strategy(const attribute::MeshAttributeHandle &attribute, const std::shared_ptr< const operations::BaseCollapseNewAttributeStrategy > &other)
void set_new_attribute_strategy(const attribute::MeshAttributeHandle &attribute, const std::shared_ptr< const operations::BaseSplitNewAttributeStrategy > &other)
void add_invariant(std::shared_ptr< Invariant > invariant)
EdgeCollapse & collapse()
The return tuple is the new vertex, pointing to the original vertex.
EdgeCollapse & collapse()
std::vector< Tuple > faces_single_dimension_tuples(const Mesh &mesh, const Simplex &simplex, const PrimitiveType face_type)
SimplexCollection faces(const Mesh &mesh, const Simplex &simplex, const bool sort_and_clean)
Returns all faces of a simplex.
constexpr PrimitiveType get_primitive_type_from_id(int8_t id)
Get the primitive type corresponding to its unique integer id.
void log_and_throw_error(const std::string &msg)
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.
spdlog::logger & logger()
Retrieves the current logger.