//---------------------------------------------------------------------------------------------------------------------- void CTRNN::fromXml(const ci::XmlTree& xml) { if(xml.getTag() == "CTRNN") { assert(xml.getAttributeValue<int>("Size") == size); ci::XmlTree::ConstIter neuron = xml.begin("Neuron"); for (; neuron != xml.end(); ++neuron) { const ci::XmlTree& n = *neuron; int i = n.getAttributeValue<int>("Index"); biases[i] = n.getAttributeValue<double>("Bias"); taus[i] = n.getAttributeValue<double>("TimeConstant"); gains[i] = n.getAttributeValue<double>("Gain"); ci::XmlTree::ConstIter weight = n.begin("Weight"); for (; weight != n.end(); ++weight) { int from = weight->getAttributeValue<int>("From"); double w = weight->getValue<double>(); weights[from][i] = w; } } } }
//---------------------------------------------------------------------------------------------------------------------- // Environment //---------------------------------------------------------------------------------------------------------------------- void SMCEnvironment::fromXml(const ci::XmlTree& xml) { for(ci::XmlTree::ConstIter elem = xml.begin(); elem != xml.end(); ++elem) { const ci::XmlTree& obj = *elem; ci::Vec2f pos = ci::Vec2f(obj["PosX"].as<float>(), obj["PosY"].as<float>()); if(obj.getTag() == "Line") { Line* l = new Line (pos, degreesToRadians(obj["Angle"].as<float>()), obj["Length"].as<float>()); m_objects.push_back(l); } else if (obj.getTag() == "Circle") { Circle* c = new Circle (pos, obj["Radius"].as<float>()); m_objects.push_back(c); } else if (obj.getTag() == "Torus") { Torus* t = new Torus (pos, obj["Radius"].as<float>(), obj["Width"].as<float>()); t->setPeak(obj.getAttributeValue<float>("Peak", 1.0f)); m_objects.push_back(t); } else if (obj.getTag() == "Gradient") { Gradient* c = new Gradient (pos, obj["Radius"].as<float>()); m_objects.push_back(c); } else if (obj.getTag() == "Triangle") { Triangle* t = new Triangle (pos, obj["Size"].as<float>()); m_objects.push_back(t); } else if (obj.getTag() == "Gaussian") { Gaussian* g = new Gaussian (pos, obj["Width"].as<float>(), obj["Height"].as<float>(), ci::Vec2f(obj["DirX"].as<float>(), obj["DirY"].as<float>())); m_objects.push_back(g); } else { // Not recognized as supported object continue; } bool visibility = obj.getAttributeValue<bool>("Visible", true); m_objects[m_objects.size() - 1]->setVisibility(visibility); float posVarX = obj.getAttributeValue<float>("PosVarX", 0.0); float posVarY = obj.getAttributeValue<float>("PosVarY", 0.0); m_objects[m_objects.size() - 1]->setPositionVariance(ci::Vec2f(posVarX, posVarY)); float angVar = degreesToRadians(obj.getAttributeValue<float>("AngleVar", 0.0)); m_objects[m_objects.size() - 1]->setAngleVariance(angVar); } }
void Pow::readXml(const ci::XmlTree& xml) { mExp = FloatParam(1.0); for (auto it=xml.begin(), end=xml.end(); it != end; ++it) { if (it->getTag() == "exp") { mExp.readXml(*it); mExp.mValue = it->getAttributeValue<double>("value", mExp.mValue); } } }
void ColorArray::readXml(const ci::XmlTree& xml) { mColor.clear(); for (auto it=xml.begin(), end=xml.end(); it != end; ++it) { if (it->getTag() == "color") { ci::ColorA clr; const std::string rgb = it->getAttributeValue<std::string>("rgb", ""); if (parse_color(rgb, clr)) { ColorParam cp(clr); cp.readXml(*it); mColor.push_back(cp); } } } }