Skip to content
Snippets Groups Projects
Commit a35bf32f authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

New occlusion culling code contributed by the guys from CERN. Disabled
by default.
parent a6afaf2b
Branches
Tags
No related merge requests found
...@@ -183,6 +183,7 @@ public : ...@@ -183,6 +183,7 @@ public :
struct{ struct{
int format; int format;
int eps_quality, eps_background, eps_font_size; int eps_quality, eps_background, eps_font_size;
int eps_occlusion_culling, eps_best_root;
char *eps_font; char *eps_font;
double eps_line_width_factor, eps_point_size_factor; double eps_line_width_factor, eps_point_size_factor;
int jpeg_quality; int jpeg_quality;
... ...
......
...@@ -975,6 +975,10 @@ StringXNumber PrintOptions_Number[] = { ...@@ -975,6 +975,10 @@ StringXNumber PrintOptions_Number[] = {
"Size factor for points in postscript output" }, "Size factor for points in postscript output" },
{ F|O, "EpsQuality" , opt_print_eps_quality , 1 , { F|O, "EpsQuality" , opt_print_eps_quality , 1 ,
"Postscript quality (1=simple sort, 2=recursive sort)" }, "Postscript quality (1=simple sort, 2=recursive sort)" },
{ F|O, "EpsOcclusionCulling" , opt_print_eps_occlusion_culling , 0 ,
"Cull occluded primitives (to reduce PostScript file size)" },
{ F|O, "EpsBestRoot" , opt_print_eps_best_root , 0 ,
"Try to minimize primitive splitting in recursive sort" },
{ F|O, "Format" , opt_print_format , FORMAT_AUTO , { F|O, "Format" , opt_print_format , FORMAT_AUTO ,
"File format (10=automatic)" }, "File format (10=automatic)" },
... ...
......
// $Id: Options.cpp,v 1.96 2002-11-17 17:08:32 geuzaine Exp $ // $Id: Options.cpp,v 1.97 2002-12-11 17:37:17 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -3009,6 +3009,16 @@ double opt_print_eps_quality(OPT_ARGS_NUM){ ...@@ -3009,6 +3009,16 @@ double opt_print_eps_quality(OPT_ARGS_NUM){
CTX.print.eps_quality = (int)val; CTX.print.eps_quality = (int)val;
return CTX.print.eps_quality; return CTX.print.eps_quality;
} }
double opt_print_eps_occlusion_culling(OPT_ARGS_NUM){
if(action & GMSH_SET)
CTX.print.eps_occlusion_culling = (int)val;
return CTX.print.eps_occlusion_culling;
}
double opt_print_eps_best_root(OPT_ARGS_NUM){
if(action & GMSH_SET)
CTX.print.eps_best_root = (int)val;
return CTX.print.eps_best_root;
}
double opt_print_eps_background(OPT_ARGS_NUM){ double opt_print_eps_background(OPT_ARGS_NUM){
if(action & GMSH_SET) if(action & GMSH_SET)
CTX.print.eps_background = (int)val; CTX.print.eps_background = (int)val;
... ...
......
...@@ -455,6 +455,8 @@ double opt_view_point_type(OPT_ARGS_NUM); ...@@ -455,6 +455,8 @@ double opt_view_point_type(OPT_ARGS_NUM);
double opt_view_line_type(OPT_ARGS_NUM); double opt_view_line_type(OPT_ARGS_NUM);
double opt_print_format(OPT_ARGS_NUM); double opt_print_format(OPT_ARGS_NUM);
double opt_print_eps_quality(OPT_ARGS_NUM); double opt_print_eps_quality(OPT_ARGS_NUM);
double opt_print_eps_occlusion_culling(OPT_ARGS_NUM);
double opt_print_eps_best_root(OPT_ARGS_NUM);
double opt_print_eps_background(OPT_ARGS_NUM); double opt_print_eps_background(OPT_ARGS_NUM);
double opt_print_eps_font_size(OPT_ARGS_NUM); double opt_print_eps_font_size(OPT_ARGS_NUM);
double opt_print_eps_line_width_factor(OPT_ARGS_NUM); double opt_print_eps_line_width_factor(OPT_ARGS_NUM);
... ...
......
// $Id: CreateFile.cpp,v 1.35 2002-10-11 07:14:34 geuzaine Exp $ // $Id: CreateFile.cpp,v 1.36 2002-12-11 17:37:17 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -184,6 +184,8 @@ void CreateOutputFile (char *name, int format) { ...@@ -184,6 +184,8 @@ void CreateOutputFile (char *name, int format) {
psformat = (format==FORMAT_PS || format==FORMAT_PSTEX) ? GL2PS_PS : GL2PS_EPS; psformat = (format==FORMAT_PS || format==FORMAT_PSTEX) ? GL2PS_PS : GL2PS_EPS;
pssort = (CTX.print.eps_quality==1) ? GL2PS_SIMPLE_SORT : GL2PS_BSP_SORT; pssort = (CTX.print.eps_quality==1) ? GL2PS_SIMPLE_SORT : GL2PS_BSP_SORT;
psoptions = GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT | psoptions = GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT |
(CTX.print.eps_occlusion_culling ? GL2PS_OCCLUSION_CULL : 0) |
(CTX.print.eps_best_root ? GL2PS_BEST_ROOT : 0) |
(CTX.print.eps_background ? GL2PS_DRAW_BACKGROUND : 0) | (CTX.print.eps_background ? GL2PS_DRAW_BACKGROUND : 0) |
(format==FORMAT_PSTEX ? GL2PS_NO_TEXT : 0) | (format==FORMAT_PSTEX ? GL2PS_NO_TEXT : 0) |
(format==FORMAT_EPSTEX ? GL2PS_NO_TEXT : 0); (format==FORMAT_EPSTEX ? GL2PS_NO_TEXT : 0);
... ...
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* GL2PS, an OpenGL to PostScript Printing Library * GL2PS, an OpenGL to PostScript Printing Library
* Copyright (C) 1999-2002 Christophe Geuzaine * Copyright (C) 1999-2002 Christophe Geuzaine
* *
* $Id: gl2ps.cpp,v 1.52 2002-11-17 02:30:13 geuzaine Exp $ * $Id: gl2ps.cpp,v 1.53 2002-12-11 17:37:17 geuzaine Exp $
* *
* E-mail: geuz@geuz.org * E-mail: geuz@geuz.org
* URL: http://www.geuz.org/gl2ps/ * URL: http://www.geuz.org/gl2ps/
...@@ -179,8 +179,10 @@ void gl2psGetNormal(GLfloat *a, GLfloat *b, GLfloat *c){ ...@@ -179,8 +179,10 @@ void gl2psGetNormal(GLfloat *a, GLfloat *b, GLfloat *c){
c[1] = c[1] / norm; c[1] = c[1] / norm;
c[2] = c[2] / norm; c[2] = c[2] / norm;
} }
else else{
gl2psMsg(GL2PS_WARNING, "Bad plane in BSP tree"); c[0] = c[1] = 0.;
c[2] = 1.;
}
} }
void gl2psGetPlane(GL2PSprimitive *prim, GL2PSplane plane){ void gl2psGetPlane(GL2PSprimitive *prim, GL2PSplane plane){
...@@ -444,10 +446,15 @@ GLint gl2psFindRoot(GL2PSlist *primitives, GL2PSprimitive **root){ ...@@ -444,10 +446,15 @@ GLint gl2psFindRoot(GL2PSlist *primitives, GL2PSprimitive **root){
GLint i, j, count, best = 1000000, index = 0; GLint i, j, count, best = 1000000, index = 0;
GL2PSprimitive *prim1, *prim2; GL2PSprimitive *prim1, *prim2;
GL2PSplane plane; GL2PSplane plane;
GLint maxp;
if(gl2ps->options & GL2PS_BEST_ROOT){ if(gl2ps->options & GL2PS_BEST_ROOT){
*root = *(GL2PSprimitive**)gl2psListPointer(primitives, 0); *root = *(GL2PSprimitive**)gl2psListPointer(primitives, 0);
for(i=0 ; i<gl2psListNbr(primitives) ; i++){ maxp = gl2psListNbr(primitives);
if(maxp > gl2ps->maxbestroot){
maxp = gl2ps->maxbestroot;
}
for(i = 0; i < maxp; i++){
prim1 = *(GL2PSprimitive**)gl2psListPointer(primitives, i); prim1 = *(GL2PSprimitive**)gl2psListPointer(primitives, i);
gl2psGetPlane(prim1, plane); gl2psGetPlane(prim1, plane);
count = 0; count = 0;
...@@ -611,9 +618,294 @@ void gl2psTraverseBspTree(GL2PSbsptree *tree, GL2PSxyz eye, GLfloat epsilon, ...@@ -611,9 +618,294 @@ void gl2psTraverseBspTree(GL2PSbsptree *tree, GL2PSxyz eye, GLfloat epsilon,
} }
} }
/* Boundary contruction */ /* The 2D sorting routines (for occlusion culling) */
#define GL2PS_BOUNDARY_OFFSET 0 GLint gl2psGetPlaneFromPoints(GL2PSxyz a, GL2PSxyz b, GL2PSplane plane){
GLfloat n;
plane[0] = b[1] - a[1];
plane[1] = a[0] - b[0];
n = sqrt(plane[0]*plane[0] + plane[1]*plane[1]);
plane[2]=0.;
if(n != 0.){
plane[0] /= n;
plane[1] /= n;
plane[3] = -plane[0]*a[0]-plane[1]*a[1];
return 1;
}
else{
plane[0] = -1.0;
plane[1] = 0.;
plane[3] = a[0];
return 0;
}
}
void gl2psFreeBspImageTree(GL2PSbsptree2d **tree){
if(*tree){
if((*tree)->back) gl2psFreeBspImageTree(&(*tree)->back);
if((*tree)->front) gl2psFreeBspImageTree(&(*tree)->front);
gl2psFree(*tree);
*tree = NULL;
}
}
GLint gl2psCheckPoint(GL2PSxyz point, GL2PSplane plane){
GLfloat pt_dis;
pt_dis = gl2psComparePointPlane(point, plane);
if(pt_dis > GL2PS_EPSILON) return GL2PS_POINT_INFRONT;
else if(pt_dis < -GL2PS_EPSILON) return GL2PS_POINT_BACK;
else return GL2PS_POINT_COINCIDENT;
}
void gl2psAddPlanesInBspTreeImage(GL2PSprimitive *prim,
GL2PSbsptree2d **tree){
GLint ret = 0;
GLint i;
GLint offset = 0;
GL2PSbsptree2d *head = NULL, *cur = NULL;
if((*tree == NULL) && (prim->numverts > 2)){
head=(GL2PSbsptree2d*)gl2psMalloc(sizeof(GL2PSbsptree2d));
for(i = 0; i < prim->numverts-1; i++){
if(!gl2psGetPlaneFromPoints(prim->verts[i].xyz,
prim->verts[i+1].xyz,
head->plane)){
if(prim->numverts-i > 3)
offset++;
else{
gl2psFree(head);
return;
}
}
else break;
}
head->back = NULL;
head->front = NULL;
for(i = 2+offset; i < prim->numverts; i++){
ret = gl2psCheckPoint(prim->verts[i].xyz, head->plane);
if(ret != 0) break;
}
switch(ret){
case GL2PS_POINT_INFRONT :
cur = head;
for(i = 1+offset; i < (prim->numverts-1); i++){
if(cur->front == NULL)
cur->front = (GL2PSbsptree2d*)gl2psMalloc(sizeof(GL2PSbsptree2d));
if(gl2psGetPlaneFromPoints(prim->verts[i].xyz,
prim->verts[i+1].xyz,
cur->front->plane)){
cur = cur->front;
cur->front = NULL;
cur->back = NULL;
}
}
if(cur->front == NULL)
cur->front = (GL2PSbsptree2d*)gl2psMalloc(sizeof(GL2PSbsptree2d));
if(gl2psGetPlaneFromPoints(prim->verts[i].xyz,
prim->verts[offset].xyz,
cur->front->plane)){
cur->front->front = NULL;
cur->front->back = NULL;
}
else{
gl2psFree(cur->front);
cur = NULL;
}
break;
case GL2PS_POINT_BACK :
for(i = 0; i < 4; i++)
head->plane[i] = -head->plane[i];
cur = head;
for(i = 1+offset; i < (prim->numverts-1); i++){
if(cur->front == NULL)
cur->front = (GL2PSbsptree2d*)gl2psMalloc(sizeof(GL2PSbsptree2d));
if(gl2psGetPlaneFromPoints(prim->verts[i+1].xyz,
prim->verts[i].xyz,
cur->front->plane)){
cur = cur->front;
cur->front = NULL;
cur->back = NULL;
}
}
if(cur->front == NULL)
cur->front = (GL2PSbsptree2d*)gl2psMalloc(sizeof(GL2PSbsptree2d));
if(gl2psGetPlaneFromPoints(prim->verts[offset].xyz,
prim->verts[i].xyz,
cur->front->plane)){
cur->front->front = NULL;
cur->front->back = NULL;
}
else{
gl2psFree(cur->front);
cur = NULL;
}
break;
default:
gl2psFree(head);
return;
}
(*tree) = head;
}
}
GLint gl2psCheckPrimitive(GL2PSprimitive *prim, GL2PSplane plane){
GLint i;
GLint pos;
pos = gl2psCheckPoint(prim->verts[0].xyz, plane);
for(i = 1; i < prim->numverts; i++){
pos |= gl2psCheckPoint(prim->verts[i].xyz, plane);
if(pos == (GL2PS_POINT_INFRONT | GL2PS_POINT_BACK)) return GL2PS_SPANNING;
}
if(pos & GL2PS_POINT_INFRONT) return GL2PS_IN_FRONT_OF;
else if(pos & GL2PS_POINT_BACK) return GL2PS_IN_BACK_OF;
else return GL2PS_COINCIDENT;
}
GL2PSprimitive* gl2psCreateSplitPrimitive2D(GL2PSprimitive *parent,
GLint numverts,
GL2PSvertex *vertx){
GLint i;
GL2PSprimitive *child = (GL2PSprimitive*)gl2psMalloc(sizeof(GL2PSprimitive));
switch(numverts){
case 1 : child->type = GL2PS_POINT; break;
case 2 : child->type = GL2PS_LINE; break;
case 3 : child->type = GL2PS_TRIANGLE; break;
case 4 : child->type = GL2PS_QUADRANGLE; break;
}
child->boundary = 0; /* not done! */
child->dash = parent->dash;
child->width = parent->width;
child->numverts = numverts;
child->verts = (GL2PSvertex *)gl2psMalloc(numverts * sizeof(GL2PSvertex));
for(i = 0; i < numverts; i++)
child->verts[i] = vertx[i];
return child;
}
void gl2psSplitPrimitive2D(GL2PSprimitive *prim,
GL2PSplane plane,
GL2PSprimitive **front,
GL2PSprimitive **back){
// cur will hold the position of current vertex
// prev will holds the position of previous vertex
// prev0 will holds the position of vertex number 0
// v1 and v2 represent the current and previous vertexs respectively
// flag will represents that should the current be checked against the plane
GLint cur = -1, prev = -1, i, v1 = 0, v2 = 0, flag = 1, prev0 = -1;
// list of vertexs which will go in front and back Primitive
GL2PSvertex *front_list = NULL, *back_list = NULL;
// number of vertex in front and back list
GLint front_count = 0, back_count = 0;
for(i = 0; i <= prim->numverts; i++){
v1 = i;
if(v1 == prim->numverts){
if(prim->numverts < 3) break;
v1 = 0;
v2 = prim->numverts-1;
cur = prev0;
}
else if(flag){
cur = gl2psCheckPoint(prim->verts[v1].xyz, plane);
if(i == 0)
prev0 = cur;
}
if(((prev == -1) || (prev == cur) || (prev == 0) || (cur == 0)) &&
(i < prim->numverts)){
if(cur == GL2PS_POINT_INFRONT){
front_count++;
front_list = (GL2PSvertex*)gl2psRealloc(front_list,
sizeof(GL2PSvertex)*front_count);
front_list[front_count-1] = prim->verts[v1];
}
else if(cur == GL2PS_POINT_BACK){
back_count++;
back_list = (GL2PSvertex*)gl2psRealloc(back_list,
sizeof(GL2PSvertex)*back_count);
back_list[back_count-1] = prim->verts[v1];
}
else{
front_count++;
front_list = (GL2PSvertex*)gl2psRealloc(front_list,
sizeof(GL2PSvertex)*front_count);
front_list[front_count-1] = prim->verts[v1];
back_count++;
back_list = (GL2PSvertex*)gl2psRealloc(back_list,
sizeof(GL2PSvertex)*back_count);
back_list[back_count-1] = prim->verts[v1];
}
flag = 1;
}
else if((prev != cur) && (cur != 0) && (prev != 0)){
if(v1 != 0){
v2 = v1-1;
i--;
}
front_count++;
front_list = (GL2PSvertex*)gl2psRealloc(front_list,
sizeof(GL2PSvertex)*front_count);
gl2psCutEdge(&prim->verts[v2],
&prim->verts[v1],
plane,
&front_list[front_count-1]);
back_count++;
back_list = (GL2PSvertex*)gl2psRealloc(back_list,
sizeof(GL2PSvertex)*back_count);
back_list[back_count-1] = front_list[front_count-1];
flag = 0;
}
prev = cur;
}
*front = gl2psCreateSplitPrimitive2D(prim, front_count, front_list);
*back = gl2psCreateSplitPrimitive2D(prim, back_count, back_list);
gl2psFree(front_list);
gl2psFree(back_list);
}
GLint gl2psAddInImageTree(GL2PSprimitive *prim, GL2PSbsptree2d **tree){
GLint ret = 0;
GL2PSprimitive *frontprim = NULL, *backprim = NULL;
if(*tree == NULL){
gl2psAddPlanesInBspTreeImage(prim, tree);
return 1;
}
else{
switch(gl2psCheckPrimitive(prim, (*tree)->plane)){
case GL2PS_IN_BACK_OF: return gl2psAddInImageTree(prim, &(*tree)->back);
case GL2PS_IN_FRONT_OF:
if((*tree)->front != NULL) return gl2psAddInImageTree(prim, &(*tree)->front);
else return 0;
case GL2PS_SPANNING:
gl2psSplitPrimitive2D(prim, (*tree)->plane, &frontprim, &backprim);
ret = gl2psAddInImageTree(backprim, &(*tree)->back);
if((*tree)->front != NULL)
if(gl2psAddInImageTree(frontprim, &(*tree)->front))
ret = 1;
gl2psFree(frontprim->verts);
gl2psFree(frontprim);
gl2psFree(backprim->verts);
gl2psFree(backprim);
return ret;
case GL2PS_COINCIDENT:
if(prim->numverts < 3) return 1;
else return 0;
}
}
return 0;
}
void gl2psAddInImage(void *a, void *b){
GL2PSprimitive *prim;
prim = *(GL2PSprimitive **)a;
if(gl2psAddInImageTree(prim, &gl2ps->image)){
prim->depth = -1.;
}
}
/* Boundary contruction */
void gl2psAddBoundaryInList(GL2PSprimitive *prim, GL2PSlist *list){ void gl2psAddBoundaryInList(GL2PSprimitive *prim, GL2PSlist *list){
GL2PSprimitive *b; GL2PSprimitive *b;
...@@ -638,6 +930,7 @@ void gl2psAddBoundaryInList(GL2PSprimitive *prim, GL2PSlist *list){ ...@@ -638,6 +930,7 @@ void gl2psAddBoundaryInList(GL2PSprimitive *prim, GL2PSlist *list){
b->numverts = 2; b->numverts = 2;
b->verts = (GL2PSvertex *)gl2psMalloc(2 * sizeof(GL2PSvertex)); b->verts = (GL2PSvertex *)gl2psMalloc(2 * sizeof(GL2PSvertex));
#define GL2PS_BOUNDARY_OFFSET 0
#if GL2PS_BOUNDARY_OFFSET #if GL2PS_BOUNDARY_OFFSET
v[0] = c[0] - prim->verts[i].xyz[0]; v[0] = c[0] - prim->verts[i].xyz[0];
v[1] = c[1] - prim->verts[i].xyz[1]; v[1] = c[1] - prim->verts[i].xyz[1];
...@@ -726,7 +1019,8 @@ void gl2psAddPolyPrimitive(GLshort type, GLshort numverts, ...@@ -726,7 +1019,8 @@ void gl2psAddPolyPrimitive(GLshort type, GLshort numverts,
} }
else if(offset && type == GL2PS_TRIANGLE){ else if(offset && type == GL2PS_TRIANGLE){
/* needs some more work... */ /* This needs some more work... */
if(gl2ps->sort == GL2PS_SIMPLE_SORT){ if(gl2ps->sort == GL2PS_SIMPLE_SORT){
factor = gl2ps->offset[0]; factor = gl2ps->offset[0];
units = gl2ps->offset[1]; units = gl2ps->offset[1];
...@@ -756,8 +1050,6 @@ void gl2psAddPolyPrimitive(GLshort type, GLshort numverts, ...@@ -756,8 +1050,6 @@ void gl2psAddPolyPrimitive(GLshort type, GLshort numverts,
dZ = factor * maxdZ + units; dZ = factor * maxdZ + units;
/* printf("dZ = %g (fact=%g units=%g)\n", dZ, factor, units); */
prim->verts[0].xyz[2] += dZ; prim->verts[0].xyz[2] += dZ;
prim->verts[1].xyz[2] += dZ; prim->verts[1].xyz[2] += dZ;
prim->verts[2].xyz[2] += dZ; prim->verts[2].xyz[2] += dZ;
...@@ -1249,7 +1541,7 @@ void gl2psPrintPostScriptFooter(void){ ...@@ -1249,7 +1541,7 @@ void gl2psPrintPostScriptFooter(void){
"%%%%EOF\n"); "%%%%EOF\n");
} }
/* The LaTeX routines. */ /* The LaTeX routines */
void gl2psPrintTeXHeader(void){ void gl2psPrintTeXHeader(void){
GLint viewport[4]; GLint viewport[4];
...@@ -1304,12 +1596,13 @@ void gl2psPrintTeXFooter(void){ ...@@ -1304,12 +1596,13 @@ void gl2psPrintTeXFooter(void){
/* The public routines */ /* The public routines */
GL2PSDLL_API void gl2psBeginPage(char *title, char *producer, GL2PSDLL_API void gl2psBeginPage(const char *title, const char *producer,
GLint format, GLint sort, GLint options, GLint format, GLint sort, GLint options,
GLint colormode, GLint colorsize, GLint colormode, GLint colorsize,
GL2PSrgba *colormap, GLint buffersize, GL2PSrgba *colormap, GLint buffersize,
FILE *stream, char *filename){ FILE *stream, const char *filename){
gl2ps = (GL2PScontext*)gl2psMalloc(sizeof(GL2PScontext)); gl2ps = (GL2PScontext*)gl2psMalloc(sizeof(GL2PScontext));
gl2ps->maxbestroot = 10;
gl2ps->format = format; gl2ps->format = format;
gl2ps->title = title; gl2ps->title = title;
gl2ps->producer = producer; gl2ps->producer = producer;
...@@ -1327,6 +1620,7 @@ GL2PSDLL_API void gl2psBeginPage(char *title, char *producer, ...@@ -1327,6 +1620,7 @@ GL2PSDLL_API void gl2psBeginPage(char *title, char *producer,
gl2ps->lastrgba[2] = -1.; gl2ps->lastrgba[2] = -1.;
gl2ps->lastrgba[3] = -1.; gl2ps->lastrgba[3] = -1.;
gl2ps->lastlinewidth = -1.; gl2ps->lastlinewidth = -1.;
gl2ps->image = NULL;
gl2ps->primitives = gl2psListCreate(500, 500, sizeof(GL2PSprimitive*)); gl2ps->primitives = gl2psListCreate(500, 500, sizeof(GL2PSprimitive*));
if(gl2ps->colormode == GL_RGBA){ if(gl2ps->colormode == GL_RGBA){
...@@ -1402,6 +1696,10 @@ GL2PSDLL_API GLint gl2psEndPage(void){ ...@@ -1402,6 +1696,10 @@ GL2PSDLL_API GLint gl2psEndPage(void){
break; break;
case GL2PS_SIMPLE_SORT : case GL2PS_SIMPLE_SORT :
gl2psListSort(gl2ps->primitives, gl2psCompareDepth); gl2psListSort(gl2ps->primitives, gl2psCompareDepth);
if(gl2ps->options & GL2PS_OCCLUSION_CULL){
gl2psListAction(gl2ps->primitives,gl2psAddInImage);
gl2psFreeBspImageTree(&gl2ps->image);
}
gl2psListActionInverse(gl2ps->primitives, pprim); gl2psListActionInverse(gl2ps->primitives, pprim);
gl2psListAction(gl2ps->primitives, gl2psFreePrimitive); gl2psListAction(gl2ps->primitives, gl2psFreePrimitive);
gl2psListDelete(gl2ps->primitives); gl2psListDelete(gl2ps->primitives);
...@@ -1411,12 +1709,11 @@ GL2PSDLL_API GLint gl2psEndPage(void){ ...@@ -1411,12 +1709,11 @@ GL2PSDLL_API GLint gl2psEndPage(void){
root = (GL2PSbsptree*)gl2psMalloc(sizeof(GL2PSbsptree)); root = (GL2PSbsptree*)gl2psMalloc(sizeof(GL2PSbsptree));
gl2psBuildBspTree(root, gl2ps->primitives); gl2psBuildBspTree(root, gl2ps->primitives);
if(gl2ps->boundary) gl2psBuildPolygonBoundary(root); if(gl2ps->boundary) gl2psBuildPolygonBoundary(root);
/* Occlusion culling is not implemented yet...
if(gl2ps->options & GL2PS_OCCLUSION_CULL){ if(gl2ps->options & GL2PS_OCCLUSION_CULL){
gl2psTraverseBspTree(root, eye, -(float)GL2PS_EPSILON, gl2psLess, gl2psTraverseBspTree(root, eye, -(float)GL2PS_EPSILON, gl2psLess,
gl2psAddInImage); gl2psAddInImage);
gl2psFreeBspImageTree(&gl2ps->image);
} }
*/
gl2psTraverseBspTree(root, eye, (float)GL2PS_EPSILON, gl2psGreater, gl2psTraverseBspTree(root, eye, (float)GL2PS_EPSILON, gl2psGreater,
pprim); pprim);
gl2psFreeBspTree(root); gl2psFreeBspTree(root);
...@@ -1430,6 +1727,7 @@ GL2PSDLL_API GLint gl2psEndPage(void){ ...@@ -1430,6 +1727,7 @@ GL2PSDLL_API GLint gl2psEndPage(void){
} }
if(gl2ps->colormap) gl2psFree(gl2ps->colormap); if(gl2ps->colormap) gl2psFree(gl2ps->colormap);
gl2psFree(gl2ps); gl2psFree(gl2ps);
...@@ -1438,7 +1736,7 @@ GL2PSDLL_API GLint gl2psEndPage(void){ ...@@ -1438,7 +1736,7 @@ GL2PSDLL_API GLint gl2psEndPage(void){
return res; return res;
} }
GL2PSDLL_API void gl2psText(char *str, char *fontname, GLint fontsize){ GL2PSDLL_API void gl2psText(const char *str, const char *fontname, GLint fontsize){
GLfloat pos[4]; GLfloat pos[4];
GL2PSprimitive *prim; GL2PSprimitive *prim;
GLboolean valid; GLboolean valid;
... ...
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* GL2PS, an OpenGL to PostScript Printing Library * GL2PS, an OpenGL to PostScript Printing Library
* Copyright (C) 1999-2002 Christophe Geuzaine * Copyright (C) 1999-2002 Christophe Geuzaine
* *
* $Id: gl2ps.h,v 1.29 2002-11-12 19:11:50 geuzaine Exp $ * $Id: gl2ps.h,v 1.30 2002-12-11 17:37:17 geuzaine Exp $
* *
* E-mail: geuz@geuz.org * E-mail: geuz@geuz.org
* URL: http://www.geuz.org/gl2ps/ * URL: http://www.geuz.org/gl2ps/
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#endif /* __APPLE__ */ #endif /* __APPLE__ */
#define GL2PS_VERSION 0.63 #define GL2PS_VERSION 0.7
#define GL2PS_NONE 0 #define GL2PS_NONE 0
/* Output file format */ /* Output file format */
...@@ -123,6 +123,12 @@ ...@@ -123,6 +123,12 @@
#define GL2PS_IN_BACK_OF 3 #define GL2PS_IN_BACK_OF 3
#define GL2PS_SPANNING 4 #define GL2PS_SPANNING 4
/* 2D BSP tree primitive comparison */
#define GL2PS_POINT_COINCIDENT 0
#define GL2PS_POINT_INFRONT 1
#define GL2PS_POINT_BACK 2
/* Pass through options */ /* Pass through options */
#define GL2PS_BEGIN_POLYGON_OFFSET_FILL 1 #define GL2PS_BEGIN_POLYGON_OFFSET_FILL 1
...@@ -138,6 +144,13 @@ typedef GLfloat GL2PSrgba[4]; ...@@ -138,6 +144,13 @@ typedef GLfloat GL2PSrgba[4];
typedef GLfloat GL2PSxyz[3]; typedef GLfloat GL2PSxyz[3];
typedef GLfloat GL2PSplane[4]; typedef GLfloat GL2PSplane[4];
typedef struct _GL2PSbsptree2d GL2PSbsptree2d;
struct _GL2PSbsptree2d {
GL2PSplane plane;
GL2PSbsptree2d *front, *back;
};
typedef struct { typedef struct {
GLint nmax, size, incr, n; GLint nmax, size, incr, n;
char *array; char *array;
...@@ -169,13 +182,14 @@ typedef struct { ...@@ -169,13 +182,14 @@ typedef struct {
} GL2PSprimitive; } GL2PSprimitive;
typedef struct { typedef struct {
GLint format, sort, options, colorsize, colormode, buffersize; GLint format, sort, options, colorsize, colormode, buffersize, maxbestroot;
char *title, *producer, *filename; const char *title, *producer, *filename;
GLboolean shade, boundary; GLboolean shade, boundary;
GLfloat *feedback, offset[2]; GLfloat *feedback, offset[2];
GL2PSrgba *colormap, lastrgba, threshold; GL2PSrgba *colormap, lastrgba, threshold;
float lastlinewidth; float lastlinewidth;
GL2PSlist *primitives; GL2PSlist *primitives;
GL2PSbsptree2d *image;
FILE *stream; FILE *stream;
} GL2PScontext; } GL2PScontext;
...@@ -186,13 +200,13 @@ typedef struct { ...@@ -186,13 +200,13 @@ typedef struct {
extern "C" { extern "C" {
#endif #endif
GL2PSDLL_API void gl2psBeginPage(char *title, char *producer, GL2PSDLL_API void gl2psBeginPage(const char *title, const char *producer,
GLint format, GLint sort, GLint options, GLint format, GLint sort, GLint options,
GLint colormode, GLint colorsize, GLint colormode, GLint colorsize,
GL2PSrgba *colormap, GLint buffersize, GL2PSrgba *colormap, GLint buffersize,
FILE *stream, char *filename); FILE *stream, const char *filename);
GL2PSDLL_API GLint gl2psEndPage(void); GL2PSDLL_API GLint gl2psEndPage(void);
GL2PSDLL_API void gl2psText(char *str, char *fontname, GLint size); GL2PSDLL_API void gl2psText(const char *str, const char *fontname, GLint size);
GL2PSDLL_API void gl2psEnable(GLint mode); GL2PSDLL_API void gl2psEnable(GLint mode);
GL2PSDLL_API void gl2psDisable(GLint mode); GL2PSDLL_API void gl2psDisable(GLint mode);
GL2PSDLL_API void gl2psPointSize(GLfloat value); GL2PSDLL_API void gl2psPointSize(GLfloat value);
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment