X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lsystem3d%2Fsrc%2Flsystemparameters.cpp;fp=lsystem3d%2Fsrc%2Flsystemparameters.cpp;h=0000000000000000000000000000000000000000;hb=db873ae7535fc6bde3c61d7d0e6346797c658477;hp=c12e9e3ecaa7583a2427a612b03c5550166ee81b;hpb=e5247a3b88c449937af08f46afc271afda2954a2;p=lsystem3d.git diff --git a/lsystem3d/src/lsystemparameters.cpp b/lsystem3d/src/lsystemparameters.cpp deleted file mode 100644 index c12e9e3..0000000 --- a/lsystem3d/src/lsystemparameters.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2006 Erik Dahlberg -// -// This file is part of LSystem3d. -// -// LSystem3D 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. -// -// LSystem3D 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 for more details. -// -// You should have received a copy of the GNU General Public License -// along with LSystem3D; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - - - -#include -#include - -#include "lsystemparameters.h" - -using namespace std; - - - -/** - * Constructor - */ -LSystemParameters::LSystemParameters() -{ -} - - - -/** - * Destructor - */ -LSystemParameters::~LSystemParameters() -{ -} - - - -/** - * Load parameters from xml file - * @param lsystem put parameters into this l-system - * @param path path to xml file - */ -void LSystemParameters::load(LindenmayerSystem *lsystem, string path) -{ - if (lsystem) - { - try - { - // load - loadFromDisk(path); - - // axiom - findChild("axiom"); - lsystem->setAxiom(getString()); - - // rules - if (findChild("rule")) - { - do - { - lsystem->setRule(getAttribute("name"), getString()); - } while (findNextChild()); - } - - // angle - findChild("angle"); - lsystem->setAngle(getNumber()); - - // iterations - findChild("iterations"); - lsystem->setNumIterations((int)getNumber()); - } - catch (xmlpp::exception e) - { - cerr << "LSystemParameters::load(): " << e.what() << endl; - } - } - else - { - cerr << "invalid lsystem" << endl; - } -} - - - -/** - * Save parameters to xml file - * @param lsystem get parameters from this l-system - * @param path path to xml file - */ -void LSystemParameters::save(LindenmayerSystem *lsystem, string path) -{ - if (lsystem && !lsystem->getAxiom().empty() && !lsystem->getRules().empty()) - { - // new document with root node - createDocumentWithRoot("lsystem"); - - // axiom - addChildToRoot("axiom"); - addString(lsystem->getAxiom()); - - // rules - map rules = lsystem->getRules(); - map::iterator currentRule; - for (currentRule = rules.begin(); currentRule != rules.end(); currentRule++) - { - addChildToRoot("rule"); - addString(currentRule->second); - addAttribute("name", currentRule->first); - } - - // angle - addChildToRoot("angle"); - addNumber(lsystem->getAngle()); - - // iterations - addChildToRoot("iterations"); - addNumber(lsystem->getNumIterations()); - - // save - saveToDisk(path); - } - else - { - cerr << "invalid lsystem" << endl; - } -}