visualization/OpenInventor/src/gl2ps.h

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 /*
00027  * GL2PS, an OpenGL to PostScript Printing Library
00028  * Copyright (C) 1999-2003  Christophe Geuzaine
00029  *
00030  * $Id: gl2ps.h,v 1.5 2006/06/29 21:23:11 gunter Exp $
00031  *
00032  * E-mail: geuz@geuz.org
00033  * URL: http://www.geuz.org/gl2ps/
00034  *
00035  * This library is free software; you can redistribute it and/or
00036  * modify it under the terms of the GNU Library General Public
00037  * License as published by the Free Software Foundation; either
00038  * version 2 of the License, or (at your option) any later version.
00039  *
00040  * This library is distributed in the hope that it will be useful,
00041  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00042  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00043  * Library General Public License for more details.
00044  *
00045  * You should have received a copy of the GNU Library General Public
00046  * License along with this library; if not, write to the Free
00047  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00048  *
00049  */
00050 
00051 #ifndef __GL2PS_H__
00052 #define __GL2PS_H__
00053 
00054 #include <stdio.h>
00055 #include <stdlib.h>
00056 #include <cmath>
00057 
00058 /* To generate a Windows dll, you have to define GL2PSDLL at compile
00059    time */
00060 
00061 #ifdef WIN32
00062 #  include <windows.h>
00063 #  ifdef GL2PSDLL
00064 #    ifdef GL2PSDLL_EXPORTS
00065 #      define GL2PSDLL_API __declspec(dllexport)
00066 #    else
00067 #      define GL2PSDLL_API __declspec(dllimport)
00068 #    endif
00069 #  else
00070 #    define GL2PSDLL_API
00071 #  endif
00072 #else
00073 #  define GL2PSDLL_API
00074 #endif
00075 
00076 #ifdef __APPLE__
00077 #  include <OpenGL/gl.h>
00078 #else
00079 #  include <GL/gl.h>
00080 #endif
00081 
00082 
00083 #define GL2PS_VERSION                    0.8
00084 #define GL2PS_NONE                       0
00085 
00086 /* Output file format */
00087 
00088 #define GL2PS_PS                         1
00089 #define GL2PS_EPS                        2
00090 #define GL2PS_TEX                        3
00091 
00092 /* Sorting algorithms */
00093 
00094 #define GL2PS_NO_SORT                    1
00095 #define GL2PS_SIMPLE_SORT                2
00096 #define GL2PS_BSP_SORT                   3
00097 
00098 /* Options for gl2psBeginPage */
00099 
00100 #define GL2PS_DRAW_BACKGROUND            (1<<0)
00101 #define GL2PS_SIMPLE_LINE_OFFSET         (1<<1)
00102 #define GL2PS_SILENT                     (1<<2)
00103 #define GL2PS_BEST_ROOT                  (1<<3)
00104 #define GL2PS_OCCLUSION_CULL             (1<<4)
00105 #define GL2PS_NO_TEXT                    (1<<5)
00106 #define GL2PS_LANDSCAPE                  (1<<6)
00107 #define GL2PS_NO_PS3_SHADING             (1<<7)
00108 #define GL2PS_NO_PIXMAP                  (1<<8)
00109 
00110 /* Arguments for gl2psEnable/gl2psDisable */
00111 
00112 #define GL2PS_POLYGON_OFFSET_FILL        1
00113 #define GL2PS_POLYGON_BOUNDARY           2
00114 #define GL2PS_LINE_STIPPLE               3
00115 
00116 /* Magic numbers */
00117 
00118 #define GL2PS_EPSILON                    5.e-3
00119 #define GL2PS_DEPTH_FACT                 1000.0
00120 #define GL2PS_SIMPLE_OFFSET              0.05
00121 #define GL2PS_SIMPLE_OFFSET_LARGE        1.0
00122 #define GL2PS_ZERO(arg)                  (std::fabs(arg)<1.e-20)
00123 /*#define GL2PS_ZERO(arg)                ((arg)==0.0)*/
00124 
00125 /* Message levels and error codes */
00126 
00127 #define GL2PS_SUCCESS                    0
00128 #define GL2PS_INFO                       1
00129 #define GL2PS_WARNING                    2
00130 #define GL2PS_ERROR                      3
00131 #define GL2PS_NO_FEEDBACK                4
00132 #define GL2PS_OVERFLOW                   5
00133 #define GL2PS_UNINITIALIZED              6
00134 
00135 /* Primitive types */
00136 
00137 #define GL2PS_TEXT                       1
00138 #define GL2PS_POINT                      2
00139 #define GL2PS_LINE                       3
00140 #define GL2PS_QUADRANGLE                 4
00141 #define GL2PS_TRIANGLE                   5
00142 #define GL2PS_PIXMAP                     6
00143 
00144 /* BSP tree primitive comparison */
00145 
00146 #define GL2PS_COINCIDENT                 1
00147 #define GL2PS_IN_FRONT_OF                2
00148 #define GL2PS_IN_BACK_OF                 3
00149 #define GL2PS_SPANNING                   4
00150 
00151 /* 2D BSP tree primitive comparison */
00152 
00153 #define GL2PS_POINT_COINCIDENT           0
00154 #define GL2PS_POINT_INFRONT              1
00155 #define GL2PS_POINT_BACK                 2
00156 
00157 /* Pass through options */
00158 
00159 #define GL2PS_BEGIN_POLYGON_OFFSET_FILL  1
00160 #define GL2PS_END_POLYGON_OFFSET_FILL    2
00161 #define GL2PS_BEGIN_POLYGON_BOUNDARY     3
00162 #define GL2PS_END_POLYGON_BOUNDARY       4
00163 #define GL2PS_BEGIN_LINE_STIPPLE         5
00164 #define GL2PS_END_LINE_STIPPLE           6
00165 #define GL2PS_SET_POINT_SIZE             7
00166 #define GL2PS_SET_LINE_WIDTH             8
00167 
00168 typedef GLfloat GL2PSrgba[4];
00169 typedef GLfloat GL2PSxyz[3];
00170 typedef GLfloat GL2PSplane[4];
00171 
00172 typedef struct _GL2PSbsptree2d GL2PSbsptree2d;
00173 
00174 struct _GL2PSbsptree2d {
00175   GL2PSplane plane;
00176   GL2PSbsptree2d *front, *back;
00177 };
00178 
00179 typedef struct {
00180   GLint nmax, size, incr, n;
00181   char *array;
00182 } GL2PSlist;
00183 
00184 typedef struct _GL2PSbsptree GL2PSbsptree;
00185 
00186 struct _GL2PSbsptree {
00187   GL2PSplane plane;
00188   GL2PSlist *primitives;
00189   GL2PSbsptree *front, *back;
00190 };
00191 
00192 typedef struct {
00193   GL2PSxyz xyz;
00194   GL2PSrgba rgba;
00195 } GL2PSvertex;
00196 
00197 typedef struct {
00198   GLshort fontsize;
00199   char *str, *fontname;
00200 } GL2PSstring;
00201 
00202 typedef struct {
00203   GLsizei width, height;
00204   GLenum format, type;
00205   GLfloat *pixels;
00206 } GL2PSimage;
00207 
00208 typedef struct {
00209   GLshort type, numverts;
00210   char boundary, dash, culled;
00211   GLfloat width, depth;
00212   GL2PSvertex *verts;
00213   GL2PSstring *text;
00214   GL2PSimage *image;
00215 } GL2PSprimitive;
00216 
00217 typedef struct {
00218   GLint format, sort, options, colorsize, colormode, buffersize, maxbestroot;
00219   const char *title, *producer, *filename;
00220   GLboolean shade, boundary;
00221   GLfloat *feedback, offset[2];
00222   GLint viewport[4];
00223   GL2PSrgba *colormap, lastrgba, threshold;
00224   float lastlinewidth;
00225   GL2PSlist *primitives;
00226   GL2PSbsptree2d *imagetree;
00227   FILE *stream;
00228 } GL2PScontext;
00229 
00230 /* public functions */
00231 
00232 #ifdef __cplusplus
00233 extern "C" {
00234 #endif
00235 
00236 GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, 
00237                                   GLint viewport[4], GLint format, GLint sort,
00238                                   GLint options, GLint colormode,
00239                                   GLint colorsize, GL2PSrgba *colormap, 
00240                                   GLint nr, GLint ng, GLint nb, GLint buffersize,
00241                                   FILE *stream, const char *filename);
00242 GL2PSDLL_API GLint gl2psEndPage(void);
00243 GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4]);
00244 GL2PSDLL_API GLint gl2psEndViewport(void);
00245 GL2PSDLL_API GLint gl2psText(const char *str, const char *fontname, GLshort fontsize);
00246 GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height,
00247                                    GLint xorig, GLint yorig,
00248                                    GLenum format, GLenum type, const void *pixels);
00249 GL2PSDLL_API GLint gl2psEnable(GLint mode);
00250 GL2PSDLL_API GLint gl2psDisable(GLint mode);
00251 GL2PSDLL_API GLint gl2psPointSize(GLfloat value);
00252 GL2PSDLL_API GLint gl2psLineWidth(GLfloat value);
00253 
00254 #ifdef __cplusplus
00255 }
00256 #endif
00257 
00258 #endif /* __GL2PS_H__ */

Generated on Fri Apr 11 17:10:49 2008 for Geant4 by  doxygen 1.4.7