51 int FIGExporter::FigCoordX(
double x)
const
54 float MaxY = MaxX * _sizeY/(float)_sizeX ;
58 MaxX *= 7000/(float)MaxY ;
62 return int(0.5f + x/_sizeX*MaxX) ;
65 int FIGExporter::FigCoordY(
double y)
const
68 float MaxY = MaxX * _sizeY/(float)_sizeX ;
72 MaxX *= 7000/(float)MaxY ;
76 return int(0.5f + (1.0 - y/_sizeY)*MaxY) ;
79 int FIGExporter::FigGrayScaleIndex(
float red,
float green,
float blue)
const
81 float intensity = 0.3f*red+0.6f*green+0.1f*blue ;
83 return int(intensity * 20.0) ;
86 FIGExporter::FIGExporter()
90 void FIGExporter::writeHeader(QTextStream& out)
const
92 out <<
"#FIG 3.2\nPortrait\nCenter\nInches\nLetter\n100.00\nSingle\n0\n1200 2\n";
94 _sizeX = int(0.5f + _xmax - _xmin) ;
95 _sizeY = int(0.5f + _ymax - _ymin) ;
98 void FIGExporter::writeFooter(QTextStream& out)
const
103 void FIGExporter::spewPoint(
const Point *P, QTextStream& out)
105 out <<
"2 1 0 5 0 7 " << (_depth--) <<
" 0 -1 0.000 0 1 -1 0 0 1\n";
107 out <<
"\t " << FigCoordX(P->vertex(0)[0]) <<
" " << FigCoordY(P->vertex(0)[1]) <<
"\n";
108 if(_depth > 0) _depth = 0 ;
111 void FIGExporter::spewSegment(
const Segment *S, QTextStream& out)
117 GLfloat dr, dg, db, absR, absG, absB, colormax;
119 GLdouble xstep, ystep;
120 GLfloat rstep, gstep, bstep;
121 GLdouble xnext, ynext, distance;
122 GLfloat rnext, gnext, bnext;
124 dr = P2.red() - P1.red();
125 dg = P2.green() - P1.green();
126 db = P2.blue() - P1.blue();
128 if (dr != 0 || dg != 0 || db != 0)
132 dx = P2.x() - P1.x();
133 dy = P2.y() - P1.y();
135 distance = sqrt(dx * dx + dy * dy);
141 colormax =
max(absR,
max(absG, absB));
142 steps = int(0.5f +
max(1.0, colormax * distance * EPS_SMOOTH_LINE_FACTOR));
160 xnext -= xstep / 2.0;
161 ynext -= ystep / 2.0;
162 rnext -= rstep / 2.0f;
163 gnext -= gstep / 2.0f;
164 bnext -= bstep / 2.0f;
172 out <<
"2 1 0 1 0 7 " << (_depth--) <<
" 0 -1 0.000 0 0 -1 0 0 2\n";
173 out <<
"\t " << FigCoordX(P1.x()) <<
" " << FigCoordY(P1.y());
175 out <<
" " << FigCoordX(P2.x()) <<
" " << FigCoordY(P2.y())<<
"\n";
176 if(_depth > 0) _depth = 0 ;
179 void FIGExporter::spewPolygone(
const Polygone *P, QTextStream& out)
182 GLfloat red, green, blue;
184 nvertices = P->nbVertices() ;
194 for(
int i = 0; i < nvertices; i++)
196 red += P->sommet3DColor(i).red() ;
197 green += P->sommet3DColor(i).green() ;
198 blue += P->sommet3DColor(i).blue() ;
208 out <<
"2 3 0 0 0 7 " << (_depth--) <<
" 0 20 0.000 0 0 -1 0 0 " << (nvertices+1) <<
"\n";
210 out <<
"2 3 0 0 0 7 " << (_depth--) <<
" 0 " << (FigGrayScaleIndex(red,green,blue)) <<
" 0.000 0 0 -1 0 0 " << (nvertices+1) <<
"\n";
216 for (
int j = 0; j < nvertices; j++)
217 out <<
" " << FigCoordX(P->sommet3DColor(j).x()) <<
" " << FigCoordY(P->sommet3DColor(j).y());
219 out <<
" " << FigCoordX(P->sommet3DColor(0).x()) <<
" " << FigCoordY(P->sommet3DColor(0).y()) <<
"\n";
222 if(_depth > 0) _depth = 0 ;
FARSA_UTIL_TEMPLATE const T max(const T &t1, const U &t2)