added RequireTriangularMesh guard and corresponding exception

This commit is contained in:
Paolo Cignoni 2014-02-19 11:58:01 +00:00
parent 4cc8a7c919
commit b2e97b9134
2 changed files with 18 additions and 0 deletions

View File

@ -610,6 +610,8 @@ template <class MeshType> void RequireCompactness (MeshType &m) {
if(m.face.size()!=size_t(m.fn)) throw vcg::MissingCompactnessException("Face Vector Contains deleted elements");
}
template <class MeshType> void RequireTriangularMesh (MeshType &m) { if(typename MeshType::FaceType::HasPolyInfo()) throw vcg::MissingTriangularRequirementException("");}
template <class MeshType> void RequireVFAdjacency (MeshType &m) { if(!tri::HasVFAdjacency (m)) throw vcg::MissingComponentException("VFAdjacency"); }
template <class MeshType> void RequireVEAdjacency (MeshType &m) { if(!tri::HasVEAdjacency (m)) throw vcg::MissingComponentException("VEAdjacency"); }
template <class MeshType> void RequireFFAdjacency (MeshType &m) { if(!tri::HasFFAdjacency (m)) throw vcg::MissingComponentException("FFAdjacency"); }

View File

@ -38,6 +38,7 @@ public:
return buf;
}
};
class MissingCompactnessException : public std::runtime_error
{
public:
@ -51,6 +52,21 @@ public:
return buf;
}
};
class MissingTriangularRequirementException : public std::runtime_error
{
public:
MissingTriangularRequirementException(const std::string &err):std::runtime_error(err)
{
std::cout << "Mesh has to be composed by triangle and not polygons -" << err << "- \n";
}
virtual const char *what() const throw ()
{
static char buf[128]="Mesh has to be composed by triangle and not polygons";
return buf;
}
};
}
#endif // EXCEPTION_H