source: GTP/trunk/Lib/Vis/Preprocessing/src/ObjExporter.cpp @ 2176

Revision 2176, 1.9 KB checked in by mattausch, 18 years ago (diff)

removed using namespace std from .h

  • Property svn:executable set to *
Line 
1#include "SceneGraph.h"
2#include "Polygon3.h"
3#include "Mesh.h"
4#include "ObjExporter.h"
5
6
7using namespace std;
8
9namespace GtpVisibilityPreprocessor {
10
11ObjExporter::ObjExporter(const string filename):Exporter(filename)
12{
13  stream.open(mFilename.c_str());
14  stream<<"#File exported by GTP visibility preprocessor"<<endl;
15  vertexIndex = 1;
16}
17
18
19ObjExporter::~ObjExporter()
20{
21  stream<<"# export finished"<<endl;
22  stream.close();
23}
24
25void
26ObjExporter::ExportSceneNode(SceneGraphNode *node)
27{
28  SceneGraphNodeContainer::iterator ni = node->mChildren.begin();
29  for (; ni != node->mChildren.end(); ni++)
30    ExportSceneNode(*ni);
31 
32 
33  ObjectContainer::const_iterator mi = node->mGeometry.begin();
34  for (; mi != node->mGeometry.end(); mi++) {
35    // export the transform...
36    ExportIntersectable(*mi);
37  }
38 
39}
40
41
42void
43ObjExporter::ExportMesh(Mesh *mesh)
44{
45  int vertexOffset = vertexIndex;
46 
47  VertexContainer::const_iterator vi = mesh->mVertices.begin();
48  for (; vi != mesh->mVertices.end(); vi++) {
49    stream<<"v "<<(*vi).x<<" "<<(*vi).y<<" "<<(*vi).z<<endl;
50        vertexIndex ++;
51  }
52 
53  FaceContainer::const_iterator fi = mesh->mFaces.begin();
54  for (; fi != mesh->mFaces.end(); fi++) {
55    Face *face = *fi;
56    VertexIndexContainer::const_iterator vi = face->mVertexIndices.begin();
57        stream<<"f ";
58    for (; vi != face->mVertexIndices.end(); vi++)
59      stream<<vertexOffset + *vi<<" ";
60        stream<<endl;
61  }
62}
63
64
65void
66ObjExporter::ExportPolygon(Polygon3 *poly)
67{
68  int vertexOffset = vertexIndex;
69 
70  VertexContainer::const_iterator vi = poly->mVertices.begin();
71  for (; vi != poly->mVertices.end(); vi++) {
72    stream<<"v "<<(*vi).x<<" "<<(*vi).y<<" "<<(*vi).z<<endl;
73        vertexIndex ++;
74  }
75 
76  stream<<"f ";
77  int i = vertexOffset;
78  vi = poly->mVertices.begin();
79  for (; vi != poly->mVertices.end(); vi++, i++)
80        stream<<i<<" ";
81  stream<<endl;
82 
83}
84
85}
Note: See TracBrowser for help on using the repository browser.