uniform edge resampling: added option to force inter-sample distance to be less than the radius
This commit is contained in:
parent
757039f2b8
commit
35ed4897f6
|
@ -639,9 +639,10 @@ static void VertexUniform(MeshType & m, VertexSampler &ps, int sampleNum)
|
||||||
///
|
///
|
||||||
/// It assumes that the mesh is 1-manifold.
|
/// It assumes that the mesh is 1-manifold.
|
||||||
/// each connected component is sampled in a independent way.
|
/// each connected component is sampled in a independent way.
|
||||||
/// For each component of lenght <L> we place on it floor(L/radius) samples.
|
/// For each component of lenght <L> we place on it floor(L/radius)+1 samples.
|
||||||
|
/// (if conservative argument is false we place ceil(L/radius)+1 samples)
|
||||||
///
|
///
|
||||||
static void EdgeMeshUniform(MeshType &m, VertexSampler &ps, float radius)
|
static void EdgeMeshUniform(MeshType &m, VertexSampler &ps, float radius, bool conservative = true)
|
||||||
{
|
{
|
||||||
tri::RequireEEAdjacency(m);
|
tri::RequireEEAdjacency(m);
|
||||||
tri::RequireCompactness(m);
|
tri::RequireCompactness(m);
|
||||||
|
@ -696,7 +697,8 @@ static void EdgeMeshUniform(MeshType &m, VertexSampler &ps, float radius)
|
||||||
totalLen += Distance(ep.V()->cP(), ep.VFlip()->cP());
|
totalLen += Distance(ep.V()->cP(), ep.VFlip()->cP());
|
||||||
|
|
||||||
// Third loop actually perform the sampling.
|
// Third loop actually perform the sampling.
|
||||||
int sampleNum = floor(totalLen / radius);
|
int sampleNum = conservative ? floor(totalLen / radius) : ceil(totalLen / radius);
|
||||||
|
|
||||||
ScalarType sampleDist = totalLen / sampleNum;
|
ScalarType sampleDist = totalLen / sampleNum;
|
||||||
// printf("Found a chain of %f with %i samples every %f (%f)\n", totalLen, sampleNum, sampleDist, radius);
|
// printf("Found a chain of %f with %i samples every %f (%f)\n", totalLen, sampleNum, sampleDist, radius);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue