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
8 // under the terms of the GNU Lesser General Public 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.
16 #include <IGESCAFControl.ixx>
18 //=======================================================================
19 //function : DecodeColor
21 //=======================================================================
23 Quantity_Color IGESCAFControl::DecodeColor (const Standard_Integer color)
26 case 1: return Quantity_Color ( Quantity_NOC_BLACK );
27 case 2: return Quantity_Color ( Quantity_NOC_RED );
28 case 3: return Quantity_Color ( Quantity_NOC_GREEN );
29 case 4: return Quantity_Color ( Quantity_NOC_BLUE1 );
30 case 5: return Quantity_Color ( Quantity_NOC_YELLOW );
31 case 6: return Quantity_Color ( Quantity_NOC_MAGENTA1 );
32 case 7: return Quantity_Color ( Quantity_NOC_CYAN1 );
34 default:return Quantity_Color ( Quantity_NOC_WHITE );
38 //=======================================================================
39 //function : DecodeColor
41 //=======================================================================
43 Standard_Integer IGESCAFControl::EncodeColor (const Quantity_Color &col)
45 Standard_Integer code = 0;
46 if ( Abs ( col.Red() - 1. ) <= col.Epsilon() ) code |= 0x001;
47 else if ( Abs ( col.Red() ) > col.Epsilon() ) return 0;
48 if ( Abs ( col.Green() - 1. ) <= col.Epsilon() ) code |= 0x010;
49 else if ( Abs ( col.Green() ) > col.Epsilon() ) return 0;
50 if ( Abs ( col.Blue() - 1. ) <= col.Epsilon() ) code |= 0x100;
51 else if ( Abs ( col.Blue() ) > col.Epsilon() ) return 0;