From c4fde3e879621f76db932ae69b6e7d81841fdfad Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 25 Mar 2013 13:13:28 +0000 Subject: [PATCH] Updated the spacepacker sample to the new interfaces for dumping, creating random outlines etc --- apps/sample/space_packer/space_packer.cpp | 41 ++++------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/apps/sample/space_packer/space_packer.cpp b/apps/sample/space_packer/space_packer.cpp index c3a4366e..bebf7d49 100644 --- a/apps/sample/space_packer/space_packer.cpp +++ b/apps/sample/space_packer/space_packer.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -67,35 +68,6 @@ void buildRandRectSetOld(int rectNum, vector &rectVec) } } -void buildRandPolySet(int polyNum, vector< vector > &polyVec) -{ - vcg::math::MarsenneTwisterRNG rnd; - rnd.initialize(time(0)); - - for(int i=0;i 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 finalSizeVec; const Point2f containerSize(1000,1000); - PolyDumperParam pp; + PolyDumper::Param pp; std::vector contInd; vector rectVec; @@ -140,17 +112,16 @@ int main( int argc, char **argv ) // PolyDumper::dumpPolySetPNG("testpolyOO.png",polySet,trVec,pp); - - buildRandPolySet(100,polySet); + vcg::tri::OutlineUtil::BuildRandomOutlineVec(25,polySet); PolyPacker::PackAsEqualSquares(polySet,containerSize,trVec,finalSize); - PolyDumper::dumpPolySetPNG("testpolyEq.png",polySet,trVec,pp); + PolyDumper::dumpOutline2VecPNG("testpolyEq.png",polySet,trVec,pp); PolyPacker::PackAsAxisAlignedRect(polySet,containerSize,trVec,finalSize); - PolyDumper::dumpPolySetPNG("testpolyAA.png",polySet,trVec,pp); + PolyDumper::dumpOutline2VecPNG("testpolyAA.png",polySet,trVec,pp); PolyPacker::PackAsObjectOrientedRect(polySet,containerSize,trVec,finalSize); - PolyDumper::dumpPolySetPNG("testpolyOO.png",polySet,trVec,pp); + PolyDumper::dumpOutline2VecPNG("testpolyOO.png",polySet,trVec,pp); return 0; }