Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
alta
alta
Commits
93b8e937
Commit
93b8e937
authored
Oct 21, 2013
by
Laurent Belcour
Browse files
Switching the input/output to be openEXR in order to get it to work
parent
667e99a0
Changes
5
Hide whitespace changes
Inline
Side-by-side
sources/core/params.cpp
View file @
93b8e937
#include
"params.h"
#include
"common.h"
struct
param_info
{
...
...
@@ -201,7 +202,7 @@ void params::from_cartesian(const double* invec, params::input outtype,
break
;
case
params
::
RUSIN_TH_TD
:
outvec
[
0
]
=
acos
(
half
[
2
]);
outvec
[
1
]
=
acos
(
half
[
0
]
*
invec
[
0
]
+
half
[
1
]
*
invec
[
1
]
+
half
[
2
]
*
invec
[
2
]);
outvec
[
1
]
=
acos
(
clamp
(
half
[
0
]
*
invec
[
0
]
+
half
[
1
]
*
invec
[
1
]
+
half
[
2
]
*
invec
[
2
]
,
-
1.0
,
1.0
)
);
break
;
// 3D Parametrization
...
...
sources/plugins/data_brdf_slice/data.cpp
View file @
93b8e937
...
...
@@ -4,11 +4,13 @@
#include
<cstdlib>
#include
<cmath>
#include
"EXR_IO.h"
data_brdf_slice
::
data_brdf_slice
()
{
// Allocate data
_data
=
new
fipImage
()
;
//
_data
->setSize(FIT_FLOAT, 512, 512, 16)
;
width
=
512
;
height
=
512
;
_data
=
new
double
[
3
*
width
*
height
]
;
// Set the input and output parametrization
_in_param
=
params
::
RUSIN_TH_TD
;
...
...
@@ -19,16 +21,14 @@ data_brdf_slice::data_brdf_slice()
data_brdf_slice
::~
data_brdf_slice
()
{
delete
_data
;
delete
[]
_data
;
}
// Load data from a file
void
data_brdf_slice
::
load
(
const
std
::
string
&
filename
)
{
_data
->
load
(
filename
.
c_str
());
_data
->
convertTo32Bits
();
width
=
_data
->
getWidth
();
height
=
_data
->
getHeight
();
delete
[]
_data
;
t_EXR_IO
<
double
>::
LoadEXR
(
filename
.
c_str
(),
width
,
height
,
_data
);
}
void
data_brdf_slice
::
load
(
const
std
::
string
&
filename
,
const
arguments
&
)
{
...
...
@@ -37,7 +37,7 @@ void data_brdf_slice::load(const std::string& filename, const arguments&)
void
data_brdf_slice
::
save
(
const
std
::
string
&
filename
)
const
{
if
(
!
_data
->
save
(
filename
.
c_str
()
))
if
(
!
t_EXR_IO
<
double
>::
SaveEXR
(
filename
.
c_str
(),
width
,
height
,
_data
))
{
std
::
cerr
<<
"<<ERROR>> unable to save image file"
<<
std
::
endl
;
}
...
...
@@ -46,16 +46,16 @@ void data_brdf_slice::save(const std::string& filename) const
// Acces to data
vec
data_brdf_slice
::
get
(
int
id
)
const
{
vec
res
(
3
)
;
int
i
=
id
%
width
;
int
j
=
id
/
width
;
vec
res
(
5
)
;
const
int
i
=
id
%
width
;
const
int
j
=
id
/
width
;
RGBQUAD
pixel
;
_data
->
getPixelColor
(
i
,
j
,
&
pixel
);
res
[
0
]
=
0.5
*
M_PI
*
i
/
double
(
width
)
;
res
[
1
]
=
0.5
*
M_PI
*
j
/
double
(
height
);
res
[
0
]
=
pixel
.
rgbRed
/
255.0
;
res
[
1
]
=
pixel
.
rgbGreen
/
255.0
;
res
[
2
]
=
pixel
.
rgbBlue
/
255.0
;
res
[
2
]
=
_data
[
3
*
id
+
0
]
;
res
[
3
]
=
_data
[
3
*
id
+
1
]
;
res
[
4
]
=
_data
[
3
*
id
+
2
]
;
return
res
;
}
...
...
@@ -68,15 +68,17 @@ vec data_brdf_slice::operator[](int i) const
void
data_brdf_slice
::
set
(
vec
x
)
{
assert
(
x
.
size
()
==
5
);
assert
(
x
[
0
]
<=
0.5
*
M_PI
&&
x
[
0
]
>=
0.0
);
assert
(
x
[
1
]
<=
0.5
*
M_PI
&&
x
[
1
]
>=
0.0
);
const
int
i
=
floor
(
x
[
0
]
*
width
/
(
0.5
*
M_PI
));
const
int
j
=
floor
(
x
[
1
]
*
height
/
(
0.5
*
M_PI
));
int
i
=
floor
(
x
[
0
]
*
width
/
(
0.5
*
M_PI
));
int
j
=
floor
(
x
[
1
]
*
height
/
(
0.5
*
M_PI
));
const
int
id
=
i
+
j
*
width
;
RGBQUAD
*
pixel
;
_data
->
getPixelColor
(
i
,
j
,
pixel
);
pixel
->
rgbRed
=
x
[
2
];
pixel
->
rgbGreen
=
x
[
3
];
pixel
->
rgbBlue
=
x
[
4
];
_data
[
3
*
id
+
0
]
=
x
[
2
];
_data
[
3
*
id
+
1
]
=
x
[
3
];
_data
[
3
*
id
+
2
]
=
x
[
4
];
}
vec
data_brdf_slice
::
value
(
vec
,
vec
)
const
...
...
@@ -86,13 +88,21 @@ vec data_brdf_slice::value(vec, vec) const
}
vec
data_brdf_slice
::
value
(
vec
x
)
const
{
int
i
=
floor
(
x
[
0
]
*
width
/
(
0.5
*
M_PI
));
int
j
=
floor
(
x
[
1
]
*
height
/
(
0.5
*
M_PI
));
assert
(
x
[
0
]
<=
0.5
*
M_PI
&&
x
[
0
]
>=
0.0
);
assert
(
x
[
1
]
<=
0.5
*
M_PI
&&
x
[
1
]
>=
0.0
);
const
int
i
=
floor
(
x
[
0
]
*
width
/
(
0.5
*
M_PI
));
const
int
j
=
floor
(
x
[
1
]
*
height
/
(
0.5
*
M_PI
));
const
int
id
=
i
+
j
*
width
;
if
(
i
<
0
||
i
>=
width
)
{
std
::
cerr
<<
"<<ERROR>> out of bounds: "
<<
x
<<
std
::
endl
;
}
if
(
j
<
0
||
j
>=
height
)
{
std
::
cerr
<<
"<<ERROR>> out of bounds: "
<<
x
<<
std
::
endl
;
}
return
get
(
i
+
j
*
width
);
vec
res
(
3
);
res
[
0
]
=
_data
[
3
*
id
+
0
];
res
[
1
]
=
_data
[
3
*
id
+
1
];
res
[
2
]
=
_data
[
3
*
id
+
2
];
return
res
;
}
// Get data size, e.g. the number of samples to fit
...
...
sources/plugins/data_brdf_slice/data.h
View file @
93b8e937
...
...
@@ -4,8 +4,6 @@
#include
<core/common.h>
#include
<core/args.h>
#include
<FreeImagePlus.h>
class
data_brdf_slice
:
public
data
{
public:
// methods
...
...
@@ -40,7 +38,7 @@ class data_brdf_slice : public data
virtual
int
dimY
()
const
;
private:
// data
fipImag
e
*
_data
;
doubl
e
*
_data
;
int
width
,
height
;
}
;
sources/plugins/data_brdf_slice/data_brdf_slice.pro
View file @
93b8e937
TEMPLATE
=
lib
CONFIG
*=
plugin
\
eigen
CONFIG
*=
plugin
\
eigen
\
openexr
DESTDIR
=
..
/../
build
...
...
@@ -10,7 +11,4 @@ SOURCES = data.cpp
LIBS
+=
-
L
..
/../
build
\
-
lcore
\
-
lfreeimageplus
-
lcore
sources/softs/data2data/main.cpp
View file @
93b8e937
...
...
@@ -61,9 +61,7 @@ int main(int argc, char** argv)
{
// Copy the input vector
vec
x
=
d_out
->
get
(
i
);
//params::convert(&x[0], d_out->parametrization(), d_in->parametrization(), &temp[0]);
temp
[
0
]
=
x
[
0
];
temp
[
1
]
=
x
[
1
];
params
::
convert
(
&
x
[
0
],
d_out
->
parametrization
(),
d_in
->
parametrization
(),
&
temp
[
0
]);
vec
y
=
d_in
->
value
(
temp
);
...
...
Write
Preview
Supports
Markdown
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