PovrayWriter.h 2.97 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  TU Dresden                                                            ==
// ==                                                                        ==
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
// ==                                                                        ==
// ============================================================================

/** \file FileWriter.h */

// Marcel Schiffel, 23.06.09

#ifndef AMDIS_POVRAYWRITER_H
#define AMDIS_POVRAYWRITER_H

#include <string>
#include <fstream>
#include <iostream>
#include "DataCollector.h"
#include "FileWriter.h"

using namespace std;

namespace AMDiS {


  typedef struct {
    double minx;
    double maxx;
    double miny;
    double maxy;
    double minz;
    double maxz;
  } BoundingBox;


  class PovrayWriter {
  public:
    PovrayWriter(FileWriter *fw, DataCollector *dc) : fileWriter(fw), dataCollector(dc)
    {
      FUNCNAME("PovrayWriter::PovrayWriter()");	

      // abort if problem not 3D //FIX THAT!!!
      /*	TEST_EXIT(dataCollector->getMesh()->getDim()==3)
		("Povray export only possible for 3D data!");*/  

      bBox = NULL;
    }

    ~PovrayWriter();
    int writeFile(const std::string filename);

    // provides the bounding box of the mesh (lazy evaluation, bounding box is computed only once)
    BoundingBox *getBoundingBox(ofstream&);

  private:
    FileWriter *fileWriter;
    DataCollector *dataCollector;
    BoundingBox *bBox;

    // TODO: remove!
    void tryMeshTraversal(ofstream&);

    void writeTestStuff(ofstream&, DataCollector&); // TODO: remove/rename
    void writeHeader(ofstream&);
    void writeIncludes(ofstream&);
    void writeCamera(ofstream&);
    void writeLight(ofstream&);
    void writeMesh2(ofstream&, DataCollector&);
    void writeVertexVectors(ofstream&, DataCollector&);
    void writeTextureList(ofstream&, DataCollector&);
    void writeFaceIndices(ofstream&, DataCollector&);
  };

} // end of namespace AMDiS

#endif