Remove duplicated XMLTree (and defs.h)
This commit is contained in:
parent
009f633576
commit
1c336dd097
|
|
@ -1,269 +0,0 @@
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <map>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include "SlotsNode.h"
|
|
||||||
#include "ClassesNode.h"
|
|
||||||
#include "InstancesNode.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FacetNode: public Node
|
|
||||||
{
|
|
||||||
virtual void printNode();
|
|
||||||
virtual int qualifyNode();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FacetsNode: public Node
|
|
||||||
{
|
|
||||||
NodeGroup facets;
|
|
||||||
virtual void printNode();
|
|
||||||
virtual int qualifyNode();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MainNode: public Node
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
MainNode(void){node_type = MAIN_NODE;};
|
|
||||||
int node_type;
|
|
||||||
list<pair<char*,char*> > headers;
|
|
||||||
|
|
||||||
void addHeaders(char* str, char*val);
|
|
||||||
virtual void printNode();
|
|
||||||
virtual int qualifyNode();
|
|
||||||
};
|
|
||||||
|
|
||||||
void MainNode::addHeaders(char* str, char*val)
|
|
||||||
{
|
|
||||||
headers.push_back(pair<char*,char*>(str,val));
|
|
||||||
}
|
|
||||||
void MainNode::printNode()
|
|
||||||
{
|
|
||||||
|
|
||||||
cout<<"MainNode: node_type is "<<node_type<<"\n";
|
|
||||||
list<pair<char*,char*> >::iterator it;
|
|
||||||
for(it = headers.begin(); it!= headers.end(); ++it)
|
|
||||||
{
|
|
||||||
cout<<"MainNode: First element is "<< it->first<<"\n";
|
|
||||||
cout<<"MainNode: Second element is "<<it->second<<"\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int MainNode::qualifyNode()
|
|
||||||
{return node_type;}
|
|
||||||
|
|
||||||
|
|
||||||
class XMLTree
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
XMLTree(void){};
|
|
||||||
~XMLTree(void){};
|
|
||||||
NodeGroup root;
|
|
||||||
|
|
||||||
|
|
||||||
// methods
|
|
||||||
void initializeMain(char* xsn);
|
|
||||||
void finalizeMain(char* xsn, char* val);
|
|
||||||
void addHeaders(char* str, char*val);
|
|
||||||
|
|
||||||
void addSlots(SlotNode* sn);
|
|
||||||
// void addFacets();
|
|
||||||
void addClasses(ClassNode* cn);
|
|
||||||
void addInstances(InstanceNode* in);
|
|
||||||
void printXMLTree();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void XMLTree::initializeMain(char* xsn)
|
|
||||||
{
|
|
||||||
MainNode* mn = new MainNode;
|
|
||||||
|
|
||||||
mn->headers.push_back(pair<char*,char*>(xsn,""));
|
|
||||||
root.Sons.push_back(mn);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void XMLTree::finalizeMain(char* xsn, char* val)
|
|
||||||
{
|
|
||||||
MainNode* mn = new MainNode;
|
|
||||||
|
|
||||||
mn->headers.push_back(pair<char*,char*>(xsn,val));
|
|
||||||
root.Sons.push_back(mn);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void XMLTree::addHeaders(char* str, char*val)
|
|
||||||
{
|
|
||||||
MainNode* mn = (MainNode*) root.Sons.front();
|
|
||||||
mn->headers.push_back(pair<char*,char*>(str,val));
|
|
||||||
}
|
|
||||||
|
|
||||||
void XMLTree::addSlots(SlotNode* sn)
|
|
||||||
{
|
|
||||||
SlotsNode* sn0 = new SlotsNode; // 1 solo
|
|
||||||
|
|
||||||
sn0->addSlot(sn);
|
|
||||||
root.Sons.push_back(sn0);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void XMLTree::addClasses(ClassNode* cn)
|
|
||||||
{
|
|
||||||
ClassesNode* cn0 = new ClassesNode; // 1 solo
|
|
||||||
|
|
||||||
cn0->addClass(cn);
|
|
||||||
root.Sons.push_back(cn0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XMLTree::addInstances(InstanceNode* in)
|
|
||||||
{
|
|
||||||
InstancesNode* in0 = new InstancesNode; // 1 solo
|
|
||||||
|
|
||||||
in0->addInstance(in);
|
|
||||||
root.Sons.push_back(in0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XMLTree::printXMLTree()
|
|
||||||
{
|
|
||||||
string ext,s("XMLFile");
|
|
||||||
cout<<"Preparing to create XML file"<<"\n";
|
|
||||||
cout<<"enter the name of the file "<< endl;
|
|
||||||
cin >> ext;
|
|
||||||
|
|
||||||
|
|
||||||
s.append(ext);
|
|
||||||
s.append(".xml");
|
|
||||||
|
|
||||||
const char* filename = s.c_str();
|
|
||||||
FILE* fp = fopen(filename, "w");
|
|
||||||
|
|
||||||
list<Node*>::iterator it;
|
|
||||||
list<Node*>::iterator it2;
|
|
||||||
list<Node*>::iterator it3;
|
|
||||||
list<pair<char*,char*> >::iterator lit;
|
|
||||||
MainNode* mn;
|
|
||||||
SlotsNode* sns;
|
|
||||||
SlotNode* sn;
|
|
||||||
OwnSlotNode* osn;
|
|
||||||
ClassesNode* csn;
|
|
||||||
ClassNode* cn;
|
|
||||||
InstancesNode* isn;
|
|
||||||
InstanceNode* in;
|
|
||||||
int nn = 0;
|
|
||||||
for(it = root.Sons.begin(); it!=root.Sons.end(); ++it){
|
|
||||||
cout<<"Creating Node #"<< nn<<"\n";
|
|
||||||
cout<<"Node Type is "<< (*it)->qualifyNode()<<"\n";
|
|
||||||
switch((*it)->qualifyNode())
|
|
||||||
{
|
|
||||||
case MAIN_NODE:
|
|
||||||
mn = (MainNode*)(*it);
|
|
||||||
fprintf(fp,"<");
|
|
||||||
for(lit = mn->headers.begin(); lit!= mn->headers.end(); ++lit)
|
|
||||||
fprintf(fp,"%s%s", lit->first,lit->second );
|
|
||||||
fprintf(fp,"> \n");
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SLOTS_NODE:
|
|
||||||
sns = (SlotsNode*)(*it);
|
|
||||||
fprintf(fp,"<slots> \n");
|
|
||||||
|
|
||||||
for(it2 = sns->slot.Sons.begin(); it2!=sns->slot.Sons.end(); ++it2)
|
|
||||||
{
|
|
||||||
sn = (SlotNode*) (*it2);
|
|
||||||
fprintf(fp,"\t<slot>");
|
|
||||||
for(it3 = sn->own_slot.Sons.begin(); it3!=sn->own_slot.Sons.end(); ++it3)
|
|
||||||
{
|
|
||||||
osn = (OwnSlotNode*) (*it3);
|
|
||||||
fprintf(fp,"<own-slot slot-name=\":%s\">\n",osn->name);
|
|
||||||
fprintf(fp,"\t\t<entry type=\"%s\">\n",osn->entry.type);
|
|
||||||
fprintf(fp,"\t\t\t<value>\n");
|
|
||||||
fprintf(fp,"\t\t\t%s\n",osn->entry.value.value);
|
|
||||||
fprintf(fp,"\t\t\t</value>\n");
|
|
||||||
fprintf(fp,"\t\t</entry>\n");
|
|
||||||
fprintf(fp,"\t</own-slot>");
|
|
||||||
}
|
|
||||||
fprintf(fp,"</slot>\n");
|
|
||||||
}
|
|
||||||
fprintf(fp,"</slots>\n");
|
|
||||||
|
|
||||||
break;
|
|
||||||
case CLASSES_NODE:
|
|
||||||
csn = (ClassesNode*)(*it);
|
|
||||||
fprintf(fp,"<classes> \n");
|
|
||||||
|
|
||||||
for(it2 = csn->classn.Sons.begin(); it2!=csn->classn.Sons.end(); ++it2)
|
|
||||||
{
|
|
||||||
cn = (ClassNode*) (*it2);
|
|
||||||
fprintf(fp,"\t<class>");
|
|
||||||
fprintf(fp,"<own-slots>\n");
|
|
||||||
for(it3 = cn->own_slots.own_slot.Sons.begin(); it3!=cn->own_slots.own_slot.Sons.end(); ++it3)
|
|
||||||
{
|
|
||||||
osn = (OwnSlotNode*) (*it3);
|
|
||||||
fprintf(fp,"\t\t<own-slot slot-name=\":%s\">\n",osn->name);
|
|
||||||
fprintf(fp,"\t\t\t<entry type=\"%s\">\n",osn->entry.type);
|
|
||||||
fprintf(fp,"\t\t\t\t<value>\n");
|
|
||||||
fprintf(fp,"\t\t\t%s\n",osn->entry.value.value);
|
|
||||||
fprintf(fp,"\t\t\t\t</value>\n");
|
|
||||||
fprintf(fp,"\t\t\t</entry>\n");
|
|
||||||
fprintf(fp,"\t\t</own-slot>\n");
|
|
||||||
}
|
|
||||||
fprintf(fp,"\t</own-slots>\n");
|
|
||||||
fprintf(fp,"</class>\n");
|
|
||||||
}
|
|
||||||
fprintf(fp,"</classes>\n");
|
|
||||||
|
|
||||||
break;
|
|
||||||
case INSTANCES_NODE:
|
|
||||||
isn = (InstancesNode*)(*it);
|
|
||||||
fprintf(fp,"<instances> \n");
|
|
||||||
|
|
||||||
for(it2 = isn->instances.Sons.begin(); it2!=isn->instances.Sons.end(); ++it2)
|
|
||||||
{
|
|
||||||
in = (InstanceNode*) (*it2);
|
|
||||||
fprintf(fp,"\t<instance>\n");
|
|
||||||
fprintf(fp,"\t\t<id>\n");
|
|
||||||
fprintf(fp,"\t\t%s\n", in->id);
|
|
||||||
fprintf(fp,"\t\t</id>\n");
|
|
||||||
fprintf(fp,"\t\t<type>\n");
|
|
||||||
fprintf(fp,"\t\t%s\n", in->type);
|
|
||||||
fprintf(fp,"\t\t</type>\n");
|
|
||||||
fprintf(fp,"\t\t<own-slots>\n");
|
|
||||||
for(it3 = in->own_slots.own_slot.Sons.begin(); it3!=in->own_slots.own_slot.Sons.end(); ++it3)
|
|
||||||
{
|
|
||||||
osn = (OwnSlotNode*) (*it3);
|
|
||||||
fprintf(fp,"\t\t\t<own-slot slot-name=\":%s\">\n",osn->name);
|
|
||||||
fprintf(fp,"\t\t\t\t<entry type=\"%s\">\n",osn->entry.type);
|
|
||||||
fprintf(fp,"\t\t\t\t<value>\n");
|
|
||||||
fprintf(fp,"\t\t\t\t%s\n",osn->entry.value.value);
|
|
||||||
fprintf(fp,"\t\t\t\t</value>\n");
|
|
||||||
fprintf(fp,"\t\t\t\t</entry>\n");
|
|
||||||
fprintf(fp,"\t\t\t</own-slot>\n");
|
|
||||||
}
|
|
||||||
fprintf(fp,"\t\t</own-slots>\n");
|
|
||||||
fprintf(fp,"\t</instance>\n");
|
|
||||||
}
|
|
||||||
fprintf(fp,"</instances>\n");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++nn;
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
// -----------------------------------------------------------------------------------------------
|
|
||||||
#ifndef _DEFS_H
|
|
||||||
#define _DEFS_H
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// command line parameters
|
|
||||||
#define CMD_LINE_ARG_HIST 'H'
|
|
||||||
#define CMD_LINE_ARG_VERTEX_SAMPLE 'V'
|
|
||||||
#define CMD_LINE_ARG_EDGE_SAMPLE 'E'
|
|
||||||
#define CMD_LINE_ARG_FACE_SAMPLE 'F'
|
|
||||||
#define CMD_LINE_ARG_SAMPLE_TYPE 'S'
|
|
||||||
#define CMD_LINE_ARG_MONTECARLO_SAMPLING 'M'
|
|
||||||
#define CMD_LINE_ARG_SUBDIVISION_SAMPLING 'S'
|
|
||||||
#define CMD_LINE_ARG_SIMILAR_TRIANGLES_SAMPLING 'T'
|
|
||||||
#define CMD_LINE_ARG_N_SAMPLES 'N'
|
|
||||||
#define CMD_LINE_ARG_SAMPLES_PER_AREA_UNIT 'A'
|
|
||||||
#define CMD_LINE_ARG_SAVE_DISPLACEMENT 'O'
|
|
||||||
#define CMD_LINE_ARG_SAVE_ERROR_AS_COLOUR 'C'
|
|
||||||
|
|
||||||
|
|
||||||
// error messages
|
|
||||||
#define MSG_ERR_N_ARGS "\nUsage: "\
|
|
||||||
"trimeshinfo filename \n"
|
|
||||||
|
|
||||||
#define MSG_ERR_MESH_LOAD "error loading the input meshes.\n"
|
|
||||||
#define MSG_ERR_INVALID_OPTION "unable to parse option '%s'\n"
|
|
||||||
#define MSG_ERR_FILE_OPEN "unable to open the output file.'n"
|
|
||||||
#define MSG_ERR_UNKNOWN_FORMAT "unknown file format '%s'.\n"
|
|
||||||
|
|
||||||
// global constants
|
|
||||||
#define NO_SAMPLES_PER_FACE 10
|
|
||||||
#define N_SAMPLES_EDGE_TO_FACE_RATIO 0.1
|
|
||||||
#define BBOX_FACTOR 0.1
|
|
||||||
#define INFLATE_PERCENTAGE 0.02
|
|
||||||
#define MIN_SIZE 125 /* 125 = 5^3 */
|
|
||||||
#define N_HIST_BINS 256
|
|
||||||
#define PRINT_EVERY_N_ELEMENTS 1000
|
|
||||||
#define FILE_EXT_SMF "smf"
|
|
||||||
#define FILE_EXT_PLY "ply"
|
|
||||||
|
|
||||||
// strings
|
|
||||||
#define STR_HIST_FILENAME_DEFAULT "hist.txt"
|
|
||||||
#define STR_NEW_MESH_FILENAME_DEFAULT "error.ply"
|
|
||||||
#define STR_NEW_MESH_FILENAME_DEFAULT_2 "error_colour.ply"
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
|
||||||
#endif
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
|
||||||
Loading…
Reference in New Issue