fix dimensions of vertices in internal c3t3

it may happen that the mesh output by Mesh_3 has vertices with dimension 2
incident to no surface patch (because the mesh is not dense enough to
provide a good approximation of the surface).
This "wrong" dimension setting may lead to bad behavior of tetrahedral remeshing
This commit is contained in:
Jane Tournois 2023-10-13 11:16:35 +02:00 committed by Jane Tournois
parent b83479ee14
commit b38b339002
2 changed files with 29 additions and 14 deletions

View File

@ -399,6 +399,11 @@ private:
//update number_of_cells and number_of_facets in c3t3
m_c3t3.rescan_after_load_of_triangulation();
#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
CGAL::Tetrahedral_remeshing::debug::dump_vertices_by_dimension(
m_c3t3.triangulation(), "00-c3t3_vertices_before_init_");
#endif
//tag cells
for (Cell_handle cit : tr().finite_cell_handles())
{
@ -414,16 +419,17 @@ private:
++nbc;
#endif
}
if (!input_is_c3t3())
for (int i = 0; i < 4; ++i)
{
for (int i = 0; i < 4; ++i)
{
if (cit->vertex(i)->in_dimension() == -1)
cit->vertex(i)->set_dimension(3);
}
Vertex_handle vi = cit->vertex(i);
if(dimension_is_modifiable(vi))
vi->set_dimension(3);
}
#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
else if (input_is_c3t3() && m_c3t3.is_in_complex(cit))
//else
if (input_is_c3t3() && m_c3t3.is_in_complex(cit))
++nbc;
#endif
}
@ -449,9 +455,10 @@ private:
for (int j = 0; j < 3; ++j)
{
Vertex_handle vij = f.first->vertex(Tr::vertex_triple_index(i, j));
if (vij->in_dimension() == -1 || vij->in_dimension() > 2)
if(dimension_is_modifiable(vij))
vij->set_dimension(2);
}
#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
++nbf;
#endif
@ -482,11 +489,11 @@ private:
m_c3t3.add_to_complex(e, 1);
Vertex_handle v = e.first->vertex(e.second);
if (v->in_dimension() == -1 || v->in_dimension() > 1)
if(dimension_is_modifiable(v))
v->set_dimension(1);
v = e.first->vertex(e.third);
if (v->in_dimension() == -1 || v->in_dimension() > 1)
if(dimension_is_modifiable(v))
v->set_dimension(1);
#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
@ -505,12 +512,10 @@ private:
if ( vit->in_dimension() == 0
|| nb_incident_complex_edges(vit, m_c3t3) > 2)
{
if(!m_c3t3.is_in_complex(vit))
if (!m_c3t3.is_in_complex(vit))
m_c3t3.add_to_complex(vit, ++corner_id);
if (vit->in_dimension() == -1 || vit->in_dimension() > 0)
vit->set_dimension(0);
vit->set_dimension(0);
vit->set_index(corner_id);
#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
@ -536,6 +541,14 @@ private:
}
private:
bool dimension_is_modifiable(const Vertex_handle& v) const
{
if (input_is_c3t3()) // feature edges and tip/endpoints vertices are kept
return v->in_dimension() != 1 && v->in_dimension() != 0;
else
return true;
}
bool check_vertex_dimensions()
{
for (Vertex_handle vit : tr().finite_vertex_handles())

View File

@ -530,6 +530,8 @@ void set_index(typename C3t3::Vertex_handle v, const C3t3& c3t3)
v->set_index(v->cell()->subdomain_index());
break;
case 2:
CGAL_assertion(surface_patch_index(v, c3t3)
!= typename C3t3::Surface_patch_index());
v->set_index(surface_patch_index(v, c3t3));
break;
case 1: