Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
vite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
vite
Commits
e686453b
Commit
e686453b
authored
7 years ago
by
Mathieu Faverge
Browse files
Options
Downloads
Patches
Plain Diff
First patch to fix issue with colors out of the range [0.,1.]
parent
a482a34e
No related branches found
No related tags found
1 merge request
!2
First patch to fix issue with colors out of the range [0.,1.]
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/Tools.cpp
+60
-61
60 additions, 61 deletions
src/common/Tools.cpp
src/trace/values/Color.cpp
+36
-8
36 additions, 8 deletions
src/trace/values/Color.cpp
src/trace/values/Color.hpp
+2
-0
2 additions, 0 deletions
src/trace/values/Color.hpp
with
98 additions
and
69 deletions
src/common/Tools.cpp
+
60
−
61
View file @
e686453b
/*
/*
** This file is part of the ViTE project.
** This file is part of the ViTE project.
**
**
** This software is governed by the CeCILL-A license under French law
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
** URL: "http://www.cecill.info".
**
**
** As a counterpart to the access to the source code and rights to copy,
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** the economic rights, and the successive licensors have only limited
** liability.
** liability.
**
**
** In this respect, the user's attention is drawn to the risks associated
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
** operate it in the same conditions as regards security.
**
**
** The fact that you are presently reading this means that you have had
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
**
**
** ViTE developers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
**
** - COULOMB Kevin
** - COULOMB Kevin
** - FAVERGE Mathieu
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - NOISETTE Pascal
** - REDONDY Arthur
** - REDONDY Arthur
** - VUCHENER Clément
** - VUCHENER Clément
**
**
*/
*/
#include
<cstdio>
#include
<cstdio>
#include
<iostream>
#include
<iostream>
...
@@ -66,27 +66,27 @@ bool convert_to_double(const std::string &arg, double *val) {
...
@@ -66,27 +66,27 @@ bool convert_to_double(const std::string &arg, double *val) {
}
}
else
{
// We change the locale to test
else
{
// We change the locale to test
bool
is_english_system_needed
=
false
;
// We have dot as separator of decimal and integer.
bool
is_english_system_needed
=
false
;
// We have dot as separator of decimal and integer.
if
(
arg
.
find
(
'.'
)
!=
string
::
npos
)
{
if
(
arg
.
find
(
'.'
)
!=
string
::
npos
)
{
is_english_system_needed
=
true
;
is_english_system_needed
=
true
;
}
}
// We had dots initially, we need to have the english system
// We had dots initially, we need to have the english system
if
(
is_english_system_needed
)
{
if
(
is_english_system_needed
)
{
if
((
setlocale
(
LC_NUMERIC
,
"C"
)
==
NULL
)
&&
if
((
setlocale
(
LC_NUMERIC
,
"C"
)
==
NULL
)
&&
(
setlocale
(
LC_NUMERIC
,
"en_GB.UTF-8"
)
==
NULL
)){
(
setlocale
(
LC_NUMERIC
,
"en_GB.UTF-8"
)
==
NULL
)){
vite_warning
(
"The locale en_GB.UTF-8 is unavailable so the decimal pointed will not be printed"
);
vite_warning
(
"The locale en_GB.UTF-8 is unavailable so the decimal pointed will not be printed"
);
}
}
}
}
else
{
// It is comma separated
else
{
// It is comma separated
if
((
setlocale
(
LC_NUMERIC
,
"fr_FR.UTF-8"
)
==
NULL
)
&&
if
((
setlocale
(
LC_NUMERIC
,
"fr_FR.UTF-8"
)
==
NULL
)
&&
(
setlocale
(
LC_NUMERIC
,
"French"
)
==
NULL
)){
(
setlocale
(
LC_NUMERIC
,
"French"
)
==
NULL
)){
vite_warning
(
"The locale fr_FR.UTF-8 is unavailable so the decimal with comma will not be printed"
);
vite_warning
(
"The locale fr_FR.UTF-8 is unavailable so the decimal with comma will not be printed"
);
}
}
}
}
// Reads the value in the new locale
// Reads the value in the new locale
sscanf
(
arg
.
c_str
(),
"%lf%n"
,
val
,
&
nb_read
);
sscanf
(
arg
.
c_str
(),
"%lf%n"
,
val
,
&
nb_read
);
return
nb_read
==
arg
.
size
();
return
nb_read
==
arg
.
size
();
...
@@ -99,17 +99,16 @@ double clockGet (void)
...
@@ -99,17 +99,16 @@ double clockGet (void)
// TODO
// TODO
return
0.
;
return
0.
;
#elif (defined X_ARCHalpha_compaq_osf1) || (defined X_ARCHi686_mac)
#elif (defined X_ARCHalpha_compaq_osf1) || (defined X_ARCHi686_mac)
struct
rusage
data
;
struct
rusage
data
;
getrusage
(
RUSAGE_SELF
,
&
data
);
getrusage
(
RUSAGE_SELF
,
&
data
);
return
(((
double
)
data
.
ru_utime
.
tv_sec
+
(
double
)
data
.
ru_stime
.
tv_sec
)
+
return
(((
double
)
data
.
ru_utime
.
tv_sec
+
(
double
)
data
.
ru_stime
.
tv_sec
)
+
((
double
)
data
.
ru_utime
.
tv_usec
+
(
double
)
data
.
ru_stime
.
tv_usec
)
*
((
double
)
data
.
ru_utime
.
tv_usec
+
(
double
)
data
.
ru_stime
.
tv_usec
)
*
1.0e-6L
);
1.0e-6L
);
#elif defined _POSIX_TIMERS && defined CLOCK_REALTIME
#elif defined _POSIX_TIMERS && defined CLOCK_REALTIME
struct
timespec
tp
;
struct
timespec
tp
;
clock_gettime
(
CLOCK_REALTIME
,
&
tp
);
/* Elapsed time */
clock_gettime
(
CLOCK_REALTIME
,
&
tp
);
/* Elapsed time */
return
((
double
)
tp
.
tv_sec
+
(
double
)
tp
.
tv_nsec
*
(
double
)
1.0e-9L
);
return
((
double
)
tp
.
tv_sec
+
(
double
)
tp
.
tv_nsec
*
(
double
)
1.0e-9L
);
#endif
#endif
}
}
This diff is collapsed.
Click to expand it.
src/trace/values/Color.cpp
+
36
−
8
View file @
e686453b
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
*/
*/
#include
<string>
#include
<string>
#include
<iostream>
#include
<sstream>
#include
<sstream>
#include
<iomanip>
// For std::setprecision
#include
<iomanip>
// For std::setprecision
#include
<cstdlib>
#include
<cstdlib>
...
@@ -53,14 +54,35 @@
...
@@ -53,14 +54,35 @@
using
namespace
std
;
using
namespace
std
;
Color
::
Color
()
:
_r
((
rand
()
%
256
)
/
256
),
double
_g
((
rand
()
%
256
)
/
256
),
Color
::
check_value
(
double
v
,
const
string
spectrum
)
_b
((
rand
()
%
256
)
/
256
)
{
{
if
(
v
<
0.
)
{
cerr
<<
"Invalid value for "
<<
spectrum
<<
" color "
<<
v
<<
" (must be between 0. and 1.)"
<<
endl
;
v
=
0.
;
}
/* Extra Test for StarPU bug in state color values */
if
(
v
>
1.
)
{
v
=
v
/
255.
;
}
if
(
v
>
1.
)
{
cerr
<<
"Invalid value for "
<<
spectrum
<<
" color "
<<
v
<<
" (must be between 0. and 1.)"
<<
endl
;
v
=
1.
;
}
return
v
;
}
Color
::
Color
()
:
_r
((
rand
()
%
256
)
/
255
),
_g
((
rand
()
%
256
)
/
255
),
_b
((
rand
()
%
256
)
/
255
)
{
_is_correct
=
true
;
_is_correct
=
true
;
}
}
Color
::
Color
(
double
r
,
double
g
,
double
b
)
:
_r
(
r
),
_g
(
g
),
_b
(
b
)
{
Color
::
Color
(
double
r
,
double
g
,
double
b
)
{
_r
=
Color
::
check_value
(
r
,
"red"
);
_g
=
Color
::
check_value
(
g
,
"green"
);
_b
=
Color
::
check_value
(
b
,
"blue"
);
_is_correct
=
true
;
_is_correct
=
true
;
}
}
...
@@ -72,7 +94,9 @@ Color::Color(const Color *c) : Value(*c), _r(c->_r), _g(c->_g), _b(c->_b) {
...
@@ -72,7 +94,9 @@ Color::Color(const Color *c) : Value(*c), _r(c->_r), _g(c->_g), _b(c->_b) {
_is_correct
=
c
->
_is_correct
;
_is_correct
=
c
->
_is_correct
;
}
}
Color
::
Color
(
const
std
::
string
&
in
)
{
Color
::
Color
(
const
std
::
string
&
in
)
{
double
r
,
g
,
b
;
string
separated_color
[
3
];
string
separated_color
[
3
];
string
temp
=
in
;
string
temp
=
in
;
...
@@ -82,9 +106,13 @@ Color::Color(const std::string &in) {
...
@@ -82,9 +106,13 @@ Color::Color(const std::string &in) {
temp
=
temp
.
substr
(
position_of_space
+
1
);
temp
=
temp
.
substr
(
position_of_space
+
1
);
}
}
_is_correct
=
convert_to_double
(
separated_color
[
0
],
&
_r
)
&&
_is_correct
=
convert_to_double
(
separated_color
[
0
],
&
r
)
&&
convert_to_double
(
separated_color
[
1
],
&
_g
)
&&
convert_to_double
(
separated_color
[
1
],
&
g
)
&&
convert_to_double
(
separated_color
[
2
],
&
_b
);
convert_to_double
(
separated_color
[
2
],
&
b
);
_r
=
Color
::
check_value
(
r
,
"red"
);
_g
=
Color
::
check_value
(
g
,
"green"
);
_b
=
Color
::
check_value
(
b
,
"blue"
);
}
}
std
::
string
Color
::
to_string
()
const
{
std
::
string
Color
::
to_string
()
const
{
...
...
This diff is collapsed.
Click to expand it.
src/trace/values/Color.hpp
+
2
−
0
View file @
e686453b
...
@@ -63,6 +63,8 @@ private :
...
@@ -63,6 +63,8 @@ private :
/*! blue value */
/*! blue value */
double
_b
;
double
_b
;
static
double
check_value
(
double
,
const
std
::
string
);
public:
public:
/*!
/*!
* \brief Constructor
* \brief Constructor
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment