0022898: IGES import fails in german environment
[occt.git] / src / IGESSelect / IGESSelect_Dumper.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <IGESSelect_Dumper.ixx>
19
20#include <IGESSelect_DispPerSingleView.hxx>
21#include <IGESSelect_DispPerDrawing.hxx>
22//#include <IGESSelect_SelectIGESTypeForm.hxx>
23#include <IGESSelect_SelectVisibleStatus.hxx>
24#include <IGESSelect_SelectLevelNumber.hxx>
25#include <IGESSelect_SelectName.hxx>
26#include <IGESSelect_SelectFromSingleView.hxx>
27#include <IGESSelect_SelectFromDrawing.hxx>
28#include <IGESSelect_SelectSingleViewFrom.hxx>
29#include <IGESSelect_SelectDrawingFrom.hxx>
30#include <IGESSelect_SelectBypassGroup.hxx>
31#include <IGESSelect_FloatFormat.hxx>
32#include <IGESSelect_UpdateCreationDate.hxx>
33#include <IGESSelect_UpdateLastChange.hxx>
34#include <IGESSelect_SetVersion5.hxx>
35#include <IGESSelect_SetGlobalParameter.hxx>
36#include <IGESSelect_AutoCorrect.hxx>
37#include <IGESSelect_ComputeStatus.hxx>
38#include <IGESSelect_RebuildDrawings.hxx>
39#include <IGESSelect_RebuildGroups.hxx>
40#include <IGESSelect_ChangeLevelList.hxx>
41#include <IGESSelect_ChangeLevelNumber.hxx>
42#include <IGESSelect_SplineToBSpline.hxx>
43
44#include <TCollection_AsciiString.hxx>
45#include <TCollection_HAsciiString.hxx>
46#include <IFSelect_IntParam.hxx>
47
48#include <Interface_Macros.hxx>
49#include <stdio.h>
50
51
52
b311480e 53IGESSelect_Dumper::IGESSelect_Dumper () { }
7fd59977 54
55
56 Standard_Boolean IGESSelect_Dumper::WriteOwn
57 (IFSelect_SessionFile& file, const Handle(Standard_Transient)& item) const
58{
59 if (item.IsNull()) return Standard_False;
60 Handle(Standard_Type) type = item->DynamicType();
61 if (type == STANDARD_TYPE(IGESSelect_DispPerSingleView)) return Standard_True;
62 if (type == STANDARD_TYPE(IGESSelect_DispPerDrawing)) return Standard_True;
63/* if (type == STANDARD_TYPE(IGESSelect_SelectIGESTypeForm)) {
64 DeclareAndCast(IGESSelect_SelectIGESTypeForm,sf,item);
65 Standard_Boolean exact = sf->IsExact();
66 TCollection_AsciiString text = sf->SignatureText(); // attention, 1-2 term
67 if (exact) file.SendText("exact");
68 else file.SendText("contains");
69 file.SendText(text.ToCString());
70 return Standard_True;
71 } */
72 if (type == STANDARD_TYPE(IGESSelect_SelectVisibleStatus)) return Standard_True;
73 if (type == STANDARD_TYPE(IGESSelect_SelectLevelNumber)) {
74 DeclareAndCast(IGESSelect_SelectLevelNumber,sl,item);
75 Handle(IFSelect_IntParam) lev = sl->LevelNumber();
76 file.SendItem(lev);
77 return Standard_True;
78 }
79 if (type == STANDARD_TYPE(IGESSelect_SelectName)) {
80 DeclareAndCast(IGESSelect_SelectName,sn,item);
81 Handle(TCollection_HAsciiString) name = sn->Name();
82 file.SendItem(name);
83 return Standard_True;
84 }
85 if (type == STANDARD_TYPE(IGESSelect_SelectFromSingleView)) return Standard_True;
86 if (type == STANDARD_TYPE(IGESSelect_SelectFromDrawing)) return Standard_True;
87 if (type == STANDARD_TYPE(IGESSelect_SelectSingleViewFrom)) return Standard_True;
88 if (type == STANDARD_TYPE(IGESSelect_SelectDrawingFrom)) return Standard_True;
89 if (type == STANDARD_TYPE(IGESSelect_SelectBypassGroup)) return Standard_True;
90
91 if (type == STANDARD_TYPE(IGESSelect_FloatFormat)) {
92 DeclareAndCast(IGESSelect_FloatFormat,ff,item);
93 Standard_Boolean zerosup, hasrange;
94 Standard_Real rangemin, rangemax;
95 TCollection_AsciiString mainform,forminrange;
96 ff->Format (zerosup,mainform,hasrange,forminrange,rangemin,rangemax);
97 file.SendText((char*)(zerosup ? "zerosup" : "nozerosup"));
98 file.SendText(mainform.ToCString());
99 if (hasrange) {
100 char flotrange[20];
101 file.SendText(forminrange.ToCString());
91322f44 102 Sprintf(flotrange,"%f",rangemin);
7fd59977 103 file.SendText(flotrange);
91322f44 104 Sprintf(flotrange,"%f",rangemax);
7fd59977 105 file.SendText(flotrange);
106 }
107 return Standard_True;
108 }
109
110 if (type == STANDARD_TYPE(IGESSelect_UpdateCreationDate)) return Standard_True;
111 if (type == STANDARD_TYPE(IGESSelect_UpdateLastChange)) return Standard_True;
112 if (type == STANDARD_TYPE(IGESSelect_SetVersion5)) return Standard_True;
113 if (type == STANDARD_TYPE(IGESSelect_SetGlobalParameter)) {
114 DeclareAndCast(IGESSelect_SetGlobalParameter,sp,item);
115 Standard_Integer np = sp->GlobalNumber();
116 Handle(TCollection_HAsciiString) val = sp->Value();
117 char intext[10];
118 sprintf(intext,"%d",np);
119 file.SendText(intext);
120 file.SendItem(val);
121 return Standard_True;
122 }
123 if (type == STANDARD_TYPE(IGESSelect_AutoCorrect)) return Standard_True;
124 if (type == STANDARD_TYPE(IGESSelect_ComputeStatus)) return Standard_True;
125 if (type == STANDARD_TYPE(IGESSelect_RebuildDrawings)) return Standard_True;
126 if (type == STANDARD_TYPE(IGESSelect_RebuildGroups)) return Standard_True;
127 if (type == STANDARD_TYPE(IGESSelect_ChangeLevelList)) {
128 DeclareAndCast(IGESSelect_ChangeLevelList,cl,item);
129 file.SendItem(cl->OldNumber());
130 file.SendItem(cl->NewNumber());
131 return Standard_True;
132 }
133 if (type == STANDARD_TYPE(IGESSelect_ChangeLevelNumber)) {
134 DeclareAndCast(IGESSelect_ChangeLevelNumber,cl,item);
135 file.SendItem(cl->OldNumber());
136 file.SendItem(cl->NewNumber());
137 return Standard_True;
138 }
139
140 if (type == STANDARD_TYPE(IGESSelect_SplineToBSpline)) {
141 Standard_Boolean tryc2 =
142 GetCasted(IGESSelect_SplineToBSpline,item)->OptionTryC2();
143 file.SendText((char*)(tryc2 ? "TryC2" : "Normal"));
144 return Standard_True;
145 }
146 return Standard_False;
147}
148
149
150 Standard_Boolean IGESSelect_Dumper::ReadOwn
151 (IFSelect_SessionFile& file, const TCollection_AsciiString& type,
152 Handle(Standard_Transient)& item) const
153{
154 if (type.IsEqual("IGESSelect_DispPerSingleView"))
155 { item = new IGESSelect_DispPerSingleView; return Standard_True; }
156 if (type.IsEqual("IGESSelect_DispPerDrawing"))
157 { item = new IGESSelect_DispPerDrawing; return Standard_True; }
158
159 if (type.IsEqual("IGESSelect_SelectIGESTypeForm")) {
160 if (file.NbParams() < 2) return Standard_False;
161 //Standard_Boolean exact; //szv#4:S4163:12Mar99 not needed
162 const TCollection_AsciiString exname = file.ParamValue(1);
163 if (exname.Length() < 1) return Standard_False;
164 if (exname.Value(1) == 'e') {} //szv#4:S4163:12Mar99 `exact = Standard_True` not needed
165 else if (exname.Value(1) == 'c') {} //szv#4:S4163:12Mar99 `exact = Standard_False` not needed
166 else return Standard_False;
167 // Attention, 2 termes possibles pour la signature
168 char sig[40];
169 if (file.NbParams() == 2) sprintf(sig,"%s",file.ParamValue(2).ToCString());
170 else sprintf(sig,"%s %s",file.ParamValue(2).ToCString(),file.ParamValue(3).ToCString());
171// item = new IGESSelect_SelectIGESTypeForm(sig,exact);
172// return Standard_True;
173 }
174 if (type.IsEqual("IGESSelect_SelectVisibleStatus"))
175 { item = new IGESSelect_SelectVisibleStatus; return Standard_True; }
176
177 if (type.IsEqual("IGESSelect_SelectLevelNumber")) {
178 if (file.NbParams() < 1) return Standard_False;
179 Handle(IGESSelect_SelectLevelNumber) sl = new IGESSelect_SelectLevelNumber;
180 DeclareAndCast(IFSelect_IntParam,lev,file.ItemValue(1));
181 sl->SetLevelNumber(lev);
182 item = sl;
183 return Standard_True;
184 }
185 if (type.IsEqual("IGESSelect_SelectName")) {
186 if (file.NbParams() < 1) return Standard_False;
187 Handle(IGESSelect_SelectName) sn = new IGESSelect_SelectName;
188 Handle(TCollection_HAsciiString) name = sn->Name();
189 item = sn;
190 return Standard_True;
191 }
192 if (type.IsEqual("IGESSelect_SelectFromSingleView"))
193 { item = new IGESSelect_SelectFromSingleView; return Standard_True; }
194 if (type.IsEqual("IGESSelect_SelectFromDrawing"))
195 { item = new IGESSelect_SelectFromDrawing; return Standard_True; }
196 if (type.IsEqual("IGESSelect_SelectSingleViewFrom"))
197 { item = new IGESSelect_SelectSingleViewFrom; return Standard_True; }
198 if (type.IsEqual("IGESSelect_SelectDrawingFrom"))
199 { item = new IGESSelect_SelectDrawingFrom; return Standard_True; }
200 if (type.IsEqual("IGESSelect_SelectBypassGroup"))
201 { item = new IGESSelect_SelectBypassGroup; return Standard_True; }
202
203 if (type.IsEqual("IGESSelect_FloatFormat")) {
204 if (file.NbParams() < 2) return Standard_False;
205 Handle(IGESSelect_FloatFormat) ff = new IGESSelect_FloatFormat;
206 Standard_Boolean zerosup;
207 const TCollection_AsciiString zsup = file.ParamValue(1);
208 if (zsup.Length() < 1) return Standard_False;
209 if (zsup.Value(1) == 'z') zerosup = Standard_True;
210 else if (zsup.Value(1) == 'n') zerosup = Standard_False;
211 else return Standard_False;
212 ff->SetFormat(file.ParamValue(2).ToCString());
213 ff->SetZeroSuppress(zerosup);
214 if (file.NbParams() >= 5) {
215 //char flotrange[20]; //szv#4:S4163:12Mar99 unused
216 Standard_Real rangemin, rangemax;
91322f44 217 rangemin = Atof (file.ParamValue(4).ToCString());
218 rangemax = Atof (file.ParamValue(5).ToCString());
7fd59977 219 ff->SetFormatForRange (file.ParamValue(3).ToCString(),rangemin,rangemax);
220 }
221 item = ff;
222 return Standard_True;
223 }
224
225 if (type.IsEqual("IGESSelect_UpdateCreationDate"))
226 { item = new IGESSelect_UpdateCreationDate; return Standard_True; }
227 if (type.IsEqual("IGESSelect_UpdateLastChange"))
228 { item = new IGESSelect_UpdateLastChange; return Standard_True; }
229 if (type.IsEqual("IGESSelect_SetVersion5"))
230 { item = new IGESSelect_SetVersion5; return Standard_True; }
231 if (type.IsEqual("IGESSelect_SetGlobalParameter")) {
232 if (file.NbParams() < 2) return Standard_False;
233 Standard_Integer np = atoi(file.ParamValue(1).ToCString());
234 DeclareAndCast(TCollection_HAsciiString,val,file.ItemValue(2));
235 Handle(IGESSelect_SetGlobalParameter) sp =
236 new IGESSelect_SetGlobalParameter(np);
237 sp->SetValue(val);
238 item = sp;
239 return Standard_True;
240 }
241
242 if (type.IsEqual("IGESSelect_AutoCorrect"))
243 { item = new IGESSelect_AutoCorrect; return Standard_True; }
244 if (type.IsEqual("IGESSelect_ComputeStatus"))
245 { item = new IGESSelect_ComputeStatus; return Standard_True; }
246 if (type.IsEqual("IGESSelect_RebuildDrawings"))
247 { item = new IGESSelect_RebuildDrawings; return Standard_True; }
248 if (type.IsEqual("IGESSelect_RebuildGroups"))
249 { item = new IGESSelect_RebuildGroups; return Standard_True; }
250
251 if (type.IsEqual("IGESSelect_ChangeLevelList")) {
252 if (file.NbParams() < 2) return Standard_False;
253 Handle(IGESSelect_ChangeLevelList) cl = new IGESSelect_ChangeLevelList;
254 DeclareAndCast(IFSelect_IntParam,oldpar,file.ItemValue(1));
255 DeclareAndCast(IFSelect_IntParam,newpar,file.ItemValue(2));
256 cl->SetOldNumber(oldpar);
257 cl->SetNewNumber(newpar);
258 item = cl;
259 return Standard_True;
260 }
261 if (type.IsEqual("IGESSelect_ChangeLevelNumber")) {
262 if (file.NbParams() < 2) return Standard_False;
263 Handle(IGESSelect_ChangeLevelNumber) cl = new IGESSelect_ChangeLevelNumber;
264 DeclareAndCast(IFSelect_IntParam,oldpar,file.ItemValue(1));
265 DeclareAndCast(IFSelect_IntParam,newpar,file.ItemValue(2));
266 cl->SetOldNumber(oldpar);
267 cl->SetNewNumber(newpar);
268 item = cl;
269 return Standard_True;
270 }
271
272 if (type.IsEqual("IGESSelect_SplineToBSpline")) {
273 if (file.NbParams() < 1) return Standard_False;
274 Standard_Boolean tryc2;
275 const TCollection_AsciiString tc2 = file.ParamValue(1);
276 if (tc2.Length() < 1) return Standard_False;
277 if (tc2.Value(1) == 'T') tryc2 = Standard_True;
278 else if (tc2.Value(1) == 'N') tryc2 = Standard_False;
279 else return Standard_False;
280 item = new IGESSelect_SplineToBSpline(tryc2);
281 return Standard_True;
282 }
283 return Standard_False;
284}