Removed Debug option

This commit is contained in:
Paolo Cignoni 2005-11-04 15:37:58 +00:00
parent 9bc80c05ea
commit a1b8cb081c
7 changed files with 770 additions and 8 deletions

View File

@ -0,0 +1,108 @@
#include <utility>
#include <map>
#include <list>
#include "Node.h"
using namespace std;
class OwnSlotsNode: public Node
{
public:
OwnSlotsNode(void){node_type = OWNSLOTS_NODE;};
int node_type;
NodeGroup own_slot;
virtual void printNode();
virtual int qualifyNode();
void addOwnSlot(NodeGroup* ng);
void addOwnSlot(OwnSlotNode* os);
};
void OwnSlotsNode::addOwnSlot(NodeGroup* ng)
{
list<Node*>::iterator it;
for(it = ng->Sons.begin(); it!=ng->Sons.end(); ++it)
own_slot.addNode(*it);
}
void OwnSlotsNode::addOwnSlot(OwnSlotNode* os)
{
//OwnSlotNode* osn = new OwnSlotNode;
// own_slots.Sons.push_back(new OwnSlotNode);
own_slot.addNode(os);
}
void OwnSlotsNode::printNode()
{
cout<<"OwnSlotsNode: Node type is "<<node_type<<"\n";
list<Node*>::iterator it;
for(it = own_slot.Sons.begin(); it!=own_slot.Sons.end(); ++it)
(*it)->printNode();
}
int OwnSlotsNode::qualifyNode()
{return node_type;}
class ClassNode: public Node
{
public:
ClassNode(void){node_type = CLASS_NODE;};
int node_type;
OwnSlotsNode own_slots;
void addOwnSlots(OwnSlotsNode* own_slots);
virtual void printNode();
virtual int qualifyNode();
};
void ClassNode::addOwnSlots(OwnSlotsNode* sn)
{
own_slots.addOwnSlot(&sn->own_slot);
}
void ClassNode::printNode()
{
cout<<"ClassNode: Node type is "<<node_type<<"\n";
own_slots.printNode();
}
int ClassNode::qualifyNode()
{return node_type;}
class ClassesNode: public Node
{
public:
ClassesNode(void){node_type = CLASSES_NODE;};
int node_type;
NodeGroup classn;
void addClass(ClassNode* cn);
virtual void printNode();
virtual int qualifyNode();
};
void ClassesNode::addClass(ClassNode* cn)
{
classn.Sons.push_back(new ClassNode);
ClassNode* clp = (ClassNode*) classn.Sons.front();
clp->addOwnSlots(&cn->own_slots);
}
void ClassesNode::printNode()
{
cout<<"ClassesNode: Node type is "<<node_type<<"\n";
list<Node*>::iterator it;
for(it = classn.Sons.begin(); it!=classn.Sons.end(); ++it)
(*it)->printNode();
}
int ClassesNode::qualifyNode()
{return node_type;}

View File

@ -0,0 +1,69 @@
#include <utility>
#include <map>
#include <list>
#include "Node.h"
class InstanceNode: public Node
{
public:
InstanceNode(void){node_type = INSTANCE_NODE; id = "empty"; type= "empty";};
char* id;
char* type;
int node_type;
OwnSlotsNode own_slots;
void addOwnSlots(OwnSlotsNode* own_slots);
virtual void printNode();
virtual int qualifyNode();
};
void InstanceNode::addOwnSlots(OwnSlotsNode* sn)
{
own_slots.addOwnSlot(&sn->own_slot);
}
void InstanceNode::printNode()
{
cout<<"InstanceNode: Node node_type is "<<node_type<<"\n";
cout<<"InstanceNode: Node type is "<<type<<"\n";
cout<<"InstanceNode: Node id is "<<id<<"\n";
own_slots.printNode();
}
int InstanceNode::qualifyNode()
{return node_type;}
class InstancesNode: public Node
{
public:
InstancesNode(void){node_type = INSTANCES_NODE;};
int node_type;
NodeGroup instances;
void addInstance(InstanceNode* in);
virtual void printNode();
virtual int qualifyNode();
};
void InstancesNode::addInstance(InstanceNode* in)
{
instances.Sons.push_back(new InstanceNode);
InstanceNode* ilp = (InstanceNode*) instances.Sons.front();
ilp->addOwnSlots(&in->own_slots);
}
void InstancesNode::printNode()
{
cout<<"InstancesNode: Node type is "<<node_type<<"\n";
list<Node*>::iterator it;
for(it = instances.Sons.begin(); it!=instances.Sons.end(); ++it)
(*it)->printNode();
}
int InstancesNode::qualifyNode()
{return node_type;}

78
apps/trimeshinfo/Node.h Normal file
View File

@ -0,0 +1,78 @@
#ifndef NODE_H
#define NODE_H
#include <list>
using namespace std;
class Node
{
public:
//int node_type;
virtual ~Node(void){};
virtual void printNode()=0;
virtual int qualifyNode()=0;
};
class NodeGroup :public Node
{
public:
virtual ~NodeGroup();
typedef list<Node *>::iterator iterator;
list<Node *> Sons;
virtual void addNode(Node* nd);
virtual void printNode();
virtual int qualifyNode();
};
NodeGroup::~NodeGroup() //distruttore: disalloca tutti i figli
{
//for(iterator i=Sons.begin();i!=Sons.end();++i)
// delete (*i);
}
void NodeGroup::addNode(Node* nd)
{
Sons.push_back(nd);
}
void NodeGroup::printNode()
{}
int NodeGroup::qualifyNode()
{return 0;}
const int MAIN_NODE= 0;
const int SLOTS_NODE= 1;
const int SLOT_NODE= 2;
const int OWNSLOT_NODE= 3;
const int ENTRY_NODE= 4;
const int VALUE_NODE= 5;
const int CLASSES_NODE= 6;
const int CLASS_NODE= 7;
const int OWNSLOTS_NODE= 8;
const int INSTANCES_NODE= 9;
const int INSTANCE_NODE= 10;
enum values {VALUE_INTEGER, VALUE_FLOAT, VALUE_BOOL, VALUE_STRING};
//#define MAIN_NODE 0;
//#define SLOTS_NODE 1;
//#define SLOT_NODE 2;
//#define OWNSLOT_NODE 3;
//#define ENTRY_NODE 4;
//#define VALUE_NODE 5;
//
//#define CLASSES_NODE 6;
//#define CLASS_NODE 7;
//#define OWNSLOTS_NODE 8;
//
//#define INSTANCES_NODE 9;
//#define INSTANCE_NODE 10;
#endif

View File

@ -0,0 +1,150 @@
#include <utility>
#include <map>
#include <list>
#include "Node.h"
using namespace std;
class ValueNode: public Node
{
public:
ValueNode(void){node_type = VALUE_NODE;value = "empty";};
int node_type;
const char* value; //tra due tag
virtual void printNode();
virtual int qualifyNode();
void setValue(ValueNode vn){value = vn.value;};
void setValue(const char* cvn){value = cvn;};
};
void ValueNode::printNode()
{
cout<<"ValueNode: Node type is "<<node_type<<"\n";
cout<<"ValueNode: Node value is "<<value<<"\n";
}
int ValueNode::qualifyNode()
{return node_type;}
class EntryNode: public Node
{
public:
EntryNode(void){node_type = ENTRY_NODE; type = "empty";};
int node_type;
char* type;
ValueNode value;
void addValue(ValueNode vn);
void setEntry(EntryNode en);
virtual void printNode();
virtual int qualifyNode();
};
void EntryNode::addValue(ValueNode vn)
{
value.setValue(vn);
}
void EntryNode::setEntry(EntryNode en)
{
type = en.type;
addValue(en.value);
}
void EntryNode::printNode()
{
cout<<"EntryNode: Node type is "<<node_type<<"\n";
cout<<"EntryNode: Node attr. type is "<<type<<"\n";
value.printNode();
}
int EntryNode::qualifyNode()
{return node_type;}
class OwnSlotNode: public Node
{
public:
OwnSlotNode(void){node_type = OWNSLOT_NODE; name = "empty";};
int node_type;
char* name;
EntryNode entry;
virtual void printNode();
virtual int qualifyNode();
void addEntry(EntryNode en);
void setName(char* s){name = s;};
};
void OwnSlotNode::printNode()
{
cout<<"OwnSlotNode: Node type is "<<node_type<<"\n";
cout<<"OwnSlotNode: Node name is "<<name<<"\n";
entry.printNode();
}
int OwnSlotNode::qualifyNode()
{return node_type;}
void OwnSlotNode::addEntry(EntryNode en)
{
entry.setEntry(en);
}
class SlotNode: public Node
{
public:
SlotNode(void){node_type = SLOT_NODE;};
int node_type;
NodeGroup own_slot;
virtual void printNode();
virtual int qualifyNode();
void addOwnSlot(OwnSlotNode* os);
};
void SlotNode::addOwnSlot(OwnSlotNode* os)
{
//OwnSlotNode* osn = new OwnSlotNode;
// own_slots.Sons.push_back(new OwnSlotNode);
own_slot.addNode(os);
}
void SlotNode::printNode()
{
cout<<"SlotNode: Node type is "<<node_type<<"\n";
list<Node*>::iterator it;
for(it = own_slot.Sons.begin(); it!=own_slot.Sons.end(); ++it)
(*it)->printNode();
}
int SlotNode::qualifyNode()
{return node_type;}
class SlotsNode: public Node
{
public:
SlotsNode(void){node_type = SLOTS_NODE;};
int node_type;
NodeGroup slot;
void addSlot(SlotNode* sn);
virtual void printNode();
virtual int qualifyNode();
};
void SlotsNode::addSlot(SlotNode* sn)
{
slot.Sons.push_back(new SlotNode);
SlotNode* slp = (SlotNode*) slot.Sons.front();
list<Node*>::iterator it;
for(it = sn->own_slot.Sons.begin(); it!=sn->own_slot.Sons.end(); ++it)
slp->addOwnSlot(((OwnSlotNode*)(*it)));
}
void SlotsNode::printNode()
{
cout<<"SlotsNode: Node type is "<<node_type<<"\n";
list<Node*>::iterator it;
for(it = slot.Sons.begin(); it!=slot.Sons.end(); ++it)
(*it)->printNode();
}
int SlotsNode::qualifyNode()
{return node_type;}

340
apps/trimeshinfo/XMLTree.h Normal file
View File

@ -0,0 +1,340 @@
#include <utility>
#include <map>
#include <list>
#include <string>
#include <iostream>
#include "SlotsNode.h"
#include "ClassesNode.h"
#include "InstancesNode.h"
using namespace std;
static char* XML_SCHEMA_NAME = "protegekb";
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;
NodeGroup ng;
SlotNode sn;
// methods
void initializeMain();
void finalizeMain();
void addHeaders(char* str, char*val);
void addSlots(SlotNode* sn);
// void addFacets();
void addClasses(ClassNode* cn);
void addInstances(InstanceNode* in);
void addNode(char* s, int value_type, char* name);
void printXMLTree();
};
void XMLTree::initializeMain()
{
MainNode* mn = new MainNode;
//NodeGroup* ng = new NodeGroup;
mn->headers.push_back(pair<char*,char*>("protegekb",""));
char* s1 = "http://www.w3.org/2001/XMLSchema-instance";
char* s2 = new(char[25]);
sprintf(s2,"\"%s\"",s1);
mn->addHeaders(" xmlns:xsi=", s2);
s1 = "http://protege.stanford.edu/plugins/xmlbackend/protege_xml_backend.xsd";
s2 = new(char[100]);
sprintf(s2,"\"%s\"",s1);
mn->addHeaders(" xsi:noNamespaceSchemaLocation=", s2);
mn->addHeaders(" xmlns:xsi=", s2);
root.Sons.push_back(mn);
}
void XMLTree::finalizeMain()
{
addSlots(&sn);
OwnSlotsNode* ossn = new OwnSlotsNode;
ossn->addOwnSlot(&ng);
ClassNode* cn = new ClassNode;
cn->addOwnSlots(ossn);
addClasses(cn);
InstanceNode* in = new InstanceNode;
in->addOwnSlots(ossn);
addInstances(in);
MainNode* mn = new MainNode;
mn->headers.push_back(pair<char*,char*>("/",XML_SCHEMA_NAME));
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::addNode(char* s, int value_type, char* name)
{
ValueNode* vn = new ValueNode;
EntryNode* en = new EntryNode;
OwnSlotNode* osn = new OwnSlotNode;
switch(value_type)
{
case VALUE_INTEGER:
en->type = "Integer";
break;
case VALUE_FLOAT:
en->type = "Float";
case VALUE_BOOL:
en->type = "Bool";
break;
case VALUE_STRING:
en->type = "String";
break;
}
vn->setValue(s);
en->addValue(*vn);
osn->setName(name);
osn->addEntry(*en);
sn.addOwnSlot(osn);
ng.addNode(osn);
}
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<<"\t Preparing to create XML file"<<"\n";
cout<<"\t enter the name for the file \n \t ";
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);
}

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.8 2005/10/11 16:03:40 rita_borgo
Moved all the main functions inside clean.h
Revision 1.7 2005/09/30 15:48:46 rita_borgo
Fixed manifold Test
@ -136,7 +139,6 @@ typedef CMesh::ScalarType ScalarType;
void main(int argc,char ** argv)
{
CMesh m;
bool DEBUG=true;
XMLTree doc;
@ -155,19 +157,15 @@ void main(int argc,char ** argv)
if(DEBUG)
// argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\tests\\kite_hole3.ply";
argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\modelli\\grog50k.ply";
else
{
// load input meshes.
if(argc <= 1)
{
printf(MSG_ERR_N_ARGS);
exit(-1);
}
}
@ -488,6 +486,7 @@ void main(int argc,char ** argv)
// SELF INTERSECTION
printf("\t Model Bounding Box Diagonal: %f\n", m.bbox.Diag());
if (tri::Clean<CMesh>::SelfIntersections(m))
{

View File

@ -0,0 +1,18 @@
#ifndef _TRIMESHTYPE_H
#define _TRIMESHTYPE_H
#include<vcg/simplex/vertex/vertex.h>
#include<vcg/simplex/face/with/afav.h>
using namespace std;
using namespace vcg;
class CFace;
class CEdge;
class CVertex : public Vertex<float,CEdge,CFace>{};
class CFace :public FaceAFAV<CVertex,CEdge,CFace>{};
class CMesh: public tri::TriMesh< vector<CVertex>, vector<CFace > >{};
#endif