mirror of https://github.com/CGAL/cgal
Factorize MC/TMC vertex interpolation functions
This commit is contained in:
parent
e843cefce0
commit
a9082f8575
|
|
@ -64,12 +64,13 @@ namespace internal {
|
|||
|
||||
// Interpolate linearly between two vertex locations v0, v1 with values d0 and d1 according to the isovalue
|
||||
template <typename GeomTraits>
|
||||
typename GeomTraits::Point_3 vertex_interpolation(const typename GeomTraits::Point_3& p0,
|
||||
const typename GeomTraits::Point_3& p1,
|
||||
const typename GeomTraits::FT d0,
|
||||
const typename GeomTraits::FT d1,
|
||||
const typename GeomTraits::FT isovalue,
|
||||
const GeomTraits& gt)
|
||||
std::pair<typename GeomTraits::Point_3, typename GeomTraits::FT>
|
||||
vertex_interpolation(const typename GeomTraits::Point_3& p0,
|
||||
const typename GeomTraits::Point_3& p1,
|
||||
const typename GeomTraits::FT d0,
|
||||
const typename GeomTraits::FT d1,
|
||||
const typename GeomTraits::FT isovalue,
|
||||
const GeomTraits& gt)
|
||||
{
|
||||
using FT = typename GeomTraits::FT;
|
||||
|
||||
|
|
@ -88,9 +89,9 @@ typename GeomTraits::Point_3 vertex_interpolation(const typename GeomTraits::Poi
|
|||
mu = std::clamp<FT>(mu, FT(0), FT(1));
|
||||
|
||||
// linear interpolation
|
||||
return point((FT(1) - mu) * x_coord(p0) + mu * x_coord(p1),
|
||||
(FT(1) - mu) * y_coord(p0) + mu * y_coord(p1),
|
||||
(FT(1) - mu) * z_coord(p0) + mu * z_coord(p1));
|
||||
return { point((FT(1) - mu) * x_coord(p0) + mu * x_coord(p1),
|
||||
(FT(1) - mu) * y_coord(p0) + mu * y_coord(p1),
|
||||
(FT(1) - mu) * z_coord(p0) + mu * z_coord(p1)), mu };
|
||||
}
|
||||
|
||||
// retrieves the values of a cell and return the lookup index
|
||||
|
|
@ -173,7 +174,7 @@ void MC_construct_vertices(const typename Domain::cell_descriptor& cell,
|
|||
|
||||
vertices[e_id] = vertex_interpolation(corners[v0], corners[v1],
|
||||
values[v0], values[v1],
|
||||
isovalue, domain.geom_traits());
|
||||
isovalue, domain.geom_traits()).first;
|
||||
}
|
||||
|
||||
flag <<= 1;
|
||||
|
|
|
|||
|
|
@ -399,18 +399,9 @@ private:
|
|||
unsigned int v0, v1;
|
||||
get_edge_vertex(eg, v0, v1, l_edges_);
|
||||
|
||||
// @todo use the domain's interpolation scheme?
|
||||
const FT den = values[v1] - values[v0];
|
||||
FT l = is_zero(den) ? FT(1) / FT(2) : (i0 - values[v0]) / den;
|
||||
l = std::clamp<FT>(l, FT(0), FT(1));
|
||||
|
||||
ecoord[eg] = l;
|
||||
|
||||
const FT px = (FT(1) - l) * x_coord(corners[v0]) + l * x_coord(corners[v1]);
|
||||
const FT py = (FT(1) - l) * y_coord(corners[v0]) + l * y_coord(corners[v1]);
|
||||
const FT pz = (FT(1) - l) * z_coord(corners[v0]) + l * z_coord(corners[v1]);
|
||||
|
||||
vertices[eg] = point(px, py, pz);
|
||||
std::tie(vertices[eg], ecoord[eg]) = vertex_interpolation(corners[v0], corners[v1],
|
||||
values[v0], values[v1],
|
||||
i0, m_domain.geom_traits());
|
||||
}
|
||||
|
||||
// next edge
|
||||
|
|
|
|||
Loading…
Reference in New Issue