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
d9fd53a0
Commit
d9fd53a0
authored
Oct 17, 2013
by
Laurent Belcour
Browse files
Adding some plugins and a correction in the parametrization.
parent
c6ea14e4
Changes
12
Hide whitespace changes
Inline
Side-by-side
sources/core/params.cpp
View file @
d9fd53a0
...
...
@@ -201,29 +201,29 @@ void params::from_cartesian(const double* invec, params::input outtype,
break
;
case
params
::
RUSIN_TH_TD
:
outvec
[
0
]
=
acos
(
half
[
2
]);
outvec
[
2
]
=
acos
(
half
[
0
]
*
invec
[
0
]
+
half
[
1
]
*
invec
[
1
]
+
half
[
2
]
*
invec
[
2
]);
outvec
[
1
]
=
acos
(
half
[
0
]
*
invec
[
0
]
+
half
[
1
]
*
invec
[
1
]
+
half
[
2
]
*
invec
[
2
]);
break
;
// 3D Parametrization
case
params
::
RUSIN_TH_PH_TD
:
outvec
[
0
]
=
acos
(
half
[
2
]);
outvec
[
1
]
=
atan2
(
half
[
1
],
half
[
0
]);
outvec
[
1
]
=
atan2
(
half
[
1
],
half
[
0
]);
outvec
[
2
]
=
acos
(
half
[
0
]
*
invec
[
0
]
+
half
[
1
]
*
invec
[
1
]
+
half
[
2
]
*
invec
[
2
]);
break
;
case
params
::
RUSIN_TH_TD_PD
:
outvec
[
0
]
=
acos
(
half
[
2
]);
// Compute the diff vector
diff
[
0
]
=
invec
[
0
];
diff
[
1
]
=
invec
[
1
];
diff
[
2
]
=
invec
[
2
];
rotate_normal
(
diff
,
-
atan2
(
half
[
1
],
half
[
0
]));
rotate_binormal
(
diff
,
-
outvec
[
0
]);
outvec
[
1
]
=
acos
(
diff
[
2
]);
outvec
[
2
]
=
atan2
(
diff
[
1
],
diff
[
0
]);
break
;
case
params
::
RUSIN_TH_TD_PD
:
outvec
[
0
]
=
acos
(
half
[
2
]);
// Compute the diff vector
diff
[
0
]
=
invec
[
0
];
diff
[
1
]
=
invec
[
1
];
diff
[
2
]
=
invec
[
2
];
rotate_normal
(
diff
,
-
atan2
(
half
[
1
],
half
[
0
]));
rotate_binormal
(
diff
,
-
outvec
[
0
]);
outvec
[
1
]
=
acos
(
diff
[
2
]);
outvec
[
2
]
=
atan2
(
diff
[
1
],
diff
[
0
]);
break
;
case
params
::
ISOTROPIC_TV_TL_DPHI
:
outvec
[
0
]
=
acos
(
invec
[
2
]);
outvec
[
1
]
=
acos
(
invec
[
5
]);
...
...
sources/plugins/data_astm/data.cpp
0 → 100644
View file @
d9fd53a0
#include
"data.h"
#include
<string>
#include
<sstream>
#include
<iostream>
#include
<fstream>
#include
<cstdio>
#include
<cstdlib>
#include
<cmath>
// Load data from a file
void
data_astm
::
load
(
const
std
::
string
&
filename
)
{
std
::
ifstream
file
(
filename
.
c_str
());
std
::
string
line
;
// Parse the header
for
(
int
i
=
0
;
i
<
22
;
++
i
)
{
std
::
getline
(
file
,
line
);
}
while
(
file
.
good
())
{
std
::
getline
(
file
,
line
);
size_t
s
=
0
;
// start
size_t
t
;
// end
bool
sample_wrong
=
false
;
vec
x
(
7
);
for
(
int
i
=
0
;
i
<
7
;
++
i
)
{
t
=
line
.
find_first_of
(
','
,
s
);
if
(
t
==
s
||
t
==
std
::
string
::
npos
)
{
sample_wrong
=
true
;
}
x
[
i
]
=
atof
(
line
.
substr
(
s
,
t
-
s
).
c_str
());
s
=
t
+
1
;
}
if
(
!
sample_wrong
)
{
_data
.
push_back
(
x
);
}
}
file
.
close
();
}
void
data_astm
::
load
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
{
this
->
load
(
filename
);
}
// Acces to data
vec
data_astm
::
get
(
int
i
)
const
{
return
_data
[
i
];
}
vec
data_astm
::
operator
[](
int
i
)
const
{
return
_data
[
i
];
}
vec
data_astm
::
value
(
vec
in
,
vec
out
)
const
{
std
::
cout
<<
"<<ERROR>> not implemented"
<<
std
::
endl
;
vec
res
(
4
);
return
res
;
}
// Get data size, e.g. the number of samples to fit
int
data_astm
::
size
()
const
{
return
_data
.
size
()
;
}
// Get min and max input space values
vec
data_astm
::
min
()
const
{
vec
res
(
4
);
res
[
0
]
=
0.0
;
res
[
1
]
=
0.0
;
res
[
2
]
=
0.0
;
res
[
3
]
=
0.0
;
return
res
;
}
vec
data_astm
::
max
()
const
{
vec
res
(
4
);
res
[
0
]
=
M_PI
/
2
;
res
[
1
]
=
0.0
;
res
[
2
]
=
M_PI
/
2
;
res
[
3
]
=
M_PI
;
return
res
;
}
data
*
provide_data
()
{
return
new
data_astm
();
}
Q_EXPORT_PLUGIN2
(
data_astm
,
data_astm
)
sources/plugins/data_astm/data.h
0 → 100644
View file @
d9fd53a0
#pragma once
#include
<QObject>
#include
<core/data.h>
#include
<core/common.h>
#include
<core/args.h>
class
data_astm
:
public
QObject
,
public
data
{
// Q_OBJECT
Q_INTERFACES
(
data
)
public:
// methods
// Load data from a file
virtual
void
load
(
const
std
::
string
&
filename
)
;
virtual
void
load
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
;
// Acces to data
virtual
vec
get
(
int
i
)
const
;
virtual
vec
operator
[](
int
i
)
const
;
virtual
vec
value
(
vec
in
,
vec
out
)
const
;
// Get data size, e.g. the number of samples to fit
virtual
int
size
()
const
;
// Get min and max input space values
virtual
vec
min
()
const
;
virtual
vec
max
()
const
;
virtual
int
dimX
()
const
{
return
4
;
}
virtual
int
dimY
()
const
{
return
3
;
}
virtual
params
::
input
parametrization
()
const
{
return
params
::
SPHERICAL_TL_PL_TV_PV
;
}
private:
// data
std
::
vector
<
vec
>
_data
;
}
;
sources/plugins/data_astm/data_astm.pro
0 → 100644
View file @
d9fd53a0
TEMPLATE
=
lib
CONFIG
*=
qt
\
plugin
DESTDIR
=
..
/../
build
INCLUDEPATH
+=
..
/..
HEADERS
=
data
.
h
SOURCES
=
data
.
cpp
LIBS
+=
-
L
..
/../
build
\
-
lcore
sources/plugins/data_brdf_slice/data.cpp
0 → 100644
View file @
d9fd53a0
#include
"data.h"
#include
<cstdio>
#include
<cstdlib>
#include
<cmath>
data_brdf_slice
::
data_brdf_slice
()
{
// Allocate data
_data
=
new
fipImage
();
//_data->setSize(FIT_FLOAT, 512, 512, 16);
// Set the input and output parametrization
_in_param
=
params
::
RUSIN_TH_TD
;
_out_param
=
params
::
RGB_COLOR
;
_nX
=
2
;
_nY
=
3
;
}
data_brdf_slice
::~
data_brdf_slice
()
{
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
();
}
void
data_brdf_slice
::
load
(
const
std
::
string
&
filename
,
const
arguments
&
)
{
load
(
filename
);
}
void
data_brdf_slice
::
save
(
const
std
::
string
&
filename
)
const
{
if
(
!
_data
->
save
(
filename
.
c_str
()))
{
std
::
cerr
<<
"<<ERROR>> unable to save image file"
<<
std
::
endl
;
}
}
// Acces to data
vec
data_brdf_slice
::
get
(
int
id
)
const
{
vec
res
(
3
)
;
int
i
=
id
%
width
;
int
j
=
id
/
width
;
RGBQUAD
pixel
;
_data
->
getPixelColor
(
i
,
j
,
&
pixel
);
res
[
0
]
=
pixel
.
rgbRed
/
255.0
;
res
[
1
]
=
pixel
.
rgbGreen
/
255.0
;
res
[
2
]
=
pixel
.
rgbBlue
/
255.0
;
return
res
;
}
vec
data_brdf_slice
::
operator
[](
int
i
)
const
{
return
get
(
i
)
;
}
//! \todo Test this function
void
data_brdf_slice
::
set
(
vec
x
)
{
assert
(
x
.
size
()
==
5
);
int
i
=
floor
(
x
[
0
]
*
width
/
(
0.5
*
M_PI
));
int
j
=
floor
(
x
[
1
]
*
height
/
(
0.5
*
M_PI
));
RGBQUAD
*
pixel
;
_data
->
getPixelColor
(
i
,
j
,
pixel
);
pixel
->
rgbRed
=
x
[
2
];
pixel
->
rgbGreen
=
x
[
3
];
pixel
->
rgbBlue
=
x
[
4
];
}
vec
data_brdf_slice
::
value
(
vec
,
vec
)
const
{
vec
res
(
3
);
return
res
;
}
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
));
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
);
}
// Get data size, e.g. the number of samples to fit
int
data_brdf_slice
::
size
()
const
{
return
width
*
height
;
}
// Get min and max input space values
vec
data_brdf_slice
::
min
()
const
{
vec
res
(
2
);
res
[
0
]
=
0.0
;
res
[
1
]
=
0.0
;
return
res
;
}
vec
data_brdf_slice
::
max
()
const
{
vec
res
(
2
);
res
[
0
]
=
M_PI
/
2
;
res
[
1
]
=
M_PI
/
2
;
return
res
;
}
int
data_brdf_slice
::
dimX
()
const
{
return
2
;
}
int
data_brdf_slice
::
dimY
()
const
{
return
3
;
}
ALTA_DLL_EXPORT
data
*
provide_data
()
{
return
new
data_brdf_slice
();
}
sources/plugins/data_brdf_slice/data.h
0 → 100644
View file @
d9fd53a0
#pragma once
#include
<core/data.h>
#include
<core/common.h>
#include
<core/args.h>
#include
<FreeImagePlus.h>
class
data_brdf_slice
:
public
data
{
public:
// methods
data_brdf_slice
();
~
data_brdf_slice
();
// Load data from a file
virtual
void
load
(
const
std
::
string
&
filename
)
;
virtual
void
load
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
;
virtual
void
save
(
const
std
::
string
&
filename
)
const
;
// Acces to data
virtual
vec
get
(
int
i
)
const
;
virtual
vec
operator
[](
int
i
)
const
;
virtual
vec
value
(
vec
in
,
vec
out
)
const
;
virtual
vec
value
(
vec
x
)
const
;
// Set data
virtual
void
set
(
vec
x
);
// Get data size, e.g. the number of samples to fit
virtual
int
size
()
const
;
// Get min and max input space values
virtual
vec
min
()
const
;
virtual
vec
max
()
const
;
virtual
int
dimX
()
const
;
virtual
int
dimY
()
const
;
private:
// data
fipImage
*
_data
;
int
width
,
height
;
}
;
sources/plugins/data_brdf_slice/data_brdf_slice.pro
0 → 100644
View file @
d9fd53a0
TEMPLATE
=
lib
CONFIG
*=
plugin
\
eigen
DESTDIR
=
..
/../
build
INCLUDEPATH
+=
..
/..
HEADERS
=
data
.
h
SOURCES
=
data
.
cpp
LIBS
+=
-
L
..
/../
build
\
-
lcore
\
-
lfreeimageplus
sources/plugins/plugins.pro
View file @
d9fd53a0
...
...
@@ -25,5 +25,6 @@ SUBDIRS = \
nonlinear_function_lafortune
\
nonlinear_function_isotropic_lafortune
\
data_merl
\
data_brdf_slice
\
#
data_astm
sources/softs/brdf2data/main.cpp
View file @
d9fd53a0
...
...
@@ -46,7 +46,7 @@ int main(int argc, char** argv)
d
=
plugins_manager
::
get_data
(
args
[
"data"
])
;
function
*
f
=
NULL
;
f
=
plugins_manager
::
get_function
(
args
[
"input"
]
);
f
=
plugins_manager
::
get_function
(
args
);
// Modify function or data to provide coherent
// interfaces
...
...
sources/softs/data2data/data2data.pro
0 → 100644
View file @
d9fd53a0
CONFIG
+=
console
\
eigen
INCLUDEPATH
+=
..
/../
DESTDIR
=
..
/../
build
SOURCES
+=
main
.
cpp
LIBS
+=
-
L
..
/../
build
-
lcore
unix
{
PRE_TARGETDEPS
+=
..
/../
build
/
libcore
.
a
LIBS
+=
-
ldl
}
sources/softs/data2data/main.cpp
0 → 100644
View file @
d9fd53a0
#include
<core/args.h>
#include
<core/data.h>
#include
<core/params.h>
#include
<core/function.h>
#include
<core/fitter.h>
#include
<core/plugins_manager.h>
#include
<iostream>
#include
<vector>
#include
<iostream>
#include
<fstream>
#include
<limits>
#include
<cstdlib>
#include
<cmath>
int
main
(
int
argc
,
char
**
argv
)
{
arguments
args
(
argc
,
argv
)
;
if
(
args
.
is_defined
(
"help"
))
{
std
::
cout
<<
"<<HELP>> data2data --input data.file --output data.file --out-data exporter.so --in-data importer.so"
<<
std
::
endl
;
std
::
cout
<<
" - input, output, func, data are mandatory parameters"
<<
std
::
endl
;
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
(
!
args
.
is_defined
(
"in-data"
))
{
std
::
cerr
<<
"<<ERROR>> the data importer is not defined"
<<
std
::
endl
;
return
1
;
}
if
(
!
args
.
is_defined
(
"out-data"
))
{
std
::
cerr
<<
"<<ERROR>> the data exporter is not defined"
<<
std
::
endl
;
return
1
;
}
// Import data
data
*
d_in
=
NULL
;
d_in
=
plugins_manager
::
get_data
(
args
[
"in-data"
])
;
d_in
->
load
(
args
[
"input"
]);
data
*
d_out
=
NULL
;
d_out
=
plugins_manager
::
get_data
(
args
[
"out-data"
])
;
if
(
d_out
->
dimY
()
!=
d_in
->
dimY
())
{
std
::
cerr
<<
"<<ERROR>> data types have incompatible output dimensions"
<<
std
::
endl
;
}
if
(
d_in
!=
NULL
&&
d_out
!=
NULL
)
{
vec
temp
(
d_in
->
dimX
());
for
(
int
i
=
0
;
i
<
d_out
->
size
();
++
i
)
{
// 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
];
vec
y
=
d_in
->
value
(
temp
);
for
(
int
j
=
0
;
j
<
d_in
->
dimY
();
++
j
)
{
x
[
d_out
->
dimX
()
+
j
]
=
y
[
j
];
}
d_out
->
set
(
x
);
}
d_out
->
save
(
args
[
"output"
]);
return
0
;
}
else
{
std
::
cerr
<<
"<<ERROR>> cannot import or export data"
<<
std
::
endl
;
return
1
;
}
}
sources/softs/softs.pro
View file @
d9fd53a0
TEMPLATE
=
subdirs
SUBDIRS
=
generate_data
\
data2brdf
\
data2data
\
brdf2data
\
brdf2brdf
\
brdf2gnuplot
\
...
...
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