/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2004-2009 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * All rights reserved. * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ #include #include #include #include #include #include #include #include using namespace vcg; using namespace std; static void buildRandRectSet(int rectNum, vector &rectVec) { math::MarsenneTwisterRNG rnd; float exp=3.0f; float ratioMin=0.2; float ratioMax=0.9; float sizeMin=0.1; float sizeMax=1.0f; rnd.initialize(time(0)); for(int i=0;i &rectVec) { math::MarsenneTwisterRNG rnd; float exp=5.0f; rnd.initialize(time(0)); for(int i=0;i > &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 rectVec; buildRandRectSet(1000, rectVec); vector trVec; vector< vector > polySet; Point2f finalSize; buildRandPolySet(100,polySet); PolyDumperParam pp; /* PolyPacker::PackAsEqualSquares(polySet,Point2f(1024.0f,1024.0f),trVec,finalSize); dumpPolySet("testpolyEq.png",polySet,trVec,pp); PolyPacker::PackAsAxisAlignedRect(polySet,Point2f(1024.0f,1024.0f),trVec,finalSize); dumpPolySet("testpolyAA.png",polySet,trVec,pp); PolyPacker::PackAsObjectOrientedRect(polySet,Point2f(1024.0f,1024.0f),trVec,finalSize); dumpPolySet("testpolyOO.png",polySet,trVec,pp);*/ //PolyPacker::PackAsAxisAlignedRect(polySet,Point2f(1024.0f,1024.0f),trVec,finalSize); PolyPacker::PackAsObjectOrientedRect(polySet,Point2f(1024.0f,1024.0f),trVec,finalSize); //dumpPolySetPNG("testpolyEq.png",polySet,trVec,pp); PolyDumper::dumpPolySetSVG("testpolyEq.svg",polySet,trVec,pp); /*PolyPacker::PackAsAxisAlignedRect(polySet,Point2f(1024.0f,1024.0f),trVec,finalSize); dumpPolySetSVG("testpolyAA.svg",polySet,trVec,pp); PolyPacker::PackAsObjectOrientedRect(polySet,Point2f(1024.0f,1024.0f),trVec,finalSize); dumpPolySetSVG("testpolyOO.svg",polySet,trVec,pp);*/ return 0; }