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.
14 #include <IFSelect_BasicDumper.ixx>
15 #include <IFSelect_IntParam.hxx>
16 #include <IFSelect_WorkSession.hxx>
17 #include <IFSelect_ShareOut.hxx>
19 #include <IFSelect_SelectModelRoots.hxx>
20 #include <IFSelect_SelectModelEntities.hxx>
21 #include <IFSelect_SelectEntityNumber.hxx>
22 #include <IFSelect_SelectPointed.hxx>
23 #include <IFSelect_SelectUnion.hxx>
24 #include <IFSelect_SelectIntersection.hxx>
25 #include <IFSelect_SelectDiff.hxx>
26 #include <IFSelect_SelectUnknownEntities.hxx>
27 #include <IFSelect_SelectErrorEntities.hxx>
28 #include <IFSelect_SelectIncorrectEntities.hxx>
29 #include <IFSelect_SelectRoots.hxx>
30 #include <IFSelect_SelectRootComps.hxx>
31 #include <IFSelect_SelectRange.hxx>
32 //#include <IFSelect_SelectTextType.hxx>
33 #include <IFSelect_SelectShared.hxx>
34 #include <IFSelect_SelectSharing.hxx>
35 #include <IFSelect_DispPerOne.hxx>
36 #include <IFSelect_DispGlobal.hxx>
37 #include <IFSelect_DispPerCount.hxx>
38 #include <IFSelect_TransformStandard.hxx>
39 #include <IFSelect_Modifier.hxx>
41 #include <Interface_Macros.hxx>
44 // Param litteral "own" sous la forme :"<val>" -> first = 3
45 // A present, forme simplifiee : <val> directement -> first = 1
49 IFSelect_BasicDumper::IFSelect_BasicDumper () { }
51 Standard_Boolean IFSelect_BasicDumper::WriteOwn
52 (IFSelect_SessionFile& file, const Handle(Standard_Transient)& item) const
54 Handle(Standard_Type) type = item->DynamicType();
55 if (type == STANDARD_TYPE(IFSelect_SelectModelRoots)) return Standard_True;
56 if (type == STANDARD_TYPE(IFSelect_SelectModelEntities)) return Standard_True;
57 if (type == STANDARD_TYPE(IFSelect_SelectEntityNumber)) {
58 DeclareAndCast(IFSelect_SelectEntityNumber,sen,item);
59 file.SendItem(sen->Number());
62 if (type == STANDARD_TYPE(IFSelect_SelectPointed)) return Standard_True;
63 if (type == STANDARD_TYPE(IFSelect_SelectUnion)) return Standard_True;
64 if (type == STANDARD_TYPE(IFSelect_SelectIntersection)) return Standard_True;
65 if (type == STANDARD_TYPE(IFSelect_SelectDiff)) return Standard_True;
66 if (type == STANDARD_TYPE(IFSelect_SelectUnknownEntities)) return Standard_True;
67 if (type == STANDARD_TYPE(IFSelect_SelectErrorEntities)) return Standard_True;
68 if (type == STANDARD_TYPE(IFSelect_SelectIncorrectEntities)) return Standard_True;
69 if (type == STANDARD_TYPE(IFSelect_SelectRoots)) return Standard_True;
70 if (type == STANDARD_TYPE(IFSelect_SelectRootComps)) return Standard_True;
71 if (type == STANDARD_TYPE(IFSelect_SelectRange)) {
72 DeclareAndCast(IFSelect_SelectRange,sra,item);
73 file.SendItem(sra->Lower());
74 file.SendItem(sra->Upper());
77 if (type == STANDARD_TYPE(IFSelect_SelectShared)) return Standard_True;
78 if (type == STANDARD_TYPE(IFSelect_SelectSharing)) return Standard_True;
80 if (type == STANDARD_TYPE(IFSelect_DispPerOne)) return Standard_True;
81 if (type == STANDARD_TYPE(IFSelect_DispGlobal)) return Standard_True;
82 if (type == STANDARD_TYPE(IFSelect_DispPerCount)) {
83 DeclareAndCast(IFSelect_DispPerCount,dpc,item);
84 file.SendItem(dpc->Count());
88 if (type == STANDARD_TYPE(IFSelect_TransformStandard)) {
89 DeclareAndCast(IFSelect_TransformStandard,trs,item);
90 if (trs->CopyOption()) file.SendText("copy");
91 else file.SendText("onthespot");
92 Standard_Integer nbm = trs->NbModifiers();
93 for (Standard_Integer i = 1; i <= nbm; i ++)
94 file.SendItem(trs->Modifier(i));
97 return Standard_False;
100 Standard_Boolean IFSelect_BasicDumper::ReadOwn
101 (IFSelect_SessionFile& file, const TCollection_AsciiString& type,
102 Handle(Standard_Transient)& item) const
104 if (type.IsEqual("IFSelect_SelectModelRoots"))
105 { item = new IFSelect_SelectModelRoots (); return Standard_True; }
106 if (type.IsEqual("IFSelect_SelectModelEntities"))
107 { item = new IFSelect_SelectModelEntities (); return Standard_True; }
108 if (type.IsEqual("IFSelect_SelectEntityNumber")) {
109 Handle(IFSelect_SelectEntityNumber) sen =
110 new IFSelect_SelectEntityNumber ();
111 sen->SetNumber (GetCasted(IFSelect_IntParam,file.ItemValue(1)));
113 return Standard_True;
115 if (type.IsEqual("IFSelect_SelectPointed"))
116 { item = new IFSelect_SelectPointed; return Standard_True; }
117 if (type.IsEqual("IFSelect_SelectUnion"))
118 { item = new IFSelect_SelectUnion; return Standard_True; }
119 if (type.IsEqual("IFSelect_SelectIntersection"))
120 { item = new IFSelect_SelectIntersection; return Standard_True; }
121 if (type.IsEqual("IFSelect_SelectDiff"))
122 { item = new IFSelect_SelectDiff; return Standard_True; }
123 if (type.IsEqual("IFSelect_SelectUnknownEntities"))
124 { item = new IFSelect_SelectUnknownEntities; return Standard_True; }
125 if (type.IsEqual("IFSelect_SelectErrorEntities"))
126 { item = new IFSelect_SelectErrorEntities; return Standard_True; }
127 if (type.IsEqual("IFSelect_SelectIncorrectEntities"))
128 { item = new IFSelect_SelectIncorrectEntities; return Standard_True; }
129 if (type.IsEqual("IFSelect_SelectRoots"))
130 { item = new IFSelect_SelectRoots; return Standard_True; }
131 if (type.IsEqual("IFSelect_SelectRootComps"))
132 { item = new IFSelect_SelectRootComps; return Standard_True; }
133 if (type.IsEqual("IFSelect_SelectRange")) {
134 Handle(IFSelect_SelectRange) sra = new IFSelect_SelectRange;
135 sra->SetRange (GetCasted(IFSelect_IntParam,file.ItemValue(1)),
136 GetCasted(IFSelect_IntParam,file.ItemValue(2)) );
138 return Standard_True;
140 if (type.IsEqual("IFSelect_SelectTextType")) {
141 const TCollection_AsciiString exname = file.ParamValue(1);
142 if (exname.Length() < FIRSTCHAR) return Standard_False;
143 if (exname.Value(FIRSTCHAR) == 'e') {}
144 else if (exname.Value(FIRSTCHAR) == 'c') {}
145 else return Standard_False;
146 // item = new IFSelect_SelectTextType (file.TextValue(2).ToCString(),exact);
147 // return Standard_True;
149 if (type.IsEqual("IFSelect_SelectShared"))
150 { item = new IFSelect_SelectShared; return Standard_True; }
151 if (type.IsEqual("IFSelect_SelectSharing"))
152 { item = new IFSelect_SelectSharing; return Standard_True; }
154 if (type.IsEqual("IFSelect_DispPerOne"))
155 { item = new IFSelect_DispPerOne; return Standard_True; }
156 if (type.IsEqual("IFSelect_DispGlobal"))
157 { item = new IFSelect_DispGlobal; return Standard_True; }
158 if (type.IsEqual("IFSelect_DispPerCount")) {
159 Handle(IFSelect_DispPerCount) dpc = new IFSelect_DispPerCount;
160 dpc->SetCount (GetCasted(IFSelect_IntParam,file.ItemValue(1)) );
162 return Standard_True;
165 if (type.IsEqual("IFSelect_TransformStandard")) {
166 Standard_Boolean copyoption;
167 const TCollection_AsciiString copyname = file.ParamValue(1);
168 if (copyname.Length() < FIRSTCHAR) return Standard_False;
169 if (copyname.Value(FIRSTCHAR) == 'c') copyoption = Standard_True;
170 else if (copyname.Value(FIRSTCHAR) == 'o') copyoption = Standard_False;
171 else return Standard_False;
172 Handle(IFSelect_TransformStandard) trs = new IFSelect_TransformStandard;
173 trs->SetCopyOption(copyoption);
174 Standard_Integer nbp = file.NbParams();
175 for (Standard_Integer i = 2; i <= nbp; i ++) {
176 DeclareAndCast(IFSelect_Modifier,modif,file.ItemValue(i));
177 if (!modif.IsNull()) trs->AddModifier(modif);
180 return Standard_True;
183 return Standard_False;