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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
cff6b329
Commit
cff6b329
authored
11 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
PGF patch
parent
8c4746f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/CreateFile.cpp
+20
-1
20 additions, 1 deletion
Common/CreateFile.cpp
Graphics/gl2pgf.cpp
+59
-30
59 additions, 30 deletions
Graphics/gl2pgf.cpp
Graphics/gl2pgf.h
+2
-1
2 additions, 1 deletion
Graphics/gl2pgf.h
with
81 additions
and
32 deletions
Common/CreateFile.cpp
+
20
−
1
View file @
cff6b329
...
@@ -528,10 +528,29 @@ void CreateOutputFile(const std::string &fileName, int format,
...
@@ -528,10 +528,29 @@ void CreateOutputFile(const std::string &fileName, int format,
case
FORMAT_PGF
:
case
FORMAT_PGF
:
{
{
if
(
!
FlGui
::
available
())
break
;
if
(
!
FlGui
::
available
())
break
;
// fill pixel buffer without colorbar and axes
int
restoreGeneralAxis
=
(
int
)
opt_general_axes
(
0
,
GMSH_GET
,
0
);
int
restoreSmallAxis
=
(
int
)
opt_general_small_axes
(
0
,
GMSH_GET
,
0
);
opt_general_axes
(
0
,
GMSH_SET
,
0
);
opt_general_small_axes
(
0
,
GMSH_SET
,
0
);
int
num
=
-
1
;
// id of the post view
int
cnt
=
0
;
// no of scales/colorbars active
for
(
unsigned
int
i
=
0
;
i
<
opt_post_nb_views
(
0
,
GMSH_GET
,
0
);
i
++
)
{
if
(
opt_view_visible
(
i
,
GMSH_GET
,
0
))
{
if
(
opt_view_show_scale
(
i
,
GMSH_GET
,
0
))
{
opt_view_show_scale
(
i
,
GMSH_SET
,
0
);
num
=
i
;
cnt
++
;
}
}
}
PixelBuffer
*
buffer
=
GetCompositePixelBuffer
(
GL_RGB
,
GL_UNSIGNED_BYTE
);
PixelBuffer
*
buffer
=
GetCompositePixelBuffer
(
GL_RGB
,
GL_UNSIGNED_BYTE
);
drawContext
*
ctx
=
FlGui
::
instance
()
->
getCurrentOpenglWindow
()
->
getDrawContext
();
drawContext
*
ctx
=
FlGui
::
instance
()
->
getCurrentOpenglWindow
()
->
getDrawContext
();
print_pgf
(
name
,
buffer
,
ctx
->
r
,
ctx
->
viewport
,
ctx
->
proj
,
ctx
->
model
);
print_pgf
(
name
,
num
,
cnt
,
buffer
,
ctx
->
r
,
ctx
->
viewport
,
ctx
->
proj
,
ctx
->
model
);
delete
buffer
;
delete
buffer
;
// restore view
if
(
restoreGeneralAxis
)
opt_general_axes
(
0
,
GMSH_SET
|
GMSH_GUI
,
1
);
if
(
restoreSmallAxis
)
opt_general_small_axes
(
0
,
GMSH_SET
|
GMSH_GUI
,
1
);
if
(
cnt
>
0
)
opt_view_show_scale
(
num
,
GMSH_SET
,
1
);
}
}
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
Graphics/gl2pgf.cpp
+
59
−
30
View file @
cff6b329
...
@@ -171,7 +171,7 @@ static int getMinMaxOfAxis(const int num, double result[8][3])
...
@@ -171,7 +171,7 @@ static int getMinMaxOfAxis(const int num, double result[8][3])
fprintf
(
stderr
,
"x=(%f,%f), y=(%f,%f), z=(%f,%f)
\n
"
,
fprintf
(
stderr
,
"x=(%f,%f), y=(%f,%f), z=(%f,%f)
\n
"
,
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
);
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
);
}
}
else
if
(
!
(
int
)
opt_view_axes_auto_position
(
num
,
GMSH_GET
,
0
)
&&
num
>=
0
)
{
else
if
(
num
>=
0
&&
!
(
int
)
opt_view_axes_auto_position
(
num
,
GMSH_GET
,
0
)
)
{
// needs to get manual axes set
// needs to get manual axes set
xmin
=
opt_view_axes_xmin
(
num
,
GMSH_GET
,
0
);
xmin
=
opt_view_axes_xmin
(
num
,
GMSH_GET
,
0
);
xmax
=
opt_view_axes_xmax
(
num
,
GMSH_GET
,
0
);
xmax
=
opt_view_axes_xmax
(
num
,
GMSH_GET
,
0
);
...
@@ -237,13 +237,13 @@ static int assemble2d(const int num, const int exportAxis, std::string &axisstr,
...
@@ -237,13 +237,13 @@ static int assemble2d(const int num, const int exportAxis, std::string &axisstr,
if
(
zlab
.
empty
())
if
(
zlab
.
empty
())
zlab
=
"z"
;
zlab
=
"z"
;
printf
(
"Euler two dim: 0:%f, 1:%f, 2:%f
\n
"
,
f
printf
(
stderr
,
"Euler two dim: 0:%f, 1:%f, 2:%f
\n
"
,
eulerAngles
[
0
],
eulerAngles
[
1
],
eulerAngles
[
2
]);
eulerAngles
[
0
],
eulerAngles
[
1
],
eulerAngles
[
2
]);
int
r0
=
(
int
)
(
eulerAngles
[
0
]
+
0.5
);
int
r0
=
(
int
)
(
eulerAngles
[
0
]
+
0.5
);
int
r1
=
(
int
)
(
eulerAngles
[
1
]
+
0.5
);
int
r1
=
(
int
)
(
eulerAngles
[
1
]
+
0.5
);
int
r2
=
(
int
)
(
eulerAngles
[
2
]
+
0.5
);
int
r2
=
(
int
)
(
eulerAngles
[
2
]
+
0.5
);
if
(
r0
%
90
!=
0
||
r1
%
90
!=
0
||
r2
%
90
!=
0
)
{
if
(
r0
%
90
!=
0
||
r1
%
90
!=
0
||
r2
%
90
!=
0
)
{
printf
(
"Euler two dim: 0:%d, 1:%d, 2:%d
\n
"
,
r0
,
r1
,
r2
);
f
printf
(
stderr
,
"Euler two dim: 0:%d, 1:%d, 2:%d
\n
"
,
r0
,
r1
,
r2
);
Msg
::
Error
(
"Please select a plane view (X, Y, Z)"
);
Msg
::
Error
(
"Please select a plane view (X, Y, Z)"
);
return
1
;
return
1
;
}
}
...
@@ -344,8 +344,8 @@ static int assemble2d(const int num, const int exportAxis, std::string &axisstr,
...
@@ -344,8 +344,8 @@ static int assemble2d(const int num, const int exportAxis, std::string &axisstr,
if
(
factor
!=
1
)
{
if
(
factor
!=
1
)
{
char
tmp
[
265
];
char
tmp
[
265
];
sprintf
(
tmp
,
"The pgf output has been rescaled in order to please "
sprintf
(
tmp
,
"The pgf output has been rescaled in order to please "
"the X number precision/range. Rescaling your results by "
"the
Te
X number precision/range. Rescaling your results by "
"a ftor %g"
,
factor
);
"a f
ac
tor %g"
,
factor
);
Msg
::
Warning
(
tmp
);
Msg
::
Warning
(
tmp
);
// sprintf(tmp, "$\\times 10^{%d}$},",(int)(log10(factor)+0.5));
// sprintf(tmp, "$\\times 10^{%d}$},",(int)(log10(factor)+0.5));
// std::string repl = tmp;
// std::string repl = tmp;
...
@@ -359,6 +359,8 @@ static int assemble2d(const int num, const int exportAxis, std::string &axisstr,
...
@@ -359,6 +359,8 @@ static int assemble2d(const int num, const int exportAxis, std::string &axisstr,
std
::
size_t
foundx
=
axisstr
.
rfind
(
"},"
,
foundy
);
std
::
size_t
foundx
=
axisstr
.
rfind
(
"},"
,
foundy
);
if
(
foundx
!=
std
::
string
::
npos
)
if
(
foundx
!=
std
::
string
::
npos
)
axisstr
.
insert
(
foundx
,
suffix
);
axisstr
.
insert
(
foundx
,
suffix
);
else
return
4
;
}
}
// axis options
// axis options
axisstr
.
append
(
"
\t
enlargelimits=false, %% tight axis, use xmin=<val>, "
);
axisstr
.
append
(
"
\t
enlargelimits=false, %% tight axis, use xmin=<val>, "
);
...
@@ -434,6 +436,7 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
...
@@ -434,6 +436,7 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
bool
reorder
=
false
;
bool
reorder
=
false
;
double
minlen
=
0.
;
double
minlen
=
0.
;
std
::
string
suffix
;
for
(
unsigned
int
j
=
0
;
j
<
8
;
j
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
8
;
j
++
)
{
// project the 8 axis end points to pixel coordinates,
// project the 8 axis end points to pixel coordinates,
// accept if they are in the screen range.
// accept if they are in the screen range.
...
@@ -453,10 +456,22 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
...
@@ -453,10 +456,22 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
// respecting TeXs range limts (1e-4 relative precision)
// respecting TeXs range limts (1e-4 relative precision)
minlen
=
norm3
(
axPts
[
j
]);
minlen
=
norm3
(
axPts
[
j
]);
//fprintf(stderr,"j=%d, vec length %f:\n", j, minlen);
//fprintf(stderr,"j=%d, vec length %f:\n", j, minlen);
if
(
minlen
<
1e-5
)
factor
=
1e6
;
if
(
minlen
<
1e-5
)
{
else
if
(
minlen
<
0.01
)
factor
=
1e3
;
factor
=
1e6
;
else
if
(
minlen
>
1e6
)
factor
=
1e-6
;
suffix
.
assign
(
"/$
\\
mu$m"
);
else
if
(
minlen
>
1000
)
factor
=
1e-3
;
}
else
if
(
minlen
<
0.01
)
{
factor
=
1e3
;
suffix
.
assign
(
"/mm"
);
}
else
if
(
minlen
>
1e6
)
{
factor
=
1e-6
;
suffix
.
assign
(
"/Mm"
);
}
else
if
(
minlen
>
1000
)
{
factor
=
1e-3
;
suffix
.
assign
(
"/Km"
);
}
}
}
if
(
j
==
1
&&
acceptableAnchors
.
size
()
==
2
)
{
if
(
j
==
1
&&
acceptableAnchors
.
size
()
==
2
)
{
// precaution: if the first two coordinates are accepted, a
// precaution: if the first two coordinates are accepted, a
...
@@ -471,10 +486,41 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
...
@@ -471,10 +486,41 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
if
(
acceptableAnchors
.
size
()
<
4
)
{
if
(
acceptableAnchors
.
size
()
<
4
)
{
Msg
::
Error
(
"Unable to calculate anchors for pgf output. "
Msg
::
Error
(
"Unable to calculate anchors for pgf output. "
"Make sure the entire scene is visible or adjust
the axes min/max values
"
"Make sure the entire scene is visible or adjust "
"to fit inside your screen"
);
"
the axes min/max values
to fit inside your screen
.
"
);
return
2
;
return
2
;
}
}
if
(
factor
!=
1
)
{
char
tmp
[
265
];
sprintf
(
tmp
,
"The pgf output has been rescaled in order to please "
"the TeX number precision/range. Rescaling your results by "
"a factor %g"
,
factor
);
Msg
::
Warning
(
tmp
);
// replace three labels
if
(
exportAxis
)
{
// xlabel={x<>}, %%
// ylabel={y<>},
// zlabel={z<>},
// zlabel style={rotate=-90},
std
::
size_t
foundrot
=
axisstr
.
rfind
(
"},"
);
std
::
size_t
foundz
=
axisstr
.
rfind
(
"},"
,
foundrot
-
1
);
if
(
foundz
!=
std
::
string
::
npos
)
axisstr
.
insert
(
foundz
,
suffix
);
else
return
4
;
std
::
size_t
foundy
=
axisstr
.
rfind
(
"},"
,
foundz
);
if
(
foundy
!=
std
::
string
::
npos
)
axisstr
.
insert
(
foundy
,
suffix
);
else
return
4
;
std
::
size_t
foundx
=
axisstr
.
rfind
(
"},"
,
foundy
);
if
(
foundx
!=
std
::
string
::
npos
)
axisstr
.
insert
(
foundx
,
suffix
);
else
return
4
;
}
}
char
tmp
[
265
];
char
tmp
[
265
];
plotstr
.
assign
(
"
\t
\\
addplot3[surf] graphics[debug=false,%%=visual,
\n
"
);
plotstr
.
assign
(
"
\t
\\
addplot3[surf] graphics[debug=false,%%=visual,
\n
"
);
...
@@ -505,27 +551,13 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
...
@@ -505,27 +551,13 @@ static int assemble3d(const int num, const int exportAxis, std::string &axisstr,
return
0
;
return
0
;
}
}
int
print_pgf
(
const
std
::
string
&
name
,
PixelBuffer
*
buffer
,
double
*
eulerAngles
,
int
print_pgf
(
const
std
::
string
&
name
,
const
int
num
,
const
int
cnt
,
PixelBuffer
*
buffer
,
double
*
eulerAngles
,
int
*
viewport
,
double
*
proj
,
double
*
model
)
int
*
viewport
,
double
*
proj
,
double
*
model
)
{
{
int
ypix
=
buffer
->
getHeight
();
int
ypix
=
buffer
->
getHeight
();
int
xpix
=
buffer
->
getWidth
();
int
xpix
=
buffer
->
getWidth
();
// write png (disable colorbar and axes)
int
restoreGeneralAxis
=
(
int
)
opt_general_axes
(
0
,
GMSH_GET
,
0
);
int
restoreSmallAxis
=
(
int
)
opt_general_small_axes
(
0
,
GMSH_GET
,
0
);
opt_general_axes
(
0
,
GMSH_SET
,
0
);
opt_general_small_axes
(
0
,
GMSH_SET
,
0
);
int
num
=
-
1
;
// id of the post view
int
cnt
=
0
;
// no of scales/colorbars active
for
(
unsigned
int
i
=
0
;
i
<
PView
::
list
.
size
();
i
++
)
{
if
(
opt_view_visible
(
i
,
GMSH_GET
,
0
))
{
if
(
opt_view_show_scale
(
i
,
GMSH_GET
,
0
))
{
opt_view_show_scale
(
i
,
GMSH_SET
,
0
);
// deactivate for png output
num
=
i
;
cnt
++
;
}
}
}
std
::
string
base
=
SplitFileName
(
name
)[
1
];
std
::
string
base
=
SplitFileName
(
name
)[
1
];
std
::
string
path
=
SplitFileName
(
name
)[
0
];
std
::
string
path
=
SplitFileName
(
name
)[
0
];
std
::
string
pngfilen
=
path
+
base
+
".png"
;
std
::
string
pngfilen
=
path
+
base
+
".png"
;
...
@@ -538,9 +570,6 @@ int print_pgf(const std::string &name, PixelBuffer *buffer, double *eulerAngles,
...
@@ -538,9 +570,6 @@ int print_pgf(const std::string &name, PixelBuffer *buffer, double *eulerAngles,
}
}
create_png
(
fp
,
buffer
,
100
);
create_png
(
fp
,
buffer
,
100
);
fclose
(
fp
);
fclose
(
fp
);
if
(
restoreGeneralAxis
)
opt_general_axes
(
0
,
GMSH_SET
|
GMSH_GUI
,
1
);
if
(
restoreSmallAxis
)
opt_general_small_axes
(
0
,
GMSH_SET
|
GMSH_GUI
,
1
);
opt_view_show_scale
(
num
,
GMSH_SET
,
1
);
// write pgf
// write pgf
int
twoDim
=
(
int
)
opt_print_pgf_two_dim
(
0
,
GMSH_GET
,
0
);
int
twoDim
=
(
int
)
opt_print_pgf_two_dim
(
0
,
GMSH_GET
,
0
);
...
...
This diff is collapsed.
Click to expand it.
Graphics/gl2pgf.h
+
2
−
1
View file @
cff6b329
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
#include
<string>
#include
<string>
#include
"PixelBuffer.h"
#include
"PixelBuffer.h"
int
print_pgf
(
const
std
::
string
&
name
,
PixelBuffer
*
buffer
,
double
*
eulerAngles
,
int
print_pgf
(
const
std
::
string
&
name
,
const
int
num
,
const
int
cnt
,
PixelBuffer
*
buffer
,
double
*
eulerAngles
,
int
*
viewport
,
double
*
proj
,
double
*
model
);
int
*
viewport
,
double
*
proj
,
double
*
model
);
#endif
#endif
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