Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

functions::Exporter Class Reference
[Functions]

#include <Exporter.h>

List of all members.

Public Member Functions

 Exporter ()
 ~Exporter ()
void exportModel (ExampleModel *model, const char *filename)
void exportModel (ReferenceModel *model, const char *filename)


Detailed Description

Write brief comment for Exporter here.

Write detailed description for Exporter here.

Remarks:
Write remarks for Exporter here.
See also:
Separate items with the '|' character.

Definition at line 48 of file Exporter.h.


Constructor & Destructor Documentation

Exporter::Exporter  ) 
 

Definition at line 9 of file Exporter.cpp.

00009                    {
00010 
00011 }

functions::Exporter::~Exporter  )  [inline]
 

Write brief comment for ~Exporter here.

Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for ~Exporter here.

Remarks:
Write remarks for ~Exporter here.
See also:
Separate items with the '|' character.

Definition at line 65 of file Exporter.h.

00065 {};


Member Function Documentation

void Exporter::exportModel ReferenceModel model,
const char *  filename
 

Write brief comment for exportModel here.

Parameters:
model Description of parameter model.
filename Description of parameter filename.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for exportModel here.

Remarks:
Write remarks for exportModel here.
See also:
Separate items with the '|' character.

Definition at line 33 of file Exporter.cpp.

References exportModel(), and log::write().

00033                                                                       {
00034   log::write("Exporter::exportModel");
00035   log::write("exportModel-ref",*model);
00036   exportModel((ExampleModel*) model, filename);
00037 }

Here is the call graph for this function:

void Exporter::exportModel ExampleModel model,
const char *  filename
 

Write brief comment for exportModel here.

Parameters:
model Description of parameter model.
filename Description of parameter filename.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for exportModel here.

Remarks:
Write remarks for exportModel here.
See also:
Separate items with the '|' character.

Definition at line 59 of file Exporter.cpp.

References model::Model::getFaces(), model::Model::getVertexs(), and log::write().

Referenced by pcggui::ExportAll(), exportModel(), and Batch::ExportModels().

00059                                                                     {
00060         log::write("exportModel-Ex",*model);
00061         //Make data
00062         string coordIndex = "";
00063         string normalIndex = "";
00064         string points = "";
00065         string vectors = "";
00066         char tmp[100];
00067         log::write("Exporter get faces");
00068         vector<Face*> faces = model->getFaces();
00069         for(int i=0; i<(int)faces.size(); i++) {
00070                 #ifndef __WINDOWS__
00071                 sprintf(tmp,"%d, %d, %d,-1,",faces[i]->getVertex(0)->getIndex(),faces[i]->getVertex(1)->getIndex(),faces[i]->getVertex(2)->getIndex());
00072                 #else
00073                 sprintf_s(tmp,"%d, %d, %d,-1,",faces[i]->getVertex(0)->getIndex(),faces[i]->getVertex(1)->getIndex(),faces[i]->getVertex(2)->getIndex());
00074                 #endif
00075                 coordIndex.append(tmp);
00076                 normalIndex.append(tmp);
00077                 /*cout << "Value:" << vertexs[i]->getCoordinates()->x << "," << vertexs[i]->getCoordinates()->y << "," << vertexs[i]->getCoordinates()->z << "\n";
00078                 cout << "Tmp: " << tmp << "\n";
00079                 cout << "Point: " << points << "\n";
00080                 system("PAUSE");*/
00081         }
00082         log::write("Exporter get vertex");
00083         vector<Vertex*> vertexs = model->getVertexs();
00084         for(int i=0; i<(int)vertexs.size(); i++) {
00085                 #ifndef __WINDOWS__
00086                 sprintf(tmp,"%.4f %.4f %.4f,",vertexs[i]->getCoordinates()->x,vertexs[i]->getCoordinates()->y,vertexs[i]->getCoordinates()->z);
00087                 #else
00088                 sprintf_s(tmp,"%.4f %.4f %.4f,",vertexs[i]->getCoordinates()->x,vertexs[i]->getCoordinates()->y,vertexs[i]->getCoordinates()->z);
00089                 #endif
00090                 points.append(tmp);
00091                 #ifndef __WINDOWS__
00092                 sprintf(tmp,"%.4f %.4f %.4f,",vertexs[i]->getNormal()->x,vertexs[i]->getNormal()->y,vertexs[i]->getNormal()->z);
00093                 #else
00094                 sprintf_s(tmp,"%.4f %.4f %.4f,",vertexs[i]->getNormal()->x,vertexs[i]->getNormal()->y,vertexs[i]->getNormal()->z);
00095                 #endif
00096                 vectors.append(tmp);
00097                 /*cout << "Value:" << vertexs[i]->getCoordinates()->x << "," << vertexs[i]->getCoordinates()->y << "," << vertexs[i]->getCoordinates()->z << "\n";
00098                 cout << "Tmp: " << tmp << "\n";
00099                 cout << "Point: " << points << "\n";
00100                 system("PAUSE");*/
00101         }
00102         log::write("Exporter make xml");
00103         //Make XML doc
00104         TiXmlDocument doc;
00105         TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "" );
00106         doc.LinkEndChild( decl );
00107         
00108         TiXmlElement * X3D = new TiXmlElement( "X3D" );
00109         X3D->SetAttribute("profile","Immersive");
00110         doc.LinkEndChild( X3D );
00111         
00112         TiXmlElement * scene = new TiXmlElement( "Scene" );
00113         X3D->LinkEndChild( scene );
00114 
00115         TiXmlElement * transform = new TiXmlElement( "Transform" );
00116         scene->LinkEndChild( transform );
00117 
00118         TiXmlElement * shape = new TiXmlElement( "Shape" );
00119         transform->LinkEndChild( shape );
00120 
00121         TiXmlElement * indexedFaceSet = new TiXmlElement( "IndexedFaceSet" );
00122         indexedFaceSet->SetAttribute("normalPerVertex","true");
00123         indexedFaceSet->SetAttribute("coordIndex",coordIndex.c_str());
00124         indexedFaceSet->SetAttribute("normalIndex",normalIndex.c_str());
00125         shape->LinkEndChild( indexedFaceSet );
00126 
00127         TiXmlElement * coordinate = new TiXmlElement( "Coordinate" );
00128         coordinate->SetAttribute("point",points.c_str());
00129         indexedFaceSet->LinkEndChild( coordinate );
00130 
00131         TiXmlElement * normal = new TiXmlElement( "Normal" );
00132         normal->SetAttribute("vector",vectors.c_str());
00133         indexedFaceSet->LinkEndChild( normal );
00134 
00135         doc.SaveFile( filename );
00136 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Tue Apr 17 09:39:52 2007 for PCG Library by  doxygen 1.3.9.1