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
45d4cb58
Commit
45d4cb58
authored
Sep 23, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned code of data2brdf & Export of L2 and Linf norm when fitting
parent
1e32f793
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
164 deletions
+100
-164
sources/core/args.h
sources/core/args.h
+5
-0
sources/core/function.cpp
sources/core/function.cpp
+4
-1
sources/softs/data2brdf/main.cpp
sources/softs/data2brdf/main.cpp
+91
-163
No files found.
sources/core/args.h
View file @
45d4cb58
...
...
@@ -130,6 +130,11 @@ class arguments
//std::cerr << "Underfined request to key : \"" << key << "\"" << std::endl ;
return
std
::
string
()
;
}
}
//! \brief update the value \a val stored under key \a key
bool
update
(
const
std
::
string
&
key
,
const
std
::
string
&
val
)
{
_map
[
key
]
=
val
;
}
//! \brief acces to the string value associated with the parameter
//! \a key.
...
...
sources/core/function.cpp
View file @
45d4cb58
...
...
@@ -85,7 +85,10 @@ void function::save_header(std::ostream& out, const arguments& args) const
out
<<
"#CMD "
<<
args
.
get_cmd
()
<<
std
::
endl
;
out
<<
"#DIM "
<<
_nX
<<
" "
<<
_nY
<<
std
::
endl
;
out
<<
"#PARAM_IN "
<<
params
::
get_name
(
input_parametrization
())
<<
std
::
endl
;
//out << "#PARAM_OUT " << params::get_name(output_parametrization()) << std::endl;
//out << "#PARAM_OUT " << params::get_name(output_parametrization()) << std::endl;*
if
(
args
.
is_defined
(
"export-append"
))
{
out
<<
args
[
"export-append"
]
<<
std
::
endl
;
}
out
<<
"#ALTA HEADER END"
<<
std
::
endl
;
out
<<
std
::
endl
;
}
...
...
sources/softs/data2brdf/main.cpp
View file @
45d4cb58
...
...
@@ -20,167 +20,95 @@
int
main
(
int
argc
,
char
**
argv
)
{
QCoreApplication
app
(
argc
,
argv
);
arguments
args
(
argc
,
argv
)
;
plugins_manager
manager
(
args
)
;
fitter
*
fit
=
manager
.
get_fitter
(
args
[
"fitter"
])
;
if
(
fit
==
NULL
)
{
fit
=
manager
.
get_fitter
()
;
}
if
(
args
.
is_defined
(
"available_params"
))
{
params
::
print_input_params
();
return
0
;
}
if
(
!
args
.
is_defined
(
"input"
))
{
std
::
cerr
<<
"<<ERROR>> the input filename is not defined"
<<
std
::
endl
;
return
1
;
}
if
(
!
args
.
is_defined
(
"output"
))
{
std
::
cerr
<<
"<<ERROR>> the output filename is not defined"
<<
std
::
endl
;
return
1
;
}
// if(fitters.size() > 0 && datas.size() > 0 && functions.size() > 0)
if
(
fit
!=
NULL
)
{
fit
->
set_parameters
(
args
)
;
function
*
f
=
plugins_manager
::
get_function
(
args
);
data
*
d
=
plugins_manager
::
get_data
(
args
[
"data"
]);
d
->
load
(
args
[
"input"
],
args
);
if
(
f
==
NULL
||
d
==
NULL
)
{
std
::
cerr
<<
"<<ERROR>> no function or data object correctly defined"
<<
std
::
endl
;
return
1
;
}
// Check the compatibility between the data and the function
plugins_manager
::
check_compatibility
(
d
,
f
,
args
);
// Start a timer
QTime
time
;
time
.
start
()
;
// Fit the data
bool
is_fitted
=
fit
->
fit_data
(
d
,
f
,
args
)
;
// Get the fitting duration
int
msec
=
time
.
elapsed
()
;
int
sec
=
(
msec
/
1000
)
%
60
;
int
min
=
(
msec
/
60000
)
%
60
;
int
hour
=
(
msec
/
3600000
)
;
// Display the result
if
(
is_fitted
)
{
std
::
cout
<<
"<<INFO>> total time: "
<<
hour
<<
"h "
<<
min
<<
"m "
<<
sec
<<
"s"
<<
std
::
endl
;
/*
vec min, max ;
min.assign(2, args.get_float("min", 0.0f)) ;
max.assign(2, args.get_float("max", 1.5f)) ;
int nb_samples = args.get_int("nb_samples", 100) ;
double dt = (max[0]-min[0]) / nb_samples ;
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
for(double x=min[0]; x<=max[0]; x+=dt)
{
vec vx ; for(int i=0;i<2; ++i) { vx.push_back(x) ; }
file << x << "\t" << f->value(vx)[0] << std::endl ;
std::cout << x << "\t" << f->value(vx)[0] << std::endl ;
}
/*/
double
L2
=
f
->
L2_distance
(
d
);
double
Linf
=
f
->
Linf_distance
(
d
);
std
::
cout
<<
"<<INFO>> L2 distance to data = "
<<
L2
<<
std
::
endl
;
std
::
cout
<<
"<<INFO>> Linf distance to data = "
<<
Linf
<<
std
::
endl
;
f
->
save
(
args
[
"output"
],
args
)
;
#ifdef OLD // use brdf2gnuplot
size_t
n
=
args
[
"output"
].
find
(
'.'
)
;
std
::
string
gnuplot_filename
=
args
[
"output"
].
substr
(
0
,
n
);
gnuplot_filename
.
append
(
".gnuplot"
)
;
/*
f->save_gnuplot(gnuplot_filename, d, args);
/*/
std
::
ofstream
file
(
gnuplot_filename
.
c_str
(),
std
::
ios_base
::
trunc
);
for
(
int
i
=
0
;
i
<
d
->
size
();
++
i
)
{
vec
v
=
d
->
get
(
i
)
;
// vec y1(d->dimY()) ;
// for(int k=0; k<d->dimY(); ++k) { y1[k] = v[d->dimX() + k] ; }
vec
y2
=
f
->
value
(
v
)
;
for
(
int
u
=
0
;
u
<
d
->
dimX
();
++
u
)
file
<<
v
[
u
]
<<
"
\t
"
;
for
(
int
u
=
0
;
u
<
d
->
dimY
();
++
u
)
file
<<
y2
[
u
]
<<
"
\t
"
;
file
<<
std
::
endl
;
}
file
.
close
();
//*/
std
::
string
error_filename
=
args
[
"output"
].
substr
(
0
,
n
);
error_filename
.
append
(
".errorplot"
)
;
file
.
open
(
error_filename
.
c_str
(),
std
::
ios_base
::
trunc
);
for
(
int
i
=
0
;
i
<
d
->
size
();
++
i
)
{
vec
v
=
d
->
get
(
i
)
;
vec
y1
(
d
->
dimY
())
;
for
(
int
k
=
0
;
k
<
d
->
dimY
();
++
k
)
{
y1
[
k
]
=
v
[
d
->
dimX
()
+
k
]
;
}
vec
y2
=
f
->
value
(
v
)
;
for
(
int
u
=
0
;
u
<
d
->
dimX
();
++
u
)
file
<<
v
[
u
]
<<
"
\t
"
;
for
(
int
u
=
0
;
u
<
d
->
dimY
();
++
u
)
file
<<
y2
[
u
]
-
y1
[
u
]
<<
"
\t
"
;
file
<<
std
::
endl
;
}
file
.
close
();
std
::
string
linerror_filename
=
args
[
"output"
].
substr
(
0
,
n
);
linerror_filename
.
append
(
".linearerrorplot"
)
;
file
.
open
(
linerror_filename
.
c_str
(),
std
::
ios_base
::
trunc
);
for
(
int
i
=
0
;
i
<
d
->
size
();
++
i
)
{
vec
v
=
d
->
get
(
i
)
;
vec
y1
(
d
->
dimY
())
;
for
(
int
k
=
0
;
k
<
d
->
dimY
();
++
k
)
{
y1
[
k
]
=
0.5
*
(
v
[
d
->
dimX
()
+
k
]
+
v
[
d
->
dimX
()
+
d
->
dimY
()
+
k
]);
}
vec
y2
=
f
->
value
(
v
)
;
file
<<
i
<<
"
\t
"
;
for
(
int
u
=
0
;
u
<
d
->
dimY
();
++
u
)
file
<<
y2
[
u
]
-
y1
[
u
]
<<
"
\t
"
;
file
<<
std
::
endl
;
}
file
.
close
();
//*/
#endif
return
0
;
}
else
{
std
::
cout
<<
"<<ERROR>> unable to fit the data"
<<
std
::
endl
;
return
1
;
}
}
else
{
std
::
cout
<<
"<<ERROR>> no fitter loaded, please check your command line arguments"
<<
std
::
endl
;
}
return
0
;
arguments
args
(
argc
,
argv
)
;
plugins_manager
manager
(
args
)
;
fitter
*
fit
=
manager
.
get_fitter
(
args
[
"fitter"
])
;
if
(
fit
==
NULL
)
{
fit
=
manager
.
get_fitter
()
;
}
if
(
args
.
is_defined
(
"available_params"
))
{
params
::
print_input_params
();
return
0
;
}
if
(
!
args
.
is_defined
(
"input"
))
{
std
::
cerr
<<
"<<ERROR>> the input filename is not defined"
<<
std
::
endl
;
return
1
;
}
if
(
!
args
.
is_defined
(
"output"
))
{
std
::
cerr
<<
"<<ERROR>> the output filename is not defined"
<<
std
::
endl
;
return
1
;
}
// if(fitters.size() > 0 && datas.size() > 0 && functions.size() > 0)
if
(
fit
!=
NULL
)
{
fit
->
set_parameters
(
args
)
;
function
*
f
=
plugins_manager
::
get_function
(
args
);
data
*
d
=
plugins_manager
::
get_data
(
args
[
"data"
]);
d
->
load
(
args
[
"input"
],
args
);
if
(
f
==
NULL
||
d
==
NULL
)
{
std
::
cerr
<<
"<<ERROR>> no function or data object correctly defined"
<<
std
::
endl
;
return
1
;
}
// Check the compatibility between the data and the function
plugins_manager
::
check_compatibility
(
d
,
f
,
args
);
// Start a timer
QTime
time
;
time
.
start
()
;
// Fit the data
bool
is_fitted
=
fit
->
fit_data
(
d
,
f
,
args
)
;
// Get the fitting duration
int
msec
=
time
.
elapsed
()
;
int
sec
=
(
msec
/
1000
)
%
60
;
int
min
=
(
msec
/
60000
)
%
60
;
int
hour
=
(
msec
/
3600000
)
;
// Display the result
if
(
is_fitted
)
{
std
::
cout
<<
"<<INFO>> total time: "
<<
hour
<<
"h "
<<
min
<<
"m "
<<
sec
<<
"s"
<<
std
::
endl
;
double
L2
=
f
->
L2_distance
(
d
);
double
Linf
=
f
->
Linf_distance
(
d
);
std
::
cout
<<
"<<INFO>> L2 distance to data = "
<<
L2
<<
std
::
endl
;
std
::
cout
<<
"<<INFO>> Linf distance to data = "
<<
Linf
<<
std
::
endl
;
std
::
stringstream
append
;
// Append informations to the export
if
(
args
.
is_defined
(
"export-append"
))
{
append
<<
args
[
"export-append"
];
}
append
<<
"#L2 "
<<
L2
<<
std
::
endl
;
append
<<
"#LINF "
<<
Linf
;
args
.
update
(
"export-append"
,
append
.
str
());
f
->
save
(
args
[
"output"
],
args
)
;
return
0
;
}
else
{
std
::
cout
<<
"<<ERROR>> unable to fit the data"
<<
std
::
endl
;
return
1
;
}
}
else
{
std
::
cout
<<
"<<ERROR>> no fitter loaded, please check your command line arguments"
<<
std
::
endl
;
}
return
0
;
}
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