Updated the spacepacker sample to the new interfaces for dumping, creating random outlines etc

This commit is contained in:
Paolo Cignoni 2013-03-25 13:13:28 +00:00
parent 013857b8fe
commit c4fde3e879
1 changed files with 6 additions and 35 deletions

View File

@ -27,6 +27,7 @@
#include<wrap/qt/col_qt_convert.h>
#include <vcg/space/rect_packer.h>
#include <vcg/space/poly_packer.h>
#include <vcg/complex/algorithms/outline_support.h>
#include <wrap/qt/PolyToQImage.h>
#include <time.h>
@ -67,35 +68,6 @@ void buildRandRectSetOld(int rectNum, vector<Box2f> &rectVec)
}
}
void buildRandPolySet(int polyNum, vector< vector<Point2f> > &polyVec)
{
vcg::math::MarsenneTwisterRNG rnd;
rnd.initialize(time(0));
for(int i=0;i<polyNum;++i)
{
vector<Point2f> poly;
for(int j=0;j<10;j++)
poly.push_back(Point2f(0.5+0.5*rnd.generate01(),2.0f*M_PI*rnd.generate01()));
std::sort(poly.begin(),poly.end());
float ratio = rnd.generateRange(0.2,0.9);
float rot = rnd.generateRange(-M_PI,M_PI);
float scale = pow(rnd.generateRange(0.3,0.9),1);
for(size_t j=0;j<poly.size();j++)
{
poly[j].Polar2Cartesian();
poly[j][1]*=ratio;
poly[j] *= scale;
poly[j].Cartesian2Polar();
poly[j][1]+=rot;
poly[j].Polar2Cartesian();
}
polyVec.push_back(poly);
}
}
int main( int argc, char **argv )
{
@ -106,7 +78,7 @@ int main( int argc, char **argv )
Point2f finalSize;
std::vector<Point2f> finalSizeVec;
const Point2f containerSize(1000,1000);
PolyDumperParam pp;
PolyDumper::Param pp;
std::vector<int> contInd;
vector<Box2f> rectVec;
@ -140,17 +112,16 @@ int main( int argc, char **argv )
// PolyDumper::dumpPolySetPNG("testpolyOO.png",polySet,trVec,pp);
buildRandPolySet(100,polySet);
vcg::tri::OutlineUtil<float>::BuildRandomOutlineVec(25,polySet);
PolyPacker<float>::PackAsEqualSquares(polySet,containerSize,trVec,finalSize);
PolyDumper::dumpPolySetPNG("testpolyEq.png",polySet,trVec,pp);
PolyDumper::dumpOutline2VecPNG("testpolyEq.png",polySet,trVec,pp);
PolyPacker<float>::PackAsAxisAlignedRect(polySet,containerSize,trVec,finalSize);
PolyDumper::dumpPolySetPNG("testpolyAA.png",polySet,trVec,pp);
PolyDumper::dumpOutline2VecPNG("testpolyAA.png",polySet,trVec,pp);
PolyPacker<float>::PackAsObjectOrientedRect(polySet,containerSize,trVec,finalSize);
PolyDumper::dumpPolySetPNG("testpolyOO.png",polySet,trVec,pp);
PolyDumper::dumpOutline2VecPNG("testpolyOO.png",polySet,trVec,pp);
return 0;
}