Skip to content

Commit 1abb2a7

Browse files
committed
geometry
1 parent afdb8be commit 1abb2a7

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

src/geometry/core/check.h

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,42 @@ void check_facet_dimension(
7878
}
7979
}
8080

81+
template <std::size_t N>
82+
void check_facets_without_boundary(
83+
const std::string_view name,
84+
const std::unordered_map<std::array<int, N>, int, RidgeHash>& ridge_facet_count)
85+
{
86+
for (const auto& [ridge, count] : ridge_facet_count)
87+
{
88+
if (count != 2)
89+
{
90+
error(std::string(name) + " ridge facet count " + to_string(count) + " is not equal to 2");
91+
}
92+
}
93+
}
94+
95+
template <std::size_t N>
96+
void check_facets_with_boundary(
97+
const std::string_view name,
98+
const std::unordered_map<std::array<int, N>, int, RidgeHash>& ridge_facet_count)
99+
{
100+
for (const auto& [ridge, count] : ridge_facet_count)
101+
{
102+
if (count > 2)
103+
{
104+
error(std::string(name) + " ridge facet count " + to_string(count) + " is greater than 2");
105+
}
106+
}
107+
}
108+
81109
template <std::size_t N>
82110
void check_manifoldness(
83111
const std::string_view name,
84112
const std::vector<std::array<int, N>>& facets,
85113
const bool has_boundary)
86114
{
87115
std::unordered_map<std::array<int, N - 1>, int, RidgeHash> ridges;
116+
88117
for (const std::array<int, N>& facet : facets)
89118
{
90119
for (std::size_t r = 0; r < N; ++r)
@@ -96,24 +125,11 @@ void check_manifoldness(
96125

97126
if (!has_boundary)
98127
{
99-
for (const auto& [ridge, count] : ridges)
100-
{
101-
if (count != 2)
102-
{
103-
error(std::string(name) + " ridge facet count " + to_string(count)
104-
+ " is not equal to 2");
105-
}
106-
}
128+
check_facets_without_boundary(name, ridges);
107129
return;
108130
}
109131

110-
for (const auto& [ridge, count] : ridges)
111-
{
112-
if (count > 2)
113-
{
114-
error(std::string(name) + " ridge facet count " + to_string(count) + " is greater than 2");
115-
}
116-
}
132+
check_facets_with_boundary(name, ridges);
117133
}
118134

119135
template <std::size_t N>

0 commit comments

Comments
 (0)