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