1 // Created on: 2000-08-16
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <IGESCAFControl.hxx>
18 #include <Quantity_Color.hxx>
20 //=======================================================================
21 //function : DecodeColor
23 //=======================================================================
24 Quantity_Color IGESCAFControl::DecodeColor (const Standard_Integer color)
27 case 1: return Quantity_Color ( Quantity_NOC_BLACK );
28 case 2: return Quantity_Color ( Quantity_NOC_RED );
29 case 3: return Quantity_Color ( Quantity_NOC_GREEN );
30 case 4: return Quantity_Color ( Quantity_NOC_BLUE1 );
31 case 5: return Quantity_Color ( Quantity_NOC_YELLOW );
32 case 6: return Quantity_Color ( Quantity_NOC_MAGENTA1 );
33 case 7: return Quantity_Color ( Quantity_NOC_CYAN1 );
35 default:return Quantity_Color ( Quantity_NOC_WHITE );
39 //=======================================================================
40 //function : DecodeColor
42 //=======================================================================
44 Standard_Integer IGESCAFControl::EncodeColor (const Quantity_Color &col)
46 Standard_Integer code = 0;
47 if ( Abs ( col.Red() - 1. ) <= col.Epsilon() ) code |= 0x001;
48 else if ( Abs ( col.Red() ) > col.Epsilon() ) return 0;
49 if ( Abs ( col.Green() - 1. ) <= col.Epsilon() ) code |= 0x010;
50 else if ( Abs ( col.Green() ) > col.Epsilon() ) return 0;
51 if ( Abs ( col.Blue() - 1. ) <= col.Epsilon() ) code |= 0x100;
52 else if ( Abs ( col.Blue() ) > col.Epsilon() ) return 0;