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
7e9555ed
Commit
7e9555ed
authored
Mar 23, 2017
by
Ludovic Courtès
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data2data: Add support for "--out-data alta-binary".
parent
cfff4831
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
4 deletions
+103
-4
sources/softs/data2data/main.cpp
sources/softs/data2data/main.cpp
+28
-4
sources/tests/SConscript
sources/tests/SConscript
+75
-0
No files found.
sources/softs/data2data/main.cpp
View file @
7e9555ed
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2014, 2017 CNRS
Copyright (C) 2013, 2014, 2015, 2016 Inria
Copyright (C) 2013, 2014, 2015, 2016
, 2017
Inria
This file is part of ALTA.
...
...
@@ -92,6 +92,7 @@
*/
#include <core/args.h>
#include <core/data.h>
#include <core/data_storage.h>
#include <core/params.h>
#include <core/function.h>
#include <core/fitter.h>
...
...
@@ -150,7 +151,8 @@ int main(int argc, char** argv)
std
::
cout
<<
"Optional arguments:"
<<
std
::
endl
;
std
::
cout
<<
" --out-data [filename] Name of the plugin used to save the outputed data file"
<<
std
::
endl
;
std
::
cout
<<
" If none is provided, data2data will export in ALTA"
<<
std
::
endl
;
std
::
cout
<<
" by default."
<<
std
::
endl
;
std
::
cout
<<
" by default. The name
\"
alta-binary
\"
specifies ALTA's"
<<
std
::
endl
;
std
::
cout
<<
" native binary format."
<<
std
::
endl
;
std
::
cout
<<
" --in-data [filename] Name of the plugin used to load the input data file"
<<
std
::
endl
;
std
::
cout
<<
" If none is provided, data2data will import in ALTA"
<<
std
::
endl
;
std
::
cout
<<
" by default."
<<
std
::
endl
;
...
...
@@ -210,7 +212,13 @@ int main(int argc, char** argv)
}
ptr
<
data
>
d_out
=
plugins_manager
::
get_data
(
args
[
"out-data"
],
// "alta-binary" denotes an output format but not a class, so we need to
// special-case it.
const
std
::
string
data_class
=
args
[
"out-data"
]
==
"alta-binary"
?
"vertical_segment"
:
args
[
"out-data"
];
ptr
<
data
>
d_out
=
plugins_manager
::
get_data
(
data_class
,
d_in
->
size
(),
compute_parameters
(
*
d_in
,
args
),
args
)
;
...
...
@@ -362,6 +370,22 @@ int main(int argc, char** argv)
}
}
d_out
->
save
(
args
[
"output"
]);
// Special-case ALTA's binary output format. TODO: In the future, 'save'
// should no longer be a method and we'd have an output format lookup
// function in plugin_manager.
if
(
args
[
"out-data"
]
==
"alta-binary"
)
{
try
{
std
::
ofstream
out
;
out
.
exceptions
(
std
::
ios_base
::
failbit
);
out
.
open
(
args
[
"output"
]);
save_data_as_binary
(
out
,
*
d_out
);
}
CATCH_FILE_IO_ERROR
(
args
[
"output"
]);
}
else
d_out
->
save
(
args
[
"output"
]);
return
EXIT_SUCCESS
;
}
sources/tests/SConscript
View file @
7e9555ed
import
os
,
sys
from
subprocess
import
call
from
os.path
import
basename
,
splitext
import
filecmp
import
obtain
...
...
@@ -297,6 +298,80 @@ env.Depends(cmd01,cmd00)
AlwaysBuild
(
cmd01
)
env
.
Alias
(
'tests'
,
cmd01
)
# Convert from ALTA's text format to ALTA's binary format and back.
cmd02
=
make_command_test
(
'data2data'
,
[
'--input'
,
test_byproduct
(
'gold-metallic-paint.alta'
),
'--output'
,
test_byproduct
(
'gold-metallic-paint-all-values.alta-bin'
),
'--out-data'
,
'alta-binary'
,
'--all-values'
],
'alta-to-alta-binary'
)
env
.
Depends
(
cmd02
,
cmd00
)
cmd03
=
make_command_test
(
'data2data'
,
[
'--input'
,
test_byproduct
(
'gold-metallic-paint-all-values.alta-bin'
),
'--output'
,
test_byproduct
(
'gold-metallic-paint2.alta'
),
'--all-values'
],
'alta-binary-to-alta'
)
env
.
Depends
(
cmd03
,
cmd02
)
def
check_that_files_are_identical
(
file1
,
file2
):
"""Return a function that checks whether FILE1 and FILE2 are identical."""
def
compare_files
(
env
,
target
,
source
):
identical
=
filecmp
.
cmp
(
file1
,
file2
)
with
open
(
str
(
target
[
0
]),
'w'
)
as
log
:
if
identical
:
log
.
write
(
"PASS: '"
+
file1
+
"' and '"
+
file2
+
"' are identical
\n
"
)
else
:
log
.
write
(
"FAIL: '"
+
file1
+
"' and '"
+
file2
+
"' differ
\n
"
)
return
1
return
compare_files
cmd04
=
env
.
Command
(
'data2data-alta-to-binary-to-alta.log'
,
test_byproduct
(
'gold-metallic-paint2.alta'
),
check_that_files_are_identical
(
test_byproduct
(
'gold-metallic-paint.alta'
),
test_byproduct
(
'gold-metallic-paint2.alta'
)))
env
.
Depends
(
cmd04
,
cmd00
)
env
.
Depends
(
cmd04
,
cmd03
)
env
.
Alias
(
'tests'
,
cmd04
)
# Convert from MERL to ALTA's binary format.
cmd05
=
make_command_test
(
'data2data'
,
[
'--param RUSIN_TH_TD_PD'
,
'--input'
,
test_byproduct
(
'gold-metallic-paint.binary'
),
'--in-data'
,
'data_merl'
,
'--out-data'
,
'alta-binary'
,
'--output'
,
test_byproduct
(
'gold-metallic-paint2.alta-bin'
),
'--all-values'
],
'merl-to-alta-all-values-binary'
)
env
.
Depends
(
cmd05
,
downloadGold
)
env
.
Alias
(
'tests'
,
cmd05
)
cmd06
=
make_command_test
(
'data2data'
,
[
'--input'
,
test_byproduct
(
'gold-metallic-paint2.alta-bin'
),
'--output'
,
test_byproduct
(
'gold-metallic-paint3.alta'
),
'--all-values'
],
'alta-binary-to-alta2'
)
env
.
Depends
(
cmd06
,
cmd05
)
env
.
Alias
(
'tests'
,
cmd06
)
cmd07
=
env
.
Command
(
'data2data-merl-to-alta-binary-to-alta.log'
,
test_byproduct
(
'gold-metallic-paint3.alta'
),
check_that_files_are_identical
(
test_byproduct
(
'gold-metallic-paint.alta'
),
test_byproduct
(
'gold-metallic-paint3.alta'
)))
env
.
Depends
(
cmd07
,
cmd00
)
env
.
Depends
(
cmd07
,
cmd06
)
env
.
Alias
(
'tests'
,
cmd07
)
# ADD C++ Test if the two previous tests have passed and if Catch submodule is available
if
have_catch
:
CXX_CATCH_TESTS
=
[
'core/conversion-catch-1.cpp'
]
...
...
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