Skip to content

Commit

Permalink
consistent color renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Nov 14, 2023
1 parent 9eac298 commit 474aa24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions include/vclib/io/mesh/stl/load.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool isStlColored(std::ifstream& fp, bool& magicsMode)
fp.seekg(fdataSize, std::ios::cur);
unsigned short attr = io::readShort<unsigned short>(fp);
Color c;
c.setFromUnsignedR5G5B5(attr);
c.setUnsignedR5G5B5(attr);
if (c != Color::White)
colored = true;
}
Expand Down Expand Up @@ -159,9 +159,9 @@ void readStlBin(
if (isPerFaceColorAvailable(m) && colored) {
Color c;
if (magicsMode)
c.setFromUnsignedR5G5B5(attr);
c.setUnsignedR5G5B5(attr);
else
c.setFromUnsignedB5G5R5(attr);
c.setUnsignedB5G5R5(attr);
f.color() = c;
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/vclib/io/mesh/stl/save.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ void saveStl(
if constexpr (HasPerFaceColor<MeshType>) {
if (meshInfo.hasFaceColors()) {
if (magicsMode)
attributes = 32768 | f.color().toUnsignedR5G5B5();
attributes = 32768 | f.color().unsignedR5G5B5();
else
attributes = 32768 | f.color().toUnsignedB5G5R5();
attributes = 32768 | f.color().unsignedB5G5R5();
}
}

Expand Down
14 changes: 8 additions & 6 deletions include/vclib/space/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ namespace vcl {
* @brief The Color class represents a RGBA color.
*
* The class is a specialization of the Point4 class, where each component is an
* unsigned char. The class provides some useful methods to convert the color
* unsigned char (0, 1, 2, 3 are respectively the red, green, blue and alpha).
*
* The class provides some useful methods to convert the color
* from/to different formats.
*
* @ingroup space
Expand All @@ -47,7 +49,7 @@ class Color : public Point4<uint8_t>
*
* It can be used to initialize a color with an RGBA integer.
*/
enum ColorRGBA {
enum ColorRGBA : uint32_t {
Black = 0x000000ff,
DarkGray = 0x404040ff,
Gray = 0x808080ff,
Expand Down Expand Up @@ -249,7 +251,7 @@ class Color : public Point4<uint8_t>
*
* @return an unsigned short containing the converted color.
*/
unsigned short toUnsignedR5G5B5() const
unsigned short unsignedR5G5B5() const
{
unsigned short r = x() / 8;
unsigned short g = y() / 8;
Expand All @@ -263,7 +265,7 @@ class Color : public Point4<uint8_t>
*
* @return an unsigned short containing the converted color.
*/
unsigned short toUnsignedB5G5R5() const
unsigned short unsignedB5G5R5() const
{
unsigned short r = x() / 8;
unsigned short g = y() / 8;
Expand Down Expand Up @@ -452,7 +454,7 @@ class Color : public Point4<uint8_t>
*
* @param[in] val: The unsigned 5-5-5 RGB value to set.
*/
void setFromUnsignedR5G5B5(unsigned short val)
void setUnsignedR5G5B5(unsigned short val)
{
x() = val % 32 * 8;
y() = ((val / 32) % 32) * 8;
Expand All @@ -473,7 +475,7 @@ class Color : public Point4<uint8_t>
*
* @param[in] val: The unsigned 5-5-5 BGR value to set.
*/
void setFromUnsignedB5G5R5(unsigned short val)
void setUnsignedB5G5R5(unsigned short val)
{
z() = val % 32 * 8;
y() = ((val / 32) % 32) * 8;
Expand Down

0 comments on commit 474aa24

Please sign in to comment.