Wildmeshing Toolkit
Loading...
Searching...
No Matches
EdgeCollapser.h
1// This file is part of TetWild, a software for generating tetrahedral meshes.
2//
3// Copyright (C) 2018 Yixin Hu <yixin.hu@nyu.edu>
4//
5// This Source Code Form is subject to the terms of the Mozilla Public License
6// v. 2.0. If a copy of the MPL was not distributed with this file, You can
7// obtain one at http://mozilla.org/MPL/2.0/.
8//
9// Created by Yixin Hu on 4/11/17.
10//
11
12#ifndef NEW_GTET_EDGECOLLAPSER_H
13#define NEW_GTET_EDGECOLLAPSER_H
14
15#include <queue>
16#include "LocalOperations.h"
17
18namespace wmtk::components::tetwild::orig {
19
21{
22public:
23 std::array<int, 2> v_ids;
24 double weight;
25
27 ElementInQueue_ec(const std::array<int, 2>& ids, double w)
28 : v_ids(ids)
29 , weight(w)
30 {}
31};
32
33struct cmp_ec
34{
35 bool operator()(const ElementInQueue_ec& e1, const ElementInQueue_ec& e2)
36 {
37 if (e1.weight == e2.weight) return e1.v_ids < e2.v_ids;
38 return e1.weight > e2.weight;
39 }
40};
41
43{
44public:
45 std::priority_queue<ElementInQueue_ec, std::vector<ElementInQueue_ec>, cmp_ec> ec_queue;
46 double ideal_weight = 0;
47
48 bool is_limit_length = true;
49 bool is_check_quality = true;
50
51 int envelop_accept_cnt = 0;
52 EdgeCollapser(LocalOperations& lo, double ideal_w)
53 : LocalOperations(lo)
54 , ideal_weight(ideal_w)
55 {}
56
57 void init();
58 void collapse();
59
60 const int SUCCESS = 0;
61 const int FLIP = 1;
62 const int QUALITY = 2;
63 const int ENVELOP = 3;
64 const int ENVELOP_SUC = 4;
65 int collapseAnEdge(int v1_id, int v2_id);
66
67 bool is_soft = false;
68 double soft_energy = 6;
69 int budget = 0;
70
71 int ts = 0;
72 std::vector<std::array<int, 2>> inf_es;
73 std::vector<int> inf_e_tss;
74 std::vector<int> tet_tss;
75 void postProcess();
76
77 bool isCollapsable_cd1(int v1_id, int v2_id);
78 // bool isCollapsable_cd2(int v1_id, int v2_id);//check if a vertex is outside the envelop
79 // bool isCollapsable_cd3(double weight);
80 bool isCollapsable_cd3(int v1_id, int v2_id, double weight);
81 bool isCollapsable_epsilon(int v1_id, int v2_id);
82
83 bool isEdgeValid(const std::array<int, 2>& e);
84 // void addNewEdge(const std::array<int, 2>& e);
85
86 int tmp = 0;
87 int tmp0 = 0;
88
89 double energy_time = 0;
90
91 // for timing
92 int id_postprocessing = 0;
93 int id_flip_fail = 1;
94 int id_env_fail = 2;
95 int id_success = 3;
96 int id_env_success = 4;
97 int id_energy_fail = 5;
98 std::array<double, 6> breakdown_timing;
99 std::array<std::string, 6> breakdown_name = {
100 {"Postprocessing",
101 "Failed (flip)",
102 "Failed (envelop)",
103 "Successful (non-surface)",
104 "Successful (surface)",
105 "Failed (energy)"}};
106 igl::Timer igl_timer;
107};
108
109} // namespace wmtk::components::tetwild::orig
110
111#endif // NEW_GTET_EDGECOLLAPSER_H
bool isCollapsable_cd3(int v1_id, int v2_id, double weight)
Definition EdgeCollapser.cpp:480
bool isCollapsable_epsilon(int v1_id, int v2_id)
Definition EdgeCollapser.cpp:495
bool isCollapsable_cd1(int v1_id, int v2_id)
Definition EdgeCollapser.cpp:458
Definition EdgeCollapser.h:34