+#include <cstdlib>
+
#include <iostream>
#include <string>
-#include <glibmm/stringutils.h>
-
#include "lsystemparameters.h"
#include "rule.h"
#include "ruleset.h"
{
if (lsystem)
{
+ lsystem->clear();
+
try
{
// load
// construct the rule
string name = getAttribute("name");
string content = getString();
- double probability = Glib::Ascii::strtod(getAttribute("probability"));
+ double probability = strtod(getAttribute("probability").c_str(), NULL);
Rule completeRule(name, content, probability);
lsystem->setRule(completeRule);
// depth
findChild("depth");
lsystem->setDepth((int)getNumber());
+
+ // initial segment diameter
+ findChild("diameter");
+ lsystem->setDiameter(getNumber());
+
+ // segment diameter factor
+ double diameterFactor = strtod(getAttribute("factor").c_str(), NULL);
+ lsystem->setDiameterFactor(diameterFactor);
+
}
catch (xmlpp::exception e)
{
addString(it->second.getContent());
addAttribute("name", it->second.getName());
-
- string probabilityString = Glib::Ascii::dtostr(it->second.getProbability());
+
+ string probabilityString = doubleToString(it->second.getProbability());
addAttribute("probability", probabilityString);
}
addChildToRoot("depth");
addNumber(lsystem->getDepth());
+ // initial segment diameter
+ addChildToRoot("diameter");
+ addNumber(lsystem->getDiameter());
+
+ // segment diameter factor
+ string diameterFactor = doubleToString(lsystem->getDiameterFactor());
+ addAttribute("factor", diameterFactor);
+
// save
saveToDisk(path);
}