small mods to isotropic remeshing
This commit is contained in:
parent
1d082b7fbe
commit
662950a347
|
|
@ -528,6 +528,7 @@ private:
|
|||
CoordType swapEdgeMidPoint = (f.cP2(i) + f.cFFp(i)->cP2(f.cFFi(i))) / 2.;
|
||||
std::vector<CoordType> toCheck(1, swapEdgeMidPoint);
|
||||
|
||||
|
||||
if(((!params.selectedOnly) || (f.IsS() && f.cFFp(i)->IsS())) &&
|
||||
face::IsManifold(f, i) && checkManifoldness(f, i) &&
|
||||
face::CheckFlipEdge(f, i) &&
|
||||
|
|
@ -640,23 +641,31 @@ private:
|
|||
|
||||
CoordType dEdgeVector = (p.V()->cP() - p.VFlip()->cP()).Normalize();
|
||||
|
||||
int incidentFeatures = 0;
|
||||
|
||||
for (size_t i = 0; i < faces.size(); ++i)
|
||||
// if (faces[i] != p.F() && faces[i] != p.FFlip())
|
||||
{
|
||||
if (faces[i]->IsFaceEdgeS(VtoE(vIdxes[i], (vIdxes[i]+1)%3)))
|
||||
{
|
||||
incidentFeatures++;
|
||||
CoordType movingEdgeVector0 = (faces[i]->cP1(vIdxes[i]) - faces[i]->cP(vIdxes[i])).Normalize();
|
||||
if (std::fabs(movingEdgeVector0 * dEdgeVector) < 1.f)
|
||||
if (std::fabs(movingEdgeVector0 * dEdgeVector) < .9f || !p.IsEdgeS())
|
||||
return false;
|
||||
}
|
||||
if (faces[i]->IsFaceEdgeS(VtoE(vIdxes[i], (vIdxes[i]+2)%3)))
|
||||
{
|
||||
incidentFeatures++;
|
||||
CoordType movingEdgeVector1 = (faces[i]->cP2(vIdxes[i]) - faces[i]->cP(vIdxes[i])).Normalize();
|
||||
if (std::fabs(movingEdgeVector1 * dEdgeVector) < 1.f)
|
||||
if (std::fabs(movingEdgeVector1 * dEdgeVector) < .9f || !p.IsEdgeS())
|
||||
return false;
|
||||
}
|
||||
allIncidentFaceSelected &= faces[i]->IsS();
|
||||
}
|
||||
|
||||
if (incidentFeatures > 4)
|
||||
return false;
|
||||
|
||||
return params.selectedOnly ? allIncidentFaceSelected : true;
|
||||
}
|
||||
|
||||
|
|
@ -693,7 +702,7 @@ private:
|
|||
Point3<ScalarType> newN = Normal(mp, v1->P(), v2->P()).Normalize();
|
||||
|
||||
float div = fastAngle(oldN, newN);
|
||||
if(div < .0f ) return false;
|
||||
if(div < .8f ) return false;
|
||||
|
||||
// // check on new face distance from original mesh
|
||||
if (params.surfDistCheck)
|
||||
|
|
@ -1111,7 +1120,7 @@ private:
|
|||
{
|
||||
int count = 0;
|
||||
ForEachFacePos(m, [&](PosType &p){
|
||||
if(((p.FFlip() > p.F()) || p.IsBorder()) && p.IsEdgeS()/*testCreaseEdge(p, creaseThr)*/)
|
||||
if(p.IsBorder() || p.IsEdgeS()/*testCreaseEdge(p, creaseThr)*/)
|
||||
{
|
||||
p.V()->SetS();
|
||||
p.VFlip()->SetS();
|
||||
|
|
@ -1135,7 +1144,7 @@ private:
|
|||
|
||||
//this aspect ratio check doesn't work on cadish meshes (long thin triangles spanning whole mesh)
|
||||
ForEachFace(m, [&] (FaceType & f) {
|
||||
if (vcg::QualityRadii(f.cP(0), f.cP(1), f.cP(2)) < params.aspectRatioThr)
|
||||
if (vcg::Quality(f.cP(0), f.cP(1), f.cP(2)) < params.aspectRatioThr)
|
||||
{
|
||||
if (creaseVerts[vcg::tri::Index(m, f.V(0))] == 0)
|
||||
f.V(0)->SetS();
|
||||
|
|
@ -1171,14 +1180,18 @@ private:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void FoldRelax(MeshType &m, Params params, const int step)
|
||||
|
||||
|
||||
|
||||
static void FoldRelax(MeshType &m, Params params, const int step, const bool strict = true)
|
||||
{
|
||||
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);
|
||||
const ScalarType maxDist = (strict) ? params.maxSurfDist / 1000. : params.maxSurfDist;
|
||||
for (int i = 0; i < step; ++i)
|
||||
{
|
||||
TD.Init(lpz);
|
||||
vcg::tri::Smooth<MeshType>::AccumulateLaplacianInfo(m, TD, true);
|
||||
vcg::tri::Smooth<MeshType>::AccumulateLaplacianInfo(m, TD, false);
|
||||
|
||||
for (auto fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||
{
|
||||
|
|
@ -1200,8 +1213,11 @@ private:
|
|||
|
||||
if (moving)
|
||||
{
|
||||
// const CoordType oldN = vcg::NormalizedTriangleNormal(*fi);
|
||||
// const CoordType newN = vcg::Normal(newPos[0], newPos[1], newPos[2]).Normalize();
|
||||
|
||||
newPos[3] = (newPos[0] + newPos[1] + newPos[2]) / 3.;
|
||||
if (!params.surfDistCheck || testHausdorff(*params.mProject, params.grid, newPos, params.maxSurfDist))
|
||||
if (/*(strict || oldN * newN > 0.99) &&*/ (!params.surfDistCheck || testHausdorff(*params.mProject, params.grid, newPos, maxDist)))
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
fi->V(j)->P() = newPos[j];
|
||||
|
|
@ -1235,12 +1251,15 @@ private:
|
|||
if(params.selectedOnly) {
|
||||
ss.popAnd();
|
||||
}
|
||||
// FoldRelax(m, params, 1, false);
|
||||
|
||||
// tri::Smooth<MeshType>::VertexCoordLaplacian(m, 1, true);
|
||||
tri::Smooth<MeshType>::VertexCoordPlanarLaplacian(m, 1, math::ToRad(1.0), true);
|
||||
|
||||
tri::UpdateSelection<MeshType>::VertexClear(m);
|
||||
|
||||
selectVertexFromFold(m, params);
|
||||
FoldRelax(m, params, 3);
|
||||
FoldRelax(m, params, 2);
|
||||
|
||||
tri::UpdateSelection<MeshType>::VertexClear(m);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue