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