#ifndef POLYMESH_HPP #define POLYMESH_HPP #include "vcg/complex/complex.h" #include #include //#include class PFace; class PVertex; struct PUsedTypes : public vcg::UsedTypes::AsVertexType, vcg::Use::AsFaceType> {}; class PVertex : public vcg::Vertex {}; class PFace : public vcg::Face< PUsedTypes, vcg::face::PolyInfo // this is necessary if you use component in // vcg/simplex/face/component_polygon.h // It says "this class is a polygon and the memory for its components // (e.g. pointer to its vertices will be allocated dynamically") , vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj ) , vcg::face::PFVAdj, vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj ) , vcg::face::BitFlags // bit flags , vcg::face::Qualityf // quality , vcg::face::Normal3f // normal > {}; class VCGPolyMesh : public vcg::tri::TriMesh, // the vector of vertices std::vector // the vector of faces > { public: void loadFromPlyFile(const std::string &filename) { vcg::tri::io::ImporterOBJ::Info info; vcg::tri::io::ImporterOBJ::Open(*this, filename.c_str(), info); // unsigned int mask = 0; // mask |= nanoply::NanoPlyWrapper::IO_VERTCOORD; // mask |= nanoply::NanoPlyWrapper::IO_VERTNORMAL; // mask |= nanoply::NanoPlyWrapper::IO_VERTCOLOR; // mask |= nanoply::NanoPlyWrapper::IO_EDGEINDEX; // mask |= nanoply::NanoPlyWrapper::IO_FACEINDEX; // if (nanoply::NanoPlyWrapper::LoadModel( // std::filesystem::absolute(filename).c_str(), *this, mask) != // 0) { // std::cout << "Could not load tri mesh" << std::endl; // } vcg::tri::UpdateTopology::FaceFace(*this); // vcg::tri::UpdateTopology::VertexFace(*this); vcg::tri::UpdateNormal::PerVertexNormalized(*this); } }; #endif // POLYMESH_HPP