mirror of https://github.com/CGAL/cgal
propagate the use of sizing field to subfunctions of remeshing
This commit is contained in:
parent
2462524af2
commit
cae6377e25
|
|
@ -1181,10 +1181,12 @@ bool can_be_collapsed(const typename C3T3::Edge& e,
|
|||
}
|
||||
}
|
||||
|
||||
template<typename C3T3, typename CellSelector, typename Visitor>
|
||||
template<typename C3T3,
|
||||
typename Sizing,
|
||||
typename CellSelector,
|
||||
typename Visitor>
|
||||
void collapse_short_edges(C3T3& c3t3,
|
||||
const typename C3T3::Triangulation::Geom_traits::FT& low,
|
||||
const typename C3T3::Triangulation::Geom_traits::FT& high,
|
||||
const Sizing& sizing,
|
||||
const bool protect_boundaries,
|
||||
CellSelector cell_selector,
|
||||
Visitor& visitor)
|
||||
|
|
@ -1206,13 +1208,17 @@ void collapse_short_edges(C3T3& c3t3,
|
|||
typename Gt::Compute_squared_length_3 sql
|
||||
= tr.geom_traits().compute_squared_length_3_object();
|
||||
|
||||
const FT target_edge_length = sizing(CGAL::ORIGIN, 0, 0);
|
||||
const FT low = FT(4) / FT(5) * target_edge_length;
|
||||
const FT high = FT(4) / FT(3) * target_edge_length;
|
||||
const FT sq_low = low*low;
|
||||
const FT sq_high = high*high;
|
||||
|
||||
#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE
|
||||
std::cout << "Collapse short edges (" << low << ", " << high << ")...";
|
||||
std::cout.flush();
|
||||
std::size_t nb_collapses = 0;
|
||||
#endif
|
||||
const FT sq_low = low*low;
|
||||
const FT sq_high = high*high;
|
||||
|
||||
//collect long edges
|
||||
Boost_bimap short_edges;
|
||||
|
|
|
|||
|
|
@ -234,9 +234,12 @@ bool can_be_split(const typename C3T3::Edge& e,
|
|||
}
|
||||
}
|
||||
|
||||
template<typename C3T3, typename CellSelector, typename Visitor>
|
||||
template<typename C3T3,
|
||||
typename Sizing,
|
||||
typename CellSelector,
|
||||
typename Visitor>
|
||||
void split_long_edges(C3T3& c3t3,
|
||||
const typename C3T3::Triangulation::Geom_traits::FT& high,
|
||||
const Sizing& sizing,
|
||||
const bool protect_boundaries,
|
||||
CellSelector cell_selector,
|
||||
Visitor& visitor)
|
||||
|
|
@ -254,6 +257,9 @@ void split_long_edges(C3T3& c3t3,
|
|||
boost::bimaps::multiset_of<FT, std::greater<FT> > > Boost_bimap;
|
||||
typedef typename Boost_bimap::value_type long_edge;
|
||||
|
||||
const FT target_edge_length = sizing(CGAL::ORIGIN, 0, 0);
|
||||
const FT high = FT(4) / FT(3) * target_edge_length;
|
||||
|
||||
#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE
|
||||
std::cout << "Split long edges (" << high << ")...";
|
||||
std::cout.flush();
|
||||
|
|
|
|||
|
|
@ -174,13 +174,40 @@ public:
|
|||
return m_c3t3_pbackup != NULL;
|
||||
}
|
||||
|
||||
bool is_too_long(const Edge& e) const
|
||||
{
|
||||
const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0);
|
||||
const FT emax = FT(4)/FT(3) * target_edge_length;
|
||||
return tr().segment(e).squared_length() > CGAL::square(emax * emax);
|
||||
}
|
||||
|
||||
bool is_too_short(const Edge& e) const
|
||||
{
|
||||
const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0);
|
||||
const FT emin = FT(4)/FT(5) * target_edge_length;
|
||||
return tr().segment(e).squared_length() < CGAL::square(emin * emin);
|
||||
}
|
||||
|
||||
bool is_too_long_or_too_short(const Edge& e) const
|
||||
{
|
||||
const FT sqlen = tr().segment(e).squared_length();
|
||||
|
||||
const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0);
|
||||
const FT sq_emax = CGAL::square(FT(4)/FT(3) * target_edge_length);
|
||||
if(sqlen > sq_emax)
|
||||
return true;
|
||||
|
||||
const FT sq_emin = CGAL::square(FT(4)/FT(5) * target_edge_length);
|
||||
if (sqlen < sq_emin)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void split()
|
||||
{
|
||||
CGAL_assertion(check_vertex_dimensions());
|
||||
|
||||
const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0);
|
||||
const FT emax = FT(4)/FT(3) * target_edge_length;
|
||||
split_long_edges(m_c3t3, emax, m_protect_boundaries,
|
||||
split_long_edges(m_c3t3, m_sizing, m_protect_boundaries,
|
||||
m_cell_selector, m_visitor);
|
||||
|
||||
#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
|
||||
|
|
@ -200,11 +227,7 @@ public:
|
|||
void collapse()
|
||||
{
|
||||
CGAL_assertion(check_vertex_dimensions());
|
||||
|
||||
const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0);
|
||||
FT emin = FT(4)/FT(5) * target_edge_length;
|
||||
FT emax = FT(4)/FT(3) * target_edge_length;
|
||||
collapse_short_edges(m_c3t3, emin, emax, m_protect_boundaries,
|
||||
collapse_short_edges(m_c3t3, m_sizing, m_protect_boundaries,
|
||||
m_cell_selector, m_visitor);
|
||||
|
||||
#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
|
||||
|
|
@ -254,14 +277,6 @@ public:
|
|||
|
||||
bool resolution_reached()
|
||||
{
|
||||
const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0);
|
||||
|
||||
FT emax = FT(4) / FT(3) * target_edge_length;
|
||||
FT emin = FT(4) / FT(5) * target_edge_length;
|
||||
|
||||
FT sqmax = emax * emax;
|
||||
FT sqmin = emin * emin;
|
||||
|
||||
for (const Edge& e : tr().finite_edges())
|
||||
{
|
||||
// skip protected edges
|
||||
|
|
@ -272,11 +287,13 @@ public:
|
|||
continue;
|
||||
}
|
||||
|
||||
FT sqlen = tr().segment(e).squared_length();
|
||||
if (sqlen < sqmin || sqlen > sqmax)
|
||||
if(is_too_long_or_too_short(e))
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE
|
||||
std::cout << "Resolution reached" << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -168,10 +168,12 @@ void tetrahedral_isotropic_remeshing(
|
|||
const NamedParameters& np = parameters::default_values())
|
||||
{
|
||||
typedef CGAL::Triangulation_3<Traits, TDS, SLDS> Triangulation;
|
||||
typedef typename TDS::Vertex::Index Index;
|
||||
tetrahedral_isotropic_remeshing(
|
||||
tr,
|
||||
[target_edge_length](const typename Triangulation::Point& /* p */)
|
||||
{return target_edge_length;},
|
||||
[target_edge_length]
|
||||
(const typename Triangulation::Point& /* p */, const Index&, const int&)
|
||||
{return target_edge_length; },
|
||||
np);
|
||||
}
|
||||
|
||||
|
|
@ -183,10 +185,12 @@ void tetrahedral_isotropic_remeshing(
|
|||
const NamedParameters& np = parameters::default_values())
|
||||
{
|
||||
typedef CGAL::Triangulation_3<Traits, TDS, SLDS> Triangulation;
|
||||
typedef typename TDS::Vertex::Index Index;
|
||||
tetrahedral_isotropic_remeshing(
|
||||
tr,
|
||||
[target_edge_length](const typename Triangulation::Point& /* p */)
|
||||
{return target_edge_length; },
|
||||
[target_edge_length]
|
||||
(const typename Triangulation::Point& /* p */, const Index&, const int&)
|
||||
{return target_edge_length;},
|
||||
np);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue