b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
19 | #include <IGESAppli_Flow.hxx> |
20 | #include <IGESAppli_ToolFlow.hxx> |
21 | #include <IGESData_DirChecker.hxx> |
22 | #include <IGESData_Dump.hxx> |
23 | #include <IGESData_HArray1OfIGESEntity.hxx> |
24 | #include <IGESData_IGESDumper.hxx> |
7fd59977 |
25 | #include <IGESData_IGESEntity.hxx> |
42cf5bc1 |
26 | #include <IGESData_IGESReaderData.hxx> |
27 | #include <IGESData_IGESWriter.hxx> |
28 | #include <IGESData_ParamCursor.hxx> |
29 | #include <IGESData_ParamReader.hxx> |
7fd59977 |
30 | #include <IGESDraw_ConnectPoint.hxx> |
31 | #include <IGESDraw_HArray1OfConnectPoint.hxx> |
7fd59977 |
32 | #include <IGESGraph_HArray1OfTextDisplayTemplate.hxx> |
42cf5bc1 |
33 | #include <IGESGraph_TextDisplayTemplate.hxx> |
34 | #include <Interface_Check.hxx> |
35 | #include <Interface_CopyTool.hxx> |
36 | #include <Interface_EntityIterator.hxx> |
37 | #include <Interface_HArray1OfHAsciiString.hxx> |
7fd59977 |
38 | #include <Interface_Macros.hxx> |
42cf5bc1 |
39 | #include <Interface_ShareTool.hxx> |
40 | #include <Message_Messenger.hxx> |
41 | #include <Standard_DomainError.hxx> |
42 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
43 | |
44 | IGESAppli_ToolFlow::IGESAppli_ToolFlow () { } |
45 | |
46 | |
47 | void IGESAppli_ToolFlow::ReadOwnParams |
48 | (const Handle(IGESAppli_Flow)& ent, |
49 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
50 | { |
51 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
52 | Standard_Integer tempNbContextFlags; |
53 | Standard_Integer tempTypeOfFlow; |
54 | Standard_Integer tempFunctionFlag; |
55 | Standard_Integer i, nf,nc,nj,nn,nt,np; |
56 | Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs; |
57 | Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints; |
58 | Handle(IGESData_HArray1OfIGESEntity) tempJoins; |
59 | Handle(Interface_HArray1OfHAsciiString) tempFlowNames; |
60 | Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates; |
61 | Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs; |
62 | |
63 | //szv#4:S4163:12Mar99 `st=` not needed |
64 | if (PR.DefinedElseSkip()) |
65 | PR.ReadInteger(PR.Current(), "Number of Context Flags", tempNbContextFlags); |
66 | else |
67 | tempNbContextFlags = 2; |
68 | |
69 | //szv#4:S4163:12Mar99 moved in if |
70 | if (!PR.ReadInteger(PR.Current(), "Number of Flow Associativities", nf)) nf = 0; |
71 | if (nf > 0) tempFlowAssocs = new IGESData_HArray1OfIGESEntity(1, nf); |
72 | else PR.AddFail ("Number of Flow Associativities: Not Positive"); |
73 | |
74 | if (!PR.ReadInteger(PR.Current(), "Number of Connect Points", nc)) nc = 0; |
75 | if (nc > 0) tempConnectPoints = new IGESDraw_HArray1OfConnectPoint(1, nc); |
76 | else PR.AddFail("Number of Connect Points: Not Positive"); |
77 | |
78 | if (!PR.ReadInteger(PR.Current(), "Number of Joins", nj)) nj = 0; |
79 | if (nj > 0) tempJoins = new IGESData_HArray1OfIGESEntity(1, nj); |
80 | else PR.AddFail("Number of Joins: Not Positive"); |
81 | |
82 | if (!PR.ReadInteger(PR.Current(), "Number of Flow Names", nn)) nn = 0; |
83 | if (nn > 0) tempFlowNames = new Interface_HArray1OfHAsciiString(1, nn); |
84 | else PR.AddFail("Number of Flow Names: Not Positive"); |
85 | |
86 | if (!PR.ReadInteger(PR.Current(), "Number of Text Displays", nt)) nt = 0; |
87 | if (nt > 0) tempTextDisplayTemplates = |
88 | new IGESGraph_HArray1OfTextDisplayTemplate(1, nt); |
89 | else PR.AddFail("Number of Text Displays: Not Positive"); |
90 | |
91 | if (!PR.ReadInteger(PR.Current(), "Number of Continuation Flows", np)) np = 0; |
92 | if (np > 0) tempContFlowAssocs = new IGESData_HArray1OfIGESEntity(1, np); |
93 | else PR.AddFail("Number of Continuation Flows Not Positive"); |
94 | |
95 | if (PR.DefinedElseSkip()) |
96 | PR.ReadInteger(PR.Current(), "Type of Flow", tempTypeOfFlow); |
97 | else |
98 | tempTypeOfFlow = 0; |
99 | |
100 | if (PR.DefinedElseSkip()) |
101 | PR.ReadInteger(PR.Current(), "Function Flag", tempFunctionFlag); |
102 | else |
103 | tempFunctionFlag = 0; |
104 | |
105 | for ( i = 1; i <= nf; i++ ) { |
106 | Handle(IGESData_IGESEntity) tempEntity; |
107 | if (PR.ReadEntity(IR, PR.Current(), "Flow Associativity", tempEntity)) |
108 | tempFlowAssocs->SetValue(i, tempEntity); |
109 | } |
110 | |
111 | for ( i = 1; i <= nc; i++ ) { |
112 | Handle(IGESDraw_ConnectPoint) tempEntity; |
113 | if (PR.ReadEntity(IR, PR.Current(), "Connect Point", STANDARD_TYPE(IGESDraw_ConnectPoint), tempEntity)) |
114 | tempConnectPoints->SetValue(i, tempEntity); |
115 | } |
116 | |
117 | for ( i = 1; i <= nj; i++ ) { |
118 | Handle(IGESData_IGESEntity) tempEntity; |
119 | if (PR.ReadEntity(IR, PR.Current(), "Join", tempEntity)) |
120 | tempJoins->SetValue(i, tempEntity); |
121 | } |
122 | |
123 | for ( i = 1; i <= nn; i++ ) { |
124 | Handle(TCollection_HAsciiString) tempString; |
125 | if (PR.ReadText(PR.Current(), "Flow Name", tempString)) |
126 | tempFlowNames->SetValue(i, tempString); |
127 | } |
128 | |
129 | for ( i = 1; i <= nt; i++ ) { |
130 | Handle(IGESGraph_TextDisplayTemplate) tempEntity; |
131 | if (PR.ReadEntity(IR, PR.Current(), "Text Display Template", |
132 | STANDARD_TYPE(IGESGraph_TextDisplayTemplate), tempEntity)) |
133 | tempTextDisplayTemplates->SetValue(i, tempEntity); |
134 | } |
135 | |
136 | for ( i = 1; i <= np; i++ ) { |
137 | Handle(IGESData_IGESEntity) tempEntity; |
138 | if (PR.ReadEntity(IR, PR.Current(), "Continuation Flow Associativities", tempEntity)) |
139 | tempContFlowAssocs->SetValue(i, tempEntity); |
140 | } |
141 | |
142 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
143 | ent->Init(tempNbContextFlags, tempTypeOfFlow, tempFunctionFlag, |
144 | tempFlowAssocs, tempConnectPoints, tempJoins, tempFlowNames, |
145 | tempTextDisplayTemplates, tempContFlowAssocs); |
146 | } |
147 | |
148 | void IGESAppli_ToolFlow::WriteOwnParams |
149 | (const Handle(IGESAppli_Flow)& ent, IGESData_IGESWriter& IW) const |
150 | { |
151 | Standard_Integer i, num; |
152 | IW.Send(ent->NbContextFlags()); |
153 | IW.Send(ent->NbFlowAssociativities()); |
154 | IW.Send(ent->NbConnectPoints()); |
155 | IW.Send(ent->NbJoins()); |
156 | IW.Send(ent->NbFlowNames()); |
157 | IW.Send(ent->NbTextDisplayTemplates()); |
158 | IW.Send(ent->NbContFlowAssociativities()); |
159 | IW.Send(ent->TypeOfFlow()); |
160 | IW.Send(ent->FunctionFlag()); |
161 | for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ ) |
162 | IW.Send(ent->FlowAssociativity(i)); |
163 | for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ ) |
164 | IW.Send(ent->ConnectPoint(i)); |
165 | for ( num = ent->NbJoins(), i = 1; i <= num; i++ ) |
166 | IW.Send(ent->Join(i)); |
167 | for ( num = ent->NbFlowNames(), i = 1; i <= num; i++ ) |
168 | IW.Send(ent->FlowName(i)); |
169 | for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ ) |
170 | IW.Send(ent->TextDisplayTemplate(i)); |
171 | for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ ) |
172 | IW.Send(ent->ContFlowAssociativity(i)); |
173 | } |
174 | |
175 | void IGESAppli_ToolFlow::OwnShared |
176 | (const Handle(IGESAppli_Flow)& ent, Interface_EntityIterator& iter) const |
177 | { |
178 | Standard_Integer i, num; |
179 | for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ ) |
180 | iter.GetOneItem(ent->FlowAssociativity(i)); |
181 | for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ ) |
182 | iter.GetOneItem(ent->ConnectPoint(i)); |
183 | for ( num = ent->NbJoins(), i = 1; i <= num; i++ ) |
184 | iter.GetOneItem(ent->Join(i)); |
185 | for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ ) |
186 | iter.GetOneItem(ent->TextDisplayTemplate(i)); |
187 | for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ ) |
188 | iter.GetOneItem(ent->ContFlowAssociativity(i)); |
189 | } |
190 | |
191 | void IGESAppli_ToolFlow::OwnCopy |
192 | (const Handle(IGESAppli_Flow)& another, |
193 | const Handle(IGESAppli_Flow)& ent, Interface_CopyTool& TC) const |
194 | { |
195 | Standard_Integer tempNbContextFlags = another->NbContextFlags(); |
196 | Standard_Integer tempTypeOfFlow = another->TypeOfFlow(); |
197 | Standard_Integer tempFunctionFlag = another->FunctionFlag(); |
198 | Standard_Integer i, num; |
199 | |
200 | num = another->NbFlowAssociativities(); |
201 | Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs; |
202 | if (num > 0) tempFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num); |
203 | for ( i = 1; i <= num; i++ ) |
204 | { |
205 | DeclareAndCast(IGESData_IGESEntity, new_item, |
206 | TC.Transferred(another->FlowAssociativity(i))); |
207 | tempFlowAssocs->SetValue(i, new_item); |
208 | } |
209 | |
210 | num = another->NbConnectPoints(); |
211 | Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints; |
212 | if (num > 0) tempConnectPoints = new IGESDraw_HArray1OfConnectPoint(1, num); |
213 | for ( i = 1; i <= num; i++ ) |
214 | { |
215 | DeclareAndCast(IGESDraw_ConnectPoint, new_item, |
216 | TC.Transferred(another->ConnectPoint(i))); |
217 | tempConnectPoints->SetValue(i, new_item); |
218 | } |
219 | |
220 | num = another->NbJoins(); |
221 | Handle(IGESData_HArray1OfIGESEntity) tempJoins; |
222 | if (num > 0) tempJoins = new IGESData_HArray1OfIGESEntity(1, num); |
223 | for ( i = 1; i <= num; i++ ) |
224 | { |
225 | DeclareAndCast(IGESData_IGESEntity, new_item, |
226 | TC.Transferred(another->Join(i))); |
227 | tempJoins->SetValue(i, new_item); |
228 | } |
229 | |
230 | num = another->NbFlowNames(); |
231 | Handle(Interface_HArray1OfHAsciiString) tempFlowNames; |
232 | if (num > 0) tempFlowNames = new Interface_HArray1OfHAsciiString(1, num); |
233 | for ( i = 1; i <= num; i++ ) |
234 | tempFlowNames->SetValue |
235 | (i, new TCollection_HAsciiString(another->FlowName(i))); |
236 | |
237 | num = another->NbTextDisplayTemplates(); |
238 | Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates; |
239 | if (num > 0) tempTextDisplayTemplates = |
240 | new IGESGraph_HArray1OfTextDisplayTemplate(1, num); |
241 | for ( i = 1; i <= num; i++ ) |
242 | { |
243 | DeclareAndCast(IGESGraph_TextDisplayTemplate, new_item, |
244 | TC.Transferred(another->TextDisplayTemplate(i))); |
245 | tempTextDisplayTemplates->SetValue(i, new_item); |
246 | } |
247 | |
248 | num = another->NbContFlowAssociativities(); |
249 | Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs; |
250 | if (num > 0) tempContFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num); |
251 | for ( i = 1; i <= num; i++ ) |
252 | { |
253 | DeclareAndCast(IGESData_IGESEntity, new_item, |
254 | TC.Transferred(another->ContFlowAssociativity(i))); |
255 | tempContFlowAssocs->SetValue(i, new_item); |
256 | } |
257 | |
258 | ent->Init (tempNbContextFlags, tempTypeOfFlow, tempFunctionFlag, |
259 | tempFlowAssocs, tempConnectPoints, tempJoins, tempFlowNames, |
260 | tempTextDisplayTemplates, tempContFlowAssocs); |
261 | } |
262 | |
263 | Standard_Boolean IGESAppli_ToolFlow::OwnCorrect |
264 | (const Handle(IGESAppli_Flow)& ent) const |
265 | { |
266 | return ent->OwnCorrect(); // nbcontextflags = 2 |
267 | } |
268 | |
269 | IGESData_DirChecker IGESAppli_ToolFlow::DirChecker |
270 | (const Handle(IGESAppli_Flow)& /* ent */ ) const |
271 | { |
272 | IGESData_DirChecker DC(402, 18); |
273 | DC.Structure(IGESData_DefVoid); |
274 | DC.GraphicsIgnored(); |
275 | DC.LineFont(IGESData_DefVoid); |
276 | DC.LineWeight(IGESData_DefVoid); |
277 | DC.Color(IGESData_DefVoid); |
278 | DC.BlankStatusIgnored(); |
279 | DC.UseFlagRequired(3); |
280 | DC.HierarchyStatusIgnored(); |
281 | return DC; |
282 | } |
283 | |
284 | void IGESAppli_ToolFlow::OwnCheck |
285 | (const Handle(IGESAppli_Flow)& ent, |
286 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
287 | { |
288 | if (ent->NbContextFlags() != 2) |
289 | ach->AddFail("Number of Context Flags != 2"); |
290 | if ((ent->TypeOfFlow() < 0) || (ent->TypeOfFlow() > 2)) |
291 | ach->AddFail("Type of Flow != 0,1,2"); |
292 | if ((ent->FunctionFlag() < 0) || (ent->FunctionFlag() > 2)) |
293 | ach->AddFail("Function Flag != 0,1,2"); |
294 | } |
295 | |
296 | void IGESAppli_ToolFlow::OwnDump |
297 | (const Handle(IGESAppli_Flow)& ent, const IGESData_IGESDumper& dumper, |
298 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
299 | { |
300 | S << "IGESAppli_Flow" << endl; |
301 | S << "Number of Context Flags : " << ent->NbContextFlags() << endl; |
302 | Standard_Integer tf = ent->TypeOfFlow(); |
303 | S << "Type of Flow : " << tf; |
304 | if (tf == 1) S << " (logical)" << endl; |
305 | else if (tf == 2) S << " (physical)" << endl; |
306 | else S << " (not specified)" << endl; |
307 | tf = ent->FunctionFlag(); |
308 | S << "Function Flag : " << tf; |
309 | if (tf == 1) S << " (electrical signal)" << endl; |
310 | else if (tf == 2) S << " (fluid flow path)" << endl; |
311 | else S << " (not specified)" << endl; |
312 | S << "Flow Associativities : "; |
313 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbFlowAssociativities(), |
314 | ent->FlowAssociativity); |
315 | S << endl << "Connect Points : "; |
316 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbConnectPoints(), |
317 | ent->ConnectPoint); |
318 | S << endl << "Joins : "; |
319 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbJoins(),ent->Join); |
320 | S << endl << "Flow Names : "; |
321 | IGESData_DumpStrings(S ,level,1, ent->NbFlowNames(),ent->FlowName); |
322 | S << endl << "Text Display Templates : "; |
323 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbTextDisplayTemplates(), |
324 | ent->TextDisplayTemplate); |
325 | S << endl << "Continuation Flow Associativities : "; |
326 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbContFlowAssociativities(), |
327 | ent->ContFlowAssociativity); |
328 | S << endl; |
329 | } |
330 | |