1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <Aspect_ColorPixel.ixx>
17 Aspect_ColorPixel::Aspect_ColorPixel () {
19 myColor.SetValues( 0.,0.,0. , Quantity_TOC_RGB ) ;
23 Aspect_ColorPixel::Aspect_ColorPixel (const Quantity_Color& aColor) {
29 const Quantity_Color& Aspect_ColorPixel::Value() const {
36 void Aspect_ColorPixel::SetValue(const Quantity_Color& aColor) {
42 void Aspect_ColorPixel::Print(Standard_OStream& s) const
44 { Standard_Real r,g,b ;
46 myColor.Values( r,g,b, Quantity_TOC_RGB ) ;
48 s << "( " << r << ", " << g << ", " << b << " )" << flush;
51 // ------------------------------------------------------------------
52 // Hascode : Computes a hascoding value for a given Aspect_ColorPixel
53 // ------------------------------------------------------------------
54 Standard_Integer Aspect_ColorPixel::HashCode(const Standard_Integer Upper) const
55 { Standard_Real r,g,b ;
56 Standard_Integer ret ;
58 myColor.Values( r,g,b, Quantity_TOC_RGB ) ;
60 ret = ( Standard_Integer ) ( ( r + g + b ) * Upper ) ;
62 return ( ret % Upper ) + 1 ;
66 Standard_Boolean Aspect_ColorPixel::IsEqual(const Aspect_ColorPixel& Other) const
68 return (myColor == Other.myColor);
71 Standard_Boolean Aspect_ColorPixel::IsNotEqual(const Aspect_ColorPixel& Other) const
73 return !IsEqual(Other);