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 | |
19 | #include <IGESAppli_ToolPipingFlow.ixx> |
20 | #include <IGESData_ParamCursor.hxx> |
21 | #include <TCollection_HAsciiString.hxx> |
22 | #include <IGESData_IGESEntity.hxx> |
23 | #include <IGESGraph_TextDisplayTemplate.hxx> |
24 | #include <IGESDraw_ConnectPoint.hxx> |
25 | #include <IGESDraw_HArray1OfConnectPoint.hxx> |
26 | #include <Interface_HArray1OfHAsciiString.hxx> |
27 | #include <IGESGraph_HArray1OfTextDisplayTemplate.hxx> |
28 | #include <IGESData_HArray1OfIGESEntity.hxx> |
29 | #include <IGESData_Dump.hxx> |
30 | #include <Interface_Macros.hxx> |
31 | |
32 | |
33 | IGESAppli_ToolPipingFlow::IGESAppli_ToolPipingFlow () { } |
34 | |
35 | |
36 | void IGESAppli_ToolPipingFlow::ReadOwnParams |
37 | (const Handle(IGESAppli_PipingFlow)& ent, |
38 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
39 | { |
40 | //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down |
41 | Standard_Integer tempNbContextFlags; |
42 | Standard_Integer tempTypeOfFlow; |
43 | Standard_Integer i, num; |
44 | Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs; |
45 | Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints; |
46 | Handle(IGESData_HArray1OfIGESEntity) tempJoins; |
47 | Handle(Interface_HArray1OfHAsciiString) tempFlowNames; |
48 | Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates; |
49 | Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs; |
50 | |
51 | //szv#4:S4163:12Mar99 `st=` not needed |
52 | if (PR.DefinedElseSkip()) |
53 | PR.ReadInteger(PR.Current(), "Number of Context Flags", tempNbContextFlags); |
54 | else |
55 | tempNbContextFlags = 1; |
56 | |
57 | if (!PR.ReadInteger(PR.Current(), "Number of Flow Associativities", num)) num = 0; |
58 | if (num > 0) tempFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num); |
59 | else PR.AddFail("Number of Flow Associativities: Not Positive"); |
60 | |
61 | if (!PR.ReadInteger(PR.Current(), "Number of Connect Points", num)) num = 0; |
62 | if (num > 0) tempConnectPoints = new IGESDraw_HArray1OfConnectPoint(1, num); |
63 | else PR.AddFail("Number of Connect Points: Not Positive"); |
64 | |
65 | if (!PR.ReadInteger(PR.Current(), "Number of Joins", num)) num = 0; |
66 | if (num > 0) tempJoins = new IGESData_HArray1OfIGESEntity(1, num); |
67 | else PR.AddFail("Number of Joins: Not Positive"); |
68 | |
69 | if (!PR.ReadInteger(PR.Current(), "Number of Flow Names", num)) num = 0; |
70 | if (num > 0) tempFlowNames = new Interface_HArray1OfHAsciiString(1, num); |
71 | else PR.AddFail("Number of Flow Names: Not Positive"); |
72 | |
73 | if (!PR.ReadInteger(PR.Current(), "Number of Text Displays", num)) num = 0; |
74 | if (num > 0) tempTextDisplayTemplates = new IGESGraph_HArray1OfTextDisplayTemplate(1, num); |
75 | else PR.AddFail("Number of Text Displays: Not Positive"); |
76 | |
77 | if (!PR.ReadInteger(PR.Current(), "Number of Continuation Flows", num)) num = 0; |
78 | if (num > 0) tempContFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num); |
79 | else PR.AddFail("Number of Continuation Flows: Not Positive"); |
80 | |
81 | if (PR.DefinedElseSkip()) |
82 | PR.ReadInteger(PR.Current(), "Type of Flow", tempTypeOfFlow); |
83 | else |
84 | tempTypeOfFlow = 0; |
85 | |
86 | if (!tempFlowAssocs.IsNull()) |
87 | for ( num = tempFlowAssocs->Length(), i = 1; i <= num; i++ ) { |
88 | Handle(IGESData_IGESEntity) tempEntity; |
89 | //szv#4:S4163:12Mar99 moved in if |
90 | if (PR.ReadEntity (IR, PR.Current(), "Flow Associativity", STANDARD_TYPE(IGESData_IGESEntity),tempEntity)) |
91 | tempFlowAssocs->SetValue(i, tempEntity); |
92 | } |
93 | |
94 | if (!tempConnectPoints.IsNull()) |
95 | for ( num = tempConnectPoints->Length(), i = 1; i <= num; i++ ) { |
96 | Handle(IGESDraw_ConnectPoint) tempEntity; |
97 | if (PR.ReadEntity(IR, PR.Current(), "Connect Point", STANDARD_TYPE(IGESDraw_ConnectPoint),tempEntity)) |
98 | tempConnectPoints->SetValue(i, tempEntity); |
99 | } |
100 | |
101 | if (!tempJoins.IsNull()) |
102 | for ( num = tempJoins->Length(), i = 1; i <= num; i++ ) { |
103 | Handle(IGESData_IGESEntity) tempEntity; |
104 | if (PR.ReadEntity(IR, PR.Current(), "Join", tempEntity)) |
105 | tempJoins->SetValue(i, tempEntity); |
106 | } |
107 | |
108 | if (!tempFlowNames.IsNull()) |
109 | for ( num = tempFlowNames->Length(), i = 1; i <= num; i++ ) { |
110 | Handle(TCollection_HAsciiString) tempString; |
111 | if (PR.ReadText(PR.Current(), "Flow Name", tempString)) |
112 | tempFlowNames->SetValue(i, tempString); |
113 | } |
114 | |
115 | if (!tempTextDisplayTemplates.IsNull()) |
116 | for ( num = tempTextDisplayTemplates->Length(), i = 1; i <= num; i++ ) { |
117 | Handle(IGESGraph_TextDisplayTemplate) tempEntity; |
118 | if (PR.ReadEntity (IR, PR.Current(), "Text Display Template", |
119 | STANDARD_TYPE(IGESGraph_TextDisplayTemplate),tempEntity)) |
120 | tempTextDisplayTemplates->SetValue(i, tempEntity); |
121 | } |
122 | |
123 | if (!tempContFlowAssocs.IsNull()) |
124 | for ( num = tempContFlowAssocs->Length(), i = 1; i <= num; i++ ) { |
125 | Handle(IGESData_IGESEntity) tempEntity; |
126 | if (PR.ReadEntity (IR, PR.Current(), "Continuation Flow Assocs", tempEntity)) |
127 | tempContFlowAssocs->SetValue(i, tempEntity); |
128 | } |
129 | |
130 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
131 | ent->Init(tempNbContextFlags, tempTypeOfFlow, tempFlowAssocs, |
132 | tempConnectPoints, tempJoins, tempFlowNames, |
133 | tempTextDisplayTemplates, tempContFlowAssocs); |
134 | } |
135 | |
136 | void IGESAppli_ToolPipingFlow::WriteOwnParams |
137 | (const Handle(IGESAppli_PipingFlow)& ent, IGESData_IGESWriter& IW) const |
138 | { |
139 | Standard_Integer i, num; |
140 | IW.Send(ent->NbContextFlags()); |
141 | IW.Send(ent->NbFlowAssociativities()); |
142 | IW.Send(ent->NbConnectPoints()); |
143 | IW.Send(ent->NbJoins()); |
144 | IW.Send(ent->NbFlowNames()); |
145 | IW.Send(ent->NbTextDisplayTemplates()); |
146 | IW.Send(ent->NbContFlowAssociativities()); |
147 | IW.Send(ent->TypeOfFlow()); |
148 | for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ ) |
149 | IW.Send(ent->FlowAssociativity(i)); |
150 | for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ ) |
151 | IW.Send(ent->ConnectPoint(i)); |
152 | for ( num = ent->NbJoins(), i = 1; i <= num; i++ ) |
153 | IW.Send(ent->Join(i)); |
154 | for ( num = ent->NbFlowNames(), i = 1; i <= num; i++ ) |
155 | IW.Send(ent->FlowName(i)); |
156 | for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ ) |
157 | IW.Send(ent->TextDisplayTemplate(i)); |
158 | for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ ) |
159 | IW.Send(ent->ContFlowAssociativity(i)); |
160 | } |
161 | |
162 | void IGESAppli_ToolPipingFlow::OwnShared |
163 | (const Handle(IGESAppli_PipingFlow)& ent, Interface_EntityIterator& iter) const |
164 | { |
165 | Standard_Integer i, num; |
166 | for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ ) |
167 | iter.GetOneItem(ent->FlowAssociativity(i)); |
168 | for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ ) |
169 | iter.GetOneItem(ent->ConnectPoint(i)); |
170 | for ( num = ent->NbJoins(), i = 1; i <= num; i++ ) |
171 | iter.GetOneItem(ent->Join(i)); |
172 | for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ ) |
173 | iter.GetOneItem(ent->TextDisplayTemplate(i)); |
174 | for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ ) |
175 | iter.GetOneItem(ent->ContFlowAssociativity(i)); |
176 | } |
177 | |
178 | void IGESAppli_ToolPipingFlow::OwnCopy |
179 | (const Handle(IGESAppli_PipingFlow)& another, |
180 | const Handle(IGESAppli_PipingFlow)& ent, Interface_CopyTool& TC) const |
181 | { |
182 | Standard_Integer tempNbContextFlags = another->NbContextFlags(); |
183 | Standard_Integer tempTypeOfFlow = another->TypeOfFlow(); |
184 | Standard_Integer i, num; |
185 | num = another->NbFlowAssociativities(); |
186 | Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs = |
187 | new IGESData_HArray1OfIGESEntity(1, num); |
188 | for ( i = 1; i <= num; i++ ) |
189 | { |
190 | DeclareAndCast(IGESData_IGESEntity, new_item, |
191 | TC.Transferred(another->FlowAssociativity(i))); |
192 | tempFlowAssocs->SetValue(i, new_item); |
193 | } |
194 | num = another->NbConnectPoints(); |
195 | Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints = |
196 | new IGESDraw_HArray1OfConnectPoint(1, num); |
197 | for ( i = 1; i <= num; i++ ) |
198 | { |
199 | DeclareAndCast(IGESDraw_ConnectPoint, new_item, |
200 | TC.Transferred(another->ConnectPoint(i))); |
201 | tempConnectPoints->SetValue(i, new_item); |
202 | } |
203 | num = another->NbJoins(); |
204 | Handle(IGESData_HArray1OfIGESEntity) tempJoins = |
205 | new IGESData_HArray1OfIGESEntity(1, num); |
206 | for ( i = 1; i <= num; i++ ) |
207 | { |
208 | DeclareAndCast(IGESData_IGESEntity, new_item, |
209 | TC.Transferred(another->Join(i))); |
210 | tempJoins->SetValue(i, new_item); |
211 | } |
212 | num = another->NbFlowNames(); |
213 | Handle(Interface_HArray1OfHAsciiString) tempFlowNames = |
214 | new Interface_HArray1OfHAsciiString(1, num); |
215 | for ( i = 1; i <= num; i++ ) |
216 | tempFlowNames->SetValue |
217 | (i, new TCollection_HAsciiString(another->FlowName(i))); |
218 | num = another->NbTextDisplayTemplates(); |
219 | Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates = |
220 | new IGESGraph_HArray1OfTextDisplayTemplate(1, num); |
221 | for ( i = 1; i <= num; i++ ) |
222 | { |
223 | DeclareAndCast(IGESGraph_TextDisplayTemplate, new_item, |
224 | TC.Transferred(another->TextDisplayTemplate(i))); |
225 | tempTextDisplayTemplates->SetValue(i, new_item); |
226 | } |
227 | num = another->NbContFlowAssociativities(); |
228 | Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs = |
229 | new IGESData_HArray1OfIGESEntity(1, num); |
230 | for ( i = 1; i <= num; i++ ) |
231 | { |
232 | DeclareAndCast(IGESData_IGESEntity, new_item, |
233 | TC.Transferred(another->ContFlowAssociativity(i))); |
234 | tempContFlowAssocs->SetValue(i, new_item); |
235 | } |
236 | ent->Init (tempNbContextFlags, tempTypeOfFlow, tempFlowAssocs, |
237 | tempConnectPoints, tempJoins, tempFlowNames, |
238 | tempTextDisplayTemplates, tempContFlowAssocs); |
239 | } |
240 | |
241 | Standard_Boolean IGESAppli_ToolPipingFlow::OwnCorrect |
242 | (const Handle(IGESAppli_PipingFlow)& ent) const |
243 | { |
244 | return ent->OwnCorrect(); // nbcontextflags = 1 |
245 | } |
246 | |
247 | IGESData_DirChecker IGESAppli_ToolPipingFlow::DirChecker |
248 | (const Handle(IGESAppli_PipingFlow)& /* ent */) const |
249 | { |
250 | IGESData_DirChecker DC(402, 20); |
251 | DC.Structure(IGESData_DefVoid); |
252 | DC.GraphicsIgnored(); |
253 | DC.LineFont(IGESData_DefVoid); |
254 | DC.LineWeight(IGESData_DefVoid); |
255 | DC.Color(IGESData_DefVoid); |
256 | DC.BlankStatusIgnored(); |
257 | DC.UseFlagRequired(3); |
258 | DC.HierarchyStatusIgnored(); |
259 | return DC; |
260 | } |
261 | |
262 | void IGESAppli_ToolPipingFlow::OwnCheck |
263 | (const Handle(IGESAppli_PipingFlow)& ent, |
264 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
265 | { |
266 | if (ent->NbContextFlags() != 1) |
267 | ach->AddFail("Number of Context Flags != 1"); |
268 | if ((ent->TypeOfFlow() < 0) || (ent->TypeOfFlow() > 2)) |
269 | ach->AddFail("Type of Flow != 0,1,2"); |
270 | } |
271 | |
272 | void IGESAppli_ToolPipingFlow::OwnDump |
273 | (const Handle(IGESAppli_PipingFlow)& ent, const IGESData_IGESDumper& dumper, |
274 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
275 | { |
276 | S << "IGESAppli_PipingFlow" << endl; |
277 | S << "Number of Context Flags : " << ent->NbContextFlags() << endl; |
278 | S << "Type of Flow : " << ent->TypeOfFlow() << endl; |
279 | S << "Flow Associativities : "; |
280 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbFlowAssociativities(), |
281 | ent->FlowAssociativity); |
282 | S << "Connect Points : "; |
283 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbConnectPoints() |
284 | ,ent->ConnectPoint); |
285 | S << "Joins : "; |
286 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbJoins(),ent->Join); |
287 | S << "Flow Names : "; |
288 | IGESData_DumpStrings(S ,level,1, ent->NbFlowNames(),ent->FlowName); |
289 | S << "Text Display Templates : "; |
290 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbTextDisplayTemplates(), |
291 | ent->TextDisplayTemplate); |
292 | S << "Continuation Flow Associativities : "; |
293 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbContFlowAssociativities(), |
294 | ent->ContFlowAssociativity); |
295 | S << endl; |
296 | } |
297 | |