Small changes to the utility function to save a bunch of 2 polygons onto a bitmap.
This commit is contained in:
parent
b338a57f67
commit
e5842d71d8
|
|
@ -6,24 +6,40 @@
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int dumpPolySet(const char * imageName,vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, int width, int height)
|
int dumpPolySet(const char * imageName, vector< vector<Point2f> > &polyVec, int width, int height)
|
||||||
{
|
{
|
||||||
|
Box2f bb;
|
||||||
|
for(size_t i=0;i<polyVec.size();++i)
|
||||||
|
for(int j=0;j<polyVec[i].size();++j)
|
||||||
|
bb.Add(polyVec[i][j]);
|
||||||
|
|
||||||
|
Similarity2f sim;
|
||||||
|
sim.sca = min(float(width)/bb.DimX(),float(height)/bb.DimY());
|
||||||
|
sim.tra = Point2f(width/2.0f,height/2.0f)-bb.Center()*sim.sca;
|
||||||
|
vector<Similarity2f> trVec(polyVec.size(),sim);
|
||||||
|
|
||||||
|
return dumpPolySet(imageName,polyVec,trVec,width,height);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dumpPolySet(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, int width, int height)
|
||||||
|
{
|
||||||
|
assert(polyVecVec.size() == trVec.size());
|
||||||
|
|
||||||
QImage img(width,height,QImage::Format_RGB32);
|
QImage img(width,height,QImage::Format_RGB32);
|
||||||
img.fill(qRgb(128,128,128));
|
img.fill(qRgb(128,128,128));
|
||||||
QPainter painter(&img); // paint in picture
|
QPainter painter(&img); // paint in picture
|
||||||
for(size_t i=0;i<polyVec.size();++i)
|
for(size_t i=0;i<polyVecVec.size();++i)
|
||||||
{
|
{
|
||||||
QVector<QPointF> ppQ;
|
QVector<QPointF> ppQ;
|
||||||
for(int j=0;j<polyVec[i].size();++j)
|
for(int j=0;j<polyVecVec[i][0].size();++j)
|
||||||
{
|
{
|
||||||
Point2f pp=trVec[i]*polyVec[i][j];
|
Point2f pp=trVec[i]*polyVecVec[i][0][j];
|
||||||
ppQ.push_back(QPointF(pp[0],pp[1]));
|
ppQ.push_back(QPointF(pp[0],pp[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush bb(vcg::ColorConverter::ToQColor(Color4b::Scatter(polyVec.size(),i)));
|
QBrush bb(vcg::ColorConverter::ToQColor(Color4b::Scatter(polyVecVec.size(),i)));
|
||||||
painter.setBrush(bb);
|
painter.setBrush(bb);
|
||||||
painter.drawPolygon(&*ppQ.begin(),ppQ.size(),Qt::OddEvenFill);
|
painter.drawPolygon(&*ppQ.begin(),ppQ.size(),Qt::OddEvenFill);
|
||||||
|
|
||||||
}
|
}
|
||||||
painter.end();
|
painter.end();
|
||||||
img = img.mirrored(false,true);
|
img = img.mirrored(false,true);
|
||||||
|
|
@ -37,3 +53,14 @@ int dumpPolySet(const char * imageName,vector< vector<Point2f> > &polyVec, vecto
|
||||||
return emptyCnt;
|
return emptyCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dumpPolySet(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, int width, int height)
|
||||||
|
{
|
||||||
|
vector< vector< vector<Point2f> > > polyVecVec(polyVec.size());
|
||||||
|
for(size_t i=0;i<polyVec.size();++i)
|
||||||
|
{
|
||||||
|
polyVecVec[i].resize(1);
|
||||||
|
polyVecVec[i][0]=polyVec[i];
|
||||||
|
}
|
||||||
|
dumpPolySet(imageName,polyVecVec,trVec,width,height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
#ifndef POLYTOQIMAGE_H
|
#ifndef POLYTOQIMAGE_H
|
||||||
#define POLYTOQIMAGE_H
|
#define POLYTOQIMAGE_H
|
||||||
#include <vcg/space/point2.h>
|
#include <vcg/space/point2.h>
|
||||||
|
#include <vcg/space/box2.h>
|
||||||
#include <vcg/math/similarity2.h>
|
#include <vcg/math/similarity2.h>
|
||||||
|
|
||||||
int dumpPolySet(const char * imageName, std::vector< std::vector<vcg::Point2f> > &polyVec, std::vector<vcg::Similarity2f> &trVec,int width=1024,int height=1024);
|
int dumpPolySet(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec, std::vector<vcg::Similarity2f> &trVec, int width, int height);
|
||||||
|
int dumpPolySet(const char * imageName, std::vector< std::vector<vcg::Point2f> > &polyVec, std::vector<vcg::Similarity2f> &trVec, int width=1024,int height=1024);
|
||||||
|
int dumpPolySet(const char * imageName, std::vector< std::vector<vcg::Point2f> > &polyVec, int width=1024,int height=1024);
|
||||||
|
|
||||||
#endif // POLYTOQIMAGE_H
|
#endif // POLYTOQIMAGE_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue