Debian Codegraph @

include/BALL/VIEW/RENDERING/RENDERERS/XML3DRenderer.h

raw symbols SCIP
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4
5 #ifndef BALL_VIEW_RENDERING_RENDERERS_XML3DRENDERER_H
6 #define BALL_VIEW_RENDERING_RENDERERS_XML3DRENDERER_H
7
8 #ifndef BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
9 # include <BALL/VIEW/RENDERING/RENDERERS/renderer.h>
10 #endif
11
12 #ifndef BALL_SYSTEM_FILE_H
13 # include <BALL/SYSTEM/file.h>
14 #endif
15
16 #ifndef BALL_MATHS_VECTOR3_H
17 # include <BALL/MATHS/vector3.h>
18 #endif
19
20 #ifndef BALL_MATHS_MATRIX44_H
21 # include <BALL/MATHS/matrix44.h>
22 #endif
23
24 #ifndef BALL_MATHS_SURFACE_H
25 # include <BALL/MATHS/surface.h>
26 #endif
27
28 namespace BALL
29 {
30 namespace VIEW
31 {
32 class ColorRGBA;
33 class ClippingPlane;
34
35 /** XML3DRenderer class.
36 This class walks over all the geometric primitives in a Scene
37 and exports them into a data file in the XML3DRay 1.5 format, which can
38 be used to render the same scene externally.
39 \ingroup ViewRendering
40
41 @deprecated Incompatible with recent XML3D versions
42 */
43 class BALL_DEPRECATED BALL_VIEW_EXPORT XML3DRenderer : public Renderer
44 {
45 public:
46
47 BALL_CREATE(XML3DRenderer)
48
49 struct XML3DRendererClippingPlane
50 {
51 public:
52 Vector3 normal;
53 float translation;
54 // Vector3 translation;
55 };
56
57 /** @name Constructors and Destructors.
58 */
59 //@{
60
61 /// Default constructor.
62 XML3DRenderer();
63
64 /** Detailed constructor.
65 \param name The name of the file we will create
66 \exception BALL::Exception::FileNotFound
67 */
68 XML3DRenderer(const String& name);
69
70 XML3DRenderer(std::ostream& name);
71
72 // Only for Python
73 XML3DRenderer(const XML3DRenderer& renderer);
74
75
76 /// Destructor.
77 virtual ~XML3DRenderer();
78
79 /// Clear method.
80 virtual void clear();
81
82 //@}
83 /** @name Accessors
84 */
85 //@{
86
87 virtual void setSize(float width, float height);
88
89 /** Sets the name of the file we will create.
90 \param name The file name
91 \exception BALL::Exception::FileNotFound
92 */
93 void setFileName(const String& name);
94
95 /// Set a stream as output device
96 void setOstream(std::ostream& out_stream);
97
98 ///
99 void setHumanReadable(bool state)
100 { human_readable_ = state;}
101
102 ///
103 bool isHumanReadable() const
104 { return human_readable_;}
105
106 /** Converts a ColorRGBA into a String in XML3D format.
107 */
108 String XML3DColorRGBA(const ColorRGBA& input, const String& name);
109
110 /** Returns the corresponding BALLFinish declaration
111 */
112 String XML3DFinish(const String& object, const ColorRGBA& input);
113
114 /** Converts an Material into the corresponding shader properties.
115 */
116 String XML3DRaytracingMaterial(const Stage::Material& /* input */);
117
118 /** Converts a Vector3 into a String in XML3DRay format.
119 */
120 String XML3DVector3(Vector3 input);
121
122 /** Prepare Strings for XML3D
123 */
124 String XML3DString(const String& input);
125
126 virtual bool renderOneRepresentation(const Representation& representation);
127
128 //@}
129
130 /** @name Processor specific methods
131 */
132 //@{
133
134 /** Initialization routine.
135 */
136 virtual bool init(Scene& scene);
137
138 /** Start method.
139 This method creates the file and writes the header.
140 */
141 virtual bool init(const Stage& stage, float width, float height);
142
143 /** Finish method.
144 This method writes the ending of the file and closes it.
145 */
146 virtual bool finish();
147
148 void createXHTMLHeader();
149
150 void createXHTMLFooter();
151
152 void renderSphere_(const Sphere& sphere);
153
154 void renderDisc_(const Disc& /* disc */);
155
156 void renderTube_(const Tube& /* tube */);
157
158 void renderTwoColoredTube_(const TwoColoredTube& tube);
159
160 void renderMesh_(const Mesh& mesh);
161
162 void renderTwoColoredLine_(const TwoColoredLine& /* line */);
163
164 void renderLine_(const Line& /* line */);
165
166 void renderPoint_(const Point& /* point */);
167
168 // do nothing
169 void renderLabel_(const Label&);
170
171 /// Render an illuminated line
172 virtual void renderMultiLine_(const MultiLine& line);
173
174 //@}
175
176 protected:
177
178 const ColorRGBA& getColor_(const GeometricObject& object);
179
180 std::ostream* outfile_;
181 String trimFloatValue_(float value);
182 void storeColor_(const GeometricObject& object);
183 String getColorIndex_(const ColorRGBA& color);
184 void createTubeTransform_(const TwoColoredTube& tube);
185 void createSphereTemplate_();
186
187
188 Vector3 origin_;
189 Matrix4x4 rotation_;
190 vector<ClippingPlane*> clipping_planes_;
191 bool human_readable_;
192
193 typedef HashMap<String, Size> ColorMap;
194 ColorMap color_map_;
195 vector<const Representation*> representations_;
196 HashSet<const Mesh*> wireframes_;
197 HashSet<String> color_strings_;
198 double m_[12];
199 Position color_index_;
200 bool create_XHTML_;
201
202 Surface sphere_template_;
203 Surface tube_template_;
204
205 Stage::Material rt_material_;
206
207 Index current_sphere_number_;
208 Index current_tube_number_;
209
210 float fov_x_;
211 float fov_y_;
212 };
213
214 } // namespace BALL
215 } // namespace VIEW
216
217 #endif // BALL_VIEW_RENDERING_XML3DRENDERER_H