0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / RWHeaderSection / RWHeaderSection_ReadWriteModule.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//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 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
7fd59977 15#include <HeaderSection_FileDescription.hxx>
42cf5bc1 16#include <HeaderSection_FileName.hxx>
7fd59977 17#include <HeaderSection_FileSchema.hxx>
42cf5bc1 18#include <HeaderSection_Protocol.hxx>
42cf5bc1 19#include <Interface_Macros.hxx>
42cf5bc1 20#include <Interface_ReaderLib.hxx>
21#include <RWHeaderSection_ReadWriteModule.hxx>
7fd59977 22#include <RWHeaderSection_RWFileDescription.hxx>
42cf5bc1 23#include <RWHeaderSection_RWFileName.hxx>
7fd59977 24#include <RWHeaderSection_RWFileSchema.hxx>
42cf5bc1 25#include <Standard_Transient.hxx>
26#include <Standard_Type.hxx>
27#include <StepData_StepReaderData.hxx>
28#include <StepData_StepWriter.hxx>
29#include <StepData_UndefinedEntity.hxx>
30#include <StepData_WriterLib.hxx>
31#include <TCollection_AsciiString.hxx>
7fd59977 32
92efcf78 33IMPLEMENT_STANDARD_RTTIEXT(RWHeaderSection_ReadWriteModule,StepData_ReadWriteModule)
34
b311480e 35// -- General Declarations (Recognize, StepType) ---
7fd59977 36static TCollection_AsciiString PasReco(""); // neutralise StartEntity de SW
37static TCollection_AsciiString Reco_FileName ("FILE_NAME");
38static TCollection_AsciiString Reco_FileDescription ("FILE_DESCRIPTION");
39static TCollection_AsciiString Reco_FileSchema ("FILE_SCHEMA");
40
41 // -- Definition of the libraries --
42
43RWHeaderSection_ReadWriteModule::RWHeaderSection_ReadWriteModule ()
44{
45 Handle(HeaderSection_Protocol) protocol = new HeaderSection_Protocol;
46 StepData_WriterLib::SetGlobal(this,protocol);
47 Interface_ReaderLib::SetGlobal(this,protocol);
48}
49
50 // --- Case Recognition ---
51
52Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep
53 (const TCollection_AsciiString& key) const
54{
55 if (key.IsEqual(Reco_FileName)) return 1;
56 if (key.IsEqual(Reco_FileDescription)) return 2;
57 if (key.IsEqual(Reco_FileSchema)) return 3;
58return 0;
59}
60
61 // --- External Mapping Case Recognition ---
0797d9d3 62#ifdef OCCT_DEBUG
498ce76b 63Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep (const TColStd_SequenceOfAsciiString& types) const
7fd59977 64{
7fd59977 65 Standard_Integer NbComp = types.Length();
7fd59977 66 if (NbComp < 2) {
04232180 67 std::cout << "Plex Instance illegal " << std::endl;
7fd59977 68 }
7fd59977 69 return 0;
70}
498ce76b 71#else
72Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep (const TColStd_SequenceOfAsciiString&) const
73{ return 0; }
74#endif
7fd59977 75
76 // --- External Mapping Recognition ---
77
78Standard_Boolean RWHeaderSection_ReadWriteModule::IsComplex
35e08fe8 79 (const Standard_Integer /*CN*/) const
7fd59977 80{
81 return Standard_False;
82}
83
84
85
86const TCollection_AsciiString& RWHeaderSection_ReadWriteModule::StepType
87 (const Standard_Integer CN) const
88{
89 switch (CN) {
90 case 1 : return Reco_FileName;
91 case 2 : return Reco_FileDescription;
92 case 3 : return Reco_FileSchema;
93 default : return PasReco;
94 }
95}
96
97 // -- Reading of a file --
98
99void RWHeaderSection_ReadWriteModule::ReadStep
100 (const Standard_Integer CN,
101 const Handle(StepData_StepReaderData)& data,
102 const Standard_Integer num,
103 Handle(Interface_Check)& ach,
104 const Handle(Standard_Transient)&ent) const
105{
106 if (CN == 0) return;
107 switch (CN) {
108 case 1 :
109 {
110 DeclareAndCast(HeaderSection_FileName, anent, ent);
111 RWHeaderSection_RWFileName tool;
112 if (anent.IsNull()) ach->AddFail("Type Mismatch on FileName");
113 else tool.ReadStep (data,num,ach,anent);
114 }
115
116 break;
117 case 2 :
118 {
119 DeclareAndCast(HeaderSection_FileDescription, anent, ent);
120 RWHeaderSection_RWFileDescription tool;
121 if (anent.IsNull()) ach->AddFail("Type Mismatch on FileDescription");
122 else tool.ReadStep (data,num,ach,anent);
123 }
124
125 break;
126 case 3 :
127 {
128 DeclareAndCast(HeaderSection_FileSchema, anent, ent);
129 RWHeaderSection_RWFileSchema tool;
130 if (anent.IsNull()) ach->AddFail("Type Mismatch on FileSchema");
131 else tool.ReadStep (data,num,ach,anent);
132 }
133
134 break;
135 case 4 :
136 {
137 DeclareAndCast(StepData_UndefinedEntity,und,ent);
138 if (und.IsNull()) ach->AddFail
139 ("# Entity neither Recognized nor set as UndefinedEntity from StepData #");
140 else und->ReadRecord(data,num,ach);
141 }
142
143 break;
144 default : ach->AddFail("Type Mismatch when reading - Entity");
145 }
146
147return;}
148
149 // -- Writing of a file --
150
151void RWHeaderSection_ReadWriteModule::WriteStep
152 (const Standard_Integer CN,
153 StepData_StepWriter& SW,
154 const Handle(Standard_Transient)&ent) const
155{
156 if (CN == 0) return;
157 switch (CN) {
158 case 1 :
159 {
160 DeclareAndCast(HeaderSection_FileName, anent, ent);
161 RWHeaderSection_RWFileName tool;
162 if (anent.IsNull()) return;
163 else tool.WriteStep (SW,anent);
164 }
165
166 break;
167 case 2 :
168 {
169 DeclareAndCast(HeaderSection_FileDescription, anent, ent);
170 RWHeaderSection_RWFileDescription tool;
171 if (anent.IsNull()) return;
172 else tool.WriteStep (SW,anent);
173 }
174
175 break;
176 case 3 :
177 {
178 DeclareAndCast(HeaderSection_FileSchema, anent, ent);
179 RWHeaderSection_RWFileSchema tool;
180 if (anent.IsNull()) return;
181 else tool.WriteStep (SW,anent);
182 }
183
184 break;
185 case 4 :
186 {
187 DeclareAndCast(StepData_UndefinedEntity,und,ent);
188 if (und.IsNull()) break;
189// Parentheses gerees par StepWriter lui-meme
190// car en recevant le type PasReco, StepWriter ne l'affiche pas,
191// mais il gere les parentheses comme si de rien n etait
192 if (und->IsComplex()) SW.StartComplex();
193 und->WriteParams(SW);
194 if (und->IsComplex()) SW.EndComplex();
195 }
196
197 break;
198 default : return;
199 }
200}
201