1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <IFSelect_BasicDumper.hxx>
16 #include <IFSelect_DispGlobal.hxx>
17 #include <IFSelect_DispPerCount.hxx>
18 #include <IFSelect_DispPerOne.hxx>
19 #include <IFSelect_IntParam.hxx>
20 #include <IFSelect_Modifier.hxx>
21 #include <IFSelect_SelectDiff.hxx>
22 #include <IFSelect_SelectEntityNumber.hxx>
23 #include <IFSelect_SelectErrorEntities.hxx>
24 #include <IFSelect_SelectIncorrectEntities.hxx>
25 #include <IFSelect_SelectIntersection.hxx>
26 #include <IFSelect_SelectModelEntities.hxx>
27 #include <IFSelect_SelectModelRoots.hxx>
28 #include <IFSelect_SelectPointed.hxx>
29 #include <IFSelect_SelectRange.hxx>
30 #include <IFSelect_SelectRootComps.hxx>
31 #include <IFSelect_SelectRoots.hxx>
32 #include <IFSelect_SelectShared.hxx>
33 #include <IFSelect_SelectSharing.hxx>
34 #include <IFSelect_SelectUnion.hxx>
35 #include <IFSelect_SelectUnknownEntities.hxx>
36 #include <IFSelect_SessionFile.hxx>
37 #include <IFSelect_ShareOut.hxx>
38 #include <IFSelect_TransformStandard.hxx>
39 #include <IFSelect_WorkSession.hxx>
40 #include <Interface_Macros.hxx>
41 #include <Standard_Transient.hxx>
42 #include <Standard_Type.hxx>
43 #include <TCollection_AsciiString.hxx>
45 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_BasicDumper,IFSelect_SessionDumper)
47 //#include <IFSelect_SelectTextType.hxx>
49 // Param litteral "own" sous la forme :"<val>" -> first = 3
50 // A present, forme simplifiee : <val> directement -> first = 1
54 IFSelect_BasicDumper::IFSelect_BasicDumper () { }
56 Standard_Boolean IFSelect_BasicDumper::WriteOwn
57 (IFSelect_SessionFile& file, const Handle(Standard_Transient)& item) const
59 Handle(Standard_Type) type = item->DynamicType();
60 if (type == STANDARD_TYPE(IFSelect_SelectModelRoots)) return Standard_True;
61 if (type == STANDARD_TYPE(IFSelect_SelectModelEntities)) return Standard_True;
62 if (type == STANDARD_TYPE(IFSelect_SelectEntityNumber)) {
63 DeclareAndCast(IFSelect_SelectEntityNumber,sen,item);
64 file.SendItem(sen->Number());
67 if (type == STANDARD_TYPE(IFSelect_SelectPointed)) return Standard_True;
68 if (type == STANDARD_TYPE(IFSelect_SelectUnion)) return Standard_True;
69 if (type == STANDARD_TYPE(IFSelect_SelectIntersection)) return Standard_True;
70 if (type == STANDARD_TYPE(IFSelect_SelectDiff)) return Standard_True;
71 if (type == STANDARD_TYPE(IFSelect_SelectUnknownEntities)) return Standard_True;
72 if (type == STANDARD_TYPE(IFSelect_SelectErrorEntities)) return Standard_True;
73 if (type == STANDARD_TYPE(IFSelect_SelectIncorrectEntities)) return Standard_True;
74 if (type == STANDARD_TYPE(IFSelect_SelectRoots)) return Standard_True;
75 if (type == STANDARD_TYPE(IFSelect_SelectRootComps)) return Standard_True;
76 if (type == STANDARD_TYPE(IFSelect_SelectRange)) {
77 DeclareAndCast(IFSelect_SelectRange,sra,item);
78 file.SendItem(sra->Lower());
79 file.SendItem(sra->Upper());
82 if (type == STANDARD_TYPE(IFSelect_SelectShared)) return Standard_True;
83 if (type == STANDARD_TYPE(IFSelect_SelectSharing)) return Standard_True;
85 if (type == STANDARD_TYPE(IFSelect_DispPerOne)) return Standard_True;
86 if (type == STANDARD_TYPE(IFSelect_DispGlobal)) return Standard_True;
87 if (type == STANDARD_TYPE(IFSelect_DispPerCount)) {
88 DeclareAndCast(IFSelect_DispPerCount,dpc,item);
89 file.SendItem(dpc->Count());
93 if (type == STANDARD_TYPE(IFSelect_TransformStandard)) {
94 DeclareAndCast(IFSelect_TransformStandard,trs,item);
95 if (trs->CopyOption()) file.SendText("copy");
96 else file.SendText("onthespot");
97 Standard_Integer nbm = trs->NbModifiers();
98 for (Standard_Integer i = 1; i <= nbm; i ++)
99 file.SendItem(trs->Modifier(i));
102 return Standard_False;
105 Standard_Boolean IFSelect_BasicDumper::ReadOwn
106 (IFSelect_SessionFile& file, const TCollection_AsciiString& type,
107 Handle(Standard_Transient)& item) const
109 if (type.IsEqual("IFSelect_SelectModelRoots"))
110 { item = new IFSelect_SelectModelRoots (); return Standard_True; }
111 if (type.IsEqual("IFSelect_SelectModelEntities"))
112 { item = new IFSelect_SelectModelEntities (); return Standard_True; }
113 if (type.IsEqual("IFSelect_SelectEntityNumber")) {
114 Handle(IFSelect_SelectEntityNumber) sen =
115 new IFSelect_SelectEntityNumber ();
116 sen->SetNumber (GetCasted(IFSelect_IntParam,file.ItemValue(1)));
118 return Standard_True;
120 if (type.IsEqual("IFSelect_SelectPointed"))
121 { item = new IFSelect_SelectPointed; return Standard_True; }
122 if (type.IsEqual("IFSelect_SelectUnion"))
123 { item = new IFSelect_SelectUnion; return Standard_True; }
124 if (type.IsEqual("IFSelect_SelectIntersection"))
125 { item = new IFSelect_SelectIntersection; return Standard_True; }
126 if (type.IsEqual("IFSelect_SelectDiff"))
127 { item = new IFSelect_SelectDiff; return Standard_True; }
128 if (type.IsEqual("IFSelect_SelectUnknownEntities"))
129 { item = new IFSelect_SelectUnknownEntities; return Standard_True; }
130 if (type.IsEqual("IFSelect_SelectErrorEntities"))
131 { item = new IFSelect_SelectErrorEntities; return Standard_True; }
132 if (type.IsEqual("IFSelect_SelectIncorrectEntities"))
133 { item = new IFSelect_SelectIncorrectEntities; return Standard_True; }
134 if (type.IsEqual("IFSelect_SelectRoots"))
135 { item = new IFSelect_SelectRoots; return Standard_True; }
136 if (type.IsEqual("IFSelect_SelectRootComps"))
137 { item = new IFSelect_SelectRootComps; return Standard_True; }
138 if (type.IsEqual("IFSelect_SelectRange")) {
139 Handle(IFSelect_SelectRange) sra = new IFSelect_SelectRange;
140 sra->SetRange (GetCasted(IFSelect_IntParam,file.ItemValue(1)),
141 GetCasted(IFSelect_IntParam,file.ItemValue(2)) );
143 return Standard_True;
145 if (type.IsEqual("IFSelect_SelectTextType")) {
146 const TCollection_AsciiString exname = file.ParamValue(1);
147 if (exname.Length() < FIRSTCHAR) return Standard_False;
148 if (exname.Value(FIRSTCHAR) == 'e') {}
149 else if (exname.Value(FIRSTCHAR) == 'c') {}
150 else return Standard_False;
151 // item = new IFSelect_SelectTextType (file.TextValue(2).ToCString(),exact);
152 // return Standard_True;
154 if (type.IsEqual("IFSelect_SelectShared"))
155 { item = new IFSelect_SelectShared; return Standard_True; }
156 if (type.IsEqual("IFSelect_SelectSharing"))
157 { item = new IFSelect_SelectSharing; return Standard_True; }
159 if (type.IsEqual("IFSelect_DispPerOne"))
160 { item = new IFSelect_DispPerOne; return Standard_True; }
161 if (type.IsEqual("IFSelect_DispGlobal"))
162 { item = new IFSelect_DispGlobal; return Standard_True; }
163 if (type.IsEqual("IFSelect_DispPerCount")) {
164 Handle(IFSelect_DispPerCount) dpc = new IFSelect_DispPerCount;
165 dpc->SetCount (GetCasted(IFSelect_IntParam,file.ItemValue(1)) );
167 return Standard_True;
170 if (type.IsEqual("IFSelect_TransformStandard")) {
171 Standard_Boolean copyoption;
172 const TCollection_AsciiString copyname = file.ParamValue(1);
173 if (copyname.Length() < FIRSTCHAR) return Standard_False;
174 if (copyname.Value(FIRSTCHAR) == 'c') copyoption = Standard_True;
175 else if (copyname.Value(FIRSTCHAR) == 'o') copyoption = Standard_False;
176 else return Standard_False;
177 Handle(IFSelect_TransformStandard) trs = new IFSelect_TransformStandard;
178 trs->SetCopyOption(copyoption);
179 Standard_Integer nbp = file.NbParams();
180 for (Standard_Integer i = 2; i <= nbp; i ++) {
181 DeclareAndCast(IFSelect_Modifier,modif,file.ItemValue(i));
182 if (!modif.IsNull()) trs->AddModifier(modif);
185 return Standard_True;
188 return Standard_False;