diff --git a/vcg/complex/base.h b/vcg/complex/base.h index 1d512167..28ff84aa 100644 --- a/vcg/complex/base.h +++ b/vcg/complex/base.h @@ -610,6 +610,8 @@ template void RequireCompactness (MeshType &m) { if(m.face.size()!=size_t(m.fn)) throw vcg::MissingCompactnessException("Face Vector Contains deleted elements"); } +template void RequireTriangularMesh (MeshType &m) { if(typename MeshType::FaceType::HasPolyInfo()) throw vcg::MissingTriangularRequirementException("");} + template void RequireVFAdjacency (MeshType &m) { if(!tri::HasVFAdjacency (m)) throw vcg::MissingComponentException("VFAdjacency"); } template void RequireVEAdjacency (MeshType &m) { if(!tri::HasVEAdjacency (m)) throw vcg::MissingComponentException("VEAdjacency"); } template void RequireFFAdjacency (MeshType &m) { if(!tri::HasFFAdjacency (m)) throw vcg::MissingComponentException("FFAdjacency"); } diff --git a/vcg/complex/exception.h b/vcg/complex/exception.h index e7207f93..bebd6c61 100644 --- a/vcg/complex/exception.h +++ b/vcg/complex/exception.h @@ -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