71 out <<
"%!PS-Adobe-2.0 EPSF-2.0\n";
73 out <<
"%%%%HiResBoundingBox: " << _xmin <<
" " << _ymin <<
" " << _xmax <<
" " << _ymax <<
"\n";
75 out <<
"%%%%Creator: " << CREATOR <<
" (using OpenGL feedback)\n";
76 out <<
"%%EndComments\n\ngsave\n\n";
79 out <<
"% Contributors:\n";
81 out <<
"% Frederic Delhoume (delhoume@ilog.fr):\n";
82 out <<
"% Gouraud triangle PostScript fragment\n";
84 out <<
"% Cyril Soler (csoler@imag.fr):\n";
85 out <<
"% BSP Sort,\n";
86 out <<
"% Topological and advanced topological Sort,\n";
87 out <<
"% Hidden surface removal,\n";
88 out <<
"% Xfig3.2 (and EPS) format\n";
91 out <<
"/threshold " << EPS_GOURAUD_THRESHOLD <<
" def\n";
93 for(
int i = 0; GOURAUD_TRIANGLE_EPS[i] != NULL; i++)
94 out << GOURAUD_TRIANGLE_EPS[i] <<
"\n";
96 out <<
"\n" << <<
" setlinewidth\n\n", _lineWidth;
102 out << _clearR <<
" " << _clearG <<
" " << _clearB <<
" setrgbcolor\n";
103 out << _xmin <<
" " << _ymin <<
" " << _xmax <<
" " << _ymax <<
" rectfill\n\n";
109 out <<
"grestore\n\n";
111 out <<
"% uncomment next line to be able to print to a printer.\n";
112 out <<
"% showpage\n";
122 "/bd{bind def}bind def /triangle { aload pop ",
123 "setrgbcolor aload pop 5 3 roll 4 2 roll 3 2 roll exch moveto lineto ",
124 "lineto closepath fill } bd /computediff1 { 2 copy sub abs threshold ",
125 "ge {pop pop pop true} { exch 2 index sub abs threshold ge { pop pop ",
126 "true} { sub abs threshold ge } ifelse } ifelse } bd /computediff3 { 3 ",
127 "copy 0 get 3 1 roll 0 get 3 1 roll 0 get computediff1 {true} { 3 copy ",
128 "1 get 3 1 roll 1 get 3 1 roll 1 get computediff1 {true} { 3 copy 2 ",
129 "get 3 1 roll 2 get 3 1 roll 2 get computediff1 } ifelse } ifelse } ",
130 "bd /middlecolor { aload pop 4 -1 roll aload pop 4 -1 roll add 2 div 5 ",
131 "1 roll 3 -1 roll add 2 div 3 1 roll add 2 div 3 1 roll exch 3 array ",
132 "astore } bd /gdt { computediff3 { 4 -1 roll aload 7 1 roll ",
133 "6 -1 roll pop 3 -1 roll pop add 2 div 3 1 roll add 2 div exch 3 -1 roll ",
134 "aload 7 1 roll exch pop 4 -1 roll pop add 2 div 3 1 roll add 2 div ",
135 "exch 3 -1 roll aload 7 1 roll pop 3 -1 roll pop add 2 div 3 1 roll add ",
136 "2 div exch 7 3 roll 10 -3 roll dup 3 index middlecolor 4 1 roll 2 copy ",
137 "middlecolor 4 1 roll 3 copy pop middlecolor 4 1 roll 13 -1 roll aload ",
138 "pop 17 index 6 index 15 index 19 index 6 index 17 index 6 array astore ",
139 "10 index 10 index 14 index gdt 17 index 5 index 17 index ",
140 "19 index 5 index 19 index 6 array astore 10 index 9 index 13 index ",
141 "gdt 13 index 16 index 5 index 15 index 18 index 5 index 6 ",
142 "array astore 12 index 12 index 9 index gdt 17 index 16 ",
143 "index 15 index 19 index 18 index 17 index 6 array astore 10 index 12 ",
144 "index 14 index gdt 18 {pop} repeat } { aload pop 5 3 roll ",
145 "aload pop 7 3 roll aload pop 9 3 roll 8 index 6 index 4 index add add 3 ",
146 "div 10 1 roll 7 index 5 index 3 index add add 3 div 10 1 roll 6 index 4 ",
147 "index 2 index add add 3 div 10 1 roll 9 {pop} repeat 3 array astore ",
148 "triangle } ifelse } bd",
155 GLfloat red, green, blue;
165 green = vertex.
green();
166 blue = vertex.
blue();
170 for(
int i=1;i < nvertices && !smooth; i++)
174 if(smooth && !_blackAndWhite)
179 for (
int j = 0; j < nvertices - 2; j++)
188 last_r = last_g = last_b = -1.0 ;
198 setColor(out,1.0,1.0,1.0) ;
200 setColor(out,red,green,blue) ;
206 for (
int i = 1; i < nvertices; i++)
209 out <<
"closepath fill\n\n";
217 GLfloat dr, dg, db, absR, absG, absB, colormax;
219 GLdouble xstep=0.0, ystep=0.0;
220 GLfloat rstep=0.0, gstep=0.0, bstep=0.0;
221 GLdouble xnext=0.0, ynext=0.0, distance=0.0;
222 GLfloat rnext=0.0, gnext=0.0, bnext=0.0;
228 dg = P2.green() - P1.
green();
229 db = P2.blue() - P1.
blue();
231 if((!_blackAndWhite)&&(dr != 0 || dg != 0 || db != 0))
235 dx = P2.x() - P1.
x();
236 dy = P2.y() - P1.
y();
238 distance = sqrt(dx*dx + dy*dy);
244 colormax = max(absR, max(absG, absB));
263 xnext -= xstep / 2.0;
264 ynext -= ystep / 2.0;
265 rnext -= rstep / 2.0f;
266 gnext -= gstep / 2.0f;
267 bnext -= bstep / 2.0f;
273 setColor(out,0.0,0.0,0.0) ;
277 out << P1.
x() <<
" " << P1.
y() <<
" moveto\n";
279 for(
int i = 0;i < steps;i++)
287 out << xnext <<
" " << ynext <<
" lineto stroke\n";
288 out << rnext <<
" " << gnext <<
" " << bnext <<
" setrgbcolor\n";
289 out << xnext <<
" " << ynext <<
" moveto\n";
291 last_r = last_g = last_b = -1.0 ;
293 out << P2.x() <<
" " << P2.y() <<
" lineto stroke\n";
301 setColor(out,0.0,0.0,0.0) ;
305 out << p.
x() <<
" " << p.
y() <<
" " << (_pointSize / 2.0) <<
" 0 360 arc fill\n\n";
310 if(last_r != red || last_g != green || last_b != blue)
311 out << red <<
" " << green <<
" " << blue <<
" setrgbcolor\n";
virtual void spewPoint(const Point *, QTextStream &out)
static const char * CREATOR
virtual void writeHeader(QTextStream &out) const
virtual void spewSegment(const Segment *, QTextStream &out)
virtual const Feedback3DColor & sommet3DColor(size_t) const
virtual size_t nbVertices() const
virtual const Feedback3DColor & sommet3DColor(size_t) const
virtual void writeFooter(QTextStream &out) const
static const char * GOURAUD_TRIANGLE_EPS[]
virtual void spewPolygone(const Polygone *, QTextStream &out)
#define EPS_SMOOTH_LINE_FACTOR
static const double EPS_GOURAUD_THRESHOLD
virtual const Feedback3DColor & sommet3DColor(size_t i) const
void setColor(QTextStream &out, float, float, float)
virtual void writeFooter(QTextStream &out) const