0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / StepData / StepData_PDescr.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
973c2be1 5// This library is free software; you can redistribute it and / or modify it
6// under the terms of the GNU Lesser General Public version 2.1 as published
7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <StepData_PDescr.ixx>
15
16#define KindInteger 1
17#define KindBoolean 2
18#define KindLogical 3
19#define KindEnum 4
20#define KindReal 5
21#define KindString 6
22#define KindEntity 7
23
b311480e 24StepData_PDescr::StepData_PDescr ()
7fd59977 25 : thesel (0), thekind (0), thearit (0),
26 theopt (Standard_False), theder (Standard_False), thefnum (0)
27 { }
28
29 void StepData_PDescr::SetName (const Standard_CString name)
30 { thename.Clear(); thename.AssignCat (name); }
31
32 Standard_CString StepData_PDescr::Name () const
33 { return thename.ToCString(); }
34
35 Standard_Integer StepData_PDescr::Kind () const
36 { return thekind; }
37
38 void StepData_PDescr::SetSelect ()
39 { thesel = 4; }
40
41 void StepData_PDescr::AddMember (const Handle(StepData_PDescr)& member)
42{
43 if (member.IsNull()) return;
44 if (thenext.IsNull()) thenext = member;
45 else thenext->AddMember (member);
46 if (thesel == 3) return;
47 if (thekind < KindEntity && thenext->Kind() >= KindEntity) thesel = 3;
48 else if (thekind < KindEntity && (thesel == 2 || thesel == 4)) thesel = 3;
49 else if (thekind >= KindEntity && (thesel == 1 || thesel == 4)) thesel = 2;
50}
51
52 void StepData_PDescr::SetMemberName (const Standard_CString memname)
53 { thesnam.Clear(); thesnam.AssignCat (memname); }
54
55 void StepData_PDescr::SetInteger ()
56 { thekind = KindInteger; }
57
58 void StepData_PDescr::SetReal ()
59 { thekind = KindReal; }
60
61 void StepData_PDescr::SetString ()
62 { thekind = KindString; }
63
64 void StepData_PDescr::SetBoolean ()
65 { thekind = KindBoolean; }
66
67 void StepData_PDescr::SetLogical ()
68 { thekind = KindLogical; }
69
70 void StepData_PDescr::SetEnum ()
71 { thekind = KindEnum; }
72
73 void StepData_PDescr::AddEnumDef (const Standard_CString enumdef)
74 { theenum.AddDefinition (enumdef); }
75
76 void StepData_PDescr::SetType (const Handle(Standard_Type)& atype)
77 { thekind = KindEntity; thetype = atype; thednam.Clear(); }
78
79 void StepData_PDescr::SetDescr (const Standard_CString dscnam)
80 { thekind = KindEntity; thetype.Nullify();
81 thednam.Clear(); thednam.AssignCat(dscnam); }
82
83 void StepData_PDescr::AddArity (const Standard_Integer arity)
84 { thearit += arity; }
85
86 void StepData_PDescr::SetArity (const Standard_Integer arity)
87 { thearit = arity; }
88
89
90 void StepData_PDescr::SetFrom (const Handle(StepData_PDescr)& other)
91{
92 if (other.IsNull()) return;
93 thekind = other->Kind();
94 Standard_Integer i, maxenum = other->EnumMax ();
95 for (i = 0; i <= maxenum; i ++) AddEnumDef (other->EnumText(i));
96// ne sont pas reprises : les SELECT
97 thetype = other->Type();
98 thearit = other->Arity();
99 thefrom = other;
100 theopt = other->IsOptional ();
101 theder = other->IsDerived ();
102 thefnam.Clear(); thefnam.AssignCat (other->FieldName());
103 thefnum = other->FieldRank ();
104}
105
106 void StepData_PDescr::SetOptional (const Standard_Boolean opt)
107 { theopt = opt; }
108
109 void StepData_PDescr::SetDerived (const Standard_Boolean der)
110 { theder = der; }
111
112 void StepData_PDescr::SetField
113 (const Standard_CString name, const Standard_Integer rank)
114{
115 thefnam.Clear(); thefnam.AssignCat (name);
116 thefnum = rank;
117}
118
119// ###### INTERRO ######
120
121 Standard_Boolean StepData_PDescr::IsSelect () const
122{
123 if (!thefrom.IsNull()) return thefrom->IsSelect();
124 return (thesel > 0);
125}
126
127 Handle(StepData_PDescr) StepData_PDescr::Member (const Standard_CString name) const
128{
129 if (!thefrom.IsNull()) return thefrom->Member (name);
130 Handle(StepData_PDescr) descr;
131 if (thesnam.IsEqual (name)) return this;
132 if (thenext.IsNull()) return descr; // null
133 return thenext->Member (name);
134}
135
136 Standard_Boolean StepData_PDescr::IsInteger () const
137 { return (thekind == KindInteger); }
138
139 Standard_Boolean StepData_PDescr::IsReal () const
140 { return (thekind == KindReal); }
141
142 Standard_Boolean StepData_PDescr::IsString () const
143 { return (thekind == KindString); }
144
145 Standard_Boolean StepData_PDescr::IsBoolean () const
146 { return (thekind == KindBoolean || thekind == KindLogical); }
147
148 Standard_Boolean StepData_PDescr::IsLogical () const
149 { return (thekind == KindLogical); }
150
151 Standard_Boolean StepData_PDescr::IsEnum () const
152 { return (thekind == KindEnum); }
153
154 Standard_Integer StepData_PDescr::EnumMax () const
155 { return theenum.MaxValue(); }
156
157 Standard_Integer StepData_PDescr::EnumValue (const Standard_CString name) const
158 { return theenum.Value (name); }
159
160 Standard_CString StepData_PDescr::EnumText (const Standard_Integer val) const
161 { return theenum.Text (val).ToCString(); }
162
163 Standard_Boolean StepData_PDescr::IsEntity () const
164 { return (thekind == KindEntity); }
165
166 Standard_Boolean StepData_PDescr::IsType (const Handle(Standard_Type)& atype) const
167{
168 if (atype.IsNull()) return Standard_False;
169 if (!thetype.IsNull()) {
170 if (atype->SubType(thetype)) return Standard_True;
171 }
172 if (!thenext.IsNull()) return thenext->IsType(atype);
173 if (!thefrom.IsNull()) return thefrom->IsType(atype);
174 return Standard_False;
175}
176
177 Handle(Standard_Type) StepData_PDescr::Type () const
178 { return thetype; }
179
180 Standard_Boolean StepData_PDescr::IsDescr
181 (const Handle(StepData_EDescr)& descr) const
182{
183 if (descr.IsNull()) return Standard_False;
184 if (thednam.Length() > 0) {
185 if (descr->Matches (thednam.ToCString())) return Standard_True;
186 }
187 if (!thenext.IsNull()) return thenext->IsDescr (descr);
188 if (!thefrom.IsNull()) return thefrom->IsDescr (descr);
189 return Standard_False;
190}
191
192 Standard_CString StepData_PDescr::DescrName () const
193 { return thednam.ToCString(); }
194
195
196 Standard_Integer StepData_PDescr::Arity () const
197 { return thearit; }
198
199 Handle(StepData_PDescr) StepData_PDescr::Simple () const
200{
201 if (thearit == 0) return this;
202 if (thefrom.IsNull()) return this;
203 return thefrom;
204}
205
206 Standard_Boolean StepData_PDescr::IsOptional () const
207 { return theopt; }
208
209 Standard_Boolean StepData_PDescr::IsDerived () const
210 { return theder; }
211
212 Standard_Boolean StepData_PDescr::IsField () const
213 { return (thefnum > 0); }
214
215 Standard_CString StepData_PDescr::FieldName () const
216 { return thefnam.ToCString (); }
217
218 Standard_Integer StepData_PDescr::FieldRank () const
219 { return thefnum; }
220
221
35e08fe8 222void StepData_PDescr::Check(const StepData_Field& /*afild*/,
302f96fb 223 Handle(Interface_Check)& /*ach*/) const
7fd59977 224{
225// pour l instant ...
226}