added check in MCSimplify
if the mesh does not have straight edges, it cannot be simplified "guessing" the error because it is not a MC-generated mesh. Before, when it fould no straigth edges, it was crashing :)
This commit is contained in:
parent
7fdb93f773
commit
ce1f23a37b
|
@ -59,7 +59,7 @@ namespace tri {
|
|||
|
||||
// Simple prototype for later use...
|
||||
template<class MeshType>
|
||||
void MCSimplify( MeshType &m, float perc, bool preserveBB=true, vcg::CallBackPos *cb=0);
|
||||
int MCSimplify( MeshType &m, float perc, bool preserveBB=true, vcg::CallBackPos *cb=0);
|
||||
|
||||
|
||||
/** Surface Reconstruction
|
||||
|
@ -550,7 +550,7 @@ template < class MeshType, class VertexPair>
|
|||
|
||||
|
||||
template< class MeshType>
|
||||
void MCSimplify( MeshType &m, float absoluteError, bool preserveBB, vcg::CallBackPos *cb)
|
||||
int MCSimplify( MeshType &m, float absoluteError, bool preserveBB, vcg::CallBackPos *cb)
|
||||
{
|
||||
|
||||
typedef PlyMCTriEdgeCollapse<MeshType,BasicVertexPair<typename MeshType::VertexType> > MyColl;
|
||||
|
@ -578,10 +578,11 @@ void MCSimplify( MeshType &m, float absoluteError, bool preserveBB, vcg::CallBac
|
|||
CoordType v1=(*fi).V(1)->P();
|
||||
CoordType v2=(*fi).V(2)->P();
|
||||
if(v0[2]==v1[2] && v0[1]!=v1[1] && v0[0]!=v1[0]) ZSet.push_back(v0[2]);
|
||||
if(v0[2]==v2[2] && v0[1]!=v1[1] && v2[0]!=v2[0]) ZSet.push_back(v0[2]);
|
||||
if(v1[2]==v2[2] && v1[1]!=v1[1] && v2[0]!=v2[0]) ZSet.push_back(v0[2]);
|
||||
if(v0[2]==v2[2] && v0[1]!=v2[1] && v0[0]!=v2[0]) ZSet.push_back(v0[2]);
|
||||
if(v1[2]==v2[2] && v1[1]!=v2[1] && v1[0]!=v2[0]) ZSet.push_back(v1[2]);
|
||||
if(ZSet.size()>100) break;
|
||||
}
|
||||
if (ZSet.size() == 0) return -1; //no straight edges found. exit with error
|
||||
std::sort(ZSet.begin(),ZSet.end());
|
||||
std::vector<float>::iterator lastV = std::unique(ZSet.begin(),ZSet.end());
|
||||
ZSet.resize(lastV-ZSet.begin());
|
||||
|
@ -607,6 +608,8 @@ void MCSimplify( MeshType &m, float absoluteError, bool preserveBB, vcg::CallBac
|
|||
sprintf(buf,"Simplyfing %7i err %9g \r",m.fn,DeciSession.currMetric);
|
||||
if (cb) cb(int(100.0f*DeciSession.currMetric/TargetError),buf);
|
||||
}
|
||||
|
||||
return 1; //success
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue