b311480e |
1 | // Created on: 1991-04-23 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1991-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. |
b311480e |
16 | |
42cf5bc1 |
17 | #include <TopAbs.hxx> |
7fd59977 |
18 | |
d2e60688 |
19 | #include <TCollection_AsciiString.hxx> |
20 | |
21 | namespace |
22 | { |
23 | static Standard_CString TopAbs_Table_PrintShapeEnum[9] = |
24 | { |
25 | "COMPOUND","COMPSOLID","SOLID","SHELL","FACE","WIRE","EDGE","VERTEX","SHAPE" |
26 | }; |
27 | |
28 | static Standard_CString TopAbs_Table_PrintOrientation[4] = |
29 | { |
30 | "FORWARD","REVERSED","INTERNAL","EXTERNAL" |
31 | }; |
32 | } |
33 | |
34 | //======================================================================= |
35 | //function : ShapeTypeToString |
36 | //purpose : |
37 | //======================================================================= |
38 | Standard_CString TopAbs::ShapeTypeToString (TopAbs_ShapeEnum theType) |
39 | { |
40 | return TopAbs_Table_PrintShapeEnum[theType]; |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : ShapeTypeFromString |
45 | //purpose : |
46 | //======================================================================= |
47 | Standard_Boolean TopAbs::ShapeTypeFromString (Standard_CString theTypeString, |
48 | TopAbs_ShapeEnum& theType) |
49 | { |
50 | TCollection_AsciiString aName (theTypeString); |
51 | aName.UpperCase(); |
52 | for (Standard_Integer aTypeIter = 0; aTypeIter <= TopAbs_SHAPE; ++aTypeIter) |
53 | { |
54 | Standard_CString aTypeName = TopAbs_Table_PrintShapeEnum[aTypeIter]; |
55 | if (aName == aTypeName) |
56 | { |
57 | theType = TopAbs_ShapeEnum(aTypeIter); |
58 | return Standard_True; |
59 | } |
60 | } |
61 | return Standard_False; |
62 | } |
63 | |
64 | //======================================================================= |
65 | //function : ShapeOrientationToString |
66 | //purpose : |
67 | //======================================================================= |
68 | Standard_CString TopAbs::ShapeOrientationToString (TopAbs_Orientation theOrientation) |
69 | { |
70 | return TopAbs_Table_PrintOrientation[theOrientation]; |
71 | } |
72 | |
6822a3be |
73 | //======================================================================= |
74 | //function : ShapeOrientationFromString |
75 | //purpose : |
76 | //======================================================================= |
77 | Standard_Boolean TopAbs::ShapeOrientationFromString (const Standard_CString theOrientationString, |
78 | TopAbs_Orientation& theOrientation) |
79 | { |
80 | TCollection_AsciiString aName (theOrientationString); |
81 | aName.UpperCase(); |
82 | for (Standard_Integer anOrientationIter = 0; anOrientationIter <= TopAbs_EXTERNAL; ++anOrientationIter) |
83 | { |
84 | Standard_CString anOrientationName = TopAbs_Table_PrintOrientation[anOrientationIter]; |
85 | if (aName == anOrientationName) |
86 | { |
87 | theOrientation = TopAbs_Orientation(anOrientationIter); |
88 | return Standard_True; |
89 | } |
90 | } |
91 | return Standard_False; |
92 | } |
93 | |
7fd59977 |
94 | //======================================================================= |
95 | //function : TopAbs_Compose |
96 | //purpose : Compose two orientations |
97 | //======================================================================= |
7fd59977 |
98 | TopAbs_Orientation TopAbs::Compose(const TopAbs_Orientation O1, |
99 | const TopAbs_Orientation O2) |
100 | { |
101 | // see the composition table in the file TopAbs.cdl |
102 | static const TopAbs_Orientation TopAbs_Table_Compose[4][4] = |
103 | { |
104 | { TopAbs_FORWARD, TopAbs_REVERSED, TopAbs_INTERNAL, TopAbs_EXTERNAL }, |
105 | { TopAbs_REVERSED, TopAbs_FORWARD, TopAbs_INTERNAL, TopAbs_EXTERNAL }, |
106 | { TopAbs_INTERNAL, TopAbs_INTERNAL, TopAbs_INTERNAL, TopAbs_INTERNAL }, |
107 | { TopAbs_EXTERNAL, TopAbs_EXTERNAL, TopAbs_EXTERNAL, TopAbs_EXTERNAL } |
108 | }; |
109 | return TopAbs_Table_Compose[(Standard_Integer)O2][(Standard_Integer)O1]; |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : TopAbs::Reverse |
114 | //purpose : reverse an Orientation |
115 | //======================================================================= |
116 | |
117 | TopAbs_Orientation TopAbs::Reverse(const TopAbs_Orientation Ori) |
118 | { |
119 | static const TopAbs_Orientation TopAbs_Table_Reverse[4] = |
120 | { |
121 | TopAbs_REVERSED, TopAbs_FORWARD, TopAbs_INTERNAL, TopAbs_EXTERNAL |
122 | }; |
123 | return TopAbs_Table_Reverse[(Standard_Integer)Ori]; |
124 | } |
125 | |
126 | //======================================================================= |
127 | //function : TopAbs::Complement |
128 | //purpose : complement an Orientation |
129 | //======================================================================= |
130 | |
131 | TopAbs_Orientation TopAbs::Complement(const TopAbs_Orientation Ori) |
132 | { |
133 | static const TopAbs_Orientation TopAbs_Table_Complement[4] = |
134 | { |
135 | TopAbs_REVERSED, TopAbs_FORWARD, TopAbs_EXTERNAL, TopAbs_INTERNAL |
136 | }; |
137 | return TopAbs_Table_Complement[(Standard_Integer)Ori]; |
138 | } |
139 | |
7fd59977 |
140 | //======================================================================= |
141 | //function : TopAbs_Print |
142 | //purpose : print the name of a State on a stream. |
143 | //======================================================================= |
144 | |
145 | Standard_OStream& TopAbs::Print(const TopAbs_State st, |
146 | Standard_OStream& s) |
147 | { |
148 | static const Standard_CString TopAbs_Table_PrintState[4] = |
149 | { |
150 | "ON","IN","OUT","UNKNOWN" |
151 | }; |
152 | return (s << TopAbs_Table_PrintState[(Standard_Integer)st]); |
153 | } |