#ifndef POLYMESH_HPP #define POLYMESH_HPP #include "mesh.hpp" #include "vcg/complex/complex.h" #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, std::vector>, public Mesh { public: virtual bool load(const std::string &filename) override { int mask; vcg::tri::io::Importer::LoadMask(filename.c_str(), mask); int error = vcg::tri::io::Importer::Open( *this, filename.c_str(), mask); if (error != 0) { return false; } // vcg::tri::io::ImporterOBJ::Open(); // 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); return true; } #ifdef POLYSCOPE_DEFINED void registerForDrawing(){ } #endif }; #endif // POLYMESH_HPP