blob: bf5cd2abf309271393a5af2f5a48e76b0cd0bd98 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
#include <StepData_HeaderTool.ixx>
#include <Interface_ReaderLib.hxx>
#include <Interface_Protocol.hxx>
// HeaderTool prend en charge le Schema de Donnees utilise pour un Fichier
// Ce Schema peut etre compose de un ou plusieurs Protocoles, chacun etant
// designe par une String. Les Strings correspondent au type "SCHEMA_NAME"
// (typedef) et le Schema est une entite de Header de type "FILE_SCHEMA",
// il a cette forme dans le fichier :
// FILE_SCHEMA ( ( 'NAME_1' [, 'NAME_2' ...] ) );
static Interface_ReaderLib lib;
StepData_HeaderTool::StepData_HeaderTool
(const Handle(StepData_StepReaderData)& data)
{
lib.SetComplete();
thedone = Standard_False;
Standard_Integer num = 0;
while ( (num = data->FindNextRecord(num)) != 0) {
const TCollection_AsciiString& headertype = data->RecordType(num);
if (headertype == "FILE_SCHEMA") {
Standard_Integer numsub = data->SubListNumber(num,1,Standard_True);
Standard_Integer nb = data->NbParams(numsub);
for (Standard_Integer i = 1; i <= nb; i ++) {
TCollection_AsciiString unom = data->ParamCValue(numsub,i);
unom.Remove(unom.Length());
unom.Remove(1); // quotes debut et fin
thenames.Append(unom);
}
}
}
}
StepData_HeaderTool::StepData_HeaderTool
(const TColStd_SequenceOfAsciiString& names)
{
lib.SetComplete();
thedone = Standard_False;
Standard_Integer nb = names.Length();
for (Standard_Integer i = 1; i <= nb; i ++) thenames.Append(names.Value(i));
}
Standard_Integer StepData_HeaderTool::NbSchemaNames () const
{ return thenames.Length(); }
const TCollection_AsciiString& StepData_HeaderTool::SchemaName
(const Standard_Integer num) const
{ return thenames.Value(num); }
Handle(StepData_Protocol) StepData_HeaderTool::NamedProtocol
(const TCollection_AsciiString& name) const
{
Handle(StepData_Protocol) proto;
for (lib.Start(); lib.More(); lib.Next()) {
proto = Handle(StepData_Protocol)::DownCast(lib.Protocol());
if ( name.IsEqual(proto->SchemaName()) ) return proto;
}
return proto;
}
void StepData_HeaderTool::Build
(const Handle(StepData_FileProtocol)& proto)
{
thedone = Standard_True;
theignored.Clear();
Standard_Integer nb = thenames.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(StepData_Protocol) unproto = NamedProtocol(thenames.Value(i));
if (unproto.IsNull()) theignored.Append(thenames.Value(i));
else proto->Add(unproto);
}
}
Handle(StepData_Protocol) StepData_HeaderTool::Protocol ()
{
thedone = Standard_True;
theignored.Clear();
Handle(StepData_Protocol) unproto;
if (thenames.IsEmpty()) return unproto;
if (thenames.Length() == 1) {
unproto = NamedProtocol (thenames.Value(1));
if (unproto.IsNull()) theignored.Append (thenames.Value(1));
return unproto;
}
Handle(StepData_FileProtocol) proto = new StepData_FileProtocol;
Build(proto);
return proto;
}
Standard_Boolean StepData_HeaderTool::IsDone () const
{ return thedone; }
Standard_Integer StepData_HeaderTool::NbIgnoreds () const
{ return theignored.Length(); }
const TCollection_AsciiString& StepData_HeaderTool::Ignored
(const Standard_Integer num) const
{ return theignored.Value(num); }
void StepData_HeaderTool::Print (Standard_OStream& S) const
{
Standard_Integer nb = thenames.Length();
Standard_Integer lng = 0; Standard_Integer ln1;
S << " --- StepData_HeaderTool : List of Protocol Names --- Count : "
<< nb << endl;
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= nb; i ++) {
ln1 = thenames.Value(i).Length() + 8; lng += ln1;
if (lng > 80) { S << endl; lng = ln1; }
S << " " << i << " : " << thenames.Value(i);
}
if (lng == 0) S << endl;
nb = theignored.Length();
if (!thedone) {
S << " --- Evaluation of Protocol not Done ---" << endl;
} else if (nb == 0) {
S << " --- All Names correspond to a known Protocol ---" << endl;
} else {
lng = ln1 = 0;
S << " --- Among them, " << nb << " remain unrecognized ---" << endl;
for (i = 1; i <= nb; i ++) {
ln1 = theignored.Value(i).Length() + 3; lng += ln1;
if (lng > 80) { S << endl; lng = ln1; }
S << " : " << theignored.Value(i);
}
if (lng == 0) S << endl;
}
}
|