Commit 12bedcdf authored by fabianw's avatar fabianw
Browse files

added orphane vertex removal + degeneracy check for triangles

parent 0042eda5
......@@ -571,6 +571,10 @@ void IsoExtractor<Tkernel,Tinterpolator>::_extractIso(const Real isoval,
m_triMesh.merge(myMesh);
}
}
// remove orpahane vertives
m_triMesh.find_and_remove_orphanes_OMP();
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
if (verbose)
......
......@@ -82,6 +82,7 @@ public:
inline std::vector<VertMap> find_duplicates_OMP(const VertVec& vlist) const;
inline void offset_connectivity_remove_duplicates(const std::vector<VertMap>& vmap, const TIntegral offset=0);
inline void offset_connectivity_remove_duplicates_OMP(const std::vector<VertMap>& vmap, const TIntegral offset=0);
inline void find_and_remove_orphanes_OMP();
private:
......@@ -130,7 +131,9 @@ void Simplex2<TReal,TIntegral>::insert(const Triangle_t& tri)
m_vertices.push_back(p);
m_triangles.push_back(vertID);
}
#else
TIntegral vertID[3];
for (int i = 0; i < 3; ++i)
{
......@@ -144,7 +147,10 @@ void Simplex2<TReal,TIntegral>::insert(const Triangle_t& tri)
else
vertID[i] = std::distance(m_vertices.begin(), pi);
}
m_triangles.push_back(vertID);
// check that face is not degenerate
if (vertID[0] != vertID[1] && vertID[1] != vertID[2] && vertID[2] != vertID[0])
m_triangles.push_back(vertID);
#endif /* EXPERIMENTAL */
}
......@@ -317,5 +323,44 @@ void Simplex2<TReal,TIntegral>::offset_connectivity_remove_duplicates_OMP(const
}
}
template <typename TReal, typename TIntegral>
void Simplex2<TReal,TIntegral>::find_and_remove_orphanes_OMP()
{
std::vector<uint8_t> cnt(m_vertices.size(), 0);
#pragma omp parallel for
for (size_t i = 0; i < m_triangles.size(); ++i)
{
Connect_t& t = m_triangles[i];
++cnt[t.i0];
++cnt[t.i1];
++cnt[t.i2];
}
std::vector<TIntegral> rem;
for (size_t i = 0; i < cnt.size(); ++i)
{
if (!cnt[i])
rem.push_back(i);
}
std::cout << "Removing " << rem.size() << " vertices" << std::endl;
// remove orphane vertices
for (auto rm = rem.crbegin(); rm != rem.crend(); ++rm)
{
const TIntegral vertID = *rm;
m_vertices.erase(m_vertices.begin() + vertID);
#pragma omp parallel for
for (size_t i = 0; i < m_triangles.size(); ++i)
{
Connect_t& t = m_triangles[i];
if (t.i0 > vertID) --t.i0;
if (t.i1 > vertID) --t.i1;
if (t.i2 > vertID) --t.i2;
}
}
}
#endif /* SIMPLEX2_H_P2FLRWGO */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment