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
b99aa61e
Commit
b99aa61e
authored
10 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
merge patch from tocket #260 to handle line continuations
parent
c1a8ee36
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Geo/GModelIO_BDF.cpp
+80
-21
80 additions, 21 deletions
Geo/GModelIO_BDF.cpp
with
80 additions
and
21 deletions
Geo/GModelIO_BDF.cpp
+
80
−
21
View file @
b99aa61e
...
...
@@ -103,7 +103,7 @@ static bool emptyFieldBDF(char *field, int length)
static
void
readLineBDF
(
char
*
buffer
,
int
format
,
std
::
vector
<
char
*>
&
fields
)
{
int
cmax
=
(
format
==
2
)
?
16
:
8
;
// max char per (center) field
int
nmax
=
(
format
==
2
)
?
4
:
8
;
// max num of (center) fields per line
int
nmax
=
(
format
==
2
)
?
4
:
8
;
// max num of (center) fields per line
if
(
format
==
0
){
// free fields
for
(
unsigned
int
i
=
0
;
i
<
strlen
(
buffer
);
i
++
){
...
...
@@ -122,28 +122,86 @@ static int readElementBDF(FILE *fp, char *buffer, int keySize, int numVertices,
int
&
num
,
int
&
region
,
std
::
vector
<
MVertex
*>
&
vertices
,
std
::
map
<
int
,
MVertex
*>
&
vertexMap
)
{
char
buffer2
[
256
],
buffer3
[
256
];
fpos_t
position
;
char
ch
,
buffer2
[
256
],
buffer3
[
256
];
std
::
vector
<
char
*>
fields
;
int
nfields
=
0
,
sizediff
,
j
,
c
,
cont
;
int
format
=
getFormatBDF
(
buffer
,
keySize
);
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
buffer2
);
i
++
)
buffer2
[
i
]
=
buffer3
[
i
]
=
'\0'
;
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
buffer2
);
i
++
)
buffer2
[
i
]
=
buffer3
[
i
]
=
'\0'
;
readLineBDF
(
buffer
,
format
,
fields
);
if
(((
int
)
fields
.
size
()
-
2
<
abs
(
numVertices
))
||
(
numVertices
<
0
&&
(
fields
.
size
()
==
9
))){
if
(
fields
.
size
()
==
9
)
fields
.
pop_back
();
if
(
!
fgets
(
buffer2
,
sizeof
(
buffer2
),
fp
))
return
0
;
readLineBDF
(
buffer2
,
format
,
fields
);
}
if
(((
int
)
fields
.
size
()
-
2
<
abs
(
numVertices
))
||
(
numVertices
<
0
&&
(
fields
.
size
()
==
17
))){
if
(
fields
.
size
()
==
17
)
fields
.
pop_back
();
if
(
!
fgets
(
buffer3
,
sizeof
(
buffer3
),
fp
))
return
0
;
readLineBDF
(
buffer3
,
format
,
fields
);
sizediff
=
fields
.
size
();
cont
=
0
;
while
(
!
feof
(
fp
))
{
if
(
format
==
0
){
// free field
// bail out if fixed number of vertices are found
if
(
numVertices
>
0
&&
(
int
)
fields
.
size
()
-
2
==
numVertices
)
break
;
// read next line to check for automatic continuation
fgetpos
(
fp
,
&
position
);
j
=
0
;
while
(
j
<
8
)
{
ch
=
(
char
)
fgetc
(
fp
);
if
(
feof
(
fp
)
||
ch
!=
' '
)
break
;
j
++
;
}
fsetpos
(
fp
,
&
position
);
if
(
j
!=
7
)
break
;
}
else
if
(
format
==
1
){
// small field
if
(
sizediff
==
9
){
// normal continuation
fields
.
pop_back
();
}
else
if
(
sizediff
==
8
){
// read next line to check for automatic continuation
c
=
fgetc
(
fp
);
ch
=
(
char
)
c
;
if
(
feof
(
fp
))
break
;
ungetc
(
c
,
fp
);
if
(
ch
!=
'*'
)
break
;
}
else
{
break
;
}
}
else
if
(
format
==
2
){
// long field
if
(
sizediff
==
5
){
// normal continuation
fields
.
pop_back
();
}
else
if
(
sizediff
==
4
){
// read next line to check for automatic continuation
c
=
getc
(
fp
);
ch
=
(
char
)
c
;
if
(
feof
(
fp
))
break
;
ungetc
(
c
,
fp
);
if
(
ch
!=
'*'
)
break
;
}
else
{
break
;
}
}
// get continuation line
if
(
cont
==
0
)
{
if
(
!
fgets
(
buffer2
,
sizeof
(
buffer2
),
fp
))
break
;
nfields
=
fields
.
size
();
readLineBDF
(
buffer2
,
format
,
fields
);
sizediff
=
fields
.
size
()
-
nfields
;
cont
++
;
}
else
{
if
(
!
fgets
(
buffer3
,
sizeof
(
buffer3
),
fp
))
break
;
readLineBDF
(
buffer3
,
format
,
fields
);
break
;
}
}
// negative 'numVertices' gives the minimum required number of vertices
if
((
int
)
fields
.
size
()
-
2
<
abs
(
numVertices
)){
Msg
::
Error
(
"Wrong number of vertices %d for element"
,
fields
.
size
()
-
2
);
...
...
@@ -156,9 +214,10 @@ static int readElementBDF(FILE *fp, char *buffer, int keySize, int numVertices,
strncpy
(
tmp
,
fields
[
0
],
cmax
);
num
=
atoi
(
tmp
);
strncpy
(
tmp
,
fields
[
1
],
cmax
);
region
=
atoi
(
tmp
);
for
(
unsigned
int
i
=
2
;
i
<
fields
.
size
();
i
++
){
strncpy
(
tmp
,
fields
[
i
],
cmax
);
n
[
i
-
2
]
=
atoi
(
tmp
);
strncpy
(
tmp
,
fields
[
i
],
cmax
);
n
[
i
-
2
]
=
atoi
(
tmp
);
}
// ignore the extra fields when we know how many vertices we need
int
numCheck
=
(
numVertices
>
0
)
?
numVertices
:
fields
.
size
()
-
2
;
...
...
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