b311480e |
1 | // Created on: 2000-08-16 |
2 | // Created by: Andrey BETENEV |
3 | // Copyright (c) 2000-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | #include <IGESCAFControl.ixx> |
22 | |
23 | //======================================================================= |
24 | //function : DecodeColor |
25 | //purpose : |
26 | //======================================================================= |
27 | |
28 | Quantity_Color IGESCAFControl::DecodeColor (const Standard_Integer color) |
29 | { |
30 | switch ( color ) { |
31 | case 1: return Quantity_Color ( Quantity_NOC_BLACK ); |
32 | case 2: return Quantity_Color ( Quantity_NOC_RED ); |
33 | case 3: return Quantity_Color ( Quantity_NOC_GREEN ); |
34 | case 4: return Quantity_Color ( Quantity_NOC_BLUE1 ); |
35 | case 5: return Quantity_Color ( Quantity_NOC_YELLOW ); |
36 | case 6: return Quantity_Color ( Quantity_NOC_MAGENTA1 ); |
37 | case 7: return Quantity_Color ( Quantity_NOC_CYAN1 ); |
38 | case 8: |
39 | default:return Quantity_Color ( Quantity_NOC_WHITE ); |
40 | } |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : DecodeColor |
45 | //purpose : |
46 | //======================================================================= |
47 | |
48 | Standard_Integer IGESCAFControl::EncodeColor (const Quantity_Color &col) |
49 | { |
50 | Standard_Integer code = 0; |
51 | if ( Abs ( col.Red() - 1. ) <= col.Epsilon() ) code |= 0x001; |
52 | else if ( Abs ( col.Red() ) > col.Epsilon() ) return 0; |
53 | if ( Abs ( col.Green() - 1. ) <= col.Epsilon() ) code |= 0x010; |
54 | else if ( Abs ( col.Green() ) > col.Epsilon() ) return 0; |
55 | if ( Abs ( col.Blue() - 1. ) <= col.Epsilon() ) code |= 0x100; |
56 | else if ( Abs ( col.Blue() ) > col.Epsilon() ) return 0; |
57 | |
58 | switch ( code ) { |
59 | case 0x000: return 1; |
60 | case 0x001: return 2; |
61 | case 0x010: return 3; |
62 | case 0x100: return 4; |
63 | case 0x011: return 5; |
64 | case 0x101: return 6; |
65 | case 0x110: return 7; |
66 | case 0x111: |
67 | default : return 8; |
68 | } |
69 | } |