blob: 5d91791e3815f37ab011bf40682d577117c117c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// File: IGESCAFControl.cxx
// Created: Wed Aug 16 18:46:01 2000
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <IGESCAFControl.ixx>
//=======================================================================
//function : DecodeColor
//purpose :
//=======================================================================
Quantity_Color IGESCAFControl::DecodeColor (const Standard_Integer color)
{
switch ( color ) {
case 1: return Quantity_Color ( Quantity_NOC_BLACK );
case 2: return Quantity_Color ( Quantity_NOC_RED );
case 3: return Quantity_Color ( Quantity_NOC_GREEN );
case 4: return Quantity_Color ( Quantity_NOC_BLUE1 );
case 5: return Quantity_Color ( Quantity_NOC_YELLOW );
case 6: return Quantity_Color ( Quantity_NOC_MAGENTA1 );
case 7: return Quantity_Color ( Quantity_NOC_CYAN1 );
case 8:
default:return Quantity_Color ( Quantity_NOC_WHITE );
}
}
//=======================================================================
//function : DecodeColor
//purpose :
//=======================================================================
Standard_Integer IGESCAFControl::EncodeColor (const Quantity_Color &col)
{
Standard_Integer code = 0;
if ( Abs ( col.Red() - 1. ) <= col.Epsilon() ) code |= 0x001;
else if ( Abs ( col.Red() ) > col.Epsilon() ) return 0;
if ( Abs ( col.Green() - 1. ) <= col.Epsilon() ) code |= 0x010;
else if ( Abs ( col.Green() ) > col.Epsilon() ) return 0;
if ( Abs ( col.Blue() - 1. ) <= col.Epsilon() ) code |= 0x100;
else if ( Abs ( col.Blue() ) > col.Epsilon() ) return 0;
switch ( code ) {
case 0x000: return 1;
case 0x001: return 2;
case 0x010: return 3;
case 0x100: return 4;
case 0x011: return 5;
case 0x101: return 6;
case 0x110: return 7;
case 0x111:
default : return 8;
}
}
|