0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / IFSelect / IFSelect_BasicDumper.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
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>
44
45 //#include <IFSelect_SelectTextType.hxx>
46 #define FIRSTCHAR 1
47 // Param litteral "own" sous la forme  :"<val>" -> first = 3
48 // A present, forme simplifiee         : <val>  directement -> first = 1
49
50
51
52 IFSelect_BasicDumper::IFSelect_BasicDumper ()  {  }
53
54     Standard_Boolean  IFSelect_BasicDumper::WriteOwn
55   (IFSelect_SessionFile& file, const Handle(Standard_Transient)& item) const
56 {
57   Handle(Standard_Type) type = item->DynamicType();
58   if (type == STANDARD_TYPE(IFSelect_SelectModelRoots))      return Standard_True;
59   if (type == STANDARD_TYPE(IFSelect_SelectModelEntities))   return Standard_True;
60   if (type == STANDARD_TYPE(IFSelect_SelectEntityNumber)) {
61     DeclareAndCast(IFSelect_SelectEntityNumber,sen,item);
62     file.SendItem(sen->Number());
63     return Standard_True;
64   }
65   if (type == STANDARD_TYPE(IFSelect_SelectPointed))         return Standard_True;
66   if (type == STANDARD_TYPE(IFSelect_SelectUnion))           return Standard_True;
67   if (type == STANDARD_TYPE(IFSelect_SelectIntersection))    return Standard_True;
68   if (type == STANDARD_TYPE(IFSelect_SelectDiff))            return Standard_True;
69   if (type == STANDARD_TYPE(IFSelect_SelectUnknownEntities)) return Standard_True;
70   if (type == STANDARD_TYPE(IFSelect_SelectErrorEntities))   return Standard_True;
71   if (type == STANDARD_TYPE(IFSelect_SelectIncorrectEntities)) return Standard_True;
72   if (type == STANDARD_TYPE(IFSelect_SelectRoots))           return Standard_True;
73   if (type == STANDARD_TYPE(IFSelect_SelectRootComps))       return Standard_True;
74   if (type == STANDARD_TYPE(IFSelect_SelectRange)) {
75     DeclareAndCast(IFSelect_SelectRange,sra,item);
76     file.SendItem(sra->Lower());
77     file.SendItem(sra->Upper());
78     return Standard_True;
79   }
80   if (type == STANDARD_TYPE(IFSelect_SelectShared))          return Standard_True;
81   if (type == STANDARD_TYPE(IFSelect_SelectSharing))         return Standard_True;
82
83   if (type == STANDARD_TYPE(IFSelect_DispPerOne))            return Standard_True;
84   if (type == STANDARD_TYPE(IFSelect_DispGlobal))            return Standard_True;
85   if (type == STANDARD_TYPE(IFSelect_DispPerCount)) {
86     DeclareAndCast(IFSelect_DispPerCount,dpc,item);
87     file.SendItem(dpc->Count());
88     return Standard_True;
89   }
90
91   if (type == STANDARD_TYPE(IFSelect_TransformStandard)) {
92     DeclareAndCast(IFSelect_TransformStandard,trs,item);
93     if (trs->CopyOption()) file.SendText("copy");
94     else                   file.SendText("onthespot");
95     Standard_Integer nbm = trs->NbModifiers();
96     for (Standard_Integer i = 1; i <= nbm; i ++)
97       file.SendItem(trs->Modifier(i));
98   }
99
100   return Standard_False;
101 }
102
103     Standard_Boolean  IFSelect_BasicDumper::ReadOwn
104   (IFSelect_SessionFile& file, const TCollection_AsciiString& type,
105    Handle(Standard_Transient)& item) const
106 {
107   if (type.IsEqual("IFSelect_SelectModelRoots"))
108     {  item = new IFSelect_SelectModelRoots ();     return Standard_True;  }
109   if (type.IsEqual("IFSelect_SelectModelEntities"))
110     {  item = new IFSelect_SelectModelEntities ();  return Standard_True;  }
111   if (type.IsEqual("IFSelect_SelectEntityNumber")) {
112     Handle(IFSelect_SelectEntityNumber) sen =
113       new IFSelect_SelectEntityNumber ();
114     sen->SetNumber (GetCasted(IFSelect_IntParam,file.ItemValue(1)));
115     item = sen;
116     return Standard_True;
117   }
118   if (type.IsEqual("IFSelect_SelectPointed"))
119     {  item = new IFSelect_SelectPointed;  return Standard_True;  }
120   if (type.IsEqual("IFSelect_SelectUnion"))
121     {  item = new IFSelect_SelectUnion;  return Standard_True;  }
122   if (type.IsEqual("IFSelect_SelectIntersection"))
123     {  item = new IFSelect_SelectIntersection;  return Standard_True;  }
124   if (type.IsEqual("IFSelect_SelectDiff"))
125     {  item = new IFSelect_SelectDiff;  return Standard_True;  }
126   if (type.IsEqual("IFSelect_SelectUnknownEntities"))
127     {  item = new IFSelect_SelectUnknownEntities;  return Standard_True;  }
128   if (type.IsEqual("IFSelect_SelectErrorEntities"))
129     {  item = new IFSelect_SelectErrorEntities;  return Standard_True;  }
130   if (type.IsEqual("IFSelect_SelectIncorrectEntities"))
131     {  item = new IFSelect_SelectIncorrectEntities;  return Standard_True;  }
132   if (type.IsEqual("IFSelect_SelectRoots"))
133     {  item = new IFSelect_SelectRoots;  return Standard_True;  }
134   if (type.IsEqual("IFSelect_SelectRootComps"))
135     {  item = new IFSelect_SelectRootComps;  return Standard_True;  }
136   if (type.IsEqual("IFSelect_SelectRange")) {
137     Handle(IFSelect_SelectRange) sra = new IFSelect_SelectRange;
138     sra->SetRange (GetCasted(IFSelect_IntParam,file.ItemValue(1)),
139                    GetCasted(IFSelect_IntParam,file.ItemValue(2)) );
140     item = sra;
141     return Standard_True;
142   }
143   if (type.IsEqual("IFSelect_SelectTextType")) {
144     const TCollection_AsciiString exname = file.ParamValue(1);
145     if (exname.Length() < FIRSTCHAR) return Standard_False;
146     if      (exname.Value(FIRSTCHAR) == 'e') {}
147     else if (exname.Value(FIRSTCHAR) == 'c') {}
148     else  return Standard_False;
149 //    item = new IFSelect_SelectTextType (file.TextValue(2).ToCString(),exact);
150 //    return Standard_True;
151   }
152   if (type.IsEqual("IFSelect_SelectShared"))
153     {  item = new IFSelect_SelectShared;  return Standard_True;  }
154   if (type.IsEqual("IFSelect_SelectSharing"))
155     {  item = new IFSelect_SelectSharing;  return Standard_True;  }
156
157   if (type.IsEqual("IFSelect_DispPerOne"))
158     {  item = new IFSelect_DispPerOne;  return Standard_True;  }
159   if (type.IsEqual("IFSelect_DispGlobal"))
160     {  item = new IFSelect_DispGlobal;  return Standard_True;  }
161   if (type.IsEqual("IFSelect_DispPerCount")) {
162     Handle(IFSelect_DispPerCount) dpc = new IFSelect_DispPerCount;
163     dpc->SetCount (GetCasted(IFSelect_IntParam,file.ItemValue(1)) );
164     item = dpc;
165     return Standard_True;
166   }
167
168   if (type.IsEqual("IFSelect_TransformStandard")) {
169     Standard_Boolean copyoption;
170     const TCollection_AsciiString copyname = file.ParamValue(1);
171     if (copyname.Length() < FIRSTCHAR) return Standard_False;
172     if      (copyname.Value(FIRSTCHAR) == 'c') copyoption = Standard_True;
173     else if (copyname.Value(FIRSTCHAR) == 'o') copyoption = Standard_False;
174     else  return Standard_False;
175     Handle(IFSelect_TransformStandard) trs = new IFSelect_TransformStandard;
176     trs->SetCopyOption(copyoption);
177     Standard_Integer nbp = file.NbParams();
178     for (Standard_Integer i = 2; i <= nbp; i ++) {
179       DeclareAndCast(IFSelect_Modifier,modif,file.ItemValue(i));
180       if (!modif.IsNull()) trs->AddModifier(modif);
181     }
182     item = trs;
183     return Standard_True;
184   }
185
186   return Standard_False;
187 }