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
b8b36a96
Commit
b8b36a96
authored
12 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
make sure -format recognizes all the same formats as CreateFile
parent
2795e213
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/CommandLine.cpp
+8
-26
8 additions, 26 deletions
Common/CommandLine.cpp
Common/CreateFile.cpp
+44
-39
44 additions, 39 deletions
Common/CreateFile.cpp
Common/CreateFile.h
+3
-2
3 additions, 2 deletions
Common/CreateFile.h
with
55 additions
and
67 deletions
Common/CommandLine.cpp
+
8
−
26
View file @
b8b36a96
...
...
@@ -631,32 +631,14 @@ void GetOptions(int argc, char *argv[])
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_MSH
;
CTX
::
instance
()
->
mesh
.
mshFileVersion
=
2.0
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"msh"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_MSH
;
else
if
(
!
strcmp
(
argv
[
i
],
"unv"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_UNV
;
else
if
(
!
strcmp
(
argv
[
i
],
"vrml"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_VRML
;
else
if
(
!
strcmp
(
argv
[
i
],
"ply2"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_PLY2
;
else
if
(
!
strcmp
(
argv
[
i
],
"stl"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_STL
;
else
if
(
!
strcmp
(
argv
[
i
],
"mesh"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_MESH
;
else
if
(
!
strcmp
(
argv
[
i
],
"bdf"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_BDF
;
else
if
(
!
strcmp
(
argv
[
i
],
"p3d"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_P3D
;
else
if
(
!
strcmp
(
argv
[
i
],
"cgns"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_CGNS
;
else
if
(
!
strcmp
(
argv
[
i
],
"diff"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_DIFF
;
else
if
(
!
strcmp
(
argv
[
i
],
"med"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_MED
;
else
if
(
!
strcmp
(
argv
[
i
],
"ir3"
))
CTX
::
instance
()
->
mesh
.
fileFormat
=
FORMAT_IR3
;
else
Msg
::
Fatal
(
"Unknown mesh format"
);
else
{
int
format
=
GetFileFormatFromExtension
(
std
::
string
(
"."
)
+
argv
[
i
]);
if
(
format
<
0
){
Msg
::
Error
(
"Unknown mesh format `%s', using `msh' instead"
,
argv
[
i
]);
format
=
FORMAT_MSH
;
}
CTX
::
instance
()
->
mesh
.
fileFormat
=
format
;
}
i
++
;
}
else
...
...
This diff is collapsed.
Click to expand it.
Common/CreateFile.cpp
+
44
−
39
View file @
b8b36a96
...
...
@@ -27,9 +27,8 @@
#include
"gl2yuv.h"
#endif
int
G
uess
FileFormatFrom
FileName
(
std
::
string
fileName
)
int
G
et
FileFormatFrom
Extension
(
const
std
::
string
&
ext
)
{
std
::
string
ext
=
SplitFileName
(
fileName
)[
2
];
if
(
ext
==
".geo"
)
return
FORMAT_GEO
;
else
if
(
ext
==
".msh"
)
return
FORMAT_MSH
;
else
if
(
ext
==
".pos"
)
return
FORMAT_POS
;
...
...
@@ -73,6 +72,12 @@ int GuessFileFormatFromFileName(std::string fileName)
else
return
-
1
;
}
int
GuessFileFormatFromFileName
(
const
std
::
string
&
fileName
)
{
std
::
string
ext
=
SplitFileName
(
fileName
)[
2
];
return
GetFileFormatFromExtension
(
ext
);
}
std
::
string
GetDefaultFileName
(
int
format
)
{
std
::
vector
<
std
::
string
>
split
=
SplitFileName
(
GModel
::
current
()
->
getFileName
());
...
...
@@ -158,10 +163,10 @@ static PixelBuffer *GetCompositePixelBuffer(GLenum format, GLenum type)
}
#endif
void
CreateOutputFile
(
std
::
string
fileName
,
int
format
,
bool
redraw
)
void
CreateOutputFile
(
const
std
::
string
&
fileName
,
int
format
,
bool
redraw
)
{
if
(
fileName
.
empty
())
fileN
ame
=
GetDefaultFileName
(
format
);
std
::
string
name
=
fileName
;
if
(
name
.
empty
())
n
ame
=
GetDefaultFileName
(
format
);
int
oldFormat
=
CTX
::
instance
()
->
print
.
fileFormat
;
CTX
::
instance
()
->
print
.
fileFormat
=
format
;
...
...
@@ -169,120 +174,120 @@ void CreateOutputFile(std::string fileName, int format, bool redraw)
bool
error
=
false
;
if
(
redraw
)
Msg
::
StatusBar
(
2
,
true
,
"Writing '%s'..."
,
fileN
ame
.
c_str
());
Msg
::
StatusBar
(
2
,
true
,
"Writing '%s'..."
,
n
ame
.
c_str
());
switch
(
format
)
{
case
FORMAT_AUTO
:
CreateOutputFile
(
fileN
ame
,
GuessFileFormatFromFileName
(
fileN
ame
),
false
);
CreateOutputFile
(
n
ame
,
GuessFileFormatFromFileName
(
n
ame
),
false
);
break
;
case
FORMAT_OPT
:
PrintOptions
(
0
,
GMSH_FULLRC
,
1
,
1
,
fileN
ame
.
c_str
());
PrintOptions
(
0
,
GMSH_FULLRC
,
1
,
1
,
n
ame
.
c_str
());
break
;
case
FORMAT_MSH
:
if
(
GModel
::
current
()
->
getMeshPartitions
().
size
()
&&
CTX
::
instance
()
->
mesh
.
mshFilePartitioned
==
1
)
GModel
::
current
()
->
writePartitionedMSH
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
saveParametric
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
else
if
(
GModel
::
current
()
->
getMeshPartitions
().
size
()
&&
CTX
::
instance
()
->
mesh
.
mshFilePartitioned
==
2
)
GModel
::
current
()
->
writeMSH
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
mshFileVersion
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
mshFileVersion
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
saveParametric
,
CTX
::
instance
()
->
mesh
.
scalingFactor
,
0
,
-
1000
);
else
GModel
::
current
()
->
writeMSH
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
mshFileVersion
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
mshFileVersion
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
saveParametric
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_STL
:
GModel
::
current
()
->
writeSTL
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_VRML
:
GModel
::
current
()
->
writeVRML
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_PLY2
:
GModel
::
current
()
->
writePLY2
(
fileN
ame
);
GModel
::
current
()
->
writePLY2
(
n
ame
);
break
;
case
FORMAT_UNV
:
GModel
::
current
()
->
writeUNV
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
saveGroupsOfNodes
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
saveGroupsOfNodes
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_VTK
:
GModel
::
current
()
->
writeVTK
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
,
CTX
::
instance
()
->
bigEndian
);
break
;
case
FORMAT_MESH
:
GModel
::
current
()
->
writeMESH
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveElementTagType
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveElementTagType
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_MAIL
:
GModel
::
current
()
->
writeMAIL
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_IR3
:
GModel
::
current
()
->
writeIR3
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveElementTagType
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveElementTagType
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_BDF
:
GModel
::
current
()
->
writeBDF
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
bdfFieldFormat
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
bdfFieldFormat
,
CTX
::
instance
()
->
mesh
.
saveElementTagType
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_DIFF
:
GModel
::
current
()
->
writeDIFF
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
binary
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_INP
:
GModel
::
current
()
->
writeINP
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_P3D
:
GModel
::
current
()
->
writeP3D
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_CGNS
:
GModel
::
current
()
->
writeCGNS
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
zoneDefinition
,
CTX
::
instance
()
->
cgnsOptions
,
(
n
ame
,
CTX
::
instance
()
->
mesh
.
zoneDefinition
,
CTX
::
instance
()
->
cgnsOptions
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_MED
:
GModel
::
current
()
->
writeMED
(
fileN
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
(
n
ame
,
CTX
::
instance
()
->
mesh
.
saveAll
,
CTX
::
instance
()
->
mesh
.
scalingFactor
);
break
;
case
FORMAT_POS
:
GModel
::
current
()
->
writePOS
(
fileN
ame
,
CTX
::
instance
()
->
print
.
posElementary
,
(
n
ame
,
CTX
::
instance
()
->
print
.
posElementary
,
CTX
::
instance
()
->
print
.
posElement
,
CTX
::
instance
()
->
print
.
posGamma
,
CTX
::
instance
()
->
print
.
posEta
,
CTX
::
instance
()
->
print
.
posRho
,
CTX
::
instance
()
->
print
.
posDisto
,
CTX
::
instance
()
->
mesh
.
saveAll
,
...
...
@@ -290,16 +295,16 @@ void CreateOutputFile(std::string fileName, int format, bool redraw)
break
;
case
FORMAT_GEO
:
GModel
::
current
()
->
writeGEO
(
fileN
ame
,
CTX
::
instance
()
->
print
.
geoLabels
,
GModel
::
current
()
->
writeGEO
(
n
ame
,
CTX
::
instance
()
->
print
.
geoLabels
,
CTX
::
instance
()
->
print
.
geoOnlyPhysicals
);
break
;
case
FORMAT_BREP
:
GModel
::
current
()
->
writeOCCBREP
(
fileN
ame
);
GModel
::
current
()
->
writeOCCBREP
(
n
ame
);
break
;
case
FORMAT_STEP
:
GModel
::
current
()
->
writeOCCSTEP
(
fileN
ame
);
GModel
::
current
()
->
writeOCCSTEP
(
n
ame
);
break
;
#if defined(HAVE_FLTK)
...
...
@@ -311,9 +316,9 @@ void CreateOutputFile(std::string fileName, int format, bool redraw)
{
if
(
!
FlGui
::
available
())
break
;
FILE
*
fp
=
fopen
(
fileN
ame
.
c_str
(),
"wb"
);
FILE
*
fp
=
fopen
(
n
ame
.
c_str
(),
"wb"
);
if
(
!
fp
){
Msg
::
Error
(
"Unable to open file '%s'"
,
fileN
ame
.
c_str
());
Msg
::
Error
(
"Unable to open file '%s'"
,
n
ame
.
c_str
());
error
=
true
;
break
;
}
...
...
@@ -348,13 +353,13 @@ void CreateOutputFile(std::string fileName, int format, bool redraw)
{
if
(
!
FlGui
::
available
())
break
;
FILE
*
fp
=
fopen
(
fileN
ame
.
c_str
(),
"wb"
);
FILE
*
fp
=
fopen
(
n
ame
.
c_str
(),
"wb"
);
if
(
!
fp
){
Msg
::
Error
(
"Unable to open file '%s'"
,
fileN
ame
.
c_str
());
Msg
::
Error
(
"Unable to open file '%s'"
,
n
ame
.
c_str
());
error
=
true
;
break
;
}
std
::
string
base
=
SplitFileName
(
fileN
ame
)[
1
];
std
::
string
base
=
SplitFileName
(
n
ame
)[
1
];
GLint
width
=
FlGui
::
instance
()
->
getCurrentOpenglWindow
()
->
w
();
GLint
height
=
FlGui
::
instance
()
->
getCurrentOpenglWindow
()
->
h
();
GLint
viewport
[
4
]
=
{
0
,
0
,
width
,
height
};
...
...
@@ -419,13 +424,13 @@ void CreateOutputFile(std::string fileName, int format, bool redraw)
{
if
(
!
FlGui
::
available
())
break
;
FILE
*
fp
=
fopen
(
fileN
ame
.
c_str
(),
"w"
);
FILE
*
fp
=
fopen
(
n
ame
.
c_str
(),
"w"
);
if
(
!
fp
){
Msg
::
Error
(
"Unable to open file '%s'"
,
fileN
ame
.
c_str
());
Msg
::
Error
(
"Unable to open file '%s'"
,
n
ame
.
c_str
());
error
=
true
;
break
;
}
std
::
string
base
=
SplitFileName
(
fileN
ame
)[
1
];
std
::
string
base
=
SplitFileName
(
n
ame
)[
1
];
GLint
width
=
FlGui
::
instance
()
->
getCurrentOpenglWindow
()
->
w
();
GLint
height
=
FlGui
::
instance
()
->
getCurrentOpenglWindow
()
->
h
();
GLint
viewport
[
4
]
=
{
0
,
0
,
width
,
height
};
...
...
@@ -487,7 +492,7 @@ void CreateOutputFile(std::string fileName, int format, bool redraw)
"PSEARCH_ALG EXHAUSTIVE
\n
BSEARCH_ALG CROSS2
\n
"
"IQSCALE 1
\n
PQSCALE 1
\n
BQSCALE 25
\n
REFERENCE_FRAME DECODED
\n
"
"OUTPUT %s
\n
INPUT_CONVERT *
\n
INPUT_DIR %s
\n
INPUT
\n
"
,
pattern
.
c_str
(),
repeat
,
fileN
ame
.
c_str
(),
pattern
.
c_str
(),
repeat
,
n
ame
.
c_str
(),
CTX
::
instance
()
->
homeDir
.
c_str
());
for
(
unsigned
int
i
=
0
;
i
<
frames
.
size
();
i
++
){
fprintf
(
fp
,
"%s"
,
frames
[
i
].
c_str
());
...
...
@@ -526,7 +531,7 @@ void CreateOutputFile(std::string fileName, int format, bool redraw)
CTX
::
instance
()
->
printing
=
0
;
if
(
redraw
&&
!
error
)
Msg
::
StatusBar
(
2
,
true
,
"Done writing '%s'"
,
fileN
ame
.
c_str
());
Msg
::
StatusBar
(
2
,
true
,
"Done writing '%s'"
,
n
ame
.
c_str
());
#if defined(HAVE_OPENGL)
if
(
redraw
)
drawContext
::
global
()
->
draw
();
...
...
This diff is collapsed.
Click to expand it.
Common/CreateFile.h
+
3
−
2
View file @
b8b36a96
...
...
@@ -8,8 +8,9 @@
#include
<string>
int
GuessFileFormatFromFileName
(
std
::
string
fileName
);
int
GetFileFormatFromExtension
(
const
std
::
string
&
fileName
);
int
GuessFileFormatFromFileName
(
const
std
::
string
&
fileName
);
std
::
string
GetDefaultFileName
(
int
format
);
void
CreateOutputFile
(
std
::
string
fileName
,
int
format
,
bool
redraw
=
true
);
void
CreateOutputFile
(
const
std
::
string
&
fileName
,
int
format
,
bool
redraw
=
true
);
#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