summaryrefslogtreecommitdiff
path: root/src/IGESAppli/IGESAppli_ToolPipingFlow.cxx
blob: abbf1d537bb5baffc6deac511bd1844546855ace (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
//--------------------------------------------------------------------
//
//  File Name : IGESAppli_PipingFlow.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESAppli_ToolPipingFlow.ixx>
#include <IGESData_ParamCursor.hxx>
#include <TCollection_HAsciiString.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGraph_TextDisplayTemplate.hxx>
#include <IGESDraw_ConnectPoint.hxx>
#include <IGESDraw_HArray1OfConnectPoint.hxx>
#include <Interface_HArray1OfHAsciiString.hxx>
#include <IGESGraph_HArray1OfTextDisplayTemplate.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESAppli_ToolPipingFlow::IGESAppli_ToolPipingFlow ()    {  }


void  IGESAppli_ToolPipingFlow::ReadOwnParams
  (const Handle(IGESAppli_PipingFlow)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
  Standard_Integer tempNbContextFlags;
  Standard_Integer tempTypeOfFlow;
  Standard_Integer i, num;
  Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs;
  Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints;
  Handle(IGESData_HArray1OfIGESEntity) tempJoins;
  Handle(Interface_HArray1OfHAsciiString) tempFlowNames;
  Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates;
  Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs;

  //szv#4:S4163:12Mar99 `st=` not needed
  if (PR.DefinedElseSkip())
    PR.ReadInteger(PR.Current(), "Number of Context Flags", tempNbContextFlags);
  else
    tempNbContextFlags = 1;

  if (!PR.ReadInteger(PR.Current(), "Number of Flow Associativities", num)) num = 0;
  if (num > 0) tempFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num);
  else  PR.AddFail("Number of Flow Associativities: Not Positive");

  if (!PR.ReadInteger(PR.Current(), "Number of Connect Points", num)) num = 0;
  if (num > 0) tempConnectPoints = new IGESDraw_HArray1OfConnectPoint(1, num);
  else  PR.AddFail("Number of Connect Points: Not Positive");

  if (!PR.ReadInteger(PR.Current(), "Number of Joins", num)) num = 0;
  if (num > 0) tempJoins = new IGESData_HArray1OfIGESEntity(1, num);
  else  PR.AddFail("Number of Joins: Not Positive");

  if (!PR.ReadInteger(PR.Current(), "Number of Flow Names", num)) num = 0;
  if (num > 0) tempFlowNames = new Interface_HArray1OfHAsciiString(1, num);
  else  PR.AddFail("Number of Flow Names: Not Positive");

  if (!PR.ReadInteger(PR.Current(), "Number of Text Displays", num)) num = 0;
  if (num > 0) tempTextDisplayTemplates = new IGESGraph_HArray1OfTextDisplayTemplate(1, num);
  else  PR.AddFail("Number of Text Displays: Not Positive");

  if (!PR.ReadInteger(PR.Current(), "Number of Continuation Flows", num)) num = 0;
  if (num > 0) tempContFlowAssocs = new IGESData_HArray1OfIGESEntity(1, num);
  else  PR.AddFail("Number of Continuation Flows: Not Positive");

  if (PR.DefinedElseSkip())
    PR.ReadInteger(PR.Current(), "Type of Flow", tempTypeOfFlow);
  else
    tempTypeOfFlow = 0;

  if (!tempFlowAssocs.IsNull())
    for ( num = tempFlowAssocs->Length(), i = 1; i <= num; i++ ) {
      Handle(IGESData_IGESEntity) tempEntity;
      //szv#4:S4163:12Mar99 moved in if
      if (PR.ReadEntity (IR, PR.Current(), "Flow Associativity", STANDARD_TYPE(IGESData_IGESEntity),tempEntity))
	tempFlowAssocs->SetValue(i, tempEntity);
    }

  if (!tempConnectPoints.IsNull())
    for ( num = tempConnectPoints->Length(), i = 1; i <= num; i++ ) {
      Handle(IGESDraw_ConnectPoint) tempEntity;
      if (PR.ReadEntity(IR, PR.Current(), "Connect Point", STANDARD_TYPE(IGESDraw_ConnectPoint),tempEntity))
	tempConnectPoints->SetValue(i, tempEntity);
    }

  if (!tempJoins.IsNull())
    for ( num = tempJoins->Length(), i = 1; i <= num; i++ ) {
      Handle(IGESData_IGESEntity) tempEntity;
      if (PR.ReadEntity(IR, PR.Current(), "Join", tempEntity))
	tempJoins->SetValue(i, tempEntity);
    }

  if (!tempFlowNames.IsNull())
    for ( num = tempFlowNames->Length(), i = 1; i <= num; i++ ) {
      Handle(TCollection_HAsciiString) tempString;
      if (PR.ReadText(PR.Current(), "Flow Name", tempString))
	tempFlowNames->SetValue(i, tempString);
    }

  if (!tempTextDisplayTemplates.IsNull())
    for ( num = tempTextDisplayTemplates->Length(), i = 1; i <= num; i++ ) {
      Handle(IGESGraph_TextDisplayTemplate) tempEntity;
      if (PR.ReadEntity (IR, PR.Current(), "Text Display Template",
			 STANDARD_TYPE(IGESGraph_TextDisplayTemplate),tempEntity))
	tempTextDisplayTemplates->SetValue(i, tempEntity);
    }

  if (!tempContFlowAssocs.IsNull())
    for ( num = tempContFlowAssocs->Length(), i = 1; i <= num; i++ ) {
      Handle(IGESData_IGESEntity) tempEntity;
      if (PR.ReadEntity (IR, PR.Current(), "Continuation Flow Assocs", tempEntity))
	tempContFlowAssocs->SetValue(i, tempEntity);
    }

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(tempNbContextFlags, tempTypeOfFlow, tempFlowAssocs,
	    tempConnectPoints, tempJoins, tempFlowNames,
	    tempTextDisplayTemplates, tempContFlowAssocs);
}

void  IGESAppli_ToolPipingFlow::WriteOwnParams
  (const Handle(IGESAppli_PipingFlow)& ent, IGESData_IGESWriter& IW) const
{
  Standard_Integer i, num;
  IW.Send(ent->NbContextFlags());
  IW.Send(ent->NbFlowAssociativities());
  IW.Send(ent->NbConnectPoints());
  IW.Send(ent->NbJoins());
  IW.Send(ent->NbFlowNames());
  IW.Send(ent->NbTextDisplayTemplates());
  IW.Send(ent->NbContFlowAssociativities());
  IW.Send(ent->TypeOfFlow());
  for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ )
    IW.Send(ent->FlowAssociativity(i));
  for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ )
    IW.Send(ent->ConnectPoint(i));
  for ( num = ent->NbJoins(), i = 1; i <= num; i++ )
    IW.Send(ent->Join(i));
  for ( num = ent->NbFlowNames(), i = 1; i <= num; i++ )
    IW.Send(ent->FlowName(i));
  for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ )
    IW.Send(ent->TextDisplayTemplate(i));
  for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ )
    IW.Send(ent->ContFlowAssociativity(i));
}

void  IGESAppli_ToolPipingFlow::OwnShared
  (const Handle(IGESAppli_PipingFlow)& ent, Interface_EntityIterator& iter) const
{
  Standard_Integer i, num;
  for ( num = ent->NbFlowAssociativities(), i = 1; i <= num; i++ )
    iter.GetOneItem(ent->FlowAssociativity(i));
  for ( num = ent->NbConnectPoints(), i = 1; i <= num; i++ )
    iter.GetOneItem(ent->ConnectPoint(i));
  for ( num = ent->NbJoins(), i = 1; i <= num; i++ )
    iter.GetOneItem(ent->Join(i));
  for ( num = ent->NbTextDisplayTemplates(), i = 1; i <= num; i++ )
    iter.GetOneItem(ent->TextDisplayTemplate(i));
  for ( num = ent->NbContFlowAssociativities(), i = 1; i <= num; i++ )
    iter.GetOneItem(ent->ContFlowAssociativity(i));
}

void  IGESAppli_ToolPipingFlow::OwnCopy
  (const Handle(IGESAppli_PipingFlow)& another,
   const Handle(IGESAppli_PipingFlow)& ent, Interface_CopyTool& TC) const
{
  Standard_Integer tempNbContextFlags = another->NbContextFlags();
  Standard_Integer tempTypeOfFlow = another->TypeOfFlow();
  Standard_Integer i, num;
  num = another->NbFlowAssociativities();
  Handle(IGESData_HArray1OfIGESEntity) tempFlowAssocs =
    new IGESData_HArray1OfIGESEntity(1, num);
  for ( i = 1; i <= num; i++ )
    {
      DeclareAndCast(IGESData_IGESEntity, new_item,
		     TC.Transferred(another->FlowAssociativity(i)));
      tempFlowAssocs->SetValue(i, new_item);
    }
  num = another->NbConnectPoints();
  Handle(IGESDraw_HArray1OfConnectPoint) tempConnectPoints =
    new IGESDraw_HArray1OfConnectPoint(1, num);
  for ( i = 1; i <= num; i++ )
    {
      DeclareAndCast(IGESDraw_ConnectPoint, new_item,
		     TC.Transferred(another->ConnectPoint(i)));
      tempConnectPoints->SetValue(i, new_item);
    }
  num = another->NbJoins();
  Handle(IGESData_HArray1OfIGESEntity) tempJoins =
    new IGESData_HArray1OfIGESEntity(1, num);
  for ( i = 1; i <= num; i++ )
    {
      DeclareAndCast(IGESData_IGESEntity, new_item,
		     TC.Transferred(another->Join(i)));
      tempJoins->SetValue(i, new_item);
    }
  num = another->NbFlowNames();
  Handle(Interface_HArray1OfHAsciiString) tempFlowNames =
    new Interface_HArray1OfHAsciiString(1, num);
  for ( i = 1; i <= num; i++ )
    tempFlowNames->SetValue
      (i, new TCollection_HAsciiString(another->FlowName(i)));
  num = another->NbTextDisplayTemplates();
  Handle(IGESGraph_HArray1OfTextDisplayTemplate) tempTextDisplayTemplates =
    new IGESGraph_HArray1OfTextDisplayTemplate(1, num);
  for ( i = 1; i <= num; i++ )
    {
      DeclareAndCast(IGESGraph_TextDisplayTemplate, new_item,
		     TC.Transferred(another->TextDisplayTemplate(i)));
      tempTextDisplayTemplates->SetValue(i, new_item);
    }
  num = another->NbContFlowAssociativities();
  Handle(IGESData_HArray1OfIGESEntity) tempContFlowAssocs =
    new IGESData_HArray1OfIGESEntity(1, num);
  for ( i = 1; i <= num; i++ )
    {
      DeclareAndCast(IGESData_IGESEntity, new_item,
		     TC.Transferred(another->ContFlowAssociativity(i)));
      tempContFlowAssocs->SetValue(i, new_item);
    }
  ent->Init (tempNbContextFlags, tempTypeOfFlow, tempFlowAssocs,
	     tempConnectPoints,  tempJoins, tempFlowNames,
	     tempTextDisplayTemplates, tempContFlowAssocs);
}

Standard_Boolean  IGESAppli_ToolPipingFlow::OwnCorrect
  (const Handle(IGESAppli_PipingFlow)& ent) const
{
  return ent->OwnCorrect();    // nbcontextflags = 1
}

IGESData_DirChecker  IGESAppli_ToolPipingFlow::DirChecker
  (const Handle(IGESAppli_PipingFlow)& /* ent  */) const
{
  IGESData_DirChecker DC(402, 20);
  DC.Structure(IGESData_DefVoid);
  DC.GraphicsIgnored();
  DC.LineFont(IGESData_DefVoid);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefVoid);
  DC.BlankStatusIgnored();
  DC.UseFlagRequired(3);
  DC.HierarchyStatusIgnored();
  return DC;
}

void  IGESAppli_ToolPipingFlow::OwnCheck
  (const Handle(IGESAppli_PipingFlow)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach) const
{
  if (ent->NbContextFlags() != 1)
    ach->AddFail("Number of Context Flags != 1");
  if ((ent->TypeOfFlow() < 0) || (ent->TypeOfFlow() > 2))
    ach->AddFail("Type of Flow != 0,1,2");
}

void  IGESAppli_ToolPipingFlow::OwnDump
  (const Handle(IGESAppli_PipingFlow)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level) const
{
  S << "IGESAppli_PipingFlow" << endl;
  S << "Number of Context Flags : " << ent->NbContextFlags() << endl;
  S << "Type of Flow : " << ent->TypeOfFlow() << endl;
  S << "Flow Associativities : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbFlowAssociativities(),
			ent->FlowAssociativity);
  S << "Connect Points : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbConnectPoints()
			,ent->ConnectPoint);
  S << "Joins : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbJoins(),ent->Join);
  S << "Flow Names : ";
  IGESData_DumpStrings(S ,level,1, ent->NbFlowNames(),ent->FlowName);
  S << "Text Display Templates : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbTextDisplayTemplates(),
			ent->TextDisplayTemplate);
  S << "Continuation Flow Associativities : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbContFlowAssociativities(),
			ent->ContFlowAssociativity);
  S << endl;
}