OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
povray.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_POVRAY_HH
20 #define OST_GFX_POVRAY_HH
21 
22 /*
23  Author: Ansgar Philippsen
24 */
25 
26 #include <string>
27 #include <fstream>
28 
29 #include <ost/geom/transform.hh>
30 
31 #include "color.hh"
32 
33 namespace ost { namespace gfx {
34 
35 class PovState {
36 public:
37  PovState(const std::string& pov_file, const std::string& inc_file, const std::string& wdir);
38 
39  void write_preamble();
40  void write_postamble();
41  void write_background(const Color& c);
42  void write_camera(float fov, float zdist);
43  void write_default_light();
44  void write_fog(float zdist, float znear, float zfar, const Color& c, bool f);
45 
46  void start_obj(const std::string& name, float tp, float lw, float ps);
47  void write_obj_tex(const std::string& name);
48  void end_obj();
49 
50  void write_sphere(const geom::Vec3& p, float r, const Color& c, const std::string& name);
51  void write_cyl(const geom::Vec3& p1, const geom::Vec3& p2, float r, const Color& c, const std::string& name, bool open);
52 
53  void write_merge_or_union(const std::string& name);
54 
55  std::string write_coord(const geom::Vec3& v);
56  std::string write_coord(float* v);
57 
58  std::string write_norm(const geom::Vec3& n);
59  std::string write_norm(float* n);
60 
61  std::ostream& pov() {return pov_;}
62  std::ostream& inc() {return inc_;}
63 
64 public:
65  bool use_tf;
67 
68 private:
69  std::string pov_file_;
70  std::string inc_file_;
71  std::string wdir_;
72  std::ofstream pov_;
73  std::ofstream inc_;
74  std::vector<std::string> obj_list_;
75 };
76 
77 
78 }} // ns
79 
80 #endif
PovState(const std::string &pov_file, const std::string &inc_file, const std::string &wdir)
void write_obj_tex(const std::string &name)
void write_default_light()
void write_background(const Color &c)
std::string write_norm(const geom::Vec3 &n)
void start_obj(const std::string &name, float tp, float lw, float ps)
basic and essential transformation class, including translation, rotation and center of rotation ...
Definition: transform.hh:39
void write_camera(float fov, float zdist)
void write_fog(float zdist, float znear, float zfar, const Color &c, bool f)
Three dimensional vector class, using Real precision.
Definition: vec3.hh:42
geom::Transform tf
Definition: povray.hh:66
std::ostream & pov()
Definition: povray.hh:61
void write_cyl(const geom::Vec3 &p1, const geom::Vec3 &p2, float r, const Color &c, const std::string &name, bool open)
void write_sphere(const geom::Vec3 &p, float r, const Color &c, const std::string &name)
std::ostream & inc()
Definition: povray.hh:62
std::string write_coord(const geom::Vec3 &v)
void write_merge_or_union(const std::string &name)