|
5 | 5 | #include <numeric> |
6 | 6 | #include <wmtk/utils/Logger.hpp> |
7 | 7 | namespace wmtk { |
8 | | - EdgeMesh::~EdgeMesh() = default; |
| 8 | +EdgeMesh::~EdgeMesh() = default; |
9 | 9 | EdgeMesh::EdgeMesh() |
10 | 10 | : MeshCRTP<EdgeMesh>(1) |
11 | 11 | , m_ve_handle(register_attribute_typed<int64_t>("m_ve", PrimitiveType::Vertex, 1, false, -1)) |
@@ -111,21 +111,21 @@ void EdgeMesh::initialize( |
111 | 111 | attribute::Accessor<int64_t> ee_accessor = create_accessor<int64_t>(m_ee_handle); |
112 | 112 | attribute::Accessor<int64_t> ve_accessor = create_accessor<int64_t>(m_ve_handle); |
113 | 113 |
|
114 | | - attribute::Accessor<char> v_flag_accessor = get_flag_accessor(PrimitiveType::Vertex); |
115 | | - attribute::Accessor<char> e_flag_accessor = get_flag_accessor(PrimitiveType::Edge); |
| 114 | + attribute::FlagAccessor<EdgeMesh> v_flag_accessor = get_flag_accessor(PrimitiveType::Vertex); |
| 115 | + attribute::FlagAccessor<EdgeMesh> e_flag_accessor = get_flag_accessor(PrimitiveType::Edge); |
116 | 116 |
|
117 | 117 | // iterate over the matrices and fill attributes |
118 | 118 |
|
119 | 119 | for (int64_t i = 0; i < capacity(PrimitiveType::Edge); ++i) { |
120 | 120 | ev_accessor.index_access().vector_attribute<2>(i) = EV.row(i).transpose(); |
121 | 121 | ee_accessor.index_access().vector_attribute<2>(i) = EE.row(i).transpose(); |
122 | 122 |
|
123 | | - e_flag_accessor.index_access().scalar_attribute(i) |= 0x1; |
| 123 | + e_flag_accessor.index_access().activate(i); |
124 | 124 | } |
125 | 125 | // m_ve |
126 | 126 | for (int64_t i = 0; i < capacity(PrimitiveType::Vertex); ++i) { |
127 | 127 | ve_accessor.index_access().scalar_attribute(i) = VE(i); |
128 | | - v_flag_accessor.index_access().scalar_attribute(i) |= 0x1; |
| 128 | + v_flag_accessor.index_access().activate(i); |
129 | 129 | } |
130 | 130 | } |
131 | 131 |
|
@@ -239,31 +239,38 @@ bool EdgeMesh::is_connectivity_valid() const |
239 | 239 | const attribute::Accessor<int64_t> ev_accessor = create_const_accessor<int64_t>(m_ev_handle); |
240 | 240 | const attribute::Accessor<int64_t> ee_accessor = create_const_accessor<int64_t>(m_ee_handle); |
241 | 241 | const attribute::Accessor<int64_t> ve_accessor = create_const_accessor<int64_t>(m_ve_handle); |
242 | | - const attribute::Accessor<char> v_flag_accessor = get_flag_accessor(PrimitiveType::Vertex); |
243 | | - const attribute::Accessor<char> e_flag_accessor = get_flag_accessor(PrimitiveType::Edge); |
| 242 | + const attribute::FlagAccessor<EdgeMesh> v_flag_accessor = |
| 243 | + get_flag_accessor(PrimitiveType::Vertex); |
| 244 | + const attribute::FlagAccessor<EdgeMesh> e_flag_accessor = |
| 245 | + get_flag_accessor(PrimitiveType::Edge); |
244 | 246 |
|
245 | 247 | // VE and EV |
246 | 248 | for (int64_t i = 0; i < capacity(PrimitiveType::Vertex); ++i) { |
247 | | - if (v_flag_accessor.index_access().const_scalar_attribute(i) == 0) { |
248 | | - wmtk::logger().debug("Vertex {} is deleted", i); |
| 249 | + if (!v_flag_accessor.index_access().is_active(i)) { |
249 | 250 | continue; |
250 | 251 | } |
251 | 252 | int cnt = 0; |
252 | 253 | for (int64_t j = 0; j < 2; ++j) { |
253 | 254 | if (ev_accessor.index_access().const_vector_attribute<2>( |
254 | | - ve_accessor.index_access().const_scalar_attribute(i))[j] == i) { |
| 255 | + ve_accessor.index_access().const_scalar_attribute(i))(j) == i) { |
255 | 256 | cnt++; |
256 | 257 | } |
257 | 258 | } |
258 | 259 | if (cnt == 0) { |
| 260 | + int64_t idx = ve_accessor.index_access().const_scalar_attribute(i); |
| 261 | + wmtk::logger().error( |
| 262 | + "EV[VE[{}]={},:]] ({}) = doesn't contain {}", |
| 263 | + i, |
| 264 | + idx, |
| 265 | + fmt::join(ev_accessor.index_access().const_vector_attribute<2>(idx), ","), |
| 266 | + i); |
259 | 267 | return false; |
260 | 268 | } |
261 | 269 | } |
262 | 270 |
|
263 | 271 | // EV and EE |
264 | 272 | for (int64_t i = 0; i < capacity(PrimitiveType::Edge); ++i) { |
265 | | - if (e_flag_accessor.index_access().const_scalar_attribute(i) == 0) { |
266 | | - wmtk::logger().debug("Edge {} is deleted", i); |
| 273 | + if (!e_flag_accessor.index_access().is_active(i)) { |
267 | 274 | continue; |
268 | 275 | } |
269 | 276 | // TODO: need to handle cornor case (self-loop) |
|
0 commit comments