0024157: Parallelization of assembly part of BO
[occt.git] / src / IFSelect / IFSelect_BasicDumper.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 <IFSelect_BasicDumper.ixx>
19#include <IFSelect_IntParam.hxx>
20#include <IFSelect_WorkSession.hxx>
21#include <IFSelect_ShareOut.hxx>
22
23#include <IFSelect_SelectModelRoots.hxx>
24#include <IFSelect_SelectModelEntities.hxx>
25#include <IFSelect_SelectEntityNumber.hxx>
26#include <IFSelect_SelectPointed.hxx>
27#include <IFSelect_SelectUnion.hxx>
28#include <IFSelect_SelectIntersection.hxx>
29#include <IFSelect_SelectDiff.hxx>
30#include <IFSelect_SelectUnknownEntities.hxx>
31#include <IFSelect_SelectErrorEntities.hxx>
32#include <IFSelect_SelectIncorrectEntities.hxx>
33#include <IFSelect_SelectRoots.hxx>
34#include <IFSelect_SelectRootComps.hxx>
35#include <IFSelect_SelectRange.hxx>
36//#include <IFSelect_SelectTextType.hxx>
37#include <IFSelect_SelectShared.hxx>
38#include <IFSelect_SelectSharing.hxx>
39#include <IFSelect_DispPerOne.hxx>
40#include <IFSelect_DispGlobal.hxx>
41#include <IFSelect_DispPerCount.hxx>
42#include <IFSelect_TransformStandard.hxx>
43
44#include <Interface_Macros.hxx>
45
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
b311480e 52IFSelect_BasicDumper::IFSelect_BasicDumper () { }
7fd59977 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_SelectTextType)) {
81 DeclareAndCast(IFSelect_SelectTextType,sty,item);
82 if (sty->IsExact()) file.SendText("exact");
83 else file.SendText("contains");
84 file.SendText(sty->SignatureText().ToCString());
85 return Standard_True;
86 } */
87 if (type == STANDARD_TYPE(IFSelect_SelectShared)) return Standard_True;
88 if (type == STANDARD_TYPE(IFSelect_SelectSharing)) return Standard_True;
89
90 if (type == STANDARD_TYPE(IFSelect_DispPerOne)) return Standard_True;
91 if (type == STANDARD_TYPE(IFSelect_DispGlobal)) return Standard_True;
92 if (type == STANDARD_TYPE(IFSelect_DispPerCount)) {
93 DeclareAndCast(IFSelect_DispPerCount,dpc,item);
94 file.SendItem(dpc->Count());
95 return Standard_True;
96 }
97
98 if (type == STANDARD_TYPE(IFSelect_TransformStandard)) {
99 DeclareAndCast(IFSelect_TransformStandard,trs,item);
100 if (trs->CopyOption()) file.SendText("copy");
101 else file.SendText("onthespot");
102 Standard_Integer nbm = trs->NbModifiers();
103 for (Standard_Integer i = 1; i <= nbm; i ++)
104 file.SendItem(trs->Modifier(i));
105 }
106
107 return Standard_False;
108}
109
110 Standard_Boolean IFSelect_BasicDumper::ReadOwn
111 (IFSelect_SessionFile& file, const TCollection_AsciiString& type,
112 Handle(Standard_Transient)& item) const
113{
114 if (type.IsEqual("IFSelect_SelectModelRoots"))
115 { item = new IFSelect_SelectModelRoots (); return Standard_True; }
116 if (type.IsEqual("IFSelect_SelectModelEntities"))
117 { item = new IFSelect_SelectModelEntities (); return Standard_True; }
118 if (type.IsEqual("IFSelect_SelectEntityNumber")) {
119 Handle(IFSelect_SelectEntityNumber) sen =
120 new IFSelect_SelectEntityNumber ();
121 sen->SetNumber (GetCasted(IFSelect_IntParam,file.ItemValue(1)));
122 item = sen;
123 return Standard_True;
124 }
125 if (type.IsEqual("IFSelect_SelectPointed"))
126 { item = new IFSelect_SelectPointed; return Standard_True; }
127 if (type.IsEqual("IFSelect_SelectUnion"))
128 { item = new IFSelect_SelectUnion; return Standard_True; }
129 if (type.IsEqual("IFSelect_SelectIntersection"))
130 { item = new IFSelect_SelectIntersection; return Standard_True; }
131 if (type.IsEqual("IFSelect_SelectDiff"))
132 { item = new IFSelect_SelectDiff; return Standard_True; }
133 if (type.IsEqual("IFSelect_SelectUnknownEntities"))
134 { item = new IFSelect_SelectUnknownEntities; return Standard_True; }
135 if (type.IsEqual("IFSelect_SelectErrorEntities"))
136 { item = new IFSelect_SelectErrorEntities; return Standard_True; }
137 if (type.IsEqual("IFSelect_SelectIncorrectEntities"))
138 { item = new IFSelect_SelectIncorrectEntities; return Standard_True; }
139 if (type.IsEqual("IFSelect_SelectRoots"))
140 { item = new IFSelect_SelectRoots; return Standard_True; }
141 if (type.IsEqual("IFSelect_SelectRootComps"))
142 { item = new IFSelect_SelectRootComps; return Standard_True; }
143 if (type.IsEqual("IFSelect_SelectRange")) {
144 Handle(IFSelect_SelectRange) sra = new IFSelect_SelectRange;
145 sra->SetRange (GetCasted(IFSelect_IntParam,file.ItemValue(1)),
146 GetCasted(IFSelect_IntParam,file.ItemValue(2)) );
147 item = sra;
148 return Standard_True;
149 }
150 if (type.IsEqual("IFSelect_SelectTextType")) {
151 Standard_Boolean exact;
152 const TCollection_AsciiString exname = file.ParamValue(1);
153 if (exname.Length() < FIRSTCHAR) return Standard_False;
154 if (exname.Value(FIRSTCHAR) == 'e') exact = Standard_True;
155 else if (exname.Value(FIRSTCHAR) == 'c') exact = Standard_False;
156 else return Standard_False;
157// item = new IFSelect_SelectTextType (file.TextValue(2).ToCString(),exact);
158// return Standard_True;
159 }
160 if (type.IsEqual("IFSelect_SelectShared"))
161 { item = new IFSelect_SelectShared; return Standard_True; }
162 if (type.IsEqual("IFSelect_SelectSharing"))
163 { item = new IFSelect_SelectSharing; return Standard_True; }
164
165 if (type.IsEqual("IFSelect_DispPerOne"))
166 { item = new IFSelect_DispPerOne; return Standard_True; }
167 if (type.IsEqual("IFSelect_DispGlobal"))
168 { item = new IFSelect_DispGlobal; return Standard_True; }
169 if (type.IsEqual("IFSelect_DispPerCount")) {
170 Handle(IFSelect_DispPerCount) dpc = new IFSelect_DispPerCount;
171 dpc->SetCount (GetCasted(IFSelect_IntParam,file.ItemValue(1)) );
172 item = dpc;
173 return Standard_True;
174 }
175
176 if (type.IsEqual("IFSelect_TransformStandard")) {
177 Standard_Boolean copyoption;
178 const TCollection_AsciiString copyname = file.ParamValue(1);
179 if (copyname.Length() < FIRSTCHAR) return Standard_False;
180 if (copyname.Value(FIRSTCHAR) == 'c') copyoption = Standard_True;
181 else if (copyname.Value(FIRSTCHAR) == 'o') copyoption = Standard_False;
182 else return Standard_False;
183 Handle(IFSelect_TransformStandard) trs = new IFSelect_TransformStandard;
184 trs->SetCopyOption(copyoption);
185 Standard_Integer nbp = file.NbParams();
186 for (Standard_Integer i = 2; i <= nbp; i ++) {
187 DeclareAndCast(IFSelect_Modifier,modif,file.ItemValue(i));
188 if (!modif.IsNull()) trs->AddModifier(modif);
189 }
190 item = trs;
191 return Standard_True;
192 }
193
194 return Standard_False;
195}