00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_VIEW_RENDERING_POVRENDERER_H
00008 #define BALL_VIEW_RENDERING_POVRENDERER_H
00009
00010 #ifndef BALL_VIEW_RENDERING_RENDERER_H
00011 # include <BALL/VIEW/RENDERING/renderer.h>
00012 #endif
00013
00014 #ifndef BALL_SYSTEM_FILE_H
00015 # include <BALL/SYSTEM/file.h>
00016 #endif
00017
00018 #ifndef BALL_MATHS_VECTOR3_H
00019 # include <BALL/MATHS/vector3.h>
00020 #endif
00021
00022 #ifndef BALL_MATHS_MATRIX44_H
00023 # include <BALL/MATHS/matrix44.h>
00024 #endif
00025
00026 namespace BALL
00027 {
00028 namespace VIEW
00029 {
00030 class ColorRGBA;
00031 class ClippingPlane;
00032
00039 class BALL_VIEW_EXPORT POVRenderer : public Renderer
00040 {
00041 public:
00042
00043 BALL_CREATE(POVRenderer)
00044
00045 struct POVRendererClippingPlane
00046 {
00047 public:
00048 Vector3 normal;
00049 float translation;
00050
00051 };
00052
00056
00058 POVRenderer();
00059
00063 POVRenderer(const String& name)
00064 throw(Exception::FileNotFound);
00065
00066
00067 POVRenderer(const POVRenderer& renderer);
00068
00069
00071 virtual ~POVRenderer();
00072
00074 virtual void clear();
00075
00077
00080
00084 void setFileName(const String& name)
00085 throw(Exception::FileNotFound);
00086
00088 void setOstream(std::ostream& out_stream);
00089
00091 void setHumanReadable(bool state)
00092 { human_readable_ = state;}
00093
00095 bool isHumanReadable() const
00096 { return human_readable_;}
00097
00100 String POVColorRGBA(const ColorRGBA& input);
00101
00104 String POVFinish(const String& object, const ColorRGBA& input);
00105
00108 String POVVector3(Vector3 input);
00109
00110 virtual bool renderOneRepresentation(const Representation& representation);
00111
00113
00117
00120 virtual bool init(Scene& scene);
00121
00125 virtual bool init(const Stage& stage, float width, float height);
00126
00130 virtual bool finish();
00131
00132 void renderSphere_(const Sphere& sphere);
00133
00134 void renderDisc_(const Disc& disc);
00135
00136 void renderTube_(const Tube& tube);
00137
00138 void renderTwoColoredTube_(const TwoColoredTube& tube);
00139
00140 void renderMesh_(const Mesh& mesh);
00141
00142 void renderTwoColoredLine_(const TwoColoredLine& line);
00143
00144 void renderLine_(const Line& line);
00145
00146 void renderPoint_(const Point& point);
00147
00148
00149 void renderLabel_(const Label&);
00150
00152 virtual void renderMultiLine_(const MultiLine& line);
00153
00155
00156 protected:
00157
00158 const ColorRGBA& getColor_(const GeometricObject& object);
00159
00160 std::ostream* outfile_;
00161 String trimFloatValue_(float value);
00162 void storeColor_(const GeometricObject& object);
00163 String getColorIndex_(const ColorRGBA& color);
00164
00165 Vector3 origin_;
00166 Matrix4x4 rotation_;
00167 vector<ClippingPlane*> clipping_planes_;
00168 bool human_readable_;
00169
00170 typedef HashMap<String, Size> ColorMap;
00171 ColorMap color_map_;
00172 vector<const Representation*> representations_;
00173 HashSet<const Mesh*> wireframes_;
00174 HashSet<String> color_strings_;
00175 String font_file_;
00176 double m_[12];
00177 Position color_index_;
00178 };
00179
00180 }
00181 }
00182
00183 #endif // BALL_VIEW_RENDERING_POVRENDERER_H