#ifndef HEXAGONREMESHER_HPP #define HEXAGONREMESHER_HPP #include "polymesh.hpp" #include "vcgtrimesh.hpp" #include #include #include #include #include #include namespace PolygonalRemeshing { //std::shared_ptr inline std::shared_ptr remeshWithPolygons(VCGTriMesh &surface) { // const std::string tileIntoFilePath( // "/home/iason/Coding/build/PatternTillingReducedModel/RelWithDebInfo/plane.ply"); // const std::string tileIntoFilePath("/home/iason/Coding/build/PatternTillingReducedModel/" // "RelWithDebInfo/hexagon.ply"); // const std::string tileIntoFilePath("/home/iason/Coding/build/PatternTillingReducedModel/" // "RelWithDebInfo/instantMeshes_plane_34.ply"); // const std::string tileIntoFilePath("/home/iason/Coding/build/PatternTillingReducedModel/" // "RelWithDebInfo/instantMeshes_plane.ply"); // assert(std::filesystem::exists(tileIntoFilePath)); // assert(tileInto_polyMesh.load(tileIntoFilePath)); ///Load triangle mesh // VCGTriMesh tileInto_triMesh; // assert(std::filesystem::exists(tileIntoFilePath)); // tileInto_triMesh.load(tileIntoFilePath); ///Sample the triangle mesh // std::vector pointVec; // double radius = 1; // int sampleNum = 50; // // // vcg::tri::PoissonSampling(tileInto_triMesh, pointVec, sampleNum, radius); // // // vcg::tri::TrivialSampler ps; // // // vcg::tri::SurfaceSampling::VertexUniform(tileInto_triMesh, ps, sampleNum); // // // pointVec = ps.SampleVec(); // vcg::tri::MontecarloSampling(tileInto_triMesh, pointVec, sampleNum); // vcg::tri::VoronoiProcessingParameter vpp; // vcg::tri::VoronoiProcessing::PreprocessForVoronoi(tileInto_triMesh, radius, vpp); // std::vector seedVec; // vcg::tri::VoronoiProcessing::SeedToVertexConversion(tileInto_triMesh, // pointVec, // seedVec); // vcg::tri::EuclideanDistance df; // vpp.geodesicRelaxFlag = false; // const int iterNum = 100; // int actualIter = vcg::tri::VoronoiProcessing::VoronoiRelaxing(tileInto_triMesh, // seedVec, // iterNum, // df, // vpp); // std::cout << "Voronoi relaxation iterations performed:" << actualIter << std::endl; // bool saveWasSuccessful // = 0 // == vcg::tri::io::ExporterOBJ::Save(tileInto_triMesh, // "./tileInto_triMesh.obj", // vcg::tri::io::Mask::IOM_ALL); // VCGTriMesh delaunay; // vcg::tri::VoronoiProcessing::ConvertDelaunayTriangulationToMesh(tileInto_triMesh, // delaunay, // seedVec); // delaunay.setLabel("Delaunay"); // delaunay.save(delaunay.getLabel() + ".ply"); // delaunay.registerForDrawing(); // ////Load surface VCGPolyMesh tileInto_polyMesh, dual; // vcg::tri::PolygonSupport::ImportFromTriMesh(tileInto_polyMesh, // delaunay); vcg::tri::PolygonSupport::ImportFromTriMesh(tileInto_polyMesh, surface); vcg::tri::DualMeshing::MakeDual(tileInto_polyMesh, dual, false); // for(size_t i=0; i< Edges.size(); ++i) // { // std::vector fpVec; // std::vector eiVec; // face::EFStarFF(Edges[i].f,Edges[i].z,fpVec,eiVec); // for(size_t j=0;jFEp(eiVec[j])=&(m.edge[i]); // } dual.setLabel(surface.getLabel() + "_polyDual"); // bool saveWasSuccessful // = 0 // == vcg::tri::io::ExporterOBJ::Save(dual, // (dual.getLabel() + ".obj").c_str(), // vcg::tri::io::Mask::IOM_BITPOLYGONAL); // assert(saveWasSuccessful); vcg::tri::UpdateNormal::PerFaceNormalized(dual); // vcg::PolygonalAlgorithm::SmoothReprojectPCA(dual, 1000, false, 0.5, 0, false, false); // vcg::tri::io::ExporterOBJ::Save(dual, // "./dual_optimized.obj", // vcg::tri::io::Mask::IOM_BITPOLYGONAL); // if (vcg::tri::VoronoiProcessing::CheckVoronoiTopology(tileInto_triMesh, seedVec)) { // VCGTriMesh voronoiMesh, voronoiPoly; // vcg::tri::VoronoiProcessing::ConvertVoronoiDiagramToMesh(tileInto_triMesh, // voronoiMesh, // voronoiPoly, // seedVec, // vpp); // vcg::tri::Allocator::CompactEveryVector(voronoiMesh); // voronoiMesh.setLabel("Voro"); // voronoiMesh.save(voronoiMesh.getLabel() + ".ply"); // // voronoiMesh.registerForDrawing(); // vcg::tri::Allocator::CompactEveryVector(voronoiPoly); // voronoiPoly.setLabel("Poly"); // voronoiPoly.save(voronoiPoly.getLabel() + ".ply"); // // voronoiPoly.registerForDrawing(); // // polyscope::show(); // } // dual.registerForDrawing(); // polyscope::show(); // assert(vcg::tri::IsValidPointer(dual, dual.face[0].cFEp(0))); return std::make_shared(dual); } } // namespace PolygonalRemeshing #endif // HEXAGONREMESHER_HPP