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