0024428: Implementation of LGPL license
[occt.git] / src / Aspect / Aspect_ColorPixel.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
973c2be1 6// This library is free software; you can redistribute it and / or modify it
7// under the terms of the GNU Lesser General Public version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15#include <Aspect_ColorPixel.ixx>
16
17Aspect_ColorPixel::Aspect_ColorPixel () {
18
19 myColor.SetValues( 0.,0.,0. , Quantity_TOC_RGB ) ;
20
21}
22
23Aspect_ColorPixel::Aspect_ColorPixel (const Quantity_Color& aColor) {
24
25 myColor = aColor;
26
27}
28
29const Quantity_Color& Aspect_ColorPixel::Value() const {
30
31return myColor;
32
33}
34
35
36void Aspect_ColorPixel::SetValue(const Quantity_Color& aColor) {
37
38 myColor = aColor;
39
40}
41
42void Aspect_ColorPixel::Print(Standard_OStream& s) const
43
44{ Standard_Real r,g,b ;
45
46 myColor.Values( r,g,b, Quantity_TOC_RGB ) ;
47
48 s << "( " << r << ", " << g << ", " << b << " )" << flush;
49}
50
51// ------------------------------------------------------------------
52// Hascode : Computes a hascoding value for a given Aspect_ColorPixel
53// ------------------------------------------------------------------
54Standard_Integer Aspect_ColorPixel::HashCode(const Standard_Integer Upper) const
55{ Standard_Real r,g,b ;
56 Standard_Integer ret ;
57
58 myColor.Values( r,g,b, Quantity_TOC_RGB ) ;
59
60 ret = ( Standard_Integer ) ( ( r + g + b ) * Upper ) ;
61
62 return ( ret % Upper ) + 1 ;
63}
64
65
66Standard_Boolean Aspect_ColorPixel::IsEqual(const Aspect_ColorPixel& Other) const
67{
68 return (myColor == Other.myColor);
69}
70
71Standard_Boolean Aspect_ColorPixel::IsNotEqual(const Aspect_ColorPixel& Other) const
72{
73 return !IsEqual(Other);
74}