summaryrefslogtreecommitdiff
path: root/src/Aspect/Aspect_ColorPixel.cxx
blob: f0ddd4c74b9652a9b3bc71537fd718a6519f0562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <Aspect_ColorPixel.ixx>

Aspect_ColorPixel::Aspect_ColorPixel () {

  myColor.SetValues( 0.,0.,0. , Quantity_TOC_RGB ) ;

}

Aspect_ColorPixel::Aspect_ColorPixel (const Quantity_Color& aColor) {

  myColor = aColor;

}

const Quantity_Color& Aspect_ColorPixel::Value() const { 

return myColor;

}


void Aspect_ColorPixel::SetValue(const Quantity_Color& aColor) {

  myColor = aColor;

}

void Aspect_ColorPixel::Print(Standard_OStream& s) const

{ Standard_Real r,g,b ;

  myColor.Values( r,g,b, Quantity_TOC_RGB ) ;

  s << "( " << r << ", " << g << ", " << b << " )" << flush;
}

// ------------------------------------------------------------------
// Hascode : Computes a hascoding value for a given Aspect_ColorPixel
// ------------------------------------------------------------------
Standard_Integer Aspect_ColorPixel::HashCode(const Standard_Integer Upper) const
{ Standard_Real r,g,b ;
  Standard_Integer ret ;

  myColor.Values( r,g,b, Quantity_TOC_RGB ) ;

  ret = ( Standard_Integer ) ( ( r + g + b ) * Upper  ) ;

  return ( ret % Upper ) + 1 ;
}


Standard_Boolean Aspect_ColorPixel::IsEqual(const Aspect_ColorPixel& Other) const
{
  return (myColor == Other.myColor);
}

Standard_Boolean Aspect_ColorPixel::IsNotEqual(const Aspect_ColorPixel& Other) const
{
  return !IsEqual(Other);
}