diff --git a/apps/trimeshinfo/ClassesNode.h b/apps/trimeshinfo/ClassesNode.h new file mode 100644 index 00000000..84f1faba --- /dev/null +++ b/apps/trimeshinfo/ClassesNode.h @@ -0,0 +1,108 @@ +#include +#include +#include +#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::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 "<::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 "<addOwnSlots(&cn->own_slots); + + +} + +void ClassesNode::printNode() +{ + cout<<"ClassesNode: Node type is "<::iterator it; + for(it = classn.Sons.begin(); it!=classn.Sons.end(); ++it) + (*it)->printNode(); + +} + +int ClassesNode::qualifyNode() +{return node_type;} + + + diff --git a/apps/trimeshinfo/InstancesNode.h b/apps/trimeshinfo/InstancesNode.h new file mode 100644 index 00000000..647e79c8 --- /dev/null +++ b/apps/trimeshinfo/InstancesNode.h @@ -0,0 +1,69 @@ + +#include +#include +#include +#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 "<addOwnSlots(&in->own_slots); + +} + +void InstancesNode::printNode() +{ + cout<<"InstancesNode: Node type is "<::iterator it; + for(it = instances.Sons.begin(); it!=instances.Sons.end(); ++it) + (*it)->printNode(); +} + +int InstancesNode::qualifyNode() +{return node_type;} diff --git a/apps/trimeshinfo/Node.h b/apps/trimeshinfo/Node.h new file mode 100644 index 00000000..f841d4b0 --- /dev/null +++ b/apps/trimeshinfo/Node.h @@ -0,0 +1,78 @@ + +#ifndef NODE_H +#define NODE_H +#include + + +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::iterator iterator; + list 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 \ No newline at end of file diff --git a/apps/trimeshinfo/SlotsNode.h b/apps/trimeshinfo/SlotsNode.h new file mode 100644 index 00000000..fecaefec --- /dev/null +++ b/apps/trimeshinfo/SlotsNode.h @@ -0,0 +1,150 @@ + +#include +#include +#include +#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 "<::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::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 "<::iterator it; + for(it = slot.Sons.begin(); it!=slot.Sons.end(); ++it) + (*it)->printNode(); +} + +int SlotsNode::qualifyNode() +{return node_type;} \ No newline at end of file diff --git a/apps/trimeshinfo/XMLTree.h b/apps/trimeshinfo/XMLTree.h new file mode 100644 index 00000000..a28b4f1d --- /dev/null +++ b/apps/trimeshinfo/XMLTree.h @@ -0,0 +1,340 @@ + +#include +#include +#include + +#include +#include +#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 > headers; + + void addHeaders(char* str, char*val); + virtual void printNode(); + virtual int qualifyNode(); +}; + +void MainNode::addHeaders(char* str, char*val) +{ + headers.push_back(pair(str,val)); +} +void MainNode::printNode() +{ + + cout<<"MainNode: node_type is "< >::iterator it; + for(it = headers.begin(); it!= headers.end(); ++it) + { + cout<<"MainNode: First element is "<< it->first<<"\n"; + cout<<"MainNode: Second element is "<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("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("/",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(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::iterator it; + list::iterator it2; + list::iterator it3; + list >::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," \n"); + + for(it2 = sns->slot.Sons.begin(); it2!=sns->slot.Sons.end(); ++it2) + { + sn = (SlotNode*) (*it2); + fprintf(fp,"\t"); + for(it3 = sn->own_slot.Sons.begin(); it3!=sn->own_slot.Sons.end(); ++it3) + { + osn = (OwnSlotNode*) (*it3); + fprintf(fp,"\n",osn->name); + fprintf(fp,"\t\t\n",osn->entry.type); + fprintf(fp,"\t\t\t\n"); + fprintf(fp,"\t\t\t%s\n",osn->entry.value.value); + fprintf(fp,"\t\t\t\n"); + fprintf(fp,"\t\t\n"); + fprintf(fp,"\t"); + } + fprintf(fp,"\n"); + } + fprintf(fp,"\n"); + + break; + case CLASSES_NODE: + csn = (ClassesNode*)(*it); + fprintf(fp," \n"); + + for(it2 = csn->classn.Sons.begin(); it2!=csn->classn.Sons.end(); ++it2) + { + cn = (ClassNode*) (*it2); + fprintf(fp,"\t"); + fprintf(fp,"\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\n",osn->name); + fprintf(fp,"\t\t\t\n",osn->entry.type); + fprintf(fp,"\t\t\t\t\n"); + fprintf(fp,"\t\t\t%s\n",osn->entry.value.value); + fprintf(fp,"\t\t\t\t\n"); + fprintf(fp,"\t\t\t\n"); + fprintf(fp,"\t\t\n"); + } + fprintf(fp,"\t\n"); + fprintf(fp,"\n"); + } + fprintf(fp,"\n"); + + break; + case INSTANCES_NODE: + isn = (InstancesNode*)(*it); + fprintf(fp," \n"); + + for(it2 = isn->instances.Sons.begin(); it2!=isn->instances.Sons.end(); ++it2) + { + in = (InstanceNode*) (*it2); + fprintf(fp,"\t\n"); + fprintf(fp,"\t\t\n"); + fprintf(fp,"\t\t%s\n", in->id); + fprintf(fp,"\t\t\n"); + fprintf(fp,"\t\t\n"); + fprintf(fp,"\t\t%s\n", in->type); + fprintf(fp,"\t\t\n"); + fprintf(fp,"\t\t\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\n",osn->name); + fprintf(fp,"\t\t\t\t\n",osn->entry.type); + fprintf(fp,"\t\t\t\t\n"); + fprintf(fp,"\t\t\t\t%s\n",osn->entry.value.value); + fprintf(fp,"\t\t\t\t\n"); + fprintf(fp,"\t\t\t\t\n"); + fprintf(fp,"\t\t\t\n"); + } + fprintf(fp,"\t\t\n"); + fprintf(fp,"\t\n"); + } + fprintf(fp,"\n"); + + break; + } + ++nn; + } + fclose(fp); +} \ No newline at end of file diff --git a/apps/trimeshinfo/trimeshinfo.cpp b/apps/trimeshinfo/trimeshinfo.cpp index 4d006a39..d913f683 100644 --- a/apps/trimeshinfo/trimeshinfo.cpp +++ b/apps/trimeshinfo/trimeshinfo.cpp @@ -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::SelfIntersections(m)) { diff --git a/apps/trimeshinfo/trimeshtype.h b/apps/trimeshinfo/trimeshtype.h new file mode 100644 index 00000000..c5326dbf --- /dev/null +++ b/apps/trimeshinfo/trimeshtype.h @@ -0,0 +1,18 @@ + +#ifndef _TRIMESHTYPE_H +#define _TRIMESHTYPE_H + +#include +#include + +using namespace std; +using namespace vcg; + +class CFace; +class CEdge; +class CVertex : public Vertex{}; +class CFace :public FaceAFAV{}; + +class CMesh: public tri::TriMesh< vector, vector >{}; + +#endif \ No newline at end of file