49#if defined(GL2PS_HAVE_ZLIB)
53#if defined(GL2PS_HAVE_LIBPNG)
66#define GL2PS_EPSILON 5.0e-3F
67#define GL2PS_ZSCALE 1000.0F
68#define GL2PS_ZOFFSET 5.0e-2F
69#define GL2PS_ZOFFSET_LARGE 20.0F
70#define GL2PS_ZERO(arg) (fabs(arg) < 1.e-20)
74#define GL2PS_NO_TYPE -1
78#define GL2PS_QUADRANGLE 4
79#define GL2PS_TRIANGLE 5
81#define GL2PS_IMAGEMAP 7
82#define GL2PS_IMAGEMAP_WRITTEN 8
83#define GL2PS_IMAGEMAP_VISIBLE 9
84#define GL2PS_SPECIAL 10
88#define GL2PS_COINCIDENT 1
89#define GL2PS_IN_FRONT_OF 2
90#define GL2PS_IN_BACK_OF 3
91#define GL2PS_SPANNING 4
95#define GL2PS_POINT_COINCIDENT 0
96#define GL2PS_POINT_INFRONT 1
97#define GL2PS_POINT_BACK 2
101#define GL2PS_BEGIN_OFFSET_TOKEN 1
102#define GL2PS_END_OFFSET_TOKEN 2
103#define GL2PS_BEGIN_BOUNDARY_TOKEN 3
104#define GL2PS_END_BOUNDARY_TOKEN 4
105#define GL2PS_BEGIN_STIPPLE_TOKEN 5
106#define GL2PS_END_STIPPLE_TOKEN 6
107#define GL2PS_POINT_SIZE_TOKEN 7
108#define GL2PS_LINE_WIDTH_TOKEN 8
109#define GL2PS_BEGIN_BLEND_TOKEN 9
110#define GL2PS_END_BLEND_TOKEN 10
111#define GL2PS_SRC_BLEND_TOKEN 11
112#define GL2PS_DST_BLEND_TOKEN 12
113#define GL2PS_IMAGEMAP_TOKEN 13
114#define GL2PS_DRAW_PIXELS_TOKEN 14
115#define GL2PS_TEXT_TOKEN 15
198#if defined(GL2PS_HAVE_ZLIB)
199 Bytef *dest, *src, *start;
200 uLongf destLen, srcLen;
284 case GL2PS_INFO : fprintf(stderr,
"GL2PS info: ");
break;
285 case GL2PS_WARNING : fprintf(stderr,
"GL2PS warning: ");
break;
286 case GL2PS_ERROR : fprintf(stderr,
"GL2PS error: ");
break;
289 vfprintf(stderr,
fmt, args);
291 fprintf(stderr,
"\n");
300 if(!size)
return NULL;
311 if(!size)
return NULL;
312 ptr = realloc(ptr, size);
329 size_t size =
sizeof(
unsigned long);
330 for(i = 1; i <= bytes; ++i){
331 fputc(0xff & (
data >> (size-i) * 8),
gl2ps->stream);
338#if defined(GL2PS_HAVE_ZLIB)
340static void gl2psSetupCompress(
void)
343 gl2ps->compress->src = NULL;
344 gl2ps->compress->start = NULL;
345 gl2ps->compress->dest = NULL;
346 gl2ps->compress->srcLen = 0;
347 gl2ps->compress->destLen = 0;
350static void gl2psFreeCompress(
void)
356 gl2ps->compress->src = NULL;
357 gl2ps->compress->start = NULL;
358 gl2ps->compress->dest = NULL;
359 gl2ps->compress->srcLen = 0;
360 gl2ps->compress->destLen = 0;
363static int gl2psAllocCompress(
unsigned int srcsize)
367 if(!
gl2ps->compress || !srcsize)
370 gl2ps->compress->srcLen = srcsize;
371 gl2ps->compress->destLen = (int)ceil(1.001 *
gl2ps->compress->srcLen + 12);
373 gl2ps->compress->start =
gl2ps->compress->src;
379static void *gl2psReallocCompress(
unsigned int srcsize)
381 if(!
gl2ps->compress || !srcsize)
384 if(srcsize < gl2ps->
compress->srcLen)
385 return gl2ps->compress->start;
387 gl2ps->compress->srcLen = srcsize;
388 gl2ps->compress->destLen = (int)ceil(1.001 *
gl2ps->compress->srcLen + 12);
390 gl2ps->compress->srcLen);
391 gl2ps->compress->start =
gl2ps->compress->src;
393 gl2ps->compress->destLen);
395 return gl2ps->compress->start;
398static size_t gl2psWriteBigEndianCompress(
unsigned long data,
size_t bytes)
401 size_t size =
sizeof(
unsigned long);
402 for(i = 1;
i <= bytes; ++
i){
403 *
gl2ps->compress->src = (Bytef)(0xff & (
data >> (size-i) * 8));
404 ++
gl2ps->compress->src;
409static int gl2psDeflate(
void)
414 gl2ps->compress->start,
gl2ps->compress->srcLen);
424#if defined(GL2PS_HAVE_ZLIB)
425 unsigned int oldsize = 0;
426 static char buf[1000];
429 ret = vsprintf(buf,
fmt, args);
431 oldsize =
gl2ps->compress->srcLen;
432 gl2ps->compress->start = (Bytef*)gl2psReallocCompress(oldsize + ret);
433 memcpy(
gl2ps->compress->start+oldsize, buf, ret);
439 ret = vfprintf(
gl2ps->stream,
fmt, args);
441#if defined(GL2PS_HAVE_ZLIB)
449#if defined(GL2PS_HAVE_ZLIB)
450 char tmp[10] = {
'\x1f',
'\x8b',
458 gl2psSetupCompress();
460 fwrite(tmp, 10, 1,
gl2ps->stream);
467#if defined(GL2PS_HAVE_ZLIB)
473 if(Z_OK != gl2psDeflate()){
479 if(
gl2ps->compress->dest[1] & (1<<5)){
483 fwrite(
gl2ps->compress->dest+n,
gl2ps->compress->destLen-(n+4),
486 crc = crc32(0L,
gl2ps->compress->start,
gl2ps->compress->srcLen);
487 for(n = 0; n < 4; ++n){
488 tmp[n] = (char)(crc & 0xff);
491 len =
gl2ps->compress->srcLen;
492 for(n = 4; n < 8; ++n){
493 tmp[n] = (char)(len & 0xff);
496 fwrite(tmp, 8, 1,
gl2ps->stream);
500 gl2ps->compress = NULL;
516 list->array = (
char*)
gl2psMalloc(list->nmax * list->size);
520 list->nmax = ((n - 1) / list->incr + 1) * list->incr;
522 list->nmax * list->size);
532 if(incr <= 0) incr = 1;
564 memcpy(&list->array[(list->n - 1) * list->size],
data, list->size);
584 return &list->array[
index * list->size];
588 int (*fcmp)(
const void *
a,
const void *b))
592 qsort(list->array, list->n, list->size, fcmp);
613#if defined(GL2PS_HAVE_LIBPNG)
619 memcpy(
data, &list->array[
index * list->size], list->size);
622static void gl2psEncodeBase64Block(
unsigned char in[3],
unsigned char out[4],
int len)
624 static const char cb64[] =
625 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
627 out[0] = cb64[ in[0] >> 2 ];
628 out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
629 out[2] = (len > 1) ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] :
'=';
630 out[3] = (len > 2) ? cb64[ in[2] & 0x3f ] :
'=';
633static void gl2psListEncodeBase64(
GL2PSlist *list)
638 n = list->n * list->size;
640 memcpy(buffer, list->array, n *
sizeof(
unsigned char));
646 for(i = 0;
i < 3;
i++) {
657 gl2psEncodeBase64Block(in, out, len);
658 for(i = 0;
i < 4;
i++)
682 for(i = 1; i < prim->
numverts; i++){
695 if(n < 2)
return GL_TRUE;
697 for(i = 1; i < n; i++){
698 if(fabs(rgba[0][0] - rgba[i][0]) >
threshold[0] ||
699 fabs(rgba[0][1] - rgba[i][1]) >
threshold[1] ||
700 fabs(rgba[0][2] - rgba[i][2]) >
threshold[2])
710 for(i = 0; i < 3; ++i){
711 gl2ps->lastrgba[i] = rgba[i];
716 GLfloat *
red, GLfloat *
green, GLfloat *blue)
719 GLsizei
width = im->width;
720 GLsizei height = im->height;
721 GLfloat *pixels = im->pixels;
727 pimag = pixels + 4 * (
width * (height - 1 -
y) +
x);
731 pimag = pixels + 3 * (
width * (height - 1 -
y) +
x);
734 *
red = *pimag; pimag++;
735 *
green = *pimag; pimag++;
736 *blue = *pimag; pimag++;
738 return (im->format == GL_RGBA) ? *pimag : 1.0F;
748 image->width = im->width;
749 image->height = im->height;
750 image->format = im->format;
751 image->type = im->type;
753 switch(image->format){
755 size = image->height * image->width * 4 *
sizeof(GLfloat);
759 size = image->height * image->width * 3 *
sizeof(GLfloat);
764 memcpy(image->pixels, im->pixels, size);
777#if defined(GL2PS_HAVE_LIBPNG)
779#if !defined(png_jmpbuf)
780# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
783static void gl2psUserWritePNG(png_structp png_ptr, png_bytep
data, png_size_t
length)
791static void gl2psUserFlushPNG(png_structp )
799 unsigned char *row_data;
803 if(!(png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)))
806 if(!(info_ptr = png_create_info_struct(png_ptr))){
807 png_destroy_write_struct(&png_ptr, NULL);
811 if(setjmp(png_jmpbuf(png_ptr))) {
812 png_destroy_write_struct(&png_ptr, &info_ptr);
816 png_set_write_fn(png_ptr, (
void *)png, gl2psUserWritePNG, gl2psUserFlushPNG);
817 png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION);
818 png_set_IHDR(png_ptr, info_ptr, pixmap->
width, pixmap->
height, 8,
819 PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
820 PNG_FILTER_TYPE_BASE);
821 png_write_info(png_ptr, info_ptr);
823 row_data = (
unsigned char*)
gl2psMalloc(3 * pixmap->
width *
sizeof(
unsigned char));
825 for(col = 0; col < pixmap->
width; col++){
827 row_data[3*col] = (
unsigned char)(255. * dr);
828 row_data[3*col+1] = (
unsigned char)(255. * dg);
829 row_data[3*col+2] = (
unsigned char)(255. * db);
831 png_write_row(png_ptr, (png_bytep)row_data);
835 png_write_end(png_ptr, info_ptr);
836 png_destroy_write_struct(&png_ptr, &info_ptr);
844 GLshort fontsize, GLint alignment, GLfloat
angle)
854 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
857 glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
872 glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->
verts[0].
rgba);
891 text->str = (
char*)
gl2psMalloc((strlen(t->str)+1)*
sizeof(
char));
892 strcpy(text->str, t->str);
893 text->fontname = (
char*)
gl2psMalloc((strlen(t->fontname)+1)*
sizeof(
char));
894 strcpy(text->fontname, t->fontname);
895 text->fontsize = t->fontsize;
896 text->alignment = t->alignment;
897 text->angle = t->angle;
918 if( (sfactor == GL_SRC_ALPHA && dfactor == GL_ONE_MINUS_SRC_ALPHA) ||
919 (sfactor == GL_ONE && dfactor == GL_ZERO) )
939 switch(
gl2ps->blendfunc[0]){
969 if(!
GL2PS_ZERO(t->vertex[0].rgba[3] - t->vertex[1].rgba[3]) ||
970 !
GL2PS_ZERO(t->vertex[1].rgba[3] - t->vertex[2].rgba[3])){
974 if(t->vertex[0].rgba[3] < 1)
982 GLboolean assignprops)
984 t->vertex[0] = p->verts[0];
985 t->vertex[1] = p->verts[1];
986 t->vertex[2] = p->verts[2];
987 if(GL_TRUE == assignprops)
994 GL2PSvertex vertex = { {-1.0F, -1.0F, -1.0F}, {-1.0F, -1.0F, -1.0F, -1.0F} };
995 for(i = 0; i < 3; i++)
996 t->vertex[i] = vertex;
1013 prim->
type = p->type;
1016 prim->
offset = p->offset;
1018 prim->
factor = p->factor;
1019 prim->
culled = p->culled;
1020 prim->
width = p->width;
1056 return (plane[0] * point[0] +
1057 plane[1] * point[1] +
1058 plane[2] * point[2] +
1064 return (
a[0]*b[0] +
a[1]*b[1] +
a[2]*b[2]);
1069 c[0] =
a[1]*b[2] -
a[2]*b[1];
1070 c[1] =
a[2]*b[0] -
a[0]*b[2];
1071 c[2] =
a[0]*b[1] -
a[1]*b[0];
1076 return (GLfloat)sqrt(
a[0]*
a[0] +
a[1]*
a[1] +
a[2]*
a[2]);
1100 GL2PSxyz v = {0.0F, 0.0F, 0.0F}, w = {0.0F, 0.0F, 0.0F};
1113 plane[0] = plane[1] = 0.0F;
1122 - plane[2] * prim->
verts[0].
xyz[2];
1130 plane[0] = plane[1] = 0.0F;
1142 - plane[2] * prim->
verts[0].
xyz[2];
1150 plane[0] = plane[1] = 0.0F;
1156 plane[0] = plane[1] = plane[3] = 0.0F;
1168 v[0] = b->xyz[0] -
a->xyz[0];
1169 v[1] = b->xyz[1] -
a->xyz[1];
1170 v[2] = b->xyz[2] -
a->xyz[2];
1177 c->xyz[0] =
a->xyz[0] + v[0] * sect;
1178 c->xyz[1] =
a->xyz[1] + v[1] * sect;
1179 c->xyz[2] =
a->xyz[2] + v[2] * sect;
1181 c->rgba[0] = (1 - sect) *
a->rgba[0] + sect * b->rgba[0];
1182 c->rgba[1] = (1 - sect) *
a->rgba[1] + sect * b->rgba[1];
1183 c->rgba[2] = (1 - sect) *
a->rgba[2] + sect * b->rgba[2];
1184 c->rgba[3] = (1 - sect) *
a->rgba[3] + sect * b->rgba[3];
1189 GLshort *index0, GLshort *index1)
1212 child->
culled = parent->culled;
1213 child->
offset = parent->offset;
1214 child->
pattern = parent->pattern;
1215 child->
factor = parent->factor;
1216 child->
width = parent->width;
1220 for(i = 0; i < numverts; i++){
1222 child->
verts[i] = parent->verts[index0[i]];
1225 gl2psCutEdge(&parent->verts[index0[i]], &parent->verts[index1[i]],
1226 plane, &child->
verts[i]);
1232 GLshort i, GLshort j)
1236 for(k = 0; k < *nb; k++){
1237 if((index0[k] == i && index1[k] == j) ||
1238 (index1[k] == i && index0[k] == j))
return;
1247 return (i < num - 1) ? i + 1 : 0;
1256 for(i = 0; i < prim->
numverts; i++){
1264 for(i = 0; i < prim->
numverts; i++){
1284 GLshort i(0), j(0), in = 0, out = 0, in0[5], in1[5], out0[5], out1[5];
1285 for (
unsigned k=0;k<5;++k)
1286 in0[k]=in1[k]=out0[k]=out1[k]=0;
1292 for(i = 0; i < prim->
numverts; i++){
1303 for(i = 0; i < prim->
numverts; i++){
1349 (*t1)->numverts = (*t2)->numverts = 3;
1350 (*t1)->culled = (*t2)->culled = quad->culled;
1351 (*t1)->offset = (*t2)->offset = quad->offset;
1352 (*t1)->pattern = (*t2)->pattern = quad->pattern;
1353 (*t1)->factor = (*t2)->factor = quad->factor;
1354 (*t1)->width = (*t2)->width = quad->width;
1357 (*t1)->verts[0] = quad->verts[0];
1358 (*t1)->verts[1] = quad->verts[1];
1359 (*t1)->verts[2] = quad->verts[2];
1360 (*t1)->boundary = ((quad->boundary & 1) ? 1 : 0) | ((quad->boundary & 2) ? 2 : 0);
1361 (*t2)->verts[0] = quad->verts[0];
1362 (*t2)->verts[1] = quad->verts[2];
1363 (*t2)->verts[2] = quad->verts[3];
1364 (*t2)->boundary = ((quad->boundary & 4) ? 2 : 0) | ((quad->boundary & 4) ? 2 : 0);
1370 GLfloat dq = 0.0F, dw = 0.0F,
diff;
1376 for(i = 0; i < q->numverts; i++){
1377 dq += q->verts[i].xyz[2];
1379 dq /= (GLfloat)q->numverts;
1381 for(i = 0; i < w->numverts; i++){
1382 dw += w->verts[i].xyz[2];
1384 dw /= (GLfloat)w->numverts;
1404 return (q->type < w->type ? 1 : -1);
1409 GLint i, j,
count, best = 1000000,
index = 0;
1423 if(maxp >
gl2ps->maxbestroot){
1424 maxp =
gl2ps->maxbestroot;
1426 for(i = 0; i < maxp; i++){
1435 if(
count > best)
break;
1455 while(list != NULL){
1499 if((*tree)->primitives){
1511 if(f1 > f2)
return GL_TRUE;
1512 else return GL_FALSE;
1517 if(f1 < f2)
return GL_TRUE;
1518 else return GL_FALSE;
1523 GL2PSprimitive *prim =
nullptr, *frontprim =
nullptr, *backprim =
nullptr;
1527 tree->front =
nullptr;
1528 tree->back =
nullptr;
1585 GLboolean (*compare)(GLfloat f1, GLfloat f2),
1586 void (*action)(
void *
data),
int inverse)
1594 if(GL_TRUE == compare(
result, epsilon)){
1604 else if(GL_TRUE == compare(-epsilon,
result)){
1623 GLfloat minZ, maxZ, rangeZ, scaleZ;
1624 GLfloat factor, units,
area, dZ, dZdX, dZdY, maxdZ;
1632 minZ = maxZ = prim->
verts[0].
xyz[2];
1633 for(i = 1; i < prim->
numverts; i++){
1639 for(j = 0; j < prim->
numverts; j++){
1644 rangeZ = (maxZ - minZ);
1650 if(scaleZ > 100000.F) scaleZ = 100000.F;
1655 for(j = 0; j < prim->
numverts; j++){
1670 factor =
gl2ps->offset[0];
1671 units =
gl2ps->offset[1];
1688 maxdZ = (GLfloat)sqrt(dZdX * dZdX + dZdY * dZdY);
1693 dZ = factor * maxdZ + units;
1711 plane[0] = b[1] -
a[1];
1712 plane[1] =
a[0] - b[0];
1713 n = (GLfloat)sqrt(plane[0]*plane[0] + plane[1]*plane[1]);
1718 plane[3] = -plane[0]*
a[0]-plane[1]*
a[1];
1763 for(i = 0; i < prim->
numverts-1; i++){
1781 for(i = 2+offset; i < prim->
numverts; i++){
1788 for(i = 1+offset; i < prim->
numverts-1; i++){
1789 if(cur->front == NULL){
1794 cur->front->plane)){
1800 if(cur->front == NULL){
1805 cur->front->plane)){
1806 cur->front->front = NULL;
1807 cur->front->back = NULL;
1815 for(i = 0; i < 4; i++){
1819 for(i = 1+offset; i < prim->
numverts-1; i++){
1820 if(cur->front == NULL){
1825 cur->front->plane)){
1831 if(cur->front == NULL){
1836 cur->front->plane)){
1837 cur->front->front = NULL;
1838 cur->front->back = NULL;
1859 for(i = 1; i < prim->
numverts; i++){
1889 child->
culled = parent->culled;
1890 child->
offset = parent->offset;
1891 child->
pattern = parent->pattern;
1892 child->
factor = parent->factor;
1893 child->
width = parent->width;
1896 for(i = 0; i < numverts; i++){
1897 child->
verts[i] = vertx[i];
1912 GLint cur = -1, prev = -1, i, v1 = 0, v2 = 0, flag = 1, prev0 = -1;
1915 GL2PSvertex *front_list = NULL, *back_list = NULL;
1918 GLshort front_count = 0, back_count = 0;
1920 for(i = 0; i <= prim->
numverts; i++){
1934 if(((prev == -1) || (prev == cur) || (prev == 0) || (cur == 0)) &&
1935 (i < prim->numverts)){
1940 front_list[front_count-1] = prim->
verts[v1];
1946 back_list[back_count-1] = prim->
verts[v1];
1952 front_list[front_count-1] = prim->
verts[v1];
1956 back_list[back_count-1] = prim->
verts[v1];
1960 else if((prev != cur) && (cur != 0) && (prev != 0)){
1969 plane, &front_list[front_count-1]);
1973 back_list[back_count-1] = front_list[front_count-1];
2013 if((*tree)->front != NULL){
2024 if((*tree)->back != NULL){
2025 gl2ps->zerosurfacearea = GL_TRUE;
2027 gl2ps->zerosurfacearea = GL_FALSE;
2030 if((*tree)->front != NULL){
2031 gl2ps->zerosurfacearea = GL_TRUE;
2033 gl2ps->zerosurfacearea = GL_FALSE;
2046 gl2ps->primitivetoadd = prim;
2066 c[0] = c[1] = c[2] = 0.0F;
2067 for(i = 0; i < prim->
numverts; i++){
2074 for(i = 0; i < prim->
numverts; i++){
2075 if(prim->
boundary & (GLint)pow(2., i)){
2078 b->offset = prim->
offset;
2080 b->factor = prim->
factor;
2081 b->culled = prim->
culled;
2082 b->width = prim->
width;
2088 v[0] = c[0] - prim->
verts[i].
xyz[0];
2089 v[1] = c[1] - prim->
verts[i].
xyz[1];
2094 b->verts[0].xyz[0] = prim->
verts[i].
xyz[0] +0.1*v[0];
2095 b->verts[0].xyz[1] = prim->
verts[i].
xyz[1] +0.1*v[1];
2096 b->verts[0].xyz[2] = prim->
verts[i].
xyz[2];
2106 b->verts[0].xyz[0] = prim->
verts[i].
xyz[0];
2107 b->verts[0].xyz[1] = prim->
verts[i].
xyz[1];
2108 b->verts[0].xyz[2] = prim->
verts[i].
xyz[2];
2114 b->verts[0].rgba[0] = 0.0F;
2115 b->verts[0].rgba[1] = 0.0F;
2116 b->verts[0].rgba[2] = 0.0F;
2117 b->verts[0].rgba[3] = 0.0F;
2118 b->verts[1].rgba[0] = 0.0F;
2119 b->verts[1].rgba[1] = 0.0F;
2120 b->verts[1].rgba[2] = 0.0F;
2121 b->verts[1].rgba[3] = 0.0F;
2150 GLushort pattern, GLint factor,
2151 GLfloat
width,
char boundary)
2181 if(
gl2ps->colormode == GL_COLOR_INDEX &&
gl2ps->colorsize > 0){
2182 i = (GLint)(p[3] + 0.5);
2183 v->rgba[0] =
gl2ps->colormap[i][0];
2184 v->rgba[1] =
gl2ps->colormap[i][1];
2185 v->rgba[2] =
gl2ps->colormap[i][2];
2186 v->rgba[3] =
gl2ps->colormap[i][3];
2201 GLushort pattern = 0;
2203 GLint i, sizeoffloat,
count, v, vtot, offset = 0, factor = 0, auxindex = 0;
2204 GLfloat lwidth = 1.0F, psize = 1.0F;
2210 current =
gl2ps->feedback;
2211 boundary =
gl2ps->boundary = GL_FALSE;
2215 if(GL_TRUE == boundary)
gl2ps->boundary = GL_TRUE;
2217 switch((GLint)*current){
2218 case GL_POINT_TOKEN :
2225 pattern, factor, psize, 0);
2227 case GL_LINE_TOKEN :
2228 case GL_LINE_RESET_TOKEN :
2238 pattern, factor, lwidth, 0);
2240 case GL_POLYGON_TOKEN :
2241 count = (GLint)current[1];
2253 if(GL_TRUE == boundary){
2254 if(!
count && vtot == 2) flag = 1|2|4;
2255 else if(!
count) flag = 2|4;
2256 else if(vtot == 2) flag = 1|2;
2262 pattern, factor, 1, flag);
2263 vertices[1] = vertices[2];
2269 case GL_BITMAP_TOKEN :
2270 case GL_DRAW_PIXEL_TOKEN :
2271 case GL_COPY_PIXEL_TOKEN :
2278 case GL_PASS_THROUGH_TOKEN :
2279 switch((GLint)current[1]){
2290 pattern = (GLushort)current[1];
2293 factor = (GLint)current[1];
2298 gl2ps->blendfunc[0] = (GLint)current[1];
2303 gl2ps->blendfunc[1] = (GLint)current[1];
2313 lwidth = current[1];
2330 node->image->format = 0;
2333 if(
gl2ps->imagemap_head == NULL)
2340 current += 2;
used -= 2;
2342 current += i;
used -= i;
2344 node->image->width = (GLint)current[2];
2345 current += 2;
used -= 2;
2346 node->image->height = (GLint)current[2];
2349 for(i = 1; i < 4; i++){
2350 for(v = 0; v < 3; v++){
2361 sizeoffloat =
sizeof(GLfloat);
2362 v = 2 * sizeoffloat;
2363 vtot =
node->image->height +
node->image->height *
2364 ((
node->image->width - 1) / 8);
2369 for(i = 0; i < vtot; i += sizeoffloat){
2370 current += 2;
used -= 2;
2372 memcpy(&(
node->image->pixels[i + v]), &(current[2]), sizeoffloat);
2374 memcpy(&(
node->image->pixels[i + v]), &(current[2]), vtot - i);
2410 unsigned char h =
byte / 16;
2411 unsigned char l =
byte % 16;
2417 GLuint nbhex, nbyte, nrgb, nbits;
2418 GLuint row, col, ibyte, icase;
2419 GLfloat dr, dg, db, fgrey;
2420 unsigned char red = 0,
green = 0, blue = 0, b, grey;
2421 GLuint
width = (GLuint)im->width;
2422 GLuint height = (GLuint)im->height;
2431 const int greyscale = 0;
2434 if((
width <= 0) || (height <= 0))
return;
2445 gl2psPrintf(
"{ currentfile picstr readhexstring pop }\n");
2447 for(row = 0; row < height; row++){
2448 for(col = 0; col <
width; col++){
2450 fgrey = (0.30F * dr + 0.59F * dg + 0.11F * db);
2451 grey = (
unsigned char)(255. * fgrey);
2456 nbhex =
width * height * 2;
2462 nbits = nrgb * nbit;
2464 if((nbyte * 8) != nbits) nbyte++;
2468 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2471 for(row = 0; row < height; row++){
2475 for(ibyte = 0; ibyte < nbyte; ibyte++){
2484 red = (
unsigned char)(3. * dr);
2485 green = (
unsigned char)(3. * dg);
2486 blue = (
unsigned char)(3. * db);
2497 red = (
unsigned char)(3. * dr);
2498 green = (
unsigned char)(3. * dg);
2499 blue = (
unsigned char)(3. * db);
2505 else if(icase == 2) {
2515 red = (
unsigned char)(3. * dr);
2516 green = (
unsigned char)(3. * dg);
2517 blue = (
unsigned char)(3. * db);
2524 else if(icase == 3) {
2533 red = (
unsigned char)(3. * dr);
2534 green = (
unsigned char)(3. * dg);
2535 blue = (
unsigned char)(3. * db);
2549 nbits = nrgb * nbit;
2551 if((nbyte * 8) != nbits) nbyte++;
2555 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2558 for(row = 0; row < height; row++){
2561 for(ibyte = 0; ibyte < nbyte; ibyte++){
2570 red = (
unsigned char)(15. * dr);
2571 green = (
unsigned char)(15. * dg);
2575 else if(icase == 2) {
2576 blue = (
unsigned char)(15. * db);
2584 red = (
unsigned char)(15. * dr);
2588 else if(icase == 3) {
2589 green = (
unsigned char)(15. * dg);
2590 blue = (
unsigned char)(15. * db);
2603 gl2psPrintf(
"{ currentfile rgbstr readhexstring pop }\n");
2606 for(row = 0; row < height; row++){
2607 for(col = 0; col <
width; col++){
2609 red = (
unsigned char)(255. * dr);
2611 green = (
unsigned char)(255. * dg);
2613 blue = (
unsigned char)(255. * db);
2624 GLsizei
width, GLsizei height,
2625 const unsigned char *imagemap){
2628 if((
width <= 0) || (height <= 0))
return;
2630 size = height + height * (
width - 1) / 8;
2636 for(i = 0; i < size; i++){
2662 "%%%%Creator: GL2PS %d.%d.%d%s, %s\n"
2664 "%%%%CreationDate: %s"
2665 "%%%%LanguageLevel: 3\n"
2666 "%%%%DocumentData: Clean7Bit\n"
2670 gl2ps->producer, ctime(&now));
2674 "%%%%DocumentMedia: Default %d %d 0 () ()\n",
2677 (
int)
gl2ps->viewport[2],
2679 (
int)
gl2ps->viewport[3]);
2683 "%%%%EndComments\n",
2685 (
int)
gl2ps->viewport[0],
2687 (
int)
gl2ps->viewport[1],
2689 (
int)
gl2ps->viewport[2],
2691 (
int)
gl2ps->viewport[3]);
2707 "/gl2psdict 64 dict def gl2psdict begin\n"
2708 "0 setlinecap 0 setlinejoin\n"
2709 "/tryPS3shading %s def %% set to false to force subdivision\n"
2710 "/rThreshold %g def %% red component subdivision threshold\n"
2711 "/gThreshold %g def %% green component subdivision threshold\n"
2712 "/bThreshold %g def %% blue component subdivision threshold\n",
2717 "/C { setrgbcolor } BD\n"
2718 "/G { 0.082 mul exch 0.6094 mul add exch 0.3086 mul add neg 1.0 add setgray } BD\n"
2719 "/W { setlinewidth } BD\n");
2721 gl2psPrintf(
"/FC { findfont exch /SH exch def SH scalefont setfont } BD\n"
2722 "/SW { dup stringwidth pop } BD\n"
2723 "/S { FC moveto show } BD\n"
2724 "/SBC{ FC moveto SW -2 div 0 rmoveto show } BD\n"
2725 "/SBR{ FC moveto SW neg 0 rmoveto show } BD\n"
2726 "/SCL{ FC moveto 0 SH -2 div rmoveto show } BD\n"
2727 "/SCC{ FC moveto SW -2 div SH -2 div rmoveto show } BD\n"
2728 "/SCR{ FC moveto SW neg SH -2 div rmoveto show } BD\n"
2729 "/STL{ FC moveto 0 SH neg rmoveto show } BD\n"
2730 "/STC{ FC moveto SW -2 div SH neg rmoveto show } BD\n"
2731 "/STR{ FC moveto SW neg SH neg rmoveto show } BD\n");
2736 "/SR { gsave FCT moveto rotate show grestore } BD\n"
2737 "/SBCR{ gsave FCT moveto rotate SW -2 div 0 rmoveto show grestore } BD\n"
2738 "/SBRR{ gsave FCT moveto rotate SW neg 0 rmoveto show grestore } BD\n"
2739 "/SCLR{ gsave FCT moveto rotate 0 SH -2 div rmoveto show grestore} BD\n");
2740 gl2psPrintf(
"/SCCR{ gsave FCT moveto rotate SW -2 div SH -2 div rmoveto show grestore} BD\n"
2741 "/SCRR{ gsave FCT moveto rotate SW neg SH -2 div rmoveto show grestore} BD\n"
2742 "/STLR{ gsave FCT moveto rotate 0 SH neg rmoveto show grestore } BD\n"
2743 "/STCR{ gsave FCT moveto rotate SW -2 div SH neg rmoveto show grestore } BD\n"
2744 "/STRR{ gsave FCT moveto rotate SW neg SH neg rmoveto show grestore } BD\n");
2746 gl2psPrintf(
"/P { newpath 0.0 360.0 arc closepath fill } BD\n"
2747 "/LS { newpath moveto } BD\n"
2748 "/L { lineto } BD\n"
2749 "/LE { lineto stroke } BD\n"
2750 "/T { newpath moveto lineto lineto closepath fill } BD\n");
2756 " /b1 exch def /g1 exch def /r1 exch def /y1 exch def /x1 exch def\n"
2757 " /b2 exch def /g2 exch def /r2 exch def /y2 exch def /x2 exch def\n"
2758 " /b3 exch def /g3 exch def /r3 exch def /y3 exch def /x3 exch def\n"
2759 " gsave << /ShadingType 4 /ColorSpace [/DeviceRGB]\n"
2760 " /DataSource [ 0 x1 y1 r1 g1 b1 0 x2 y2 r2 g2 b2 0 x3 y3 r3 g3 b3 ] >>\n"
2761 " shfill grestore } BD\n");
2767 "/Tm { 3 -1 roll 8 -1 roll 13 -1 roll add add 3 div\n"
2769 " 3 -1 roll 7 -1 roll 11 -1 roll add add 3 div\n"
2771 " 3 -1 roll 6 -1 roll 9 -1 roll add add 3 div"
2781 " 4 index 15 index add 0.5 mul\n"
2782 " 4 index 15 index add 0.5 mul\n"
2783 " 4 index 15 index add 0.5 mul\n"
2784 " 4 index 15 index add 0.5 mul\n"
2785 " 4 index 15 index add 0.5 mul\n"
2786 " 5 copy 5 copy 25 15 roll\n");
2791 " 9 index 30 index add 0.5 mul\n"
2792 " 9 index 30 index add 0.5 mul\n"
2793 " 9 index 30 index add 0.5 mul\n"
2794 " 9 index 30 index add 0.5 mul\n"
2795 " 5 copy 5 copy 35 5 roll 25 5 roll 15 5 roll\n");
2800 " 4 index 10 index add 0.5 mul\n"
2801 " 4 index 10 index add 0.5 mul\n"
2802 " 4 index 10 index add 0.5 mul\n"
2803 " 4 index 10 index add 0.5 mul\n"
2804 " 5 copy 5 copy 40 5 roll 25 5 roll 15 5 roll 25 5 roll\n");
2808 gl2psPrintf(
" STnoshfill STnoshfill STnoshfill STnoshfill } BD\n");
2815 " 2 index 8 index sub abs rThreshold gt\n"
2817 " { 1 index 7 index sub abs gThreshold gt\n"
2819 " { dup 6 index sub abs bThreshold gt\n"
2821 " { 2 index 13 index sub abs rThreshold gt\n"
2823 " { 1 index 12 index sub abs gThreshold gt\n"
2825 " { dup 11 index sub abs bThreshold gt\n"
2827 " { 7 index 13 index sub abs rThreshold gt\n");
2829 " { 6 index 12 index sub abs gThreshold gt\n"
2831 " { 5 index 11 index sub abs bThreshold gt\n"
2846 " { /ST { STshfill } BD }\n"
2847 " { /ST { STnoshfill } BD }\n"
2849 "{ /ST { STnoshfill } BD }\n"
2855 "/DeviceRGB setcolorspace\n"
2859 "%%%%BeginPageSetup\n");
2863 (
int)
gl2ps->viewport[3]);
2873 "newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n"
2876 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[1], (
int)
gl2ps->viewport[2],
2877 (
int)
gl2ps->viewport[1], (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[3],
2878 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[3]);
2886 gl2psPrintf(
"%g %g %g C\n", rgba[0], rgba[1], rgba[2]);
2898 if(
gl2ps->lastvertex.rgba[0] >= 0.){
2900 for(i = 0; i < 3; i++)
2901 gl2ps->lastvertex.xyz[i] = -1.;
2902 for(i = 0; i < 4; i++)
2903 gl2ps->lastvertex.rgba[i] = -1.;
2908 int *nb,
int array[10])
2911 int on[8] = {0, 0, 0, 0, 0, 0, 0, 0};
2912 int off[8] = {0, 0, 0, 0, 0, 0, 0, 0};
2916 for(n = 15; n >= 0; n--){
2917 tmp[n] = (char)(pattern & 0x01);
2922 for(i = 0; i < 8; i++){
2923 while(n < 16 && !tmp[n]){ off[i]++; n++; }
2924 while(n < 16 && tmp[n]){ on[i]++; n++; }
2925 if(n >= 15){ i++;
break; }
2934 for(n = i - 1; n >= 0 && *nb <= 8; n--){
2935 array[(*nb)++] = factor * on[n];
2936 array[(*nb)++] = factor * off[n];
2942 int len = 0, i, n, array[10];
2944 if(pattern ==
gl2ps->lastpattern && factor ==
gl2ps->lastfactor)
2947 gl2ps->lastpattern = pattern;
2948 gl2ps->lastfactor = factor;
2950 if(!pattern || !factor){
2957 for(i = 0; i < n; i++){
3014 newline ?
"LS" :
"L");
3020 gl2psPrintf(
"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g ST\n",
3051 reinterpret_cast<const unsigned char*
>(&(prim->
data.
image->
pixels[2])));
3123 int x = viewport[0],
y = viewport[1], w = viewport[2],
h = viewport[3];
3125 glRenderMode(GL_FEEDBACK);
3129 gl2ps->header = GL_FALSE;
3136 if(
gl2ps->colormode == GL_RGBA ||
gl2ps->colorsize == 0){
3137 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
3140 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &
index);
3147 "newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n"
3149 rgba[0], rgba[1], rgba[2],
3153 gl2psPrintf(
"newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n"
3195 "Encapsulated Postscript"
3210 if(
gl2ps->filename && strlen(
gl2ps->filename) < 256){
3211 for(i = strlen(
gl2ps->filename)-1; i >= 0; i--){
3212 if(
gl2ps->filename[i] ==
'.'){
3213 strncpy(name,
gl2ps->filename, i);
3218 if(i <= 0) strcpy(name,
gl2ps->filename);
3221 strcpy(name,
"untitled");
3226 fprintf(
gl2ps->stream,
3228 "%% Creator: GL2PS %d.%d.%d%s, %s\n"
3230 "%% CreationDate: %s",
3233 gl2ps->producer, ctime(&now));
3235 fprintf(
gl2ps->stream,
3236 "\\setlength{\\unitlength}{1pt}\n"
3237 "\\begin{picture}(0,0)\n"
3238 "\\includegraphics{%s}\n"
3239 "\\end{picture}%%\n"
3240 "%s\\begin{picture}(%d,%d)(0,0)\n",
3242 (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[3]);
3253 fprintf(
gl2ps->stream,
"\\fontsize{%d}{0}\n\\selectfont",
3255 fprintf(
gl2ps->stream,
"\\put(%g,%g){\\makebox(0,0)",
3259 fprintf(
gl2ps->stream,
"{");
3262 fprintf(
gl2ps->stream,
"[l]{");
3265 fprintf(
gl2ps->stream,
"[r]{");
3268 fprintf(
gl2ps->stream,
"[b]{");
3271 fprintf(
gl2ps->stream,
"[br]{");
3274 fprintf(
gl2ps->stream,
"[t]{");
3277 fprintf(
gl2ps->stream,
"[tl]{");
3280 fprintf(
gl2ps->stream,
"[tr]{");
3284 fprintf(
gl2ps->stream,
"[bl]{");
3289 fprintf(
gl2ps->stream,
"\\textcolor[rgb]{%g,%g,%g}{{%s}}",
3293 fprintf(
gl2ps->stream,
"}");
3294 fprintf(
gl2ps->stream,
"}}\n");
3309 fprintf(
gl2ps->stream,
"\\end{picture}%s\n",
3316 glRenderMode(GL_FEEDBACK);
3320 gl2ps->header = GL_FALSE;
3354#if defined(GL2PS_HAVE_ZLIB)
3356 return fprintf(
gl2ps->stream,
"/Filter [/FlateDecode]\n");
3367 for(i = 0; i < 3; ++i){
3370 else if(rgba[i] < 1e-4 || rgba[i] > 1e6)
3383 for(i = 0; i < 3; ++i){
3386 else if(rgba[i] < 1e-4 || rgba[i] > 1e6)
3399 else if(lw < 1e-4 || lw > 1e6)
3407 GLfloat rad, crad, srad;
3409 if(text->angle == 0.0F){
3416 cnt, text->fontsize,
x,
y, text->str);
3419 rad =
M_PI * text->angle / 180.0F;
3420 srad = (GLfloat)sin(rad);
3421 crad = (GLfloat)cos(rad);
3425 "%f %f %f %f %f %f Tm\n"
3428 cnt, text->fontsize, crad, srad, -srad, crad,
x,
y, text->str);
3436 "%d 0 0 %d %f %f cm\n"
3439 (
int)image->width, (
int)image->height,
x,
y, cnt);
3444 gl2ps->objects_stack = 7 + 1;
3445 gl2ps->extgs_stack = 0;
3446 gl2ps->font_stack = 0;
3447 gl2ps->im_stack = 0;
3448 gl2ps->trgroupobjects_stack = 0;
3449 gl2ps->shader_stack = 0;
3450 gl2ps->mshader_stack = 0;
3472 GL2PSrgba lastrgba = {-1.0F, -1.0F, -1.0F, -1.0F};
3473 GLushort lastpattern = 0;
3474 GLint lastfactor = 0;
3475 GLfloat lastwidth = 1;
3477 int lastTriangleWasNotSimpleWithSameColor = 0;
3479 if(!
gl2ps->pdfprimlist)
3503 if(lasttype != p->type || lastwidth != p->width ||
3504 lastpattern != p->pattern || lastfactor != p->factor ||
3514 lastpattern = p->pattern;
3515 lastfactor = p->factor;
3516 lastwidth = p->width;
3517 lastrgba[0] = p->verts[0].rgba[0];
3518 lastrgba[1] = p->verts[0].rgba[1];
3519 lastrgba[2] = p->verts[0].rgba[2];
3522 if(lasttype != p->type || lastwidth != p->width ||
3532 lastwidth = p->width;
3533 lastrgba[0] = p->verts[0].rgba[0];
3534 lastrgba[1] = p->verts[0].rgba[1];
3535 lastrgba[2] = p->verts[0].rgba[2];
3539 lastTriangleWasNotSimpleWithSameColor =
3542 if(lasttype == p->type && tmpt.
prop == lastt.
prop &&
3543 lastTriangleWasNotSimpleWithSameColor){
3623 if(!
gl2ps->pdfgrouplist)
3640 for(j = 0; j <= lastel; ++j){
3642 gl2ps->streamlength +=
3658 gl2ps->streamlength +=
3662 for(j = 1; j <= lastel; ++j){
3669 gl2ps->streamlength +=
3671 prev->verts[1].xyz[0], prev->verts[1].xyz[1]);
3672 gl2ps->streamlength +=
3679 gl2ps->streamlength +=
3685 gl2ps->streamlength +=
3697 for(j = 0; j <= lastel; ++j){
3705 t.vertex[0].xyz[0], t.vertex[0].xyz[1],
3706 t.vertex[1].xyz[0], t.vertex[1].xyz[1],
3707 t.vertex[2].xyz[0], t.vertex[2].xyz[1]);
3717 for(j = 0; j <= lastel; ++j){
3725 t.vertex[0].xyz[0], t.vertex[0].xyz[1],
3726 t.vertex[1].xyz[0], t.vertex[1].xyz[1],
3727 t.vertex[2].xyz[0], t.vertex[2].xyz[1]);
3740 for(j = 0; j <= lastel; ++j){
3748 t.vertex[0].xyz[0], t.vertex[0].xyz[1],
3749 t.vertex[1].xyz[0], t.vertex[1].xyz[1],
3750 t.vertex[2].xyz[0], t.vertex[2].xyz[1]);
3782 for(j = 0; j <= lastel; ++j){
3789 for(j = 0; j <= lastel; ++j){
3810 offs += fprintf(
gl2ps->stream,
3819 offs += fprintf(
gl2ps->stream,
">>\n");
3831 offs += fprintf(
gl2ps->stream,
3841 offs += fprintf(
gl2ps->stream,
">>\n");
3854 offs += fprintf(
gl2ps->stream,
3866 if(GL_RGBA == p->data.image->format)
3867 gl2ps->objects_stack++;
3878 offs += fprintf(
gl2ps->stream,
">>\n");
3890 offs += fprintf(
gl2ps->stream,
"/Font\n<<\n");
3899 offs += fprintf(
gl2ps->stream,
">>\n");
3909 if(!
gl2ps->pdfgrouplist)
3918 gl2ps->pdfgrouplist = NULL;
3931 offs = fprintf(
gl2ps->stream,
3935 "/Creator (GL2PS %d.%d.%d%s, %s)\n"
3941 if(!gmtime_r(&now, &newtime)){
3942 offs += fprintf(
gl2ps->stream,
3948 offs += fprintf(
gl2ps->stream,
3949 "/CreationDate (D:%d%02d%02d%02d%02d%02d)\n"
3952 newtime.tm_year+1900,
3965 return fprintf(
gl2ps->stream,
3976 return fprintf(
gl2ps->stream,
3992 offs += fprintf(
gl2ps->stream,
3995 "/Length 5 0 R\n" );
3997 offs += fprintf(
gl2ps->stream,
4014 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[1],
4015 (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[3]);
4031#if defined(GL2PS_HAVE_ZLIB)
4033 gl2psSetupCompress();
4036 gl2ps->xreflist[0] = 0;
4037 offs += fprintf(
gl2ps->stream,
"%%PDF-1.4\n");
4038 gl2ps->xreflist[1] = offs;
4041 gl2ps->xreflist[2] = offs;
4044 gl2ps->xreflist[3] = offs;
4047 gl2ps->xreflist[4] = offs;
4050 gl2ps->xreflist[5] = offs;
4073#if defined(GL2PS_HAVE_ZLIB)
4075 if(Z_OK != gl2psDeflate())
4078 fwrite(
gl2ps->compress->dest,
gl2ps->compress->destLen, 1,
gl2ps->stream);
4079 gl2ps->streamlength +=
gl2ps->compress->destLen;
4081 offs +=
gl2ps->streamlength;
4082 gl2psFreeCompress();
4086 offs += fprintf(
gl2ps->stream,
4096 return fprintf(
gl2ps->stream,
4110 offs = fprintf(
gl2ps->stream,
4115 "/MediaBox [%d %d %d %d]\n",
4116 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[1],
4117 (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[3]);
4120 offs += fprintf(
gl2ps->stream,
"/Rotate -90\n");
4122 offs += fprintf(
gl2ps->stream,
4126 "/ProcSet [/PDF /Text /ImageB /ImageC] %%/ImageI\n");
4150 offs += fprintf(
gl2ps->stream,
4161 return fprintf(
gl2ps->stream,
4164 "/Type /ExtGState\n"
4180 size_t (*action)(
unsigned long data,
4182 GLfloat dx, GLfloat dy,
4188 double dmax =
static_cast<double>(~1UL);
4192 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4194 offs += (*action)(edgeflag, 1);
4200 offs += (*action)(0, 4);
4201 offs += (*action)(0, 4);
4204 diff = (vertex->xyz[0] -
xmin) / dx;
4209 imap = (
unsigned long)(
diff * dmax);
4210 offs += (*action)(imap, 4);
4212 diff = (vertex->xyz[1] -
ymin) / dy;
4217 imap = (
unsigned long)(
diff * dmax);
4218 offs += (*action)(imap, 4);
4227 size_t (*action)(
unsigned long data,
4232 double dmax =
static_cast<double>(~1UL);
4235 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4237 imap = (
unsigned long)((vertex->rgba[0]) * dmax);
4238 offs += (*action)(imap, 1);
4240 imap = (
unsigned long)((vertex->rgba[1]) * dmax);
4241 offs += (*action)(imap, 1);
4243 imap = (
unsigned long)((vertex->rgba[2]) * dmax);
4244 offs += (*action)(imap, 1);
4252 size_t (*action)(
unsigned long data,
4258 double dmax =
static_cast<double>(~1UL);
4261 if(
sizeof(
unsigned long) == 8) dmax = dmax - 2048.;
4263 if(sigbyte != 8 && sigbyte != 16)
4268 imap = (
unsigned long)((vertex->rgba[3]) * dmax);
4270 offs += (*action)(imap, sigbyte);
4278 GLfloat dx, GLfloat dy,
4280 size_t (*action)(
unsigned long data,
4287 if(gray && gray != 8 && gray != 16)
4290 for(i = 0; i < 3; ++i){
4316 for(i = 0; i < cnt; ++i){
4317 for(j = 0; j < 3; ++j){
4318 if(*
xmin > triangles[i].vertex[j].
xyz[0])
4320 if(*
xmax < triangles[i].vertex[j].
xyz[0])
4322 if(*
ymin > triangles[i].vertex[j].
xyz[1])
4324 if(*
ymax < triangles[i].vertex[j].
xyz[1])
4338 int i, offs = 0, vertexbytes, done = 0;
4343 vertexbytes = 1+4+4+1+1+1;
4346 vertexbytes = 1+4+4+1;
4349 vertexbytes = 1+4+4+2;
4353 vertexbytes = 1+4+4+1;
4359 offs += fprintf(
gl2ps->stream,
4364 "/BitsPerCoordinate 32 "
4365 "/BitsPerComponent %d "
4367 "/Decode [%f %f %f %f 0 1 %s] ",
4369 (gray) ?
"/DeviceGray" :
"/DeviceRGB",
4372 (gray) ?
"" :
"0 1 0 1");
4374#if defined(GL2PS_HAVE_ZLIB)
4376 gl2psAllocCompress(vertexbytes * size * 3);
4378 for(i = 0; i < size; ++i)
4381 gl2psWriteBigEndianCompress, gray);
4383 if(Z_OK == gl2psDeflate() && 23 +
gl2ps->compress->destLen <
gl2ps->compress->srcLen){
4385 offs += fprintf(
gl2ps->stream,
4389 (
int)
gl2ps->compress->destLen);
4390 offs +=
gl2ps->compress->destLen * fwrite(
gl2ps->compress->dest,
4391 gl2ps->compress->destLen,
4395 gl2psFreeCompress();
4402 offs += fprintf(
gl2ps->stream,
4406 vertexbytes * 3 * size);
4407 for(i = 0; i < size; ++i)
4413 offs += fprintf(
gl2ps->stream,
4426 offs += fprintf(
gl2ps->stream,
4431 "/BBox [ %d %d %d %d ]\n"
4432 "/Group \n<<\n/S /Transparency /CS /DeviceRGB\n"
4435 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[1],
4436 (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[3]);
4439 ? strlen(
"/TrSh sh\n") + (int)log10((
double)childobj)+1
4440 : strlen(
"/TrSh0 sh\n");
4442 offs += fprintf(
gl2ps->stream,
4447 offs += fprintf(
gl2ps->stream,
4450 offs += fprintf(
gl2ps->stream,
4465 offs += fprintf(
gl2ps->stream,
4470 offs += fprintf(
gl2ps->stream,
4471 "/SMask << /S /Alpha /G %d 0 R >> ",
4474 offs += fprintf(
gl2ps->stream,
4486 offs += fprintf(
gl2ps->stream,
4499 size_t (*action)(
unsigned long data,
4506 if(im->format != GL_RGBA && gray)
4509 if(gray && gray != 8 && gray != 16)
4514 shift = (
sizeof(
unsigned long) - 1) * 8;
4516 for(
y = 0;
y < im->height; ++
y){
4517 for(
x = 0;
x < im->width; ++
x){
4519 if(im->format == GL_RGBA && gray){
4520 (*action)((
unsigned long)(
a * 255) << shift, gray);
4523 (*action)((
unsigned long)(
r * 255) << shift, 1);
4524 (*action)((
unsigned long)(g * 255) << shift, 1);
4525 (*action)((
unsigned long)(b * 255) << shift, 1);
4531 case 0:
return 3 * im->width * im->height;
4532 case 1:
return im->width * im->height;
4533 case 2:
return 2 * im->width * im->height;
4534 default:
return 3 * im->width * im->height;
4540 int offs = 0, done = 0, sigbytes = 3;
4542 if(gray && gray !=8 && gray != 16)
4546 sigbytes = gray / 8;
4548 offs += fprintf(
gl2ps->stream,
4556 "/BitsPerComponent 8\n",
4558 (
int)im->width, (
int)im->height,
4559 (gray) ?
"/DeviceGray" :
"/DeviceRGB" );
4560 if(GL_RGBA == im->format && gray == 0){
4561 offs += fprintf(
gl2ps->stream,
4566#if defined(GL2PS_HAVE_ZLIB)
4568 gl2psAllocCompress((
int)(im->width * im->height * sigbytes));
4572 if(Z_OK == gl2psDeflate() && 23 +
gl2ps->compress->destLen <
gl2ps->compress->srcLen){
4574 offs += fprintf(
gl2ps->stream,
4578 (
int)
gl2ps->compress->destLen);
4579 offs +=
gl2ps->compress->destLen * fwrite(
gl2ps->compress->dest,
gl2ps->compress->destLen,
4583 gl2psFreeCompress();
4590 offs += fprintf(
gl2ps->stream,
4594 (
int)(im->width * im->height * sigbytes));
4598 offs += fprintf(
gl2ps->stream,
4609 offs += fprintf(
gl2ps->stream,
4616 "/Encoding /MacRomanEncoding\n"
4619 obj, fontnumber, s->fontname);
4630 int offs = entryoffs;
4634 if(!
gl2ps->pdfgrouplist)
4650 for(j = 0; j < size; ++j){
4675 if(p->data.image->format == GL_RGBA){
4687 if(p->data.text->alignment ==
GL2PS_PDF)
4688 offs += fprintf(
gl2ps->stream,
"%s\n", p->data.text->str);
4708 offs =
gl2ps->xreflist[5] +
gl2ps->streamlength;
4710 gl2ps->xreflist[5] = offs;
4713 gl2ps->xreflist[6] = offs;
4714 gl2ps->streamlength = 0;
4719 sizeof(
int) * (
gl2ps->objects_stack + 1));
4720 gl2ps->xreflist[7] = offs;
4723 gl2ps->xreflist[8] = offs;
4730 fprintf(
gl2ps->stream,
4733 "%010d 65535 f \n",
gl2ps->objects_stack, 0);
4735 for(i = 1; i <
gl2ps->objects_stack; ++i)
4736 fprintf(
gl2ps->stream,
"%010d 00000 n \n",
gl2ps->xreflist[i]);
4738 fprintf(
gl2ps->stream,
4755#if defined(GL2PS_HAVE_ZLIB)
4757 gl2psFreeCompress();
4759 gl2ps->compress = NULL;
4771 int x = viewport[0],
y = viewport[1], w = viewport[2],
h = viewport[3];
4773 glRenderMode(GL_FEEDBACK);
4777 gl2ps->header = GL_FALSE;
4783 if(
gl2ps->colormode == GL_RGBA ||
gl2ps->colorsize == 0){
4784 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
4787 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &
index);
4806 gl2ps->streamlength += offs;
4832 "Portable Document Format"
4846 for(i = 0; i < n; i++){
4847 xyz[i][0] = verts[i].
xyz[0];
4850 for(j = 0; j < 4; j++)
4851 rgba[i][j] = verts[i].rgba[j];
4857 int r = (int)(255. * rgba[0]);
4858 int g = (int)(255. * rgba[1]);
4859 int b = (int)(255. * rgba[2]);
4860 int rc = (
r < 0) ? 0 : (
r > 255) ? 255 :
r;
4861 int gc = (g < 0) ? 0 : (g > 255) ? 255 : g;
4862 int bc = (b < 0) ? 0 : (b > 255) ? 255 : b;
4863 sprintf(
str,
"#%2.2x%2.2x%2.2x",
rc, gc, bc);
4875 x = (int)
gl2ps->viewport[1];
4876 y = (int)
gl2ps->viewport[0];
4878 height = (int)
gl2ps->viewport[2];
4881 x = (int)
gl2ps->viewport[0];
4882 y = (int)
gl2ps->viewport[1];
4884 height = (int)
gl2ps->viewport[3];
4890 gl2psPrintf(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
4891 gl2psPrintf(
"<svg xmlns=\"http://www.w3.org/2000/svg\"\n");
4892 gl2psPrintf(
" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
4893 " width=\"%dpx\" height=\"%dpx\" viewBox=\"%d %d %d %d\">\n",
4908 gl2psPrintf(
"<polygon fill=\"%s\" points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n", col,
4909 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[1],
4910 (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[1],
4911 (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[3],
4912 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[3]);
4916 gl2psPrintf(
"<g shape-rendering=\"crispEdges\">\n");
4933 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"fill-opacity=\"%g\" ", rgba[0][3]);
4939 for(i = 0; i < 3; i++){
4940 xyz2[0][i] =
xyz[0][i];
4941 xyz2[1][i] = 0.5F * (
xyz[0][i] +
xyz[1][i]);
4942 xyz2[2][i] = 0.5F * (
xyz[0][i] +
xyz[2][i]);
4944 for(i = 0; i < 4; i++){
4945 rgba2[0][i] = rgba[0][i];
4946 rgba2[1][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
4947 rgba2[2][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
4950 for(i = 0; i < 3; i++){
4951 xyz2[0][i] = 0.5F * (
xyz[0][i] +
xyz[1][i]);
4952 xyz2[1][i] =
xyz[1][i];
4953 xyz2[2][i] = 0.5F * (
xyz[1][i] +
xyz[2][i]);
4955 for(i = 0; i < 4; i++){
4956 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
4957 rgba2[1][i] = rgba[1][i];
4958 rgba2[2][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
4961 for(i = 0; i < 3; i++){
4962 xyz2[0][i] = 0.5F * (
xyz[0][i] +
xyz[2][i]);
4963 xyz2[1][i] =
xyz[2][i];
4964 xyz2[2][i] = 0.5F * (
xyz[1][i] +
xyz[2][i]);
4966 for(i = 0; i < 4; i++){
4967 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
4968 rgba2[1][i] = rgba[2][i];
4969 rgba2[2][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
4972 for(i = 0; i < 3; i++){
4973 xyz2[0][i] = 0.5F * (
xyz[0][i] +
xyz[1][i]);
4974 xyz2[1][i] = 0.5F * (
xyz[1][i] +
xyz[2][i]);
4975 xyz2[2][i] = 0.5F * (
xyz[0][i] +
xyz[2][i]);
4977 for(i = 0; i < 4; i++){
4978 rgba2[0][i] = 0.5F * (rgba[0][i] + rgba[1][i]);
4979 rgba2[1][i] = 0.5F * (rgba[1][i] + rgba[2][i]);
4980 rgba2[2][i] = 0.5F * (rgba[0][i] + rgba[2][i]);
4988 int i, n, array[10];
4990 if(!pattern || !factor)
return;
4994 for(i = 0; i < n; i++){
5004 if(
gl2ps->lastvertex.rgba[0] >= 0.){
5006 gl2ps->viewport[3] -
gl2ps->lastvertex.xyz[1]);
5007 for(i = 0; i < 3; i++)
5008 gl2ps->lastvertex.xyz[i] = -1.;
5009 for(i = 0; i < 4; i++)
5010 gl2ps->lastvertex.rgba[i] = -1.;
5015#
if defined(GL2PS_HAVE_LIBPNG)
5023#if defined(GL2PS_HAVE_LIBPNG)
5035 sizeof(
unsigned char));
5036 gl2psConvertPixmapToPNG(pixmap, png);
5037 gl2psListEncodeBase64(png);
5038 gl2psPrintf(
"<image x=\"%g\" y=\"%g\" width=\"%d\" height=\"%d\"\n",
5040 gl2psPrintf(
"xlink:href=\"data:image/png;base64,");
5042 gl2psListRead(png, i, &c);
5049 "order to embed images in SVG streams");
5076 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"fill-opacity=\"%g\" ", rgba[0][3]);
5103 gl2psPrintf(
"<polyline fill=\"none\" stroke=\"%s\" stroke-width=\"%g\" ",
5105 if(rgba[0][3] < 1.0F)
gl2psPrintf(
"stroke-opacity=\"%g\" ", rgba[0][3]);
5124 gl2psPrintf(
"<text fill=\"%s\" x=\"%g\" y=\"%g\" font-size=\"%d\" ",
5132 gl2psPrintf(
"font-family=\"Times\" font-weight=\"bold\">");
5134 gl2psPrintf(
"font-family=\"Times\" font-style=\"italic\">");
5136 gl2psPrintf(
"font-family=\"Times\" font-style=\"italic\" font-weight=\"bold\">");
5138 gl2psPrintf(
"font-family=\"Helvetica\" font-weight=\"bold\">");
5140 gl2psPrintf(
"font-family=\"Helvetica\" font-style=\"oblique\">");
5142 gl2psPrintf(
"font-family=\"Helvetica\" font-style=\"oblique\" font-weight=\"bold\">");
5144 gl2psPrintf(
"font-family=\"Courier\" font-weight=\"bold\">");
5146 gl2psPrintf(
"font-family=\"Courier\" font-style=\"oblique\">");
5148 gl2psPrintf(
"font-family=\"Courier\" font-style=\"oblique\" font-weight=\"bold\">");
5177 int x = viewport[0],
y = viewport[1], w = viewport[2],
h = viewport[3];
5179 glRenderMode(GL_FEEDBACK);
5183 gl2ps->header = GL_FALSE;
5187 if(
gl2ps->colormode == GL_RGBA ||
gl2ps->colorsize == 0){
5188 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
5191 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &
index);
5198 gl2psPrintf(
"<polygon fill=\"%s\" points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n", col,
5200 x + w,
gl2ps->viewport[3] -
y,
5201 x + w,
gl2ps->viewport[3] - (
y +
h),
5206 gl2psPrintf(
" <polygon points=\"%d,%d %d,%d %d,%d %d,%d\"/>\n",
5208 x + w,
gl2ps->viewport[3] -
y,
5209 x + w,
gl2ps->viewport[3] - (
y +
h),
5240 "Scalable Vector Graphics"
5253 fprintf(
gl2ps->stream,
"\\color[rgb]{%f,%f,%f}\n", rgba[0], rgba[1], rgba[2]);
5263 fprintf(
gl2ps->stream,
5265 "%% Creator: GL2PS %d.%d.%d%s, %s\n"
5267 "%% CreationDate: %s",
5270 gl2ps->producer, ctime(&now));
5272 fprintf(
gl2ps->stream,
"\\begin{pgfpicture}\n");
5275 fprintf(
gl2ps->stream,
5276 "\\pgfpathrectanglecorners{"
5277 "\\pgfpoint{%dpt}{%dpt}}{\\pgfpoint{%dpt}{%dpt}}\n"
5278 "\\pgfusepath{fill}\n",
5279 (
int)
gl2ps->viewport[0], (
int)
gl2ps->viewport[1],
5280 (
int)
gl2ps->viewport[2], (
int)
gl2ps->viewport[3]);
5286 int i, n, array[10];
5288 if(pattern ==
gl2ps->lastpattern && factor ==
gl2ps->lastfactor)
5291 gl2ps->lastpattern = pattern;
5292 gl2ps->lastfactor = factor;
5294 if(!pattern || !factor){
5296 fprintf(
gl2ps->stream,
"\\pgfsetdash{}{0pt}\n");
5300 fprintf(
gl2ps->stream,
"\\pgfsetdash{");
5301 for(i = 0; i < n; i++) fprintf(
gl2ps->stream,
"{%dpt}", array[i]);
5302 fprintf(
gl2ps->stream,
"}{0pt}\n");
5318 default :
return "south west";
5332 fprintf(
gl2ps->stream,
5333 "\\pgfpathrectangle{\\pgfpoint{%fpt}{%fpt}}"
5334 "{\\pgfpoint{%fpt}{%fpt}}\n\\pgfusepath{fill}\n",
5343 fprintf(
gl2ps->stream,
"\\pgfsetlinewidth{%fpt}\n",
gl2ps->lastlinewidth);
5346 fprintf(
gl2ps->stream,
5347 "\\pgfpathmoveto{\\pgfpoint{%fpt}{%fpt}}\n"
5348 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n"
5349 "\\pgfusepath{stroke}\n",
5354 if(
gl2ps->lastlinewidth != 0){
5355 gl2ps->lastlinewidth = 0;
5356 fprintf(
gl2ps->stream,
"\\pgfsetlinewidth{0.01pt}\n");
5359 fprintf(
gl2ps->stream,
5360 "\\pgfpathmoveto{\\pgfpoint{%fpt}{%fpt}}\n"
5361 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n"
5362 "\\pgflineto{\\pgfpoint{%fpt}{%fpt}}\n"
5364 "\\pgfusepath{fill,stroke}\n",
5370 fprintf(
gl2ps->stream,
"{\n\\pgftransformshift{\\pgfpoint{%fpt}{%fpt}}\n",
5376 fprintf(
gl2ps->stream,
"\\pgfnode{rectangle}{%s}{\\fontsize{%d}{0}\\selectfont",
5380 fprintf(
gl2ps->stream,
"\\textcolor[rgb]{%g,%g,%g}{{%s}}",
5384 fprintf(
gl2ps->stream,
"}{}{\\pgfusepath{discard}}}\n");
5399 fprintf(
gl2ps->stream,
"\\end{pgfpicture}\n");
5406 int x = viewport[0],
y = viewport[1], w = viewport[2],
h = viewport[3];
5408 glRenderMode(GL_FEEDBACK);
5412 gl2ps->header = GL_FALSE;
5415 fprintf(
gl2ps->stream,
"\\begin{pgfscope}\n");
5417 if(
gl2ps->colormode == GL_RGBA ||
gl2ps->colorsize == 0){
5418 glGetFloatv(GL_COLOR_CLEAR_VALUE, rgba);
5421 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &
index);
5428 fprintf(
gl2ps->stream,
5429 "\\pgfpathrectangle{\\pgfpoint{%dpt}{%dpt}}"
5430 "{\\pgfpoint{%dpt}{%dpt}}\n"
5431 "\\pgfusepath{fill}\n",
5435 fprintf(
gl2ps->stream,
5436 "\\pgfpathrectangle{\\pgfpoint{%dpt}{%dpt}}"
5437 "{\\pgfpoint{%dpt}{%dpt}}\n"
5438 "\\pgfusepath{clip}\n",
5446 fprintf(
gl2ps->stream,
"\\end{pgfscope}\n");
5464 "PGF Latex Graphics"
5492 for(i = 0; i < prim->
numverts; i++){
5510 used = glRenderMode(GL_RENDER);
5525 gl2ps->viewport[0] =
gl2ps->viewport[1] = 100000;
5526 gl2ps->viewport[2] =
gl2ps->viewport[3] = -100000;
5530 gl2ps->header = GL_FALSE;
5538 switch(
gl2ps->sort){
5585 GLint viewport[4], GLint format, GLint
sort,
5586 GLint options, GLint colormode,
5588 GLint nr, GLint ng, GLint nb, GLint buffersize,
5589 FILE *stream,
const char *filename)
5602 gl2ps->format = format;
5625 gl2ps->stream = stream;
5634 gl2ps->header = GL_TRUE;
5635 gl2ps->maxbestroot = 10;
5636 gl2ps->options = options;
5637 gl2ps->compress = NULL;
5638 gl2ps->imagemap_head = NULL;
5639 gl2ps->imagemap_tail = NULL;
5642 glGetIntegerv(GL_VIEWPORT,
gl2ps->viewport);
5645 for(i = 0; i < 4; i++){
5646 gl2ps->viewport[i] = viewport[i];
5650 if(!
gl2ps->viewport[2] || !
gl2ps->viewport[3]){
5659 gl2ps->threshold[0] = nr ? 1.0F / (GLfloat)nr : 0.064F;
5660 gl2ps->threshold[1] = ng ? 1.0F / (GLfloat)ng : 0.034F;
5661 gl2ps->threshold[2] = nb ? 1.0F / (GLfloat)nb : 0.100F;
5662 gl2ps->colormode = colormode;
5663 gl2ps->buffersize = buffersize > 0 ? buffersize : 2048 * 2048;
5664 for(i = 0; i < 3; i++){
5665 gl2ps->lastvertex.xyz[i] = -1.0F;
5667 for(i = 0; i < 4; i++){
5668 gl2ps->lastvertex.rgba[i] = -1.0F;
5669 gl2ps->lastrgba[i] = -1.0F;
5671 gl2ps->lastlinewidth = -1.0F;
5672 gl2ps->lastpattern = 0;
5673 gl2ps->lastfactor = 0;
5674 gl2ps->imagetree = NULL;
5675 gl2ps->primitivetoadd = NULL;
5676 gl2ps->zerosurfacearea = GL_FALSE;
5677 gl2ps->pdfprimlist = NULL;
5678 gl2ps->pdfgrouplist = NULL;
5679 gl2ps->xreflist = NULL;
5684 glGetIntegerv(GL_BLEND_SRC, &
gl2ps->blendfunc[0]);
5685 glGetIntegerv(GL_BLEND_DST, &
gl2ps->blendfunc[1]);
5687 if(
gl2ps->colormode == GL_RGBA){
5688 gl2ps->colorsize = 0;
5689 gl2ps->colormap = NULL;
5690 glGetFloatv(GL_COLOR_CLEAR_VALUE,
gl2ps->bgcolor);
5692 else if(
gl2ps->colormode == GL_COLOR_INDEX){
5693 if(!colorsize || !colormap){
5699 gl2ps->colorsize = colorsize;
5702 glGetIntegerv(GL_INDEX_CLEAR_VALUE, &
index);
5706 gl2ps->bgcolor[3] = 1.0F;
5717 gl2ps->title[0] =
'\0';
5721 strcpy(
gl2ps->title, title);
5726 gl2ps->producer[0] =
'\0';
5730 strcpy(
gl2ps->producer, producer);
5735 gl2ps->filename[0] =
'\0';
5739 strcpy(
gl2ps->filename, filename);
5745 glFeedbackBuffer(
gl2ps->buffersize, GL_3D_COLOR,
gl2ps->feedback);
5746 glRenderMode(GL_FEEDBACK);
5762 fflush(
gl2ps->stream);
5796 gl2ps->lastlinewidth = -1.0F;
5802 GLshort fontsize, GLint alignment, GLfloat
angle)
5818 GLint xorig, GLint yorig,
5819 GLenum format, GLenum
type,
5823 GLfloat pos[4], *piv;
5833 if((format != GL_RGB && format != GL_RGBA) ||
type != GL_FLOAT){
5835 "GL_RGB/GL_RGBA, GL_FLOAT pixels");
5839 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
5842 glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
5849 prim->
verts[0].
xyz[0] = pos[0] + xorig;
5850 prim->
verts[0].
xyz[1] = pos[1] + yorig;
5857 glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->
verts[0].
rgba);
5869 size = height *
width * 3;
5871 piv = (GLfloat*)pixels;
5872 for(i = 0; i < size; ++i, ++piv){
5879 size = height *
width * 4;
5886 size = height *
width * 3;
5899 const GLfloat position[3],
5900 const unsigned char *imagemap){
5902 int sizeoffloat =
sizeof(GLfloat);
5908 size = height + height * ((
width - 1) / 8);
5911 glVertex3f(position[0], position[1],position[2]);
5913 glPassThrough((GLfloat)
width);
5914 glPassThrough((GLfloat)height);
5915 for(i = 0; i < size; i += sizeoffloat){
5917 const float *value =
reinterpret_cast<const float*
>(imagemap);
5918 glPassThrough(*value);
5919 imagemap += sizeoffloat;
5933 glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &
gl2ps->offset[0]);
5934 glGetFloatv(GL_POLYGON_OFFSET_UNITS, &
gl2ps->offset[1]);
5941 glGetIntegerv(GL_LINE_STIPPLE_PATTERN, &tmp);
5942 glPassThrough((GLfloat)tmp);
5943 glGetIntegerv(GL_LINE_STIPPLE_REPEAT, &tmp);
5944 glPassThrough((GLfloat)tmp);
5987 glPassThrough(value);
5997 glPassThrough(value);
6010 glPassThrough((GLfloat)sfactor);
6012 glPassThrough((GLfloat)dfactor);
6021 gl2ps->options = options;
6033 *options =
gl2ps->options;
6043 return "Unknown format";
6051 return "Unknown format";
char data[hepevt_bytes_allocation_ATLAS]
std::pair< std::vector< unsigned int >, bool > res
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
Header file for AthHistogramAlgorithm.
holding In fact this class is here in order to allow STL container for all features This class is sho...
std::string head(std::string s, const std::string &pattern)
head of a string
static void gl2psPDFgroupObjectInit(GL2PSpdfgroup *gro)
#define GL2PS_END_STIPPLE_TOKEN
#define GL2PS_BEGIN_OFFSET_TOKEN
static void gl2psPrintTeXFooter(void)
static void gl2psListSort(GL2PSlist *list, int(*fcmp)(const void *a, const void *b))
static void gl2psPrintPGFHeader(void)
static void gl2psGetPlane(GL2PSprimitive *prim, GL2PSplane plane)
static GLfloat gl2psNorm(GLfloat *a)
static GL2PSbackend * gl2psbackends[]
#define GL2PS_DST_BLEND_TOKEN
static GLboolean gl2psSameColorThreshold(int n, GL2PSrgba rgba[], GL2PSrgba threshold)
static void gl2psAssignTriangleProperties(GL2PStriangle *t)
struct _GL2PSimagemap GL2PSimagemap
static GL2PSbackend gl2psPS
static void gl2psPrintTeXPrimitive(void *data)
static GL2PSbackend gl2psTEX
GL2PSDLL_API GLint gl2psEndViewport(void)
static GL2PScontext * gl2ps
static void gl2psPrintPostScriptFooter(void)
static void gl2psDivideQuad(GL2PSprimitive *quad, GL2PSprimitive **t1, GL2PSprimitive **t2)
GL2PSDLL_API const char * gl2psGetFormatDescription(GLint format)
static int gl2psPrintPDFOpenPage(void)
static GLboolean gl2psSameColor(GL2PSrgba rgba1, GL2PSrgba rgba2)
static const char * gl2psPGFTextAlignment(int align)
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, GLint xorig, GLint yorig, GLenum format, GLenum type, const void *pixels)
static void gl2psPrintTeXBeginViewport(GLint viewport[4])
static int gl2psPrintPDFShader(int obj, GL2PStriangle *triangles, int size, int gray)
static int gl2psListNbr(GL2PSlist *list)
static GLboolean gl2psSamePosition(GL2PSxyz p1, GL2PSxyz p2)
static void gl2psSplitPrimitive2D(GL2PSprimitive *prim, GL2PSplane plane, GL2PSprimitive **front, GL2PSprimitive **back)
static int gl2psPrintPDFPages(void)
static GLint gl2psPrintPrimitives(void)
static GLfloat gl2psPsca(GLfloat *a, GLfloat *b)
#define GL2PS_BEGIN_STIPPLE_TOKEN
GL2PSDLL_API const char * gl2psGetFileExtension(GLint format)
static void gl2psPrintPostScriptFinalPrimitive(void)
static void gl2psPrintPGFPrimitive(void *data)
static void gl2psEndPostScriptLine(void)
static int gl2psPDFgroupListWriteXObjectResources(void)
static void gl2psFreePrimitive(void *data)
static GLint gl2psSplitPrimitive(GL2PSprimitive *prim, GL2PSplane plane, GL2PSprimitive **front, GL2PSprimitive **back)
static void * gl2psListPointer(GL2PSlist *list, GLint index)
static GLshort gl2psGetIndex(GLshort i, GLshort num)
#define GL2PS_IMAGEMAP_VISIBLE
static void gl2psInitTriangle(GL2PStriangle *t)
static void gl2psPrintTeXHeader(void)
static void gl2psPDFgroupListWriteMainStream(void)
static void gl2psAddPrimitiveInList(GL2PSprimitive *prim, GL2PSlist *list)
static int gl2psPDFgroupListWriteFontResources(void)
static void gl2psAdaptVertexForBlending(GL2PSvertex *v)
static int gl2psPrintPDFCompressorType(void)
static GLint gl2psPrintPostScriptEndViewport(void)
static void gl2psAddIndex(GLshort *index0, GLshort *index1, GLshort *nb, GLshort i, GLshort j)
static void gl2psPrintSVGFooter(void)
GL2PSDLL_API GLint gl2psPointSize(GLfloat value)
static void gl2psFreeBspImageTree(GL2PSbsptree2d **tree)
static GLboolean gl2psVertsSameColor(const GL2PSprimitive *prim)
GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str)
static int gl2psOpenPDFDataStreamWritePreface(void)
static int gl2psPrintPDFShaderStreamDataRGB(GL2PSvertex *vertex, size_t(*action)(unsigned long data, size_t size))
static void gl2psPrintGzipHeader()
static int gl2psPDFgroupListWriteShaderResources(void)
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, GLint viewport[4], GLint format, GLint sort, GLint options, GLint colormode, GLint colorsize, GL2PSrgba *colormap, GLint nr, GLint ng, GLint nb, GLint buffersize, FILE *stream, const char *filename)
static GLboolean gl2psGreater(GLfloat f1, GLfloat f2)
static void gl2psPrintPDFPrimitive(void *data)
#define GL2PS_IMAGEMAP_WRITTEN
static int gl2psCompareDepth(const void *a, const void *b)
static void gl2psSetLastColor(GL2PSrgba rgba)
static int gl2psPrintPDFShaderSimpleExtGS(int obj, GLfloat alpha)
#define GL2PS_POINT_SIZE_TOKEN
static void gl2psPrintPostScriptPixmap(GLfloat x, GLfloat y, GL2PSimage *im)
struct _GL2PSbsptree2d GL2PSbsptree2d
static void gl2psPrintPGFDash(GLushort pattern, GLint factor)
static void gl2psTraverseBspTree(GL2PSbsptree *tree, GL2PSxyz eye, GLfloat epsilon, GLboolean(*compare)(GLfloat f1, GLfloat f2), void(*action)(void *data), int inverse)
static void gl2psPrintPGFBeginViewport(GLint viewport[4])
GL2PSDLL_API GLint gl2psBlendFunc(GLenum sfactor, GLenum dfactor)
static void * gl2psRealloc(void *ptr, size_t size)
#define GL2PS_END_BLEND_TOKEN
static void gl2psPrintPostScriptPrimitive(void *data)
static int gl2psPrintPDFShaderStreamDataCoord(GL2PSvertex *vertex, size_t(*action)(unsigned long data, size_t size), GLfloat dx, GLfloat dy, GLfloat xmin, GLfloat ymin)
static void gl2psFreePixmap(GL2PSimage *im)
static void gl2psListDelete(GL2PSlist *list)
GL2PSDLL_API GLint gl2psDrawImageMap(GLsizei width, GLsizei height, const GLfloat position[3], const unsigned char *imagemap)
static int gl2psPrintPostScriptDash(GLushort pattern, GLint factor, const char *str)
static void gl2psComputeTightBoundingBox(void *data)
static void gl2psBuildBspTree(GL2PSbsptree *tree, GL2PSlist *primitives)
static int gl2psPDFgroupListWriteGStateResources(void)
GL2PSDLL_API GLint gl2psSetOptions(GLint options)
struct _GL2PSbsptree GL2PSbsptree
static void gl2psCutEdge(GL2PSvertex *a, GL2PSvertex *b, GL2PSplane plane, GL2PSvertex *c)
static GLboolean gl2psLess(GLfloat f1, GLfloat f2)
static GLint gl2psGetVertex(GL2PSvertex *v, GLfloat *p)
static int gl2psPrintPDFText(int obj, GL2PSstring *s, int fontnumber)
static GLint gl2psCheckPoint(GL2PSxyz point, GL2PSplane plane)
#define GL2PS_SRC_BLEND_TOKEN
static void gl2psPrintGzipFooter()
static void gl2psPvec(GLfloat *a, GLfloat *b, GLfloat *c)
static void * gl2psMalloc(size_t size)
static void gl2psPDFRectHull(GLfloat *xmin, GLfloat *xmax, GLfloat *ymin, GLfloat *ymax, GL2PStriangle *triangles, int cnt)
static void gl2psPrintSVGPrimitive(void *data)
static void gl2psSVGGetCoordsAndColors(int n, GL2PSvertex *verts, GL2PSxyz *xyz, GL2PSrgba *rgba)
static GL2PSimage * gl2psCopyPixmap(GL2PSimage *im)
static GLint gl2psPrintSVGEndViewport(void)
GL2PSDLL_API GLint gl2psDisable(GLint mode)
static void gl2psRescaleAndOffset()
static void gl2psSVGGetColorString(GL2PSrgba rgba, char str[32])
static int gl2psPrintPDFInfo(void)
GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4])
static int gl2psTrianglesFirst(const void *a, const void *b)
static void gl2psBuildPolygonBoundary(GL2PSbsptree *tree)
static GLint gl2psCheckPrimitive(GL2PSprimitive *prim, GL2PSplane plane)
static void gl2psPrintSVGHeader(void)
static void gl2psFreeBspTree(GL2PSbsptree **tree)
static void gl2psSortOutTrianglePDFgroup(GL2PSpdfgroup *gro)
static void gl2psPrintTeXFinalPrimitive(void)
static void gl2psPrintPGFFinalPrimitive(void)
static int gl2psPrintPDFDataStreamLength(int val)
static void gl2psPrintPDFFooter(void)
#define GL2PS_POINT_INFRONT
static void gl2psFree(void *ptr)
static void gl2psAddPolyPrimitive(GLshort type, GLshort numverts, GL2PSvertex *verts, GLint offset, GLushort pattern, GLint factor, GLfloat width, char boundary)
static GLint gl2psFindRoot(GL2PSlist *primitives, GL2PSprimitive **root)
static GLint gl2psAddInBspImageTree(GL2PSprimitive *prim, GL2PSbsptree2d **tree)
static void gl2psListAction(GL2PSlist *list, void(*action)(void *data))
#define GL2PS_IMAGEMAP_TOKEN
#define GL2PS_BEGIN_BLEND_TOKEN
GL2PSDLL_API GLint gl2psTextOpt(const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle)
static GLint gl2psPrintTeXEndViewport(void)
static int gl2psPDFgroupListWriteObjects(int entryoffs)
#define GL2PS_END_OFFSET_TOKEN
#define GL2PS_ZOFFSET_LARGE
static GL2PSstring * gl2psCopyText(GL2PSstring *t)
static int gl2psPrintPDFPixmapStreamData(GL2PSimage *im, size_t(*action)(unsigned long data, size_t size), int gray)
static void gl2psEndSVGLine(void)
GL2PSDLL_API GLint gl2psEndPage(void)
static void gl2psAddBoundaryInList(GL2PSprimitive *prim, GL2PSlist *list)
static void gl2psPrintPostScriptImagemap(GLfloat x, GLfloat y, GLsizei width, GLsizei height, const unsigned char *imagemap)
static void gl2psAddPlanesInBspTreeImage(GL2PSprimitive *prim, GL2PSbsptree2d **tree)
static void gl2psMsg(GLint level, const char *fmt,...)
static void gl2psPDFgroupListInit(void)
static GLint gl2psPrintPDFEndViewport(void)
GL2PSDLL_API GLint gl2psText(const char *str, const char *fontname, GLshort fontsize)
static void gl2psPrintSVGSmoothTriangle(GL2PSxyz xyz[3], GL2PSrgba rgba[3])
static GLint gl2psAddText(GLint type, const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle)
static void gl2psPrintPDFHeader(void)
GL2PSDLL_API GLint gl2psEnable(GLint mode)
static void gl2psListAdd(GL2PSlist *list, void *data)
static int gl2psPrintPDFStrokeColor(GL2PSrgba rgba)
static void gl2psPrintPostScriptHeader(void)
static void gl2psPrintSVGFinalPrimitive(void)
static void gl2psAddInImageTree(void *data)
static int gl2psPrintf(const char *fmt,...)
static int gl2psClosePDFDataStream(void)
static void gl2psPDFgroupListDelete(void)
static int gl2psPrintPDFLineWidth(GLfloat lw)
static int gl2psPrintPDFShaderStreamDataAlpha(GL2PSvertex *vertex, size_t(*action)(unsigned long data, size_t size), int sigbyte)
static int gl2psPrintPDFCatalog(void)
static GL2PSprimitive * gl2psCreateSplitPrimitive2D(GL2PSprimitive *parent, GLshort numverts, GL2PSvertex *vertx)
static void gl2psPutPDFText(GL2PSstring *text, int cnt, GLfloat x, GLfloat y)
static GLint gl2psPrintPGFEndViewport(void)
static void gl2psFreeText(GL2PSstring *text)
static int gl2psPrintPDFPixmap(int obj, int childobj, GL2PSimage *im, int gray)
static GL2PSbackend gl2psPGF
static void gl2psPrintPostScriptBeginViewport(GLint viewport[4])
static void gl2psListRealloc(GL2PSlist *list, GLint n)
#define GL2PS_IN_FRONT_OF
static void gl2psPrintPostScriptColor(GL2PSrgba rgba)
static void gl2psListActionInverse(GL2PSlist *list, void(*action)(void *data))
static void gl2psPrintPDFFinalPrimitive(void)
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value)
static void gl2psCreateSplitPrimitive(GL2PSprimitive *parent, GL2PSplane plane, GL2PSprimitive *child, GLshort numverts, GLshort *index0, GLshort *index1)
static GLboolean gl2psSupportedBlendMode(GLenum sfactor, GLenum dfactor)
static GLfloat gl2psGetRGB(GL2PSimage *im, GLuint x, GLuint y, GLfloat *red, GLfloat *green, GLfloat *blue)
static void gl2psPrintPDFBeginViewport(GLint viewport[4])
static GL2PSprimitive * gl2psCopyPrimitive(GL2PSprimitive *p)
static size_t gl2psWriteBigEndian(unsigned long data, size_t bytes)
static void gl2psPDFstacksInit(void)
static void gl2psFreeImagemap(GL2PSimagemap *list)
static GLint gl2psTestSplitPrimitive(GL2PSprimitive *prim, GL2PSplane plane)
static int gl2psPrintPDFShaderExtGS(int obj, int childobj)
static void gl2psGetNormal(GLfloat *a, GLfloat *b, GLfloat *c)
static void gl2psPrintSVGBeginViewport(GLint viewport[4])
static int gl2psOpenPDFDataStream(void)
static void gl2psPrintSVGDash(GLushort pattern, GLint factor)
#define GL2PS_BEGIN_BOUNDARY_TOKEN
static void gl2psParseFeedbackBuffer(GLint used)
static void gl2psPrintPGFColor(GL2PSrgba rgba)
static int gl2psPrintPDFShaderMask(int obj, int childobj)
static int gl2psPrintPDFFillColor(GL2PSrgba rgba)
static void gl2psParseStipplePattern(GLushort pattern, GLint factor, int *nb, int array[10])
static GL2PSbackend gl2psPDF
static GL2PSbackend gl2psSVG
static void gl2psListReset(GL2PSlist *list)
#define GL2PS_END_BOUNDARY_TOKEN
#define GL2PS_DRAW_PIXELS_TOKEN
static GL2PSlist * gl2psListCreate(GLint n, GLint incr, GLint size)
static int gl2psPrintPDFGSObject(void)
static void gl2psPutPDFImage(GL2PSimage *image, int cnt, GLfloat x, GLfloat y)
static void gl2psWriteByte(unsigned char byte)
static void gl2psResetPostScriptColor(void)
static GLfloat gl2psComparePointPlane(GL2PSxyz point, GL2PSplane plane)
GL2PSDLL_API GLint gl2psGetOptions(GLint *options)
static void gl2psPrintSVGPixmap(GLfloat, GLfloat, GL2PSimage *)
static GL2PSbackend gl2psEPS
static int gl2psPDFgroupListWriteVariableResources(void)
static void gl2psFillTriangleFromPrimitive(GL2PStriangle *t, GL2PSprimitive *p, GLboolean assignprops)
#define GL2PS_POINT_COINCIDENT
#define GL2PS_LINE_WIDTH_TOKEN
static void gl2psPrintPGFFooter(void)
static int gl2psPrintPDFShaderStreamData(GL2PStriangle *triangle, GLfloat dx, GLfloat dy, GLfloat xmin, GLfloat ymin, size_t(*action)(unsigned long data, size_t size), int gray)
static GLint gl2psGetPlaneFromPoints(GL2PSxyz a, GL2PSxyz b, GL2PSplane plane)
#define GL2PS_UNINITIALIZED
#define GL2PS_TIGHT_BOUNDING_BOX
#define GL2PS_SIMPLE_SORT
#define GL2PS_NO_BLENDING
#define GL2PS_SIMPLE_LINE_OFFSET
#define GL2PS_OCCLUSION_CULL
#define GL2PS_PATCH_VERSION
#define GL2PS_LINE_STIPPLE
#define GL2PS_POLYGON_BOUNDARY
#define GL2PS_MAJOR_VERSION
#define GL2PS_POLYGON_OFFSET_FILL
#define GL2PS_DRAW_BACKGROUND
#define GL2PS_NO_PS3_SHADING
#define GL2PS_EXTRA_VERSION
#define GL2PS_MINOR_VERSION
#define GL2PS_NO_FEEDBACK
#define GL2PS_USE_CURRENT_VIEWPORT
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
row
Appending html table to final .html summary file.
void(* printFinalPrimitive)(void)
const char * file_extension
GLint(* endViewport)(void)
void(* printPrimitive)(void *data)
void(* beginViewport)(GLint viewport[4])
void(* printFooter)(void)
void(* printHeader)(void)
GLboolean zerosurfacearea
GL2PSimagemap * imagemap_head
GL2PSimagemap * imagemap_tail
GL2PSprimitive * primitivetoadd
GL2PSbsptree2d * imagetree
GL2PSlist * auxprimitives
union GL2PSprimitive::@040324153072217261054023207035000330116237114065 data