Updated to include better control of the voronoi parametrization. Changed packer (warning it requires qt...)
This commit is contained in:
parent
135f5f9ecb
commit
eeddfe6a90
vcg/complex/algorithms/parametrization
|
@ -1,14 +1,17 @@
|
||||||
#ifndef VORONOI_ATLAS_H
|
#ifndef VORONOI_ATLAS_H
|
||||||
#define VORONOI_ATLAS_H
|
#define VORONOI_ATLAS_H
|
||||||
|
|
||||||
#include<vcg/complex/algorithms/parametrization/poisson_solver.h>
|
#include<vcg/complex/algorithms/parametrization/poisson_solver.h>
|
||||||
#include<vcg/complex/algorithms/parametrization/uv_utils.h>
|
#include<vcg/complex/algorithms/parametrization/uv_utils.h>
|
||||||
#include<vcg/complex/algorithms/parametrization/distortion.h>
|
#include<vcg/complex/algorithms/parametrization/distortion.h>
|
||||||
#include<vcg/space/poly_packer.h>
|
#include<vcg/space/outline2_packer.h>
|
||||||
#include<vcg/complex/append.h>
|
#include<vcg/space/rasterized_outline2_packer.h>
|
||||||
#include<vcg/complex/algorithms/update/texture.h>
|
#include<vcg/complex/algorithms/update/texture.h>
|
||||||
#include<vcg/complex/algorithms/point_sampling.h>
|
#include<vcg/complex/algorithms/point_sampling.h>
|
||||||
#include<vcg/complex/algorithms/voronoi_clustering.h>
|
#include<vcg/complex/algorithms/voronoi_clustering.h>
|
||||||
|
|
||||||
|
#include<wrap/qt/outline2_rasterizer.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
|
|
||||||
|
@ -83,6 +86,7 @@ public:
|
||||||
{
|
{
|
||||||
VoronoiAtlasParam()
|
VoronoiAtlasParam()
|
||||||
{
|
{
|
||||||
|
maxIterNum = 5;
|
||||||
sampleNum=10;
|
sampleNum=10;
|
||||||
overlap=false;
|
overlap=false;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +106,7 @@ public:
|
||||||
int sampleNum;
|
int sampleNum;
|
||||||
bool overlap;
|
bool overlap;
|
||||||
Stat vas;
|
Stat vas;
|
||||||
|
int maxIterNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Main parametrization function:
|
// Main parametrization function:
|
||||||
|
@ -125,13 +130,14 @@ public:
|
||||||
// Main processing loop
|
// Main processing loop
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
qDebug("************ ITERATION %i sampling mesh of %i with %i ************",pp.vas.iterNum,m.fn,pp.sampleNum);
|
||||||
int st0=clock();
|
int st0=clock();
|
||||||
std::vector<Point3f> PoissonSamples;
|
std::vector<Point3f> PoissonSamples;
|
||||||
float diskRadius=0;
|
float diskRadius=0;
|
||||||
tri::PoissonSampling(m,PoissonSamples,pp.sampleNum,diskRadius);
|
tri::PoissonSampling(m,PoissonSamples,pp.sampleNum,diskRadius);
|
||||||
int st1=clock();
|
int st1=clock();
|
||||||
pp.vas.samplingTime+= st1-st0;
|
pp.vas.samplingTime+= st1-st0;
|
||||||
printf("Sampling created a new mesh of %lu points\n",PoissonSamples.size());
|
qDebug("Sampling created a new mesh of %lu points\n",PoissonSamples.size());
|
||||||
std::vector<VertexType *> seedVec;
|
std::vector<VertexType *> seedVec;
|
||||||
tri::VoronoiProcessing<VoroMesh>::SeedToVertexConversion(m,PoissonSamples,seedVec);
|
tri::VoronoiProcessing<VoroMesh>::SeedToVertexConversion(m,PoissonSamples,seedVec);
|
||||||
tri::UpdateTopology<VoroMesh>::VertexFace(m);
|
tri::UpdateTopology<VoroMesh>::VertexFace(m);
|
||||||
|
@ -145,6 +151,8 @@ public:
|
||||||
{
|
{
|
||||||
VoroMesh *rm = new VoroMesh();
|
VoroMesh *rm = new VoroMesh();
|
||||||
int selCnt = tri::VoronoiProcessing<VoroMesh>::FaceSelectAssociateRegion(m,seedVec[i]);
|
int selCnt = tri::VoronoiProcessing<VoroMesh>::FaceSelectAssociateRegion(m,seedVec[i]);
|
||||||
|
qDebug("Region %i of %i faces",i,selCnt);
|
||||||
|
if(selCnt==0) continue;
|
||||||
assert(selCnt>0);
|
assert(selCnt>0);
|
||||||
if(pp.overlap){
|
if(pp.overlap){
|
||||||
tri::UpdateSelection<VoroMesh>::VertexFromFaceLoose(m);
|
tri::UpdateSelection<VoroMesh>::VertexFromFaceLoose(m);
|
||||||
|
@ -165,16 +173,24 @@ public:
|
||||||
CollectUVBorder(rm,uvBorder);
|
CollectUVBorder(rm,uvBorder);
|
||||||
meshRegionVec.push_back(rm);
|
meshRegionVec.push_back(rm);
|
||||||
uvBorders.push_back(uvBorder);
|
uvBorders.push_back(uvBorder);
|
||||||
|
int foldedCnt = tri::Distortion<VoroMesh,false>::Folded(*rm);
|
||||||
|
if( foldedCnt > rm->fn/10)
|
||||||
|
{
|
||||||
|
badRegionVec.push_back(rm);
|
||||||
|
qDebug("-- region %i Parametrized but with %i fold on %i!",i,foldedCnt,rm->fn);
|
||||||
|
}
|
||||||
|
else qDebug("-- region %i Parametrized!",i);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
qDebug("ACH - mesh %i is NOT homeomorphic to a disk\n",i);
|
qDebug("-- region %i is NOT homeomorphic to a disk\n",i);
|
||||||
badRegionVec.push_back(rm);
|
badRegionVec.push_back(rm);
|
||||||
}
|
}
|
||||||
int tp1=clock();
|
int tp1=clock();
|
||||||
pp.vas.unwrapTime +=tp1-tp0;
|
pp.vas.unwrapTime +=tp1-tp0;
|
||||||
++pp.vas.iterNum;
|
++pp.vas.iterNum;
|
||||||
}
|
}
|
||||||
|
qDebug("\n -- Completed (%i bad regions) -- \n", badRegionVec.size());
|
||||||
VoroMesh *rm = new VoroMesh();
|
VoroMesh *rm = new VoroMesh();
|
||||||
tri::VoronoiProcessing<VoroMesh>::FaceSelectAssociateRegion(m,0);
|
tri::VoronoiProcessing<VoroMesh>::FaceSelectAssociateRegion(m,0);
|
||||||
tri::Append<VoroMesh,VoroMesh>::Mesh(*rm, m, true);
|
tri::Append<VoroMesh,VoroMesh>::Mesh(*rm, m, true);
|
||||||
|
@ -189,7 +205,7 @@ public:
|
||||||
if(!badRegionVec.empty())
|
if(!badRegionVec.empty())
|
||||||
{
|
{
|
||||||
for(size_t i=0;i<badRegionVec.size();++i)
|
for(size_t i=0;i<badRegionVec.size();++i)
|
||||||
if(badRegionVec[i]->fn>10)
|
if(badRegionVec[i]->fn>50)
|
||||||
tri::Append<VoroMesh,VoroMesh>::Mesh(m, *badRegionVec[i], false);
|
tri::Append<VoroMesh,VoroMesh>::Mesh(m, *badRegionVec[i], false);
|
||||||
|
|
||||||
tri::Clean<VoroMesh>::RemoveDuplicateFace(m);
|
tri::Clean<VoroMesh>::RemoveDuplicateFace(m);
|
||||||
|
@ -201,7 +217,10 @@ public:
|
||||||
|
|
||||||
std::vector<Similarity2f> trVec;
|
std::vector<Similarity2f> trVec;
|
||||||
Point2f finalSize;
|
Point2f finalSize;
|
||||||
PolyPacker<float>::PackAsObjectOrientedRect(uvBorders,Point2f(1024.0f,1024.0f),trVec,finalSize);
|
//PolyPacker<float>::WritePolyVec(uvBorders,"borders.poly");
|
||||||
|
PolyPacker<float>::PackAsObjectOrientedRect(uvBorders,Point2i(1024,1024),trVec,finalSize);
|
||||||
|
RasterizedOutline2Packer<float,QtOutline2Rasterizer>::Parameters prp;
|
||||||
|
RasterizedOutline2Packer<float,QtOutline2Rasterizer>::Pack(uvBorders,Point2i(1024,1024),trVec,prp);
|
||||||
// loop again over all the patches
|
// loop again over all the patches
|
||||||
pp.vas.regionNum=meshRegionVec.size();
|
pp.vas.regionNum=meshRegionVec.size();
|
||||||
for(size_t i=0; i<meshRegionVec.size();++i)
|
for(size_t i=0; i<meshRegionVec.size();++i)
|
||||||
|
|
Loading…
Reference in New Issue