additional parameter added to remesher

This commit is contained in:
Luigi Malomo 2017-07-31 15:01:22 +02:00
parent f0a2e655e3
commit fbd29ab314
3 changed files with 21 additions and 13 deletions

View File

@ -70,15 +70,15 @@ int main( int argc, char **argv )
}
tri::UpdateBounding<MyMesh>::Box(startMesh);
float samplingRadius = startMesh.bbox.Diag() * 0.01f;
float samplingRadius = startMesh.bbox.Diag() * 0.005f;
if (argc == 3)
{
try {
samplingRadius = stof(string(argv[2]));
} catch (exception &) {}
}
std::cout << "using sampling radius: " << samplingRadius << std::endl;
auto remeshed = Remesher<MyMesh>::Remesh(startMesh, samplingRadius, 75.0);
std::cout << "Remeshing using sampling radius: " << samplingRadius << std::endl;
auto remeshed = Remesher<MyMesh>::Remesh(startMesh, samplingRadius, 50.0, 0.0);
tri::io::ExporterPLY<MyMesh>::Save(*remeshed,"Full.ply",tri::io::Mask::IOM_VERTCOLOR|tri::io::Mask::IOM_WEDGTEXCOORD );

View File

@ -1224,7 +1224,7 @@ static int RestrictedVoronoiRelaxing(MeshType &m, std::vector<CoordType> &seedPo
area[fi->V(i)]+=a3;
}
assert(m.vn > (int)seedPosVec.size()*20);
// assert(m.vn > (int)seedPosVec.size()*20);
int i;
ScalarType perturb = m.bbox.Diag()*vpp.seedPerturbationAmount;
for(i=0;i<relaxStep;++i)

View File

@ -140,9 +140,10 @@ public:
/// \param original the mesh
/// \param samplingRadius is the sampling ragius for remeshing
/// \param borderCreaseAngleDeg is the angle treshold for preserving corner points on the mesh boundary
/// \param internalCreaseAngleDeg is the angle treshold for preserving creases on the mesh surface (if this value is < 0 it is set to borderCreaseAngleDeg)
/// \return the remeshed mesh
///
static inline MeshPtr Remesh(Mesh & original, const ScalarType samplingRadius, const ScalarType borderCreaseAngleDeg = 0.0)
static inline MeshPtr Remesh(Mesh & original, const ScalarType samplingRadius, const ScalarType borderCreaseAngleDeg = 0.0, const ScalarType internalCreaseAngleDeg = -1.0)
{
RequireFFAdjacency(original);
RequireVFAdjacency(original);
@ -157,12 +158,18 @@ public:
return nullptr;
}
const ScalarType borderAngleDeg = std::max(ScalarType(0), borderCreaseAngleDeg);
const ScalarType creaseAngleDeg = internalCreaseAngleDeg < 0 ? borderAngleDeg : internalCreaseAngleDeg;
// split on creases
CreaseCut<Mesh>(original, vcg::math::ToRad(borderCreaseAngleDeg));
Allocator<Mesh>::CompactEveryVector(original);
UpdateTopology<Mesh>::FaceFace(original);
UpdateFlags<Mesh>::FaceBorderFromFF(original);
UpdateFlags<Mesh>::VertexBorderFromFaceAdj(original);
if (creaseAngleDeg > 0)
{
CreaseCut<Mesh>(original, vcg::math::ToRad(creaseAngleDeg));
Allocator<Mesh>::CompactEveryVector(original);
UpdateTopology<Mesh>::FaceFace(original);
UpdateFlags<Mesh>::FaceBorderFromFF(original);
UpdateFlags<Mesh>::VertexBorderFromFaceAdj(original);
}
// Mark the non manifold border vertices as visited on the input mesh
// TODO maybe optimize this
@ -218,7 +225,7 @@ public:
std::vector<MeshPtr> ccs = splitCC(original);
if (ccs.empty())
{
return RemeshOneCC(original, samplingRadius, borderCreaseAngleDeg);
return RemeshOneCC(original, samplingRadius, borderAngleDeg);
}
// Multiple CCs
@ -226,7 +233,7 @@ public:
for (size_t i=0; i<ccs.size(); i++)
{
// std::cout << "Remeshing component " << (i+1) << "/" << ccs.size() << std::endl;
ccs[i] = RemeshOneCC(*ccs[i], samplingRadius, borderCreaseAngleDeg, i);
ccs[i] = RemeshOneCC(*ccs[i], samplingRadius, borderAngleDeg, i);
}
MeshPtr ret = std::make_shared<Mesh>();
@ -238,6 +245,8 @@ public:
return ret;
}
protected:
///
/// \brief RemeshOneCC the function that remeshes a single connected component mesh preserving its boundary (consistently for eventually adjacent meshes).
/// \param original the mesh
@ -448,7 +457,6 @@ public:
return finalMeshPtr;
}
protected:
static inline void ExtractMeshBorders(Mesh & mesh, EdgeMeshType & sides)
{
RequireFFAdjacency(mesh);