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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
/*
* A simple utility for exporting Inkscape svg Shapes as PovRay bezier
* prisms. Note that this is output-only, and would thus seem to be
* better placed as an 'export' rather than 'output'. However, Export
* handles all or partial documents, while this outputs ALL shapes in
* the current SVG document.
*
* Authors:
* Bob Jamison <ishmal@inkscape.org>
*
* Copyright (C) 2004-2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifndef EXTENSION_INTERNAL_POV_OUT_H
#define EXTENSION_INTERNAL_POV_OUT_H
#include <glib.h>
#include "extension/implementation/implementation.h"
namespace Inkscape
{
namespace Extension
{
namespace Internal
{
/**
* Output bezier splines in POVRay format.
*
* For information, @see:
* http://www.povray.org
*/
class PovOutput : public Inkscape::Extension::Implementation::Implementation
{
public:
/**
* Our internal String definition
*/
typedef Glib::ustring String;
/**
* Check whether we can actually output using this module
*/
bool check (Inkscape::Extension::Extension * module);
/**
* API call to perform the output to a file
*/
void save (Inkscape::Extension::Output *mod,
SPDocument *doc, const gchar *uri);
/**
* Inkscape runtime startup call.
*/
static void init(void);
/**
* Reset variables to initial state
*/
void reset();
private:
/**
* Format text to our output buffer
*/
void out(const char *fmt, ...) G_GNUC_PRINTF(2,3);
/**
* Output a 2d vector
*/
void vec2(double a, double b);
/**
* Output a 3d vector
*/
void vec3(double a, double b, double c);
/**
* Output a 4d vector
*/
void vec4(double a, double b, double c, double d);
/**
* Output an rgbf color vector
*/
void rgbf(double r, double g, double b, double f);
/**
* Output one bezier's start, start-control,
* end-control, and end nodes
*/
void segment(int segNr, double a0, double a1,
double b0, double b1,
double c0, double c1,
double d0, double d1);
/**
* Output the file header
*/
void doHeader();
/**
* Output the file footer
*/
void doTail();
/**
* Output the SVG document's curve data as POV curves
*/
void doCurves(SPDocument *doc);
/**
* Actual method to save document
*/
void saveDocument(SPDocument *doc, const gchar *uri);
/**
* used for saving information about shapes
*/
class PovShapeInfo
{
public:
PovShapeInfo()
{}
PovShapeInfo(const PovShapeInfo &other)
{ assign(other); }
PovShapeInfo operator=(const PovShapeInfo &other)
{ assign(other); return *this; }
virtual ~PovShapeInfo()
{}
String id;
String color;
private:
void assign(const PovShapeInfo &other)
{
id = other.id;
color = other.color;
}
};
//A list for saving information about the shapes
std::vector<PovShapeInfo> povShapes;
//For formatted output
String outbuf;
//For statistics
int nrNodes;
int nrSegments;
int nrShapes;
};
} // namespace Internal
} // namespace Extension
} // namespace Inkscape
#endif /* EXTENSION_INTERNAL_POV_OUT_H */
|