Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
febabc2b
Commit
febabc2b
authored
23 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
Optimized EPS output file size
parent
6f89ae31
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Graphics/gl2ps.cpp
+75
-61
75 additions, 61 deletions
Graphics/gl2ps.cpp
Graphics/gl2ps.h
+2
-2
2 additions, 2 deletions
Graphics/gl2ps.h
with
77 additions
and
63 deletions
Graphics/gl2ps.cpp
+
75
−
61
View file @
febabc2b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* GL2PS, an OpenGL to Postscript Printing Library
* GL2PS, an OpenGL to Postscript Printing Library
* Copyright (C) 1999-2001 Christophe Geuzaine
* Copyright (C) 1999-2001 Christophe Geuzaine
*
*
* $Id: gl2ps.cpp,v 1.2
7
2001-
09-25 08:20:20
geuzaine Exp $
* $Id: gl2ps.cpp,v 1.2
8
2001-
10-08 21:48:19
geuzaine Exp $
*
*
* E-mail: Christophe.Geuzaine@AdValvas.be
* E-mail: Christophe.Geuzaine@AdValvas.be
* URL: http://www.geuz.org/gl2ps/
* URL: http://www.geuz.org/gl2ps/
...
@@ -1065,14 +1065,15 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
...
@@ -1065,14 +1065,15 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
glGetIntegerv
(
GL_VIEWPORT
,
viewport
);
glGetIntegerv
(
GL_VIEWPORT
,
viewport
);
/*
/*
Greyscale
: r g b
G
(replace C by G in output to change from rgb to gray)
RGB color
: r g b
C
(replace C by G in output to change from rgb to gray)
RGB color
: r g b
C
Greyscale
: r g b
G
Font choose: size fontname FC
Font choose: size fontname FC
String primitive: (string) x y r g b size fontname S
String primitive: (string) x y size fontname S
Point primitive: x y size r g b P
Point primitive: x y size P
Flat-shaded line: x2 y2 x1 y1 r g b width L
Line width: width W
Flat-shaded triangle: x3 y3 x2 y2 x1 y1 r g b T
Flat-shaded line: x2 y2 x1 y1 L
Smooth-shaded line: x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 width SL
Smooth-shaded line: x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 SL
Flat-shaded triangle: x3 y3 x2 y2 x1 y1 T
Smooth-shaded triangle: x3 y3 r3 g3 b3 x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 ST
Smooth-shaded triangle: x3 y3 r3 g3 b3 x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 ST
*/
*/
...
@@ -1083,9 +1084,7 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
...
@@ -1083,9 +1084,7 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
"%%%%For: %s
\n
"
"%%%%For: %s
\n
"
"%%%%CreationDate: %s"
"%%%%CreationDate: %s"
"%%%%LanguageLevel: 2
\n
"
"%%%%LanguageLevel: 2
\n
"
"%%%%Pages: 1
\n
"
"%%%%DocumentData: Clean7Bit
\n
"
"%%%%DocumentData: Clean7Bit
\n
"
"%%%%PageOrder: Ascend
\n
"
"%%%%Orientation: Portrait
\n
"
"%%%%Orientation: Portrait
\n
"
"%%%%DocumentMedia: Default %d %d 0 () ()
\n
"
"%%%%DocumentMedia: Default %d %d 0 () ()
\n
"
"%%%%BoundingBox: %d %d %d %d
\n
"
"%%%%BoundingBox: %d %d %d %d
\n
"
...
@@ -1093,20 +1092,25 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
...
@@ -1093,20 +1092,25 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
"%%%%EndComments
\n
"
"%%%%EndComments
\n
"
"%%%%BeginProlog
\n
"
"%%%%BeginProlog
\n
"
"/gl2psdict 64 dict def gl2psdict begin
\n
"
"/gl2psdict 64 dict def gl2psdict begin
\n
"
"1 setlinecap 1 setlinejoin /bd {bind def} bind def
\n
"
"1 setlinecap 1 setlinejoin
\n
"
"/BD { bind def } bind def
\n
"
"/C { setrgbcolor } BD
\n
"
"/G { 0.082 mul exch 0.6094 mul add exch 0.3086 mul add neg 1.0 add
\n
"
"/G { 0.082 mul exch 0.6094 mul add exch 0.3086 mul add neg 1.0 add
\n
"
"setgray } bd /C { setrgbcolor } bd /FC { findfont exch scalefont
\n
"
" setgray } BD
\n
"
"setfont } bd /S { FC C moveto show } bd /P { C newpath 0.0 360.0
\n
"
"/W { setlinewidth } BD
\n
"
"arc closepath fill } bd /L { setlinewidth C newpath moveto lineto
\n
"
"/FC { findfont exch scalefont setfont } BD
\n
"
"stroke } bd /T { C newpath moveto lineto lineto closepath fill } bd
\n
"
"/S { FC moveto show } BD
\n
"
"/SL { /lw exch def /b1 exch def /g1 exch def /r1 exch def /y1 exch def
\n
"
"/P { newpath 0.0 360.0 arc closepath fill } BD
\n
"
"/L { newpath moveto lineto stroke } BD
\n
"
"/SL { /b1 exch def /g1 exch def /r1 exch def /y1 exch def
\n
"
" /x1 exch def /b2 exch def /g2 exch def /r2 exch def /y2 exch def
\n
"
" /x1 exch def /b2 exch def /g2 exch def /r2 exch def /y2 exch def
\n
"
" /x2 exch def b2 b1 sub abs 0.01 gt g2 g1 sub abs 0.005 gt r2 r1 sub
\n
"
" /x2 exch def b2 b1 sub abs 0.01 gt g2 g1 sub abs 0.005 gt r2 r1 sub
\n
"
" abs 0.008 gt or or { /bm b1 b2 add 0.5 mul def /gm g1 g2 add 0.5 mul def
\n
"
" abs 0.008 gt or or { /bm b1 b2 add 0.5 mul def /gm g1 g2 add 0.5 mul def
\n
"
" /rm r1 r2 add 0.5 mul def /ym y1 y2 add 0.5 mul def /xm x1 x2 add
\n
"
" /rm r1 r2 add 0.5 mul def /ym y1 y2 add 0.5 mul def /xm x1 x2 add
\n
"
"0.5 mul def x1 y1 r1 g1 b1 xm ym rm gm bm lw SL xm ym rm gm bm x2 y2 r2
\n
"
" 0.5 mul def x1 y1 r1 g1 b1 xm ym rm gm bm SL xm ym rm gm bm x2 y2 r2
\n
"
"g2 b2 lw SL } { x1 y1 x2 y2 r1 g1 b1 lw L } ifelse } bd /ST {/b1 exch
\n
"
" g2 b2 SL } { x1 y1 x2 y2 r1 g1 b1 C L } ifelse } BD
\n
"
"def /g1 exch def /r1 exch def /y1 exch def /x1 exch def
\n
"
"/T { newpath moveto lineto lineto closepath fill } BD
\n
"
"/ST { /b1 exch def /g1 exch def /r1 exch def /y1 exch def /x1 exch def
\n
"
" /b2 exch def /g2 exch def /r2 exch def /y2 exch def /x2 exch def
\n
"
" /b2 exch def /g2 exch def /r2 exch def /y2 exch def /x2 exch def
\n
"
" /b3 exch def /g3 exch def /r3 exch def /y3 exch def /x3 exch def
\n
"
" /b3 exch def /g3 exch def /r3 exch def /y3 exch def /x3 exch def
\n
"
" b2 b1 sub abs 0.05 gt g2 g1 sub abs 0.017 gt r2 r1 sub abs 0.032 gt
\n
"
" b2 b1 sub abs 0.05 gt g2 g1 sub abs 0.017 gt r2 r1 sub abs 0.032 gt
\n
"
...
@@ -1122,16 +1126,13 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
...
@@ -1122,16 +1126,13 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
" r12 g12 b12 x13 y13 r13 g13 b13 x2 y2 r2 g2 b2 x12 y12 r12 g12 b12
\n
"
" r12 g12 b12 x13 y13 r13 g13 b13 x2 y2 r2 g2 b2 x12 y12 r12 g12 b12
\n
"
" x32 y32 r32 g32 b32 x3 y3 r3 g3 b3 x32 y32 r32 g32 b32 x13 y13 r13
\n
"
" x32 y32 r32 g32 b32 x3 y3 r3 g3 b3 x32 y32 r32 g32 b32 x13 y13 r13
\n
"
" g13 b13 x32 y32 r32 g32 b32 x12 y12 r12 g12 b12 x13 y13 r13 g13 b13
\n
"
" g13 b13 x32 y32 r32 g32 b32 x12 y12 r12 g12 b12 x13 y13 r13 g13 b13
\n
"
"ST ST ST ST } { x1 y1 x2 y2 x3 y3 r1 g1 b1 T } ifelse }
bd
\n
"
"
ST ST ST ST } { x1 y1 x2 y2 x3 y3 r1 g1 b1
C
T } ifelse }
BD
\n
"
"end
\n
"
"end
\n
"
"%%%%EndProlog
\n
"
"%%%%EndProlog
\n
"
"%%%%BeginSetup
\n
"
"%%%%BeginSetup
\n
"
"/DeviceRGB setcolorspace
\n
"
"/DeviceRGB setcolorspace
\n
"
"gl2psdict begin
\n
"
"gl2psdict begin
\n
"
"%%%%EndSetup
\n
"
"%%%%EndSetup
\n
"
"%%%%Page: 1 1
\n
"
"%%%%BeginPageSetup
\n
"
"%%%%EndPageSetup
\n
"
"mark
\n
"
"mark
\n
"
"gsave
\n
"
"gsave
\n
"
"1.0 1.0 scale
\n
"
,
"1.0 1.0 scale
\n
"
,
...
@@ -1158,7 +1159,20 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
...
@@ -1158,7 +1159,20 @@ GLvoid gl2psPrintPostscriptHeader(GLvoid){
}
}
}
}
#define PRINTCOLOR \
if(rgba[0] != prim->verts[0].rgba[0] || \
rgba[1] != prim->verts[0].rgba[1] || \
rgba[2] != prim->verts[0].rgba[2]){ \
rgba[0] = prim->verts[0].rgba[0]; \
rgba[1] = prim->verts[0].rgba[1]; \
rgba[2] = prim->verts[0].rgba[2]; \
fprintf(gl2ps.stream, "%g %g %g C\n", rgba[0], rgba[1], rgba[2]); \
}
GLvoid
gl2psPrintPostscriptPrimitive
(
GLvoid
*
a
,
GLvoid
*
b
){
GLvoid
gl2psPrintPostscriptPrimitive
(
GLvoid
*
a
,
GLvoid
*
b
){
static
GL2PSrgba
rgba
=
{
-
1.
,
-
1.
,
-
1.
,
-
1.
};
static
int
linewidth
=-
1
;
GL2PSprimitive
*
prim
;
GL2PSprimitive
*
prim
;
prim
=
*
(
GL2PSprimitive
**
)
a
;
prim
=
*
(
GL2PSprimitive
**
)
a
;
...
@@ -1167,35 +1181,36 @@ GLvoid gl2psPrintPostscriptPrimitive(GLvoid *a, GLvoid *b){
...
@@ -1167,35 +1181,36 @@ GLvoid gl2psPrintPostscriptPrimitive(GLvoid *a, GLvoid *b){
switch
(
prim
->
type
){
switch
(
prim
->
type
){
case
GL2PS_TEXT
:
case
GL2PS_TEXT
:
fprintf
(
gl2ps
.
stream
,
"(%s) %g %g %g %g %g %d /%s S
\n
"
,
PRINTCOLOR
;
fprintf
(
gl2ps
.
stream
,
"(%s) %g %g %d /%s S
\n
"
,
prim
->
text
->
str
,
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
prim
->
text
->
str
,
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
prim
->
verts
[
0
].
rgba
[
0
],
prim
->
verts
[
0
].
rgba
[
1
],
prim
->
text
->
fontsize
,
prim
->
text
->
fontname
);
prim
->
verts
[
0
].
rgba
[
2
],
prim
->
text
->
fontsize
,
prim
->
text
->
fontname
);
break
;
break
;
case
GL2PS_POINT
:
case
GL2PS_POINT
:
fprintf
(
gl2ps
.
stream
,
"%g %g %g %g %g %g P
\n
"
,
PRINTCOLOR
;
pri
m
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
0.5
*
prim
->
width
,
f
pri
ntf
(
gl2ps
.
stream
,
"%g %g %g P
\n
"
,
prim
->
verts
[
0
].
rgba
[
0
],
prim
->
verts
[
0
].
rgba
[
1
],
prim
->
verts
[
0
].
rgba
[
2
]
);
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
0.5
*
prim
->
width
);
break
;
break
;
case
GL2PS_LINE
:
case
GL2PS_LINE
:
if
(
linewidth
!=
prim
->
width
){
linewidth
=
prim
->
width
;
fprintf
(
gl2ps
.
stream
,
"%g W
\n
"
,
0.2
*
linewidth
*
linewidth
);
}
if
(
prim
->
dash
)
if
(
prim
->
dash
)
fprintf
(
gl2ps
.
stream
,
"[%d] 0 setdash
\n
"
,
prim
->
dash
);
fprintf
(
gl2ps
.
stream
,
"[%d] 0 setdash
\n
"
,
prim
->
dash
);
if
(
gl2ps
.
shade
){
if
(
gl2ps
.
shade
){
fprintf
(
gl2ps
.
stream
,
"%g %g %g %g %g %g %g %g %g %g
%g
SL
\n
"
,
fprintf
(
gl2ps
.
stream
,
"%g %g %g %g %g %g %g %g %g %g SL
\n
"
,
prim
->
verts
[
1
].
xyz
[
0
],
prim
->
verts
[
1
].
xyz
[
1
],
prim
->
verts
[
1
].
xyz
[
0
],
prim
->
verts
[
1
].
xyz
[
1
],
prim
->
verts
[
1
].
rgba
[
0
],
prim
->
verts
[
1
].
rgba
[
1
],
prim
->
verts
[
1
].
rgba
[
0
],
prim
->
verts
[
1
].
rgba
[
1
],
prim
->
verts
[
1
].
rgba
[
2
],
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
1
].
rgba
[
2
],
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
prim
->
verts
[
0
].
rgba
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
prim
->
verts
[
0
].
rgba
[
0
],
prim
->
verts
[
0
].
rgba
[
1
],
prim
->
verts
[
0
].
rgba
[
2
],
prim
->
verts
[
0
].
rgba
[
1
],
prim
->
verts
[
0
].
rgba
[
2
]);
0.2
*
prim
->
width
*
prim
->
width
);
}
}
else
{
else
{
fprintf
(
gl2ps
.
stream
,
"%g %g %g %g %g %g %g %g L
\n
"
,
PRINTCOLOR
;
fprintf
(
gl2ps
.
stream
,
"%g %g %g %g L
\n
"
,
prim
->
verts
[
1
].
xyz
[
0
],
prim
->
verts
[
1
].
xyz
[
1
],
prim
->
verts
[
1
].
xyz
[
0
],
prim
->
verts
[
1
].
xyz
[
1
],
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
]);
prim
->
verts
[
0
].
rgba
[
0
],
prim
->
verts
[
0
].
rgba
[
1
],
prim
->
verts
[
0
].
rgba
[
2
],
0.2
*
prim
->
width
*
prim
->
width
);
}
}
if
(
prim
->
dash
)
if
(
prim
->
dash
)
fprintf
(
gl2ps
.
stream
,
"[] 0 setdash
\n
"
);
fprintf
(
gl2ps
.
stream
,
"[] 0 setdash
\n
"
);
...
@@ -1213,12 +1228,11 @@ GLvoid gl2psPrintPostscriptPrimitive(GLvoid *a, GLvoid *b){
...
@@ -1213,12 +1228,11 @@ GLvoid gl2psPrintPostscriptPrimitive(GLvoid *a, GLvoid *b){
prim
->
verts
[
0
].
rgba
[
2
]);
prim
->
verts
[
0
].
rgba
[
2
]);
}
}
else
{
else
{
fprintf
(
gl2ps
.
stream
,
"%g %g %g %g %g %g %g %g %g T
\n
"
,
PRINTCOLOR
;
fprintf
(
gl2ps
.
stream
,
"%g %g %g %g %g %g T
\n
"
,
prim
->
verts
[
2
].
xyz
[
0
],
prim
->
verts
[
2
].
xyz
[
1
],
prim
->
verts
[
2
].
xyz
[
0
],
prim
->
verts
[
2
].
xyz
[
1
],
prim
->
verts
[
1
].
xyz
[
0
],
prim
->
verts
[
1
].
xyz
[
1
],
prim
->
verts
[
1
].
xyz
[
0
],
prim
->
verts
[
1
].
xyz
[
1
],
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
],
prim
->
verts
[
0
].
xyz
[
0
],
prim
->
verts
[
0
].
xyz
[
1
]);
prim
->
verts
[
0
].
rgba
[
0
],
prim
->
verts
[
0
].
rgba
[
1
],
prim
->
verts
[
0
].
rgba
[
2
]);
}
}
break
;
break
;
case
GL2PS_QUADRANGLE
:
case
GL2PS_QUADRANGLE
:
...
...
This diff is collapsed.
Click to expand it.
Graphics/gl2ps.h
+
2
−
2
View file @
febabc2b
...
@@ -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-2001 Christophe Geuzaine
* Copyright (C) 1999-2001 Christophe Geuzaine
*
*
* $Id: gl2ps.h,v 1.1
2
2001-
06-12 08:49:42
geuzaine Exp $
* $Id: gl2ps.h,v 1.1
3
2001-
10-08 21:48:19
geuzaine Exp $
*
*
* E-mail: Christophe.Geuzaine@AdValvas.be
* E-mail: Christophe.Geuzaine@AdValvas.be
* URL: http://www.geuz.org/gl2ps/
* URL: http://www.geuz.org/gl2ps/
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include
<stdlib.h>
#include
<stdlib.h>
#include
<GL/gl.h>
#include
<GL/gl.h>
#define GL2PS_VERSION 0.4
#define GL2PS_VERSION 0.4
2
#define GL2PS_NONE 0
#define GL2PS_NONE 0
/* Output file format */
/* Output file format */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment