Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alta
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alta
alta
Commits
53118958
Commit
53118958
authored
Apr 23, 2015
by
Ludovic Courtès
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data_storage: Separate out ALTA header parsing.
parent
5219ee9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
55 deletions
+86
-55
sources/core/data_storage.cpp
sources/core/data_storage.cpp
+86
-55
No files found.
sources/core/data_storage.cpp
View file @
53118958
...
...
@@ -19,6 +19,48 @@
# include <endian.h>
#endif
// Key/value association list.
typedef
std
::
map
<
std
::
string
,
std
::
string
>
alist
;
// Read the ALTA header on INPUT and fill in RESULT as a list of key/value
// pairs.
static
void
read_header
(
std
::
istream
&
input
,
alist
&
result
)
{
while
(
input
.
good
())
{
if
(
input
.
peek
()
==
'#'
)
{
input
.
get
();
// consume the hash sign
std
::
string
line
;
std
::
getline
(
input
,
line
);
std
::
stringstream
linestream
(
line
);
// Lines starting with '# ' are real comments and we ignore them.
// Others are key/value associations that we want to use.
if
(
linestream
.
peek
()
!=
' '
)
{
std
::
string
key
,
rest
;
linestream
>>
key
;
if
(
!
key
.
empty
())
{
getline
(
linestream
,
rest
);
if
(
key
==
"ALTA"
&&
rest
==
"END HEADER"
)
{
break
;
}
else
{
result
[
key
]
=
rest
;
}
}
}
}
// The first non-comment line terminates the header.
else
break
;
}
}
void
vertical_segment
::
load_data_from_text
(
std
::
istream
&
input
,
vertical_segment
&
result
,
const
arguments
&
args
)
...
...
@@ -28,72 +70,61 @@ void vertical_segment::load_data_from_text(std::istream& input,
result
.
_nX
=
0
;
result
.
_nY
=
0
;
std
::
vector
<
int
>
vs
;
int
current_vs
=
0
;
while
(
input
.
good
())
{
std
::
string
line
;
std
::
getline
(
input
,
line
)
;
std
::
stringstream
linestream
(
line
)
;
// Discard incorrect lines
if
(
linestream
.
peek
()
==
'#'
)
{
linestream
.
ignore
(
1
)
;
std
::
string
comment
;
linestream
>>
comment
;
alist
header
;
read_header
(
input
,
header
)
;
if
(
comment
==
std
::
string
(
"DIM"
))
{
linestream
>>
result
.
_nX
>>
result
.
_nY
;
{
std
::
stringstream
dim
(
header
[
"DIM"
]);
dim
>>
result
.
_nX
>>
result
.
_nY
;
}
vs
.
reserve
(
result
.
dimY
())
;
for
(
int
k
=
0
;
k
<
result
.
dimY
();
++
k
)
{
vs
[
k
]
=
0
;
}
vs
.
reserve
(
result
.
dimY
())
;
for
(
int
k
=
0
;
k
<
result
.
dimY
();
++
k
)
{
vs
[
k
]
=
0
;
}
result
.
_min
.
resize
(
result
.
dimX
())
;
result
.
_max
.
resize
(
result
.
dimX
())
;
result
.
_min
.
resize
(
result
.
dimX
())
;
result
.
_max
.
resize
(
result
.
dimX
())
;
min
=
args
.
get_vec
(
"min"
,
result
.
_nX
,
-
std
::
numeric_limits
<
float
>::
max
())
;
max
=
args
.
get_vec
(
"max"
,
result
.
_nX
,
std
::
numeric_limits
<
float
>::
max
())
;
min
=
args
.
get_vec
(
"min"
,
result
.
_nX
,
-
std
::
numeric_limits
<
float
>::
max
())
;
max
=
args
.
get_vec
(
"max"
,
result
.
_nX
,
std
::
numeric_limits
<
float
>::
max
())
;
#ifdef DEBUG
std
::
cout
<<
"<<DEBUG>> data will remove outside of "
<<
min
<<
" -> "
<<
max
<<
" x-interval"
<<
std
::
endl
;
std
::
cout
<<
"<<DEBUG>> data will remove outside of "
<<
min
<<
" -> "
<<
max
<<
" x-interval"
<<
std
::
endl
;
#endif
ymin
=
args
.
get_vec
(
"ymin"
,
result
.
_nY
,
-
std
::
numeric_limits
<
float
>::
max
())
;
ymax
=
args
.
get_vec
(
"ymax"
,
result
.
_nY
,
std
::
numeric_limits
<
float
>::
max
())
;
ymin
=
args
.
get_vec
(
"ymin"
,
result
.
_nY
,
-
std
::
numeric_limits
<
float
>::
max
())
;
ymax
=
args
.
get_vec
(
"ymax"
,
result
.
_nY
,
std
::
numeric_limits
<
float
>::
max
())
;
#ifdef DEBUG
std
::
cout
<<
"<<DEBUG>> data will remove outside of "
<<
ymin
<<
" -> "
<<
ymax
<<
" y-interval"
<<
std
::
endl
;
std
::
cout
<<
"<<DEBUG>> data will remove outside of "
<<
ymin
<<
" -> "
<<
ymax
<<
" y-interval"
<<
std
::
endl
;
#endif
for
(
int
k
=
0
;
k
<
result
.
dimX
();
++
k
)
{
result
.
_min
[
k
]
=
std
::
numeric_limits
<
double
>::
max
()
;
result
.
_max
[
k
]
=
-
std
::
numeric_limits
<
double
>::
max
()
;
}
}
else
if
(
comment
==
std
::
string
(
"VS"
))
{
int
t
;
linestream
>>
t
;
vs
[
current_vs
]
=
t
;
++
current_vs
;
}
else
if
(
comment
==
std
::
string
(
"PARAM_IN"
))
{
std
::
string
param
;
linestream
>>
param
;
result
.
_in_param
=
params
::
parse_input
(
param
);
}
else
if
(
comment
==
std
::
string
(
"PARAM_OUT"
))
{
std
::
string
param
;
linestream
>>
param
;
result
.
_out_param
=
params
::
parse_output
(
param
);
}
continue
;
}
else
if
(
line
.
empty
())
for
(
int
k
=
0
;
k
<
result
.
dimX
();
++
k
)
{
result
.
_min
[
k
]
=
std
::
numeric_limits
<
double
>::
max
()
;
result
.
_max
[
k
]
=
-
std
::
numeric_limits
<
double
>::
max
()
;
}
result
.
_in_param
=
params
::
parse_input
(
header
[
"PARAM_IN"
]);
result
.
_out_param
=
params
::
parse_output
(
header
[
"PARAM_OUT"
]);
{
int
number
;
std
::
stringstream
line
(
header
[
"VS"
]);
line
>>
number
;
vs
[
current_vs
]
=
number
;
++
current_vs
;
}
// Now read the body.
while
(
input
.
good
())
{
std
::
string
line
;
std
::
getline
(
input
,
line
)
;
std
::
stringstream
linestream
(
line
)
;
// Discard comments and empty lines.
if
(
line
.
empty
()
||
linestream
.
peek
()
==
'#'
)
{
continue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment