0028646: Draw Harness, ViewerTest - rename vsetfilter command with vselfilter
[occt.git] / src / TopAbs / TopAbs.cxx
CommitLineData
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
21namespace
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//=======================================================================
38Standard_CString TopAbs::ShapeTypeToString (TopAbs_ShapeEnum theType)
39{
40 return TopAbs_Table_PrintShapeEnum[theType];
41}
42
43//=======================================================================
44//function : ShapeTypeFromString
45//purpose :
46//=======================================================================
47Standard_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//=======================================================================
68Standard_CString TopAbs::ShapeOrientationToString (TopAbs_Orientation theOrientation)
69{
70 return TopAbs_Table_PrintOrientation[theOrientation];
71}
72
7fd59977 73//=======================================================================
74//function : TopAbs_Compose
75//purpose : Compose two orientations
76//=======================================================================
7fd59977 77TopAbs_Orientation TopAbs::Compose(const TopAbs_Orientation O1,
78 const TopAbs_Orientation O2)
79{
80 // see the composition table in the file TopAbs.cdl
81 static const TopAbs_Orientation TopAbs_Table_Compose[4][4] =
82 {
83 { TopAbs_FORWARD, TopAbs_REVERSED, TopAbs_INTERNAL, TopAbs_EXTERNAL },
84 { TopAbs_REVERSED, TopAbs_FORWARD, TopAbs_INTERNAL, TopAbs_EXTERNAL },
85 { TopAbs_INTERNAL, TopAbs_INTERNAL, TopAbs_INTERNAL, TopAbs_INTERNAL },
86 { TopAbs_EXTERNAL, TopAbs_EXTERNAL, TopAbs_EXTERNAL, TopAbs_EXTERNAL }
87 };
88 return TopAbs_Table_Compose[(Standard_Integer)O2][(Standard_Integer)O1];
89}
90
91//=======================================================================
92//function : TopAbs::Reverse
93//purpose : reverse an Orientation
94//=======================================================================
95
96TopAbs_Orientation TopAbs::Reverse(const TopAbs_Orientation Ori)
97{
98 static const TopAbs_Orientation TopAbs_Table_Reverse[4] =
99 {
100 TopAbs_REVERSED, TopAbs_FORWARD, TopAbs_INTERNAL, TopAbs_EXTERNAL
101 };
102 return TopAbs_Table_Reverse[(Standard_Integer)Ori];
103}
104
105//=======================================================================
106//function : TopAbs::Complement
107//purpose : complement an Orientation
108//=======================================================================
109
110TopAbs_Orientation TopAbs::Complement(const TopAbs_Orientation Ori)
111{
112 static const TopAbs_Orientation TopAbs_Table_Complement[4] =
113 {
114 TopAbs_REVERSED, TopAbs_FORWARD, TopAbs_EXTERNAL, TopAbs_INTERNAL
115 };
116 return TopAbs_Table_Complement[(Standard_Integer)Ori];
117}
118
7fd59977 119//=======================================================================
120//function : TopAbs_Print
121//purpose : print the name of a State on a stream.
122//=======================================================================
123
124Standard_OStream& TopAbs::Print(const TopAbs_State st,
125 Standard_OStream& s)
126{
127 static const Standard_CString TopAbs_Table_PrintState[4] =
128 {
129 "ON","IN","OUT","UNKNOWN"
130 };
131 return (s << TopAbs_Table_PrintState[(Standard_Integer)st]);
132}