1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
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>
25 #include <IGESData_IGESEntity.hxx>
26 #include <IGESData_IGESReaderData.hxx>
27 #include <IGESData_IGESWriter.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESDraw_ConnectPoint.hxx>
30 #include <IGESDraw_HArray1OfConnectPoint.hxx>
31 #include <IGESGraph_HArray1OfTextDisplayTemplate.hxx>
32 #include <IGESGraph_TextDisplayTemplate.hxx>
33 #include <Interface_Check.hxx>
34 #include <Interface_CopyTool.hxx>
35 #include <Interface_EntityIterator.hxx>
36 #include <Interface_HArray1OfHAsciiString.hxx>
37 #include <Interface_Macros.hxx>
38 #include <Interface_ShareTool.hxx>
39 #include <Message_Messenger.hxx>
40 #include <Standard_DomainError.hxx>
41 #include <TCollection_HAsciiString.hxx>
43 IGESAppli_ToolPipingFlow::IGESAppli_ToolPipingFlow () { }
46 void IGESAppli_ToolPipingFlow::ReadOwnParams
47 (const Handle(IGESAppli_PipingFlow)& ent,
48 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
50 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
51 Standard_Integer tempNbContextFlags;
52 Standard_Integer tempTypeOfFlow;
53 Standard_Integer i, num;
54 Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs;
55 Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints;
56 Handle(IGESData_HArray1OfIGESEntity) tempJoins;
57 Handle(Interface_HArray1OfHAsciiString) tempFlowNames;
58 Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates;
59 Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs;
61 //szv#4:S4163:12Mar99 `st=` not needed
62 if (PR.DefinedElseSkip())
63 PR.ReadInteger(PR.Current(), "Number of Context Flags", tempNbContextFlags);
65 tempNbContextFlags = 1;
67 if (!PR.ReadInteger(PR.Current(), "Number of Flow Associativities", num)) num = 0;
68 if (num > 0) tempFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num);
69 else PR.AddFail("Number of Flow Associativities: Not Positive");
71 if (!PR.ReadInteger(PR.Current(), "Number of Connect Points", num)) num = 0;
72 if (num > 0) tempConnectPoints = new IGESDraw_HArray1OfConnectPoint(1, num);
73 else PR.AddFail("Number of Connect Points: Not Positive");
75 if (!PR.ReadInteger(PR.Current(), "Number of Joins", num)) num = 0;
76 if (num > 0) tempJoins = new IGESData_HArray1OfIGESEntity(1, num);
77 else PR.AddFail("Number of Joins: Not Positive");
79 if (!PR.ReadInteger(PR.Current(), "Number of Flow Names", num)) num = 0;
80 if (num > 0) tempFlowNames = new Interface_HArray1OfHAsciiString(1, num);
81 else PR.AddFail("Number of Flow Names: Not Positive");
83 if (!PR.ReadInteger(PR.Current(), "Number of Text Displays", num)) num = 0;
84 if (num > 0) tempTextDisplayTemplates = new IGESGraph_HArray1OfTextDisplayTemplate(1, num);
85 else PR.AddFail("Number of Text Displays: Not Positive");
87 if (!PR.ReadInteger(PR.Current(), "Number of Continuation Flows", num)) num = 0;
88 if (num > 0) tempContFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num);
89 else PR.AddFail("Number of Continuation Flows: Not Positive");
91 if (PR.DefinedElseSkip())
92 PR.ReadInteger(PR.Current(), "Type of Flow", tempTypeOfFlow);
96 if (!tempFlowAssocs.IsNull())
97 for ( num = tempFlowAssocs->Length(), i = 1; i <= num; i++ ) {
98 Handle(IGESData_IGESEntity) tempEntity;
99 //szv#4:S4163:12Mar99 moved in if
100 if (PR.ReadEntity (IR, PR.Current(), "Flow Associativity", STANDARD_TYPE(IGESData_IGESEntity),tempEntity))
101 tempFlowAssocs->SetValue(i, tempEntity);
104 if (!tempConnectPoints.IsNull())
105 for ( num = tempConnectPoints->Length(), i = 1; i <= num; i++ ) {
106 Handle(IGESDraw_ConnectPoint) tempEntity;
107 if (PR.ReadEntity(IR, PR.Current(), "Connect Point", STANDARD_TYPE(IGESDraw_ConnectPoint),tempEntity))
108 tempConnectPoints->SetValue(i, tempEntity);
111 if (!tempJoins.IsNull())
112 for ( num = tempJoins->Length(), i = 1; i <= num; i++ ) {
113 Handle(IGESData_IGESEntity) tempEntity;
114 if (PR.ReadEntity(IR, PR.Current(), "Join", tempEntity))
115 tempJoins->SetValue(i, tempEntity);
118 if (!tempFlowNames.IsNull())
119 for ( num = tempFlowNames->Length(), i = 1; i <= num; i++ ) {
120 Handle(TCollection_HAsciiString) tempString;
121 if (PR.ReadText(PR.Current(), "Flow Name", tempString))
122 tempFlowNames->SetValue(i, tempString);
125 if (!tempTextDisplayTemplates.IsNull())
126 for ( num = tempTextDisplayTemplates->Length(), i = 1; i <= num; i++ ) {
127 Handle(IGESGraph_TextDisplayTemplate) tempEntity;
128 if (PR.ReadEntity (IR, PR.Current(), "Text Display Template",
129 STANDARD_TYPE(IGESGraph_TextDisplayTemplate),tempEntity))
130 tempTextDisplayTemplates->SetValue(i, tempEntity);
133 if (!tempContFlowAssocs.IsNull())
134 for ( num = tempContFlowAssocs->Length(), i = 1; i <= num; i++ ) {
135 Handle(IGESData_IGESEntity) tempEntity;
136 if (PR.ReadEntity (IR, PR.Current(), "Continuation Flow Assocs", tempEntity))
137 tempContFlowAssocs->SetValue(i, tempEntity);
140 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
141 ent->Init(tempNbContextFlags, tempTypeOfFlow, tempFlowAssocs,
142 tempConnectPoints, tempJoins, tempFlowNames,
143 tempTextDisplayTemplates, tempContFlowAssocs);
146 void IGESAppli_ToolPipingFlow::WriteOwnParams
147 (const Handle(IGESAppli_PipingFlow)& ent, IGESData_IGESWriter& IW) const
149 Standard_Integer i, num;
150 IW.Send(ent->NbContextFlags());
151 IW.Send(ent->NbFlowAssociativities());
152 IW.Send(ent->NbConnectPoints());
153 IW.Send(ent->NbJoins());
154 IW.Send(ent->NbFlowNames());
155 IW.Send(ent->NbTextDisplayTemplates());
156 IW.Send(ent->NbContFlowAssociativities());
157 IW.Send(ent->TypeOfFlow());
158 for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ )
159 IW.Send(ent->FlowAssociativity(i));
160 for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ )
161 IW.Send(ent->ConnectPoint(i));
162 for ( num = ent->NbJoins(), i = 1; i <= num; i++ )
163 IW.Send(ent->Join(i));
164 for ( num = ent->NbFlowNames(), i = 1; i <= num; i++ )
165 IW.Send(ent->FlowName(i));
166 for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ )
167 IW.Send(ent->TextDisplayTemplate(i));
168 for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ )
169 IW.Send(ent->ContFlowAssociativity(i));
172 void IGESAppli_ToolPipingFlow::OwnShared
173 (const Handle(IGESAppli_PipingFlow)& ent, Interface_EntityIterator& iter) const
175 Standard_Integer i, num;
176 for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ )
177 iter.GetOneItem(ent->FlowAssociativity(i));
178 for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ )
179 iter.GetOneItem(ent->ConnectPoint(i));
180 for ( num = ent->NbJoins(), i = 1; i <= num; i++ )
181 iter.GetOneItem(ent->Join(i));
182 for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ )
183 iter.GetOneItem(ent->TextDisplayTemplate(i));
184 for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ )
185 iter.GetOneItem(ent->ContFlowAssociativity(i));
188 void IGESAppli_ToolPipingFlow::OwnCopy
189 (const Handle(IGESAppli_PipingFlow)& another,
190 const Handle(IGESAppli_PipingFlow)& ent, Interface_CopyTool& TC) const
192 Standard_Integer tempNbContextFlags = another->NbContextFlags();
193 Standard_Integer tempTypeOfFlow = another->TypeOfFlow();
194 Standard_Integer i, num;
195 num = another->NbFlowAssociativities();
196 Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs =
197 new IGESData_HArray1OfIGESEntity(1, num);
198 for ( i = 1; i <= num; i++ )
200 DeclareAndCast(IGESData_IGESEntity, new_item,
201 TC.Transferred(another->FlowAssociativity(i)));
202 tempFlowAssocs->SetValue(i, new_item);
204 num = another->NbConnectPoints();
205 Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints =
206 new IGESDraw_HArray1OfConnectPoint(1, num);
207 for ( i = 1; i <= num; i++ )
209 DeclareAndCast(IGESDraw_ConnectPoint, new_item,
210 TC.Transferred(another->ConnectPoint(i)));
211 tempConnectPoints->SetValue(i, new_item);
213 num = another->NbJoins();
214 Handle(IGESData_HArray1OfIGESEntity) tempJoins =
215 new IGESData_HArray1OfIGESEntity(1, num);
216 for ( i = 1; i <= num; i++ )
218 DeclareAndCast(IGESData_IGESEntity, new_item,
219 TC.Transferred(another->Join(i)));
220 tempJoins->SetValue(i, new_item);
222 num = another->NbFlowNames();
223 Handle(Interface_HArray1OfHAsciiString) tempFlowNames =
224 new Interface_HArray1OfHAsciiString(1, num);
225 for ( i = 1; i <= num; i++ )
226 tempFlowNames->SetValue
227 (i, new TCollection_HAsciiString(another->FlowName(i)));
228 num = another->NbTextDisplayTemplates();
229 Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates =
230 new IGESGraph_HArray1OfTextDisplayTemplate(1, num);
231 for ( i = 1; i <= num; i++ )
233 DeclareAndCast(IGESGraph_TextDisplayTemplate, new_item,
234 TC.Transferred(another->TextDisplayTemplate(i)));
235 tempTextDisplayTemplates->SetValue(i, new_item);
237 num = another->NbContFlowAssociativities();
238 Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs =
239 new IGESData_HArray1OfIGESEntity(1, num);
240 for ( i = 1; i <= num; i++ )
242 DeclareAndCast(IGESData_IGESEntity, new_item,
243 TC.Transferred(another->ContFlowAssociativity(i)));
244 tempContFlowAssocs->SetValue(i, new_item);
246 ent->Init (tempNbContextFlags, tempTypeOfFlow, tempFlowAssocs,
247 tempConnectPoints, tempJoins, tempFlowNames,
248 tempTextDisplayTemplates, tempContFlowAssocs);
251 Standard_Boolean IGESAppli_ToolPipingFlow::OwnCorrect
252 (const Handle(IGESAppli_PipingFlow)& ent) const
254 return ent->OwnCorrect(); // nbcontextflags = 1
257 IGESData_DirChecker IGESAppli_ToolPipingFlow::DirChecker
258 (const Handle(IGESAppli_PipingFlow)& /* ent */) const
260 IGESData_DirChecker DC(402, 20);
261 DC.Structure(IGESData_DefVoid);
262 DC.GraphicsIgnored();
263 DC.LineFont(IGESData_DefVoid);
264 DC.LineWeight(IGESData_DefVoid);
265 DC.Color(IGESData_DefVoid);
266 DC.BlankStatusIgnored();
267 DC.UseFlagRequired(3);
268 DC.HierarchyStatusIgnored();
272 void IGESAppli_ToolPipingFlow::OwnCheck
273 (const Handle(IGESAppli_PipingFlow)& ent,
274 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
276 if (ent->NbContextFlags() != 1)
277 ach->AddFail("Number of Context Flags != 1");
278 if ((ent->TypeOfFlow() < 0) || (ent->TypeOfFlow() > 2))
279 ach->AddFail("Type of Flow != 0,1,2");
282 void IGESAppli_ToolPipingFlow::OwnDump
283 (const Handle(IGESAppli_PipingFlow)& ent, const IGESData_IGESDumper& dumper,
284 Standard_OStream& S, const Standard_Integer level) const
286 S << "IGESAppli_PipingFlow\n";
287 S << "Number of Context Flags : " << ent->NbContextFlags() << "\n";
288 S << "Type of Flow : " << ent->TypeOfFlow() << "\n";
289 S << "Flow Associativities : ";
290 IGESData_DumpEntities(S,dumper ,level,1, ent->NbFlowAssociativities(),
291 ent->FlowAssociativity);
292 S << "Connect Points : ";
293 IGESData_DumpEntities(S,dumper ,level,1, ent->NbConnectPoints()
296 IGESData_DumpEntities(S,dumper ,level,1, ent->NbJoins(),ent->Join);
297 S << "Flow Names : ";
298 IGESData_DumpStrings(S ,level,1, ent->NbFlowNames(),ent->FlowName);
299 S << "Text Display Templates : ";
300 IGESData_DumpEntities(S,dumper ,level,1, ent->NbTextDisplayTemplates(),
301 ent->TextDisplayTemplate);
302 S << "Continuation Flow Associativities : ";
303 IGESData_DumpEntities(S,dumper ,level,1, ent->NbContFlowAssociativities(),
304 ent->ContFlowAssociativity);