improvements to smoothing step
This commit is contained in:
parent
9af4312450
commit
3a15e94e95
|
|
@ -176,7 +176,6 @@ public:
|
||||||
|
|
||||||
if(cb) cb(100*i/params.iter, "Remeshing");
|
if(cb) cb(100*i/params.iter, "Remeshing");
|
||||||
|
|
||||||
// debug_crease(toRemesh, std::string("pre_ref"), i);
|
|
||||||
if(params.splitFlag)
|
if(params.splitFlag)
|
||||||
SplitLongEdges(toRemesh, params);
|
SplitLongEdges(toRemesh, params);
|
||||||
#ifdef DEBUG_CREASE
|
#ifdef DEBUG_CREASE
|
||||||
|
|
@ -187,7 +186,6 @@ public:
|
||||||
{
|
{
|
||||||
CollapseShortEdges(toRemesh, params);
|
CollapseShortEdges(toRemesh, params);
|
||||||
CollapseCrosses(toRemesh, params);
|
CollapseCrosses(toRemesh, params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(params.swapFlag)
|
if(params.swapFlag)
|
||||||
|
|
@ -1055,13 +1053,12 @@ private:
|
||||||
//and feature preservations tests.
|
//and feature preservations tests.
|
||||||
static void CollapseCrosses(MeshType &m , Params ¶ms)
|
static void CollapseCrosses(MeshType &m , Params ¶ms)
|
||||||
{
|
{
|
||||||
tri::UpdateTopology<MeshType>::ClearFaceFace(m);
|
|
||||||
tri::UpdateTopology<MeshType>::VertexFace(m);
|
tri::UpdateTopology<MeshType>::VertexFace(m);
|
||||||
tri::UpdateFlags<MeshType>::VertexBorderFromNone(m);
|
tri::UpdateFlags<MeshType>::VertexBorderFromNone(m);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for(auto fi=m.face.begin(); fi!=m.face.end(); ++fi)
|
for(auto fi=m.face.begin(); fi!=m.face.end(); ++fi)
|
||||||
if(!(*fi).IsD() && (params.selectedOnly == false || fi->IsS()))
|
if(!(*fi).IsD() && (!params.selectedOnly || fi->IsS()))
|
||||||
{
|
{
|
||||||
for(auto i=0; i<3; ++i)
|
for(auto i=0; i<3; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -1110,8 +1107,9 @@ private:
|
||||||
|
|
||||||
// //todo: think about if you should try doing the other collapse if test or link fails for this one
|
// //todo: think about if you should try doing the other collapse if test or link fails for this one
|
||||||
// if(testCrossCollapse(pi, ff, vi, mp, params) && Collapser::LinkConditions(bp))
|
// if(testCrossCollapse(pi, ff, vi, mp, params) && Collapser::LinkConditions(bp))
|
||||||
if(testCollapse1(pi, mp, 0, 0, params) && Collapser::LinkConditions(bp))
|
if(testCollapse1(pi, mp, 0, 0, params, true) && Collapser::LinkConditions(bp))
|
||||||
{
|
{
|
||||||
|
bp = VertexPair(pi.VFlip(), pi.V());
|
||||||
Collapser::Do(m, bp, mp, true);
|
Collapser::Do(m, bp, mp, true);
|
||||||
++count;
|
++count;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1234,6 +1232,61 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void VertexCoordPlanarLaplacian(MeshType &m, Params & params, int step)
|
||||||
|
{
|
||||||
|
typename vcg::tri::Smooth<MeshType>::LaplacianInfo lpz(CoordType(0, 0, 0), 0);
|
||||||
|
SimpleTempData<typename MeshType::VertContainer, typename vcg::tri::Smooth<MeshType>::LaplacianInfo> TD(m.vert, lpz);
|
||||||
|
for (int i = 0; i < step; ++i)
|
||||||
|
{
|
||||||
|
TD.Init(lpz);
|
||||||
|
vcg::tri::Smooth<MeshType>::AccumulateLaplacianInfo(m, TD, false);
|
||||||
|
// First normalize the AccumulateLaplacianInfo
|
||||||
|
for (auto vi = m.vert.begin(); vi != m.vert.end(); ++vi)
|
||||||
|
if (!(*vi).IsD() && TD[*vi].cnt > 0)
|
||||||
|
{
|
||||||
|
if ((*vi).IsS())
|
||||||
|
TD[*vi].sum = ((*vi).P() + TD[*vi].sum) / (TD[*vi].cnt + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||||
|
{
|
||||||
|
if (!(*fi).IsD())
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
if (Angle(Normal(TD[(*fi).V0(j)].sum, (*fi).P1(j), (*fi).P2(j)),
|
||||||
|
Normal((*fi).P0(j), (*fi).P1(j), (*fi).P2(j))) > M_PI/2.)
|
||||||
|
TD[(*fi).V0(j)].sum = (*fi).P0(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||||
|
{
|
||||||
|
if (!(*fi).IsD())
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
if (Angle(Normal(TD[(*fi).V0(j)].sum, TD[(*fi).V1(j)].sum, (*fi).P2(j)),
|
||||||
|
Normal((*fi).P0(j), (*fi).P1(j), (*fi).P2(j))) > M_PI/2.)
|
||||||
|
{
|
||||||
|
TD[(*fi).V0(j)].sum = (*fi).P0(j);
|
||||||
|
TD[(*fi).V1(j)].sum = (*fi).P1(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto vi = m.vert.begin(); vi != m.vert.end(); ++vi)
|
||||||
|
if (!(*vi).IsD() && TD[*vi].cnt > 0)
|
||||||
|
{
|
||||||
|
std::vector<CoordType> newPos(1, TD[*vi].sum);
|
||||||
|
if ((*vi).IsS() && testHausdorff(*params.mProject, params.grid, newPos, params.maxSurfDist))
|
||||||
|
(*vi).P() = TD[*vi].sum;
|
||||||
|
}
|
||||||
|
} // end step
|
||||||
|
}
|
||||||
|
|
||||||
// static int
|
// static int
|
||||||
/**
|
/**
|
||||||
* Simple Laplacian Smoothing step
|
* Simple Laplacian Smoothing step
|
||||||
|
|
@ -1259,15 +1312,13 @@ private:
|
||||||
if(params.selectedOnly) {
|
if(params.selectedOnly) {
|
||||||
ss.popAnd();
|
ss.popAnd();
|
||||||
}
|
}
|
||||||
// FoldRelax(m, params, 1, false);
|
|
||||||
|
|
||||||
// tri::Smooth<MeshType>::VertexCoordLaplacian(m, 1, true);
|
VertexCoordPlanarLaplacian(m, params, 1);
|
||||||
tri::Smooth<MeshType>::VertexCoordPlanarLaplacian(m, 1, math::ToRad(1.0), true);
|
|
||||||
|
|
||||||
tri::UpdateSelection<MeshType>::VertexClear(m);
|
tri::UpdateSelection<MeshType>::VertexClear(m);
|
||||||
|
|
||||||
selectVertexFromFold(m, params);
|
selectVertexFromFold(m, params);
|
||||||
FoldRelax(m, params, 2);
|
FoldRelax(m, params, 2);
|
||||||
|
|
||||||
tri::UpdateSelection<MeshType>::VertexClear(m);
|
tri::UpdateSelection<MeshType>::VertexClear(m);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue