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
bccc682f
Commit
bccc682f
authored
Aug 26, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding the loading of ALTA file from the plugin manager
parent
0791b93a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
12 deletions
+88
-12
documents/format.dox
documents/format.dox
+2
-2
sources/core/plugins_manager.cpp
sources/core/plugins_manager.cpp
+79
-9
sources/core/plugins_manager.h
sources/core/plugins_manager.h
+7
-1
No files found.
documents/format.dox
View file @
bccc682f
...
...
@@ -81,7 +81,7 @@ ALTA library assumes that all functions are exported using the following convent
Example of a .function file for a single Lafortune lobe without any diffuse:
\verbatim
#ALTA_HEADER_
START
#ALTA_HEADER_
DATA
#CMD lafortune --nb_lobes 1 --isotrope
#DIM 2 1
#PARAM_IN ROMEIRO_TH_TD
...
...
@@ -98,7 +98,7 @@ For multiple BRDFs lobes (when you want to add a diffuse for example), you need
specify it into the command line. The different parameters are outputed sequentially
into the file:
\verbatim
#ALTA_HEADER_
START
#ALTA_HEADER_
FUNC
#CMD [diffuse, lafortune --nb_lobes 1 --isotrope, phong --fresnel schlick]
#DIM 2 3
#PARAM_IN ROMEIRO_TH_TD
...
...
sources/core/plugins_manager.cpp
View file @
bccc682f
...
...
@@ -194,6 +194,64 @@ fitter* plugins_manager::get_fitter()
#endif
}
//! \brief load a function from the ALTA input file.
function
*
plugins_manager
::
get_function
(
const
std
::
string
&
filename
)
{
std
::
ifstream
file
;
file
.
open
(
filename
.
c_str
())
;
if
(
!
file
.
is_open
())
{
std
::
cerr
<<
"<<ERROR>> unable to open file
\"
"
<<
filename
<<
"
\"
"
<<
std
::
endl
;
throw
;
}
// Parameters of the function object
int
nX
,
nY
;
arguments
args
;
// Test for the first line of the file. Should be a ALTA FUNC HEADER
std
::
string
line
;
std
::
getline
(
file
,
line
)
;
if
(
line
!=
"#ALTA FUNC HEADER"
)
{
std
::
cerr
<<
"<<ERROR>> this is not a function file"
<<
std
::
endl
;
}
// Parse the header for the function command line and the dimension
// of the function
while
(
line
!=
"#ALTA HEADER END"
)
{
std
::
getline
(
file
,
line
)
;
std
::
stringstream
linestream
(
line
)
;
linestream
.
ignore
(
1
)
;
std
::
string
comment
;
linestream
>>
comment
;
if
(
comment
==
std
::
string
(
"DIM"
))
{
linestream
>>
nX
>>
nY
;
}
else
if
(
comment
==
std
::
string
(
"CMD"
))
{
args
=
arguments
::
create_arguments
(
line
.
substr
(
4
,
std
::
string
::
npos
));
}
}
// Create the function from the command line
function
*
f
=
get_function
(
args
);
f
->
setDimX
(
nX
);
f
->
setDimY
(
nY
);
// Load the function part from the file object
//f->load(file);
return
f
;
}
//! Get an instance of the function selected based on the name <em>n</em>.
//! Return NULL if no one exist.
function
*
plugins_manager
::
get_function
(
const
arguments
&
args
)
...
...
@@ -219,18 +277,30 @@ function* plugins_manager::get_function(const arguments& args)
return
NULL
;
}
//!
\todo
create a <em>compound</em> class to store multiple
//! create a <em>compound</em> class to store multiple
//! functions in it.
compound_function
*
compound
=
new
compound_function
();
//! For each args_vec element, create a function object and add
//! it to the compound one.
std
::
string
n
(
"--func "
);
n
.
append
(
args_vec
[
0
]);
func
=
get_function
(
arguments
::
create_arguments
(
n
));
//! return the compound class
for
(
int
i
=
0
;
i
<
args_vec
.
size
();
++
i
)
{
std
::
string
n
(
"--func "
);
n
.
append
(
args_vec
[
i
]);
function
*
f
=
get_function
(
arguments
::
create_arguments
(
n
));
if
(
dynamic_cast
<
nonlinear_function
*>
(
f
)
==
NULL
)
{
std
::
cerr
<<
"<<ERROR>> only non-linear function care compatible with a compound"
<<
std
::
endl
;
}
else
{
compound
->
push_back
(
dynamic_cast
<
nonlinear_function
*>
(
f
));
}
}
//! return the compound class
func
=
compound
;
}
else
{
...
...
sources/core/plugins_manager.h
View file @
bccc682f
...
...
@@ -46,7 +46,13 @@ class plugins_manager
#ifdef USING_STATIC
static
#endif
function
*
get_function
(
const
arguments
&
args
)
;
function
*
get_function
(
const
arguments
&
args
)
;
//! \brief load a function from the ALTA input file.
#ifdef USING_STATIC
static
#endif
function
*
get_function
(
const
std
::
string
&
filename
);
//! \brief get an instance of the data that is defined in the plugin with
//! filename n. Return null if no one exist.
...
...
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