PovrayWriter.h 2.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
 * 
 ******************************************************************************/
20 21


Thomas Witkowski's avatar
Thomas Witkowski committed
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

/** \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:
53
    PovrayWriter(FileWriter *fw, DataCollector<> *dc) : fileWriter(fw), dataCollector(dc)
Thomas Witkowski's avatar
Thomas Witkowski committed
54
    {
55
//       FUNCNAME("PovrayWriter::PovrayWriter()");	
Thomas Witkowski's avatar
Thomas Witkowski committed
56 57 58 59 60

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

61
      bBox = nullptr;
Thomas Witkowski's avatar
Thomas Witkowski committed
62 63 64 65 66 67 68 69 70 71
    }

    ~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;
72
    DataCollector<> *dataCollector;
Thomas Witkowski's avatar
Thomas Witkowski committed
73 74 75 76 77
    BoundingBox *bBox;

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

78
    void writeTestStuff(ofstream&, DataCollector<>&); // TODO: remove/rename
Thomas Witkowski's avatar
Thomas Witkowski committed
79 80 81 82
    void writeHeader(ofstream&);
    void writeIncludes(ofstream&);
    void writeCamera(ofstream&);
    void writeLight(ofstream&);
83 84 85 86
    void writeMesh2(ofstream&, DataCollector<>&);
    void writeVertexVectors(ofstream&, DataCollector<>&);
    void writeTextureList(ofstream&, DataCollector<>&);
    void writeFaceIndices(ofstream&, DataCollector<>&);
Thomas Witkowski's avatar
Thomas Witkowski committed
87 88 89 90 91
  };

} // end of namespace AMDiS

#endif