Changed ComputeFaceEdgeHistogram into ComputeFaceEdgeDistribution. It was plainly wrong... :(

This commit is contained in:
Paolo Cignoni 2012-07-06 08:08:24 +00:00
parent 38b8ab1f15
commit 3d956d8b48
1 changed files with 13 additions and 20 deletions

View File

@ -235,37 +235,30 @@ class Stat
return h.Avg(); return h.Avg();
} }
static int ComputeFaceEdgeHistogram( MeshType & m, Histogramf &h) static void ComputeFaceEdgeDistribution( MeshType & m, Distribution<float> &h)
{ {
h.Clear(); h.Clear();
h.SetRange( 0, m.bbox.Diag(), 10000); tri::UpdateFlags<MeshType>::FaceBorderFromNone(m);
tri::UpdateFlags<MeshType>::VertexClearV(m);
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
{ {
if(!(*fi).IsD()) if(!(*fi).IsD())
{ {
if( !(*fi).V(0)->IsV() && !(*fi).V(1)->IsV() ) for(int i=0;i<3;++i)
{ {
h.Add(Distance<float>((*fi).V(0)->P(),(*fi).V(1)->P())); h.Add(Distance<float>(fi->P0(i),fi->P1(i)));
(*fi).V(0)->SetV(); if(fi->IsB(i)) // to be uniform border edges must be added twice...
(*fi).V(1)->SetV(); h.Add(Distance<float>(fi->P0(i),fi->P1(i)));
} }
if( !(*fi).V(1)->IsV() && !(*fi).V(2)->IsV()) }
}
}
static ScalarType ComputeFaceEdgeAverage(MeshType & m)
{ {
h.Add(Distance<float>((*fi).V(1)->P(),(*fi).V(2)->P())); Distribution<float> h;
(*fi).V(2)->SetV(); ComputeFaceEdgeDistribution(m,h);
(*fi).V(1)->SetV(); return h.Avg();
}
if( !(*fi).V(2)->IsV() && !(*fi).V(0)->IsV())
{
h.Add(Distance<float>((*fi).V(2)->P(),(*fi).V(0)->P()));
(*fi).V(0)->SetV();
(*fi).V(2)->SetV();
}
}
}
return 0;
} }
}; // end class }; // end class
} //End Namespace tri } //End Namespace tri