Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
alta
alta
Commits
92313844
Commit
92313844
authored
Feb 25, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The min and max arguments can be vectors now
parent
52fb76f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
14 deletions
+44
-14
sources/core/args.h
sources/core/args.h
+24
-9
sources/core/vertical_segment.cpp
sources/core/vertical_segment.cpp
+6
-4
sources/softs/brdf2gnuplot/main.cpp
sources/softs/brdf2gnuplot/main.cpp
+14
-1
No files found.
sources/core/args.h
View file @
92313844
...
...
@@ -27,13 +27,19 @@ class arguments
if
(
temp
.
compare
(
0
,
2
,
"--"
)
==
0
)
{
key
=
temp
.
substr
(
2
,
temp
.
size
()
-
2
)
;
if
(
i
+
1
<
argc
)
int
j
=
i
+
1
;
while
(
j
<
argc
)
{
std
::
string
next
(
argv
[
i
+
1
])
;
std
::
string
next
(
argv
[
j
])
;
if
(
next
.
compare
(
0
,
2
,
"--"
)
!=
0
)
{
data
=
next
;
data
.
append
(
next
)
;
}
else
{
break
;
}
++
j
;
}
}
_map
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
key
,
data
))
;
...
...
@@ -79,34 +85,43 @@ class arguments
else
return
default_value
;
}
vec
get_vec
(
const
std
::
string
&
key
,
float
default_value
)
const
vec
get_vec
(
const
std
::
string
&
key
,
int
size
,
float
default_value
=
0.0
f
)
const
{
vec
res
;
vec
res
(
size
)
;
if
(
_map
.
count
(
key
)
>
0
)
{
std
::
string
s
=
_map
.
at
(
key
);
if
(
s
[
0
]
==
'\['
)
// Is an array of type [a, b, c]
{
int
i
=
0
;
size_t
pos
=
0
;
size_t
pos
=
1
;
while
(
pos
!=
std
::
string
::
npos
)
{
size_t
ppos
=
s
.
find
(
","
,
pos
);
size_t
ppos
=
s
.
find
(
','
,
pos
);
if
(
ppos
!=
std
::
string
::
npos
)
{
std
::
cout
<<
s
.
substr
(
pos
,
ppos
)
<<
std
::
endl
;
res
[
i
]
=
atof
(
s
.
substr
(
pos
,
ppos
).
c_str
());
pos
=
ppos
+
1
;
++
i
;
}
else
{
res
[
i
]
=
atof
(
s
.
substr
(
pos
,
ppos
-
1
).
c_str
());
pos
=
ppos
;
++
i
;
}
}
std
::
cout
<<
std
::
endl
;
return
res
;
}
}
float
val
=
get_float
(
key
,
default_value
);
res
.
push_back
(
default_value
);
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
res
[
i
]
=
val
;
}
return
res
;
}
...
...
sources/core/vertical_segment.cpp
View file @
92313844
...
...
@@ -23,9 +23,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
throw
;
}
double
min
,
max
;
min
=
args
.
get_float
(
"min"
,
-
std
::
numeric_limits
<
double
>::
max
())
;
max
=
args
.
get_float
(
"max"
,
std
::
numeric_limits
<
double
>::
max
())
;
vec
min
,
max
;
_nX
=
0
;
_nY
=
0
;
std
::
vector
<
int
>
vs
;
int
current_vs
=
0
;
...
...
@@ -57,6 +55,10 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
_min
.
resize
(
dimX
())
;
_max
.
resize
(
dimX
())
;
min
=
args
.
get_vec
(
"min"
,
_nX
,
-
std
::
numeric_limits
<
double
>::
max
())
;
max
=
args
.
get_vec
(
"max"
,
_nX
,
std
::
numeric_limits
<
double
>::
max
())
;
for
(
int
k
=
0
;
k
<
dimX
();
++
k
)
{
_min
[
k
]
=
std
::
numeric_limits
<
double
>::
max
()
;
...
...
@@ -115,7 +117,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
bool
is_in
=
true
;
for
(
int
i
=
0
;
i
<
dimX
();
++
i
)
{
if
(
v
[
i
]
<
min
||
v
[
i
]
>
max
)
if
(
v
[
i
]
<
min
[
i
]
||
v
[
i
]
>
max
[
i
]
)
{
is_in
=
false
;
}
...
...
sources/softs/brdf2gnuplot/main.cpp
View file @
92313844
...
...
@@ -53,6 +53,13 @@ int main(int argc, char** argv)
d
->
load
(
args
[
"data"
])
;
}
bool
plot_error
=
false
;
if
(
args
.
is_defined
(
"error"
))
{
std
::
cout
<<
"<<INFO>> Exporting an error plot"
<<
std
::
endl
;
plot_error
=
true
;
}
// Load the BRDF
f
->
load
(
args
[
"input"
]);
...
...
@@ -70,7 +77,13 @@ int main(int argc, char** argv)
file
<<
v
[
u
]
<<
"
\t
"
;
for
(
int
u
=
0
;
u
<
d
->
dimY
();
++
u
)
file
<<
y2
[
u
]
<<
"
\t
"
;
{
if
(
plot_error
)
{
file
<<
y2
[
u
]
<<
"
\t
"
;
}
else
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
/
v
[
d
->
dimX
()
+
u
]
<<
"
\t
"
;
}
}
file
<<
std
::
endl
;
}
...
...
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