本文整理汇总了C++中ofXml::setToSibling方法的典型用法代码示例。如果您正苦于以下问题:C++ ofXml::setToSibling方法的具体用法?C++ ofXml::setToSibling怎么用?C++ ofXml::setToSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofXml
的用法示例。
在下文中一共展示了ofXml::setToSibling方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupFromXml
void setupFromXml(string filename) {
size = ofVec2f(ofGetWidth(), ofGetHeight());
if (xml.load(filename)) {
xml.setTo("STAR[0]");
do {
xml.setTo("POSITION");
int x = xml.getValue<float>("X");
int y = xml.getValue<float>("Y");
xml.setToParent();
int m = xml.getValue<int>("MAGNITUDE");
int id = xml.getValue<int>("ID");
BPStar s;
s.setPosition(x, y);
s.setMagnitude(m);
s.setId(id);
stars.push_back(s);
}while( xml.setToSibling() ); // go to next STAR
} else {
}
shader.load("","SkyShader.frag");
skyShader.setup();
}
示例2: addClass
void KinectV2Classifier::setFromLearnXml(ofXml &xml)
{
xml.setTo("LearnInfo");
if (xml.exists("Classes")) {
xml.setTo("Classes");
if (xml.exists("Class[0]"))
{
xml.setTo("Class[0]");
do {
addClass(xml.getValue<string>("Name"));
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
}
if (xml.exists("Ranges")) {
xml.setTo("Ranges");
if (xml.exists("Joint[0]"))
{
int idx = 0;
xml.setTo("Joint[0]");
do {
min[idx] = xml.getValue<float>("Min");
max[idx] = xml.getValue<float>("Max");
idx++;
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
}
if (xml.exists("Training")) {
xml.setTo("Training");
if (xml.exists("Entry[0]"))
{
xml.setTo("Entry[0]");
do {
double label = xml.getValue<double>("Label");
vector<string> featureVectorS = ofSplitString(xml.getValue<string>("Features"), ",");
vector<float> entry;
entry.push_back(label);
for (auto f : featureVectorS) {
entry.push_back(ofToFloat(f));
}
data.addEntry(entry);
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
}
if (xml.exists("Model")) {
xml.setTo("Model");
string path = xml.getValue<string>("Path");
svm.loadModel(path);
trained = true;
xml.setToParent();
}
xml.setToParent();
}
示例3: buildFromXml
//.........这里部分代码省略.........
ofShader *shader = new ofShader();
stringstream shader_path;
shader_path<<ofToDataPath("../../src/shader/")<<shader_name;
shader->load(shader_path.str());
if(!shader->isLoaded()){
cout<<"ofxShaderGraph warning: shader "<<shader_name<<" failed to load from path "<<shader_path.str()<<endl;
}
else{
cout<<"ofxShaderGraph: loaded shader "<<shader_name<<endl;
}
node = new ofxBaseShaderNode(allocator, node_fbo_settings, name, shader);
}
//grab all of the new node's parameters
params.add(node->getParameterGroup());
//put it in the map from names to nodes
nodes.insert(pair<string, ofxBaseShaderNode*>(name, node));
//everything goes in root_names, to be removed when is appears as an input
root_names.insert(name);
cout<<"ofxShaderGraph: inserted node "<<name<<endl;
//set defaults
if(x.setTo("defaults") && x.setToChild(0)){
do{
string param_type = x.getName();
string param_name = x.getAttribute("name");
if(param_type=="float"){
float v = x.getFloatValue();
node->setParameter(param_name, v);
}else if(param_type=="int"){
int v = x.getIntValue();
node->setParameter(param_name, v);
}else{
cout<<"ofxShaderGraph warning: parameter type "<<param_type<<" unsupported"<<endl;
}
}while(x.setToSibling());
x.setToParent();
x.setToParent();
}
//set aliases
/*if(x.setTo("aliases") && x.setToChild(0)){
do{
string param_type = x.getName();
string param_name = x.getAttribute("name");
string alias_name = x.getValue();
if(param_type=="float"){
auto alias_param = aliases.getFloat(alias_name);
node->setParameterAlias(param_name, alias_param);
}else if(param_type=="int"){
auto alias_param = aliases.getInt(alias_name);
node->setParameterAlias(param_name, alias_param);
}else{
cout<<"ofxShaderGraph warning: aliased parameter type "<<param_type<<" unsupported"<<endl;
}
}while(x.setToSibling());
x.setToParent();
x.setToParent();
}*/
}
//second pass, fill in inputs for each node and remove all referenced nodes from root_names
for(unsigned long i=0; i<n; i++){
x.reset();
x.setToChild(i);
if(x.getName()!="node")
continue;
string name = x.getAttribute("name");
if(name=="")
continue;
ofxBaseShaderNode *node = nodes[name];
//set inputs
if(!x.setTo("inputs"))
continue;
if(!x.setToChild(0))
continue;
do{
string input_name = x.getValue();
if(nodes.find(input_name) == nodes.end()){
cout << "ofxShaderGraph error: node "<<name<<" lists input "<<input_name<<" which does not exist"<<endl;
}
else{
ofxBaseShaderNode *input = nodes.at(input_name);
node->inputs.push_back(input);
input->num_dependents++;
root_names.erase(input_name);
cout<<"ofxShaderGraph: connected node "<<input_name<<" to node "<<name<<endl;
}
}while(x.setToSibling());
}
//populate roots
for(string root_name:root_names){
ofxBaseShaderNode *root_node = nodes.at(root_name);
roots.insert(root_node);
cout<<"ofxShaderGraph: node "<<root_name<<" is a root"<<endl;
}
}