b311480e |
1 | // Created on: 1998-06-10 |
2 | // Created by: data exchange team |
3 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
ee5befae |
17 | #include <ShapeExtend.hxx> |
42cf5bc1 |
18 | |
7fd59977 |
19 | #include <Message_MsgFile.hxx> |
ee5befae |
20 | #include <Standard_ProgramError.hxx> |
21 | #include <TCollection_AsciiString.hxx> |
22 | |
23 | #include "../SHMessage/SHMessage_SHAPE_us.pxx" |
7fd59977 |
24 | |
25 | //======================================================================= |
26 | //function : Init |
27 | //purpose : |
28 | //======================================================================= |
7fd59977 |
29 | void ShapeExtend::Init() |
30 | { |
31 | static Standard_Boolean init = Standard_False; |
32 | if (init) return; |
33 | |
34 | init = Standard_True; |
35 | |
36 | // load Message File for Shape Healing |
ee5befae |
37 | if (!Message_MsgFile::HasMsg ("ShapeFix.FixSmallSolid.MSG0")) |
38 | { |
39 | if (!Message_MsgFile::LoadFromEnv ("CSF_SHMessage", "SHAPE")) |
40 | { |
41 | Message_MsgFile::LoadFromString (SHMessage_SHAPE_us, sizeof(SHMessage_SHAPE_us) - 1); |
42 | } |
43 | if (!Message_MsgFile::HasMsg ("ShapeFix.FixSmallSolid.MSG0")) |
44 | { |
9775fa61 |
45 | throw Standard_ProgramError("Critical Error - message resources for ShapeExtend are invalid or undefined!"); |
ee5befae |
46 | } |
47 | } |
7fd59977 |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : EncodeStatus |
52 | //purpose : |
53 | //======================================================================= |
54 | |
55 | Standard_Integer ShapeExtend::EncodeStatus (const ShapeExtend_Status status) |
56 | { |
57 | switch ( status ) { |
58 | case ShapeExtend_OK : return 0x0000; |
59 | case ShapeExtend_DONE1: return 0x0001; |
60 | case ShapeExtend_DONE2: return 0x0002; |
61 | case ShapeExtend_DONE3: return 0x0004; |
62 | case ShapeExtend_DONE4: return 0x0008; |
63 | case ShapeExtend_DONE5: return 0x0010; |
64 | case ShapeExtend_DONE6: return 0x0020; |
65 | case ShapeExtend_DONE7: return 0x0040; |
66 | case ShapeExtend_DONE8: return 0x0080; |
67 | case ShapeExtend_DONE : return 0x00ff; |
68 | case ShapeExtend_FAIL1: return 0x0100; |
69 | case ShapeExtend_FAIL2: return 0x0200; |
70 | case ShapeExtend_FAIL3: return 0x0400; |
71 | case ShapeExtend_FAIL4: return 0x0800; |
72 | case ShapeExtend_FAIL5: return 0x1000; |
73 | case ShapeExtend_FAIL6: return 0x2000; |
74 | case ShapeExtend_FAIL7: return 0x4000; |
75 | case ShapeExtend_FAIL8: return 0x8000; |
76 | case ShapeExtend_FAIL : return 0xff00; |
77 | } |
78 | return 0; |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : DecodeStatus |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | Standard_Boolean ShapeExtend::DecodeStatus (const Standard_Integer flag, |
87 | const ShapeExtend_Status status) |
88 | { |
89 | if ( status == ShapeExtend_OK ) return ( flag == 0 ); |
90 | return ( flag & ShapeExtend::EncodeStatus ( status ) ? Standard_True : Standard_False ); |
91 | } |