Skip to content

Commit 9e79246

Browse files
authored
Merge pull request #857 from wildmeshing/dzint/attribute_documentation
Attribute Documentation
2 parents 4392743 + db15518 commit 9e79246

35 files changed

+723
-497
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ endif()
1010
# Check required CMake version
1111
set(REQUIRED_CMAKE_VERSION "3.24.0")
1212

13+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0")
14+
message(WARNING "CMake version is ${CMAKE_VERSION}, setting stuff for dependencies.")
15+
SET(CMAKE_POLICY_VERSION_MINIMUM ${REQUIRED_CMAKE_VERSION})
16+
endif()
17+
1318
if(WILDMESHING_TOOLKIT_TOPLEVEL_PROJECT)
1419
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})
1520
else()

src/wmtk/EdgeMesh.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const
6666

6767
const attribute::Accessor<int64_t> ev_accessor =
6868
create_const_accessor<int64_t>(m_ev_handle);
69-
auto ev = ev_accessor.index_access().const_vector_attribute<2>(gcid_new);
69+
auto ev = ev_accessor.const_vector_attribute<2>(gcid_new);
7070

7171
for (int64_t i = 0; i < 2; ++i) {
7272
if (ev(i) == gvid) {
@@ -117,14 +117,14 @@ void EdgeMesh::initialize(
117117
// iterate over the matrices and fill attributes
118118

119119
for (int64_t i = 0; i < capacity(PrimitiveType::Edge); ++i) {
120-
ev_accessor.index_access().vector_attribute<2>(i) = EV.row(i).transpose();
121-
ee_accessor.index_access().vector_attribute<2>(i) = EE.row(i).transpose();
120+
ev_accessor.vector_attribute<2>(i) = EV.row(i).transpose();
121+
ee_accessor.vector_attribute<2>(i) = EE.row(i).transpose();
122122

123123
e_flag_accessor.index_access().activate(i);
124124
}
125125
// m_ve
126126
for (int64_t i = 0; i < capacity(PrimitiveType::Vertex); ++i) {
127-
ve_accessor.index_access().scalar_attribute(i) = VE(i);
127+
ve_accessor.scalar_attribute(i) = VE(i);
128128
v_flag_accessor.index_access().activate(i);
129129
}
130130
}
@@ -171,9 +171,9 @@ Tuple EdgeMesh::tuple_from_id(const PrimitiveType type, const int64_t gid) const
171171
Tuple EdgeMesh::vertex_tuple_from_id(int64_t id) const
172172
{
173173
const attribute::Accessor<int64_t> ve_accessor = create_const_accessor<int64_t>(m_ve_handle);
174-
auto e = ve_accessor.index_access().const_scalar_attribute(id);
174+
auto e = ve_accessor.const_scalar_attribute(id);
175175
const attribute::Accessor<int64_t> ev_accessor = create_const_accessor<int64_t>(m_ev_handle);
176-
auto ev = ev_accessor.index_access().const_vector_attribute<2>(e);
176+
auto ev = ev_accessor.const_vector_attribute<2>(e);
177177
for (int64_t i = 0; i < 2; ++i) {
178178
if (ev(i) == id) {
179179
Tuple v_tuple = Tuple(i, -1, -1, e);
@@ -196,7 +196,7 @@ Tuple EdgeMesh::edge_tuple_from_id(int64_t id) const
196196
Tuple EdgeMesh::tuple_from_global_ids(int64_t eid, int64_t vid) const
197197
{
198198
const attribute::Accessor<int64_t> ev_accessor = create_const_accessor<int64_t>(m_ev_handle);
199-
auto ev = ev_accessor.index_access().const_vector_attribute<2>(eid);
199+
auto ev = ev_accessor.const_vector_attribute<2>(eid);
200200

201201
int64_t lvid = -1;
202202

@@ -251,18 +251,18 @@ bool EdgeMesh::is_connectivity_valid() const
251251
}
252252
int cnt = 0;
253253
for (int64_t j = 0; j < 2; ++j) {
254-
if (ev_accessor.index_access().const_vector_attribute<2>(
255-
ve_accessor.index_access().const_scalar_attribute(i))(j) == i) {
254+
if (ev_accessor.const_vector_attribute<2>(
255+
ve_accessor.const_scalar_attribute(i))(j) == i) {
256256
cnt++;
257257
}
258258
}
259259
if (cnt == 0) {
260-
int64_t idx = ve_accessor.index_access().const_scalar_attribute(i);
260+
int64_t idx = ve_accessor.const_scalar_attribute(i);
261261
wmtk::logger().error(
262262
"EV[VE[{}]={},:]] ({}) = doesn't contain {}",
263263
i,
264264
idx,
265-
fmt::join(ev_accessor.index_access().const_vector_attribute<2>(idx), ","),
265+
fmt::join(ev_accessor.const_vector_attribute<2>(idx), ","),
266266
i);
267267
return false;
268268
}

src/wmtk/EdgeMeshOperationExecutor.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void EdgeMesh::EdgeMeshOperationExecutor::delete_simplices()
3838
{
3939
for (size_t d = 0; d < simplex_ids_to_delete.size(); ++d) {
4040
for (const int64_t id : simplex_ids_to_delete[d]) {
41-
flag_accessors[d].index_access().deactivate(id) ;
41+
flag_accessors[d].index_access().deactivate(id);
4242
}
4343
}
4444
}
@@ -106,8 +106,8 @@ Tuple EdgeMesh::EdgeMeshOperationExecutor::split_edge_single_mesh()
106106
if (m_mesh.is_free()) {
107107
} else {
108108
// for 2 new edges
109-
auto ee_new_0 = ee_accessor.index_access().vector_attribute(m_split_e[0]);
110-
auto ee_new_1 = ee_accessor.index_access().vector_attribute(m_split_e[1]);
109+
auto ee_new_0 = ee_accessor.vector_attribute(m_split_e[0]);
110+
auto ee_new_1 = ee_accessor.vector_attribute(m_split_e[1]);
111111
ee_new_0[local_vid ^ 1] = m_split_e[1];
112112
ee_new_1[local_vid] = m_split_e[0];
113113
if (m_is_self_loop) {
@@ -119,10 +119,8 @@ Tuple EdgeMesh::EdgeMeshOperationExecutor::split_edge_single_mesh()
119119
// for neighbor edges
120120
for (int64_t i = 0; i < 2; i++) {
121121
if (m_neighbor_eids[i] != -1) {
122-
auto ee_neighbor =
123-
ee_accessor.index_access().vector_attribute(m_neighbor_eids[i]);
124-
auto ev_neighbor =
125-
ev_accessor.index_access().vector_attribute(m_neighbor_eids[i]);
122+
auto ee_neighbor = ee_accessor.vector_attribute(m_neighbor_eids[i]);
123+
auto ev_neighbor = ev_accessor.vector_attribute(m_neighbor_eids[i]);
126124
for (int64_t j = 0; j < 2; j++) {
127125
if (ee_neighbor[j] == m_operating_edge_id &&
128126
ev_neighbor[j] == m_spine_vids[i]) {
@@ -138,8 +136,8 @@ Tuple EdgeMesh::EdgeMeshOperationExecutor::split_edge_single_mesh()
138136
// update ev
139137
{
140138
// for new edges
141-
auto ev_new_0 = ev_accessor.index_access().vector_attribute(m_split_e[0]);
142-
auto ev_new_1 = ev_accessor.index_access().vector_attribute(m_split_e[1]);
139+
auto ev_new_0 = ev_accessor.vector_attribute(m_split_e[0]);
140+
auto ev_new_1 = ev_accessor.vector_attribute(m_split_e[1]);
143141
ev_new_0[local_vid] = m_spine_vids[0];
144142
if (m_mesh.is_free()) {
145143
ev_new_0[local_vid ^ 1] = m_free_split_v[0];
@@ -155,15 +153,15 @@ Tuple EdgeMesh::EdgeMeshOperationExecutor::split_edge_single_mesh()
155153
{
156154
// for new vertex
157155
if (m_mesh.is_free()) {
158-
ve_accessor.index_access().scalar_attribute(m_free_split_v[0]) = m_split_e[0];
159-
ve_accessor.index_access().scalar_attribute(m_free_split_v[1]) = m_split_e[1];
156+
ve_accessor.scalar_attribute(m_free_split_v[0]) = m_split_e[0];
157+
ve_accessor.scalar_attribute(m_free_split_v[1]) = m_split_e[1];
160158
} else {
161-
ve_accessor.index_access().scalar_attribute(m_split_v) = m_split_e[0];
159+
ve_accessor.scalar_attribute(m_split_v) = m_split_e[0];
162160
}
163161

164162
// for spine vertices
165-
ve_accessor.index_access().scalar_attribute(m_spine_vids[0]) = m_split_e[0];
166-
ve_accessor.index_access().scalar_attribute(m_spine_vids[1]) = m_split_e[1];
163+
ve_accessor.scalar_attribute(m_spine_vids[0]) = m_split_e[0];
164+
ve_accessor.scalar_attribute(m_spine_vids[1]) = m_split_e[1];
167165
}
168166
delete_simplices();
169167

@@ -214,7 +212,7 @@ Tuple EdgeMesh::EdgeMeshOperationExecutor::collapse_edge_single_mesh()
214212
// for neighbor edges
215213
for (int64_t i = 0; i < 2; i++) {
216214
if (m_neighbor_eids[i] != -1) {
217-
auto ee_neighbor = ee_accessor.index_access().vector_attribute(m_neighbor_eids[i]);
215+
auto ee_neighbor = ee_accessor.vector_attribute(m_neighbor_eids[i]);
218216
for (int64_t j = 0; j < 2; j++) {
219217
if (ee_neighbor[j] == m_operating_edge_id) {
220218
ee_neighbor[j] = m_neighbor_eids[i ^ 1];
@@ -228,7 +226,7 @@ Tuple EdgeMesh::EdgeMeshOperationExecutor::collapse_edge_single_mesh()
228226
// update ev
229227
{
230228
if (m_neighbor_eids[0] != -1) {
231-
auto ev_neighbor = ev_accessor.index_access().vector_attribute(m_neighbor_eids[0]);
229+
auto ev_neighbor = ev_accessor.vector_attribute(m_neighbor_eids[0]);
232230
for (int64_t j = 0; j < 2; j++) {
233231
if (ev_neighbor[j] == m_spine_vids[0]) {
234232
ev_neighbor[j] = m_spine_vids[1];
@@ -240,7 +238,7 @@ Tuple EdgeMesh::EdgeMeshOperationExecutor::collapse_edge_single_mesh()
240238

241239
// update ve
242240
{
243-
ve_accessor.index_access().scalar_attribute(m_spine_vids[1]) =
241+
ve_accessor.scalar_attribute(m_spine_vids[1]) =
244242
(m_neighbor_eids[1] != -1) ? m_neighbor_eids[1] : m_neighbor_eids[0];
245243
}
246244

src/wmtk/Mesh.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,14 @@ bool Mesh::is_boundary(const simplex::Simplex& s) const
113113
bool Mesh::is_valid(const Tuple& tuple) const
114114
{
115115
const bool null = tuple.is_null();
116-
if(null) {
116+
if (null) {
117117
logger().trace("Tuple was null and therefore invalid");
118118
return false;
119-
} else if(is_removed(tuple)) {
119+
} else if (is_removed(tuple)) {
120120
logger().trace("Tuple was removed and therefore invalid");
121121
return false;
122122
}
123123
return true;
124-
125124
}
126125

127126
bool Mesh::is_removed(const Tuple& tuple) const
@@ -164,12 +163,6 @@ bool Mesh::is_valid(const simplex::Simplex& s) const
164163
#endif
165164
}
166165

167-
bool Mesh::validate_attributes() const
168-
{
169-
return m_attribute_manager.validate();
170-
}
171-
172-
173166
const attribute::FlagAccessor<Mesh> Mesh::get_flag_accessor(PrimitiveType type) const
174167
{
175168
return get_const_flag_accessor(type);

src/wmtk/Mesh.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,17 @@ class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::Merk
221221

222222

223223
template <typename T, int D = Eigen::Dynamic>
224-
attribute::Accessor<T, Mesh, attribute::CachingAttribute<T>, D> create_accessor(const attribute::MeshAttributeHandle& handle);
224+
attribute::Accessor<T, Mesh, attribute::CachingAttribute<T>, D> create_accessor(
225+
const attribute::MeshAttributeHandle& handle);
225226

226227

227228
template <typename T, int D = Eigen::Dynamic>
228229
const attribute::Accessor<T, Mesh, attribute::CachingAttribute<T>, D> create_const_accessor(
229230
const attribute::MeshAttributeHandle& handle) const;
230231

231232
template <typename T, int D = Eigen::Dynamic>
232-
attribute::Accessor<T, Mesh, attribute::CachingAttribute<T>, D> create_accessor(const TypedAttributeHandle<T>& handle);
233+
attribute::Accessor<T, Mesh, attribute::CachingAttribute<T>, D> create_accessor(
234+
const TypedAttributeHandle<T>& handle);
233235

234236
template <typename T, int D = Eigen::Dynamic>
235237
const attribute::Accessor<T, Mesh, attribute::CachingAttribute<T>, D> create_const_accessor(
@@ -443,8 +445,6 @@ class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::Merk
443445
*/
444446
bool is_valid(const simplex::Simplex& s) const;
445447

446-
bool validate_attributes() const;
447-
448448
template <typename T>
449449
bool validate_handle(const TypedAttributeHandle<T>& handle) const;
450450

@@ -810,12 +810,12 @@ class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::Merk
810810
template <typename T, typename MeshType>
811811
static auto& get_index_access(attribute::Accessor<T, MeshType>& attr)
812812
{
813-
return attr.index_access();
813+
return attr.attribute();
814814
}
815815
template <typename T, typename MeshType>
816816
static auto& get_index_access(const attribute::Accessor<T, MeshType>& attr)
817817
{
818-
return attr.index_access();
818+
return attr.attribute();
819819
}
820820

821821

0 commit comments

Comments
 (0)