Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
alta
alta
Commits
4b89bdbf
Commit
4b89bdbf
authored
Jul 12, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding test suite for Lafortune
parent
7bef7190
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
237 additions
and
140 deletions
+237
-140
sources/core/params.cpp
sources/core/params.cpp
+1
-1
sources/core/params.h
sources/core/params.h
+3
-3
sources/plugins/nonlinear_function_lafortune/function.cpp
sources/plugins/nonlinear_function_lafortune/function.cpp
+0
-4
sources/scripts/unitary_lafortune.sh
sources/scripts/unitary_lafortune.sh
+42
-0
sources/softs/brdf2gnuplot/main.cpp
sources/softs/brdf2gnuplot/main.cpp
+20
-20
sources/softs/data2diff/main.cpp
sources/softs/data2diff/main.cpp
+2
-2
sources/softs/generate_data/main.cpp
sources/softs/generate_data/main.cpp
+113
-110
sources/softs/softs.pro
sources/softs/softs.pro
+1
-0
sources/softs/tests/main.cpp
sources/softs/tests/main.cpp
+43
-0
sources/softs/tests/tests.pro
sources/softs/tests/tests.pro
+12
-0
No files found.
sources/core/params.cpp
View file @
4b89bdbf
...
...
@@ -82,7 +82,7 @@ void params::to_cartesian(const double* invec, params::input intype,
break
;
case
params
::
RUSIN_TH_TD
:
half_to_cartesian
(
invec
[
0
],
0.0
,
invec
[
1
],
0.
5
*
M_PI
,
outvec
);
half_to_cartesian
(
invec
[
0
],
0.0
,
invec
[
1
],
0.
0
,
outvec
);
break
;
// 3D Parametrization
...
...
sources/core/params.h
View file @
4b89bdbf
...
...
@@ -167,8 +167,8 @@ class params
//! \todo investigate here, the rotation along N should be
//1 of phi_h not theta_h !
rotate_normal
(
out
,
phi_h
);
rotate_binormal
(
out
,
theta_h
);
rotate_normal
(
out
,
phi_h
);
// Compute the out vector from the in vector and the half
// vector.
...
...
@@ -211,8 +211,8 @@ class params
const
double
cost
=
cos
(
theta
);
const
double
sint
=
sin
(
theta
);
vec
[
0
]
=
cost
*
vec
[
0
]
-
sint
*
vec
[
2
];
vec
[
2
]
=
sint
*
vec
[
0
]
+
cost
*
vec
[
2
];
vec
[
1
]
=
cost
*
vec
[
1
]
-
sint
*
vec
[
2
];
vec
[
2
]
=
sint
*
vec
[
1
]
+
cost
*
vec
[
2
];
}
static
void
print_input_params
();
...
...
sources/plugins/nonlinear_function_lafortune/function.cpp
View file @
4b89bdbf
...
...
@@ -55,8 +55,6 @@ vec lafortune_function::value(const vec& x) const
const
double
d
=
Cx
*
dx
+
Cy
*
dy
+
Cz
*
dz
;
if
(
d
>
0.0
)
res
[
i
]
+=
pow
(
d
,
N
);
else
res
[
i
]
+=
0.0
;
}
}
...
...
@@ -102,8 +100,6 @@ vec lafortune_function::value(const vec& x, const vec& p) const
const
double
d
=
Cx
*
dx
+
Cy
*
dy
+
Cz
*
dz
;
if
(
d
>
0.0
)
res
[
i
]
+=
pow
(
d
,
N
);
else
res
[
i
]
+=
0.0
;
}
}
...
...
sources/scripts/unitary_lafortune.sh
0 → 100755
View file @
4b89bdbf
#! /bin/sh
## Params
function
=
"--func ./build/libnonlinear_function_lafortune.so"
fitter
=
"--fitter ./build/libnonlinear_levenberg_eigen.so"
test_generated
=
1
test_alta
=
0
mkdir
tests
## Test with generated data
##
if
[
$test_generated
-eq
1
]
;
then
min_test
=
7
;
max_test
=
8
for
i
in
`
seq
$min_test
$max_test
`
do
./build/generate_data
--f
$i
mv
input.gnuplot tests/input_
$i
.gnuplot
./build/data2brdf
--input
tests/input_
$i
.gnuplot
--output
tests/output_lafortune_
$i
.lafortune
${
function
}
${
fitter
}
${
fitter_args
}
>
tests/output_lafortune_
$i
.out
if
[
$?
-eq
0
]
;
then
echo
"Test number
$i
passed"
#./build/brdf2gnuplot --input tests/output_lafortune_$i.lafortune $function --data tests/input_$i.gnuplot --output tests/output_lafortune_$i.gnuplot > /dev/null
else
echo
"Test number
$i
failed"
fi
done
fi
## Test with ALTA internal data
##
if
[
$test_alta
-eq
1
]
;
then
./build/data2brdf
--input
../data/2d/matusik_merl/beige-fabric-double-cc-cos-th-td-90deg.dat
--output
tests/beige.lafortune
${
function
}
${
fitter
}
${
fitter_args
}
>
tests/beige_lafortune.out
if
[
$?
-eq
0
]
;
then
echo
"Test beige matusik passed"
./build/brdf2gnuplot
--input
tests/beige.lafortune
$function
--data
../data/2d/matusik_merl/beige-fabric-double-cc-cos-th-td-90deg.dat
--output
tests/beige_lafortune.gnuplot
>
/dev/null
else
echo
"Test beige matusik failed"
fi
fi
sources/softs/brdf2gnuplot/main.cpp
View file @
4b89bdbf
...
...
@@ -79,29 +79,29 @@ int main(int argc, char** argv)
vec
v
=
d
->
get
(
i
)
;
vec
y2
=
f
->
value
(
v
)
;
if
(
!
linear_plot
)
{
for
(
int
u
=
0
;
u
<
d
->
dimX
();
++
u
)
file
<<
v
[
u
]
<<
"
\t
"
;
}
else
{
file
<<
i
<<
"
\t
"
;
}
if
(
!
linear_plot
)
{
for
(
int
u
=
0
;
u
<
d
->
dimX
();
++
u
)
file
<<
v
[
u
]
<<
"
\t
"
;
}
else
{
file
<<
i
<<
"
\t
"
;
}
for
(
int
u
=
0
;
u
<
d
->
dimY
();
++
u
)
{
if
(
plot_error
)
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
/
v
[
d
->
dimX
()
+
u
]
<<
"
\t
"
;
}
else
if
(
linear_plot
)
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
/
v
[
d
->
dimX
()
+
u
]
<<
"
\t
"
;
}
else
{
file
<<
y2
[
u
]
<<
"
\t
"
;
if
(
plot_error
)
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
/
v
[
d
->
dimX
()
+
u
]
<<
"
\t
"
;
}
else
if
(
linear_plot
)
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
/
v
[
d
->
dimX
()
+
u
]
<<
"
\t
"
;
}
else
{
file
<<
y2
[
u
]
<<
"
\t
"
;
}
}
...
...
sources/softs/data2diff/main.cpp
View file @
4b89bdbf
...
...
@@ -5,7 +5,7 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QApplication>
#include <Q
Core
Application>
#include <iostream>
#include <vector>
...
...
@@ -17,7 +17,7 @@
int
main
(
int
argc
,
char
**
argv
)
{
QApplication
app
(
argc
,
argv
,
false
);
Q
Core
Application
app
(
argc
,
argv
,
false
);
arguments
args
(
argc
,
argv
)
;
plugins_manager
manager
(
args
)
;
...
...
sources/softs/generate_data/main.cpp
View file @
4b89bdbf
...
...
@@ -10,7 +10,7 @@ int main(int argc, char** argv)
std
::
ofstream
f
(
"input.gnuplot"
)
;
arguments
args
(
argc
,
argv
);
std
::
cout
.
precision
(
10
);
std
::
cout
.
precision
(
10
);
int
nbx
=
100
;
int
nby
=
100
;
...
...
@@ -24,30 +24,30 @@ int main(int argc, char** argv)
if
(
k
==
1
)
{
f
<<
"#DIM 1 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN UNKNOWN"
<<
std
::
endl
;
//f << "#VS 2" << std::endl;
f
<<
"#PARAM_IN UNKNOWN"
<<
std
::
endl
;
//f << "#VS 2" << std::endl;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
const
float
x
=
i
/
(
float
)
nbx
;
//const float y = 100.0f * exp(-10.0 * x*x) * x*x - 0.01 *x*x*x + 0.1 ;
const
float
y
=
(
1.0
)
/
(
1.0E-10
+
x
*
x
*
x
);
//const float y = 100.0f * exp(-10.0 * x*x) * x*x - 0.01 *x*x*x + 0.1 ;
const
float
y
=
(
1.0
)
/
(
1.0E-10
+
x
*
x
*
x
);
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
y
*
0.9
f
<<
"
\t
"
<<
y
*
1.1
f
<<
std
::
endl
;
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
y
*
0.9
f
<<
"
\t
"
<<
y
*
1.1
f
<<
std
::
endl
;
}
}
else
if
(
k
==
2
)
{
f
<<
"#DIM 1 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN UNKNOWN"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
const
float
x
=
i
/
(
float
)
nbx
;
const
float
y
=
(
1.0
+
7.0
*
x
-
10.5
*
x
*
x
)
/
(
1.0
+
7.0
*
x
)
;
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
0.1
f
<<
std
::
endl
;
}
}
else
if
(
k
==
3
)
else
if
(
k
==
2
)
{
f
<<
"#DIM 1 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN UNKNOWN"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
const
float
x
=
i
/
(
float
)
nbx
;
const
float
y
=
(
1.0
+
7.0
*
x
-
10.5
*
x
*
x
)
/
(
1.0
+
7.0
*
x
)
;
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
0.1
f
<<
std
::
endl
;
}
}
else
if
(
k
==
3
)
{
f
<<
"#DIM 2 1"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
...
...
@@ -55,123 +55,126 @@ int main(int argc, char** argv)
{
const
float
x
=
i
/
(
float
)
nbx
;
const
float
y
=
j
/
(
float
)
nby
;
const
float
z
=
10
*
x
+
1.0
;
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
z
<<
"
\t
"
<<
z
-
0.1
f
<<
"
\t
"
<<
z
<<
std
::
endl
;
const
float
z
=
10
*
x
+
1.0
;
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
z
<<
"
\t
"
<<
z
-
0.1
f
<<
"
\t
"
<<
z
<<
std
::
endl
;
}
}
else
if
(
k
==
4
)
else
if
(
k
==
4
)
{
f
<<
"#DIM 2 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN UNKNOWN"
<<
std
::
endl
;
f
<<
"#PARAM_IN UNKNOWN"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
for
(
int
j
=
0
;
j
<
nby
;
++
j
)
{
const
float
x
=
i
/
(
float
)
nbx
;
const
float
y
=
j
/
(
float
)
nby
;
const
float
z
=
x
*
y
/
(
1.0E-3
+
x
*
x
*
x
)
+
10.
;
const
float
z
=
x
*
y
/
(
1.0E-3
+
x
*
x
*
x
)
+
10.
;
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
z
<<
std
::
endl
;
f
<<
x
<<
"
\t
"
<<
y
<<
"
\t
"
<<
z
<<
std
::
endl
;
}
}
else
if
(
k
==
5
)
else
if
(
k
==
5
)
{
f
<<
"#DIM 1 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN COS_TH"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
const
double
x
=
i
/
(
float
)
nbx
;
// const float d[3] = {0.1, 0.0, 0.5};
const
float
d
[
3
]
=
{
0.0
,
0.0
,
0.0
};
const
float
z1
=
d
[
0
]
+
0.2
*
std
::
pow
(
x
,
1.5
)
;
// const float z2 = d[1] - 0.1 * std::pow(x, 4.0) ;
// const float z3 = d[2] + 0.7 * std::pow(x, 1.0) ;
f
<<
x
<<
"
\t
"
<<
z1
;
// f << "\t" << z2 ;
// f << "\t" << z3 ;
f
<<
std
::
endl
;
const
double
x
=
i
/
(
float
)
nbx
;
// const float d[3] = {0.1, 0.0, 0.5};
const
float
d
[
3
]
=
{
0.0
,
0.0
,
0.0
};
const
float
z1
=
d
[
0
]
+
0.2
*
std
::
pow
(
x
,
1.5
)
;
// const float z2 = d[1] - 0.1 * std::pow(x, 4.0) ;
// const float z3 = d[2] + 0.7 * std::pow(x, 1.0) ;
f
<<
x
<<
"
\t
"
<<
z1
;
// f << "\t" << z2 ;
// f << "\t" << z3 ;
f
<<
std
::
endl
;
}
}
else
if
(
k
==
6
)
else
if
(
k
==
6
)
{
f
<<
"#DIM 1 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN COS_TH"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
const
double
x
=
i
/
(
float
)
nbx
;
const
double
z
=
0.1
+
0.5
*
std
::
pow
(
x
,
1.5
)
;
f
<<
x
<<
"
\t
"
<<
z
<<
std
::
endl
;
const
double
x
=
i
/
(
float
)
nbx
;
const
double
z
=
0.1
+
0.5
*
std
::
pow
(
x
,
1.5
)
;
f
<<
x
<<
"
\t
"
<<
z
<<
std
::
endl
;
}
}
// Lafortune fitting
// Single lobe (0.86, 0.77, 18.6)
else
if
(
k
==
7
)
{
f
<<
"#DIM 2 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN RUSIN_TH_TD"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
for
(
int
j
=
0
;
j
<
nby
;
++
j
)
{
double
in_r
[
2
],
in_c
[
6
];
in_r
[
0
]
=
M_PI
*
0.5
*
i
/
(
float
)
nbx
;
in_r
[
1
]
=
M_PI
*
0.5
*
j
/
(
float
)
nby
;
params
::
convert
(
in_r
,
params
::
RUSIN_TH_TD
,
params
::
CARTESIAN
,
in_c
);
const
double
Cx
=
0.86
;
const
double
Cz
=
0.77
;
const
double
n
=
18.6
;
const
double
cos
=
Cx
*
(
in_c
[
0
]
*
in_c
[
3
]
+
in_c
[
1
]
*
in_c
[
4
])
+
Cz
*
in_c
[
2
]
*
in_c
[
5
];
if
(
cos
>
0.0
)
{
const
double
z
=
std
::
pow
(
cos
,
n
)
;
f
<<
in_r
[
0
]
<<
"
\t
"
<<
in_r
[
1
]
<<
"
\t
"
<<
z
<<
std
::
endl
;
}
else
{
f
<<
in_r
[
0
]
<<
"
\t
"
<<
in_r
[
1
]
<<
"
\t
"
<<
0.0
<<
std
::
endl
;
}
}
}
}
// Lafortune fitting
// Triple lobe (0.86, 0.77, 18.6), (-0.41, 0.018, 2.58), (-1.03, 0.7, 63.8)
else
if
(
k
==
8
)
{
f
<<
"#DIM 2 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN RUSIN_TH_TD"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<=
90
;
++
i
)
{
for
(
int
j
=
0
;
j
<=
90
;
++
j
)
{
double
in_r
[
2
],
in_c
[
6
];
in_r
[
0
]
=
M_PI
*
0.5
*
i
/
(
double
)
90
;
in_r
[
1
]
=
M_PI
*
0.5
*
j
/
(
double
)
90
;
params
::
convert
(
in_r
,
params
::
RUSIN_TH_TD
,
params
::
CARTESIAN
,
in_c
);
const
double
Cx
[
3
]
=
{
0.86
,
-
0.410
,
-
1.03
};
const
double
Cz
[
3
]
=
{
0.77
,
0.018
,
0.70
};
const
double
n
[
3
]
=
{
18.6
,
2.580
,
63.8
};
double
z
=
0.0
;
for
(
int
k
=
0
;
k
<
3
;
++
k
)
{
const
double
cos
=
Cx
[
k
]
*
(
in_c
[
0
]
*
in_c
[
3
]
+
in_c
[
1
]
*
in_c
[
4
])
+
Cz
[
k
]
*
in_c
[
2
]
*
in_c
[
5
];
if
(
cos
>
0.0
)
{
z
+=
std
::
pow
(
cos
,
n
[
k
])
;
}
}
f
<<
in_r
[
0
]
<<
"
\t
"
<<
in_r
[
1
]
<<
"
\t
"
<<
z
<<
std
::
endl
;
}
}
}
// Lafortune fitting
// Single lobe (0.86, 0.77, 18.6)
else
if
(
k
==
7
)
{
f
<<
"#DIM 2 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN RUSIN_TH_TD"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
for
(
int
j
=
0
;
j
<
nby
;
++
j
)
{
double
in_r
[
2
],
in_c
[
6
];
in_r
[
0
]
=
M_PI
*
0.5
*
i
/
(
float
)
nbx
;
in_r
[
1
]
=
M_PI
*
0.5
*
j
/
(
float
)
nby
;
params
::
convert
(
in_r
,
params
::
RUSIN_TH_TD
,
params
::
CARTESIAN
,
in_c
);
const
double
Cx
=
0.86
;
const
double
Cz
=
0.77
;
const
double
n
=
18.6
;
const
double
cos
=
Cx
*
(
in_c
[
0
]
*
in_c
[
3
]
+
in_c
[
1
]
*
in_c
[
4
])
+
Cz
*
in_c
[
2
]
*
in_c
[
5
];
if
(
cos
>
0.0
)
{
const
double
z
=
std
::
pow
(
cos
,
n
)
;
f
<<
in_r
[
0
]
<<
"
\t
"
<<
in_r
[
1
]
<<
"
\t
"
<<
z
<<
std
::
endl
;
}
}
}
}
// Lafortune fitting
// Triple lobe (0.86, 0.77, 18.6), (-0.41, 0.018, 2.58), (-1.03, 0.7, 63.8)
else
if
(
k
==
8
)
{
f
<<
"#DIM 2 1"
<<
std
::
endl
;
f
<<
"#PARAM_IN RUSIN_TH_TD"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nbx
;
++
i
)
{
for
(
int
j
=
0
;
j
<
nby
;
++
j
)
{
double
in_r
[
2
],
in_c
[
6
];
in_r
[
0
]
=
M_PI
*
0.5
*
i
/
(
float
)
nbx
;
in_r
[
1
]
=
M_PI
*
0.5
*
j
/
(
float
)
nby
;
params
::
convert
(
in_r
,
params
::
RUSIN_TH_TD
,
params
::
CARTESIAN
,
in_c
);
const
double
Cx
[
3
]
=
{
0.86
,
-
0.410
,
-
1.03
};
const
double
Cz
[
3
]
=
{
0.77
,
0.018
,
0.70
};
const
double
n
[
3
]
=
{
18.6
,
2.580
,
63.8
};
double
z
=
0.0
;
for
(
int
k
=
0
;
k
<
3
;
++
k
)
{
const
double
cos
=
Cx
[
k
]
*
(
in_c
[
0
]
*
in_c
[
3
]
+
in_c
[
1
]
*
in_c
[
4
])
+
Cz
[
k
]
*
in_c
[
2
]
*
in_c
[
5
];
if
(
cos
>
0.0
)
{
z
+=
std
::
pow
(
cos
,
n
[
k
])
;
}
}
f
<<
in_r
[
0
]
<<
"
\t
"
<<
in_r
[
1
]
<<
"
\t
"
<<
z
<<
std
::
endl
;
}
}
}
return
0
;
}
sources/softs/softs.pro
View file @
4b89bdbf
...
...
@@ -6,4 +6,5 @@ SUBDIRS = generate_data \
data2gnuplot
\
data2diff
\
data2moments
\
tests
\
#
fourieranalysis
sources/softs/tests/main.cpp
0 → 100644
View file @
4b89bdbf
#include <core/args.h>
#include <core/data.h>
#include <core/function.h>
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QPluginLoader>
#include <QtPlugin>
#include <QCoreApplication>
#include <QDir>
#include <QTime>
#include <iostream>
#include <vector>
#include <iostream>
#include <fstream>
#include <limits>
#include <cstdlib>
#define EPSILON 1.0E-10
int
main
(
int
argc
,
char
**
argv
)
{
QCoreApplication
app
(
argc
,
argv
,
false
);
arguments
args
(
argc
,
argv
)
;
plugins_manager
manager
(
args
)
;
int
nb_tests_failed
=
0
;
// Parametrization tests
//
// Evaluation tests
//
std
::
cout
<<
"<<INFO>> "
<<
nb_tests_failed
<<
" tests failed"
<<
std
::
endl
;
return
nb_tests_failed
;
}
sources/softs/tests/tests.pro
0 → 100644
View file @
4b89bdbf
CONFIG
+=
qt
\
console
DESTDIR
=
..
/../
build
INCLUDEPATH
+=
..
/../
..
/../
libs
/
rational_1d
\
SOURCES
+=
main
.
cpp
LIBS
+=
-
L
..
/../
build
-
lcore
unix
{
PRE_TARGETDEPS
+=
..
/../
build
/
libcore
.
a
}
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