0024947: Redesign OCCT legacy type system -- automatic
[occt.git] / src / StepAP209 / StepAP209_Construct.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <StepAP209_Construct.ixx>
15
16#include <Interface_EntityIterator.hxx>
17#include <Interface_HArray1OfHAsciiString.hxx>
18#include <TCollection_HAsciiString.hxx>
19#include <TColStd_HArray1OfAsciiString.hxx>
20#include <TColStd_HArray1OfReal.hxx>
21#include <OSD_Process.hxx>
22#include <Quantity_Date.hxx>
23
24#include <HeaderSection_FileName.hxx>
25#include <HeaderSection_FileSchema.hxx>
26#include <HeaderSection_FileDescription.hxx>
27
28#include <StepBasic_ProductDefinitionFormation.hxx>
29#include <StepBasic_ProductDefinitionFormationRelationship.hxx>
30#include <StepBasic_HArray1OfProductContext.hxx>
31#include <StepBasic_ProductDefinitionContext.hxx>
32#include <StepBasic_HArray1OfNamedUnit.hxx>
33#include <StepBasic_HArray1OfUncertaintyMeasureWithUnit.hxx>
34#include <StepBasic_SiUnitAndTimeUnit.hxx>
35#include <StepBasic_SiUnitAndMassUnit.hxx>
36#include <StepBasic_SiUnitAndThermodynamicTemperatureUnit.hxx>
37#include <StepBasic_DimensionalExponents.hxx>
38#include <StepBasic_ApprovalStatus.hxx>
39#include <StepBasic_Approval.hxx>
40#include <StepBasic_SecurityClassificationLevel.hxx>
41#include <StepBasic_SecurityClassification.hxx>
42#include <StepBasic_CalendarDate.hxx>
43#include <StepBasic_CoordinatedUniversalTimeOffset.hxx>
44#include <StepBasic_LocalTime.hxx>
45#include <StepBasic_DateAndTime.hxx>
46#include <StepBasic_DateTimeRole.hxx>
47#include <StepBasic_ApprovalDateTime.hxx>
48#include <StepBasic_DateTimeSelect.hxx>
49#include <StepBasic_Person.hxx>
50#include <StepBasic_Organization.hxx>
51#include <StepBasic_PersonAndOrganization.hxx>
52#include <StepBasic_PersonAndOrganizationRole.hxx>
53#include <StepBasic_ApprovalRole.hxx>
54#include <StepBasic_ApprovalPersonOrganization.hxx>
55#include <StepBasic_PersonOrganizationSelect.hxx>
56#include <StepBasic_HArray1OfProduct.hxx>
57#include <StepBasic_ProductRelatedProductCategory.hxx>
58#include <StepBasic_ProductCategory.hxx>
59#include <StepBasic_ProductCategoryRelationship.hxx>
60#include <StepBasic_MechanicalContext.hxx>
61#include <StepBasic_DesignContext.hxx>
62#include <StepBasic_ApplicationProtocolDefinition.hxx>
63
64#include <StepRepr_PropertyDefinitionRepresentation.hxx>
65#include <StepRepr_StructuralResponseProperty.hxx>
66#include <StepRepr_StructuralResponsePropertyDefinitionRepresentation.hxx>
67#include <StepRepr_RepresentationItem.hxx>
68#include <StepRepr_HArray1OfRepresentationItem.hxx>
69#include <StepRepr_ShapeRepresentationRelationship.hxx>
70#include <StepRepr_GlobalUncertaintyAssignedContext.hxx>
71#include <StepRepr_GlobalUnitAssignedContext.hxx>
72
73#include <StepFEA_Curve3dElementRepresentation.hxx>
74#include <StepFEA_Surface3dElementRepresentation.hxx>
75#include <StepFEA_Volume3dElementRepresentation.hxx>
76#include <StepFEA_FeaModelDefinition.hxx>
77#include <StepFEA_HArray1OfCurveElementInterval.hxx>
78#include <StepFEA_CurveElementIntervalConstant.hxx>
79#include <StepFEA_Curve3dElementProperty.hxx>
80#include <StepFEA_ElementGeometricRelationship.hxx>
81#include <StepFEA_FeaModel3d.hxx>
82#include <StepFEA_FeaAxis2Placement3d.hxx>
83#include <StepFEA_CoordinateSystemType.hxx>
84
85#include <StepShape_ShapeDefinitionRepresentation.hxx>
86
87#include <StepData_StepModel.hxx>
88
89#include <StepElement_AnalysisItemWithinRepresentation.hxx>
90
91#include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
92#include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
93#include <StepGeom_CartesianPoint.hxx>
94#include <StepGeom_Direction.hxx>
95
96#include <StepAP203_CcDesignApproval.hxx>
97#include <StepAP203_CcDesignPersonAndOrganizationAssignment.hxx>
98#include <StepAP203_CcDesignDateAndTimeAssignment.hxx>
99#include <StepAP203_CcDesignSecurityClassification.hxx>
100#include <StepAP203_HArray1OfApprovedItem.hxx>
101#include <StepAP203_HArray1OfPersonOrganizationItem.hxx>
102#include <StepAP203_HArray1OfDateTimeItem.hxx>
103#include <StepAP203_HArray1OfClassifiedItem.hxx>
104
105#include <StepAP214_AppliedApprovalAssignment.hxx>
106#include <StepAP214_AppliedPersonAndOrganizationAssignment.hxx>
107#include <StepAP214_AppliedDateAndTimeAssignment.hxx>
108#include <StepAP214_AppliedSecurityClassificationAssignment.hxx>
109#include <StepAP214_HArray1OfApprovalItem.hxx>
110#include <StepAP214_ApprovalItem.hxx>
111#include <StepAP214_HArray1OfPersonAndOrganizationItem.hxx>
112#include <StepAP214_PersonAndOrganizationItem.hxx>
113#include <StepAP214_HArray1OfDateAndTimeItem.hxx>
114#include <StepAP214_DateAndTimeItem.hxx>
115#include <StepAP214_HArray1OfSecurityClassificationItem.hxx>
116#include <StepAP214_SecurityClassificationItem.hxx>
117#include <StepAP214_ApprovalItem.hxx>
ec357c5c 118#include <StepElement_ElementMaterial.hxx>
119#include <StepFEA_FeaModel.hxx>
120#include <StepFEA_ElementRepresentation.hxx>
121#include <StepShape_ShapeRepresentation.hxx>
122#include <StepBasic_ProductDefinition.hxx>
123#include <StepRepr_ProductDefinitionShape.hxx>
124#include <StepBasic_ProductContext.hxx>
7fd59977 125
126//#include <.hxx>
127
128
129//=======================================================================
130//function : StepAP209_Construct
131//purpose :
132//=======================================================================
133
134StepAP209_Construct::StepAP209_Construct ()
135{
136}
137
138//=======================================================================
139//function : StepAP209_Construct
140//purpose :
141//=======================================================================
142
143StepAP209_Construct::StepAP209_Construct (const Handle(XSControl_WorkSession) &WS)
144 : STEPConstruct_Tool ( WS )
145{
146}
147
148//=======================================================================
149//function : Init
150//purpose :
151//=======================================================================
152
153Standard_Boolean StepAP209_Construct::Init (const Handle(XSControl_WorkSession) &WS)
154{
155 return SetWS ( WS );
156}
157
158
159//=======================================================================
160//function : IsDesing
161//purpose :
162//=======================================================================
163
164Standard_Boolean StepAP209_Construct::IsDesing (const Handle(StepBasic_ProductDefinitionFormation) &PDF) const
165{
166 Interface_EntityIterator subs = Graph().Sharings(PDF);
167 for (subs.Start(); subs.More(); subs.Next()) {
168 Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR =
169 Handle(StepBasic_ProductDefinitionFormationRelationship)::DownCast(subs.Value());
170 if(PDFR.IsNull()) continue;
171 if ( PDF == PDFR->RelatingProductDefinitionFormation() ) return Standard_True;
172 }
173 return Standard_False;
174}
175
176
177//=======================================================================
178//function : IsAnalys
179//purpose :
180//=======================================================================
181
182Standard_Boolean StepAP209_Construct::IsAnalys (const Handle(StepBasic_ProductDefinitionFormation) &PDF) const
183{
184 Interface_EntityIterator subs = Graph().Sharings(PDF);
185 for (subs.Start(); subs.More(); subs.Next()) {
186 Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR =
187 Handle(StepBasic_ProductDefinitionFormationRelationship)::DownCast(subs.Value());
188 if(PDFR.IsNull()) continue;
189 if ( PDF == PDFR->RelatedProductDefinitionFormation() ) return Standard_True;
190 }
191 return Standard_False;
192}
193
194
195//=======================================================================
196//function : GetElementMaterial
197//purpose :
198//=======================================================================
199
200Handle(StepElement_HSequenceOfElementMaterial) StepAP209_Construct::GetElementMaterial() const
201{
202 Handle(StepElement_HSequenceOfElementMaterial) aSequence =
203 new StepElement_HSequenceOfElementMaterial;
204 Handle(Interface_InterfaceModel) model = Model();
205 Standard_Integer nb = model->NbEntities();
206 for(Standard_Integer i=1; i<=nb; i++) {
207 Handle(Standard_Transient) anEntity = model->Value(i);
208 if(anEntity->IsKind(STANDARD_TYPE(StepElement_ElementMaterial))) {
209 Handle(StepElement_ElementMaterial) anElement =
210 Handle(StepElement_ElementMaterial)::DownCast(anEntity);
211 aSequence->Append(anElement);
212 }
213 }
214 return aSequence;
215}
216
217
218//=======================================================================
219//function : GetElemGeomRelat
220//purpose :
221//=======================================================================
222
223Handle(StepFEA_HSequenceOfElementGeometricRelationship) StepAP209_Construct::GetElemGeomRelat() const
224{
225 Handle(StepFEA_HSequenceOfElementGeometricRelationship) aSequence =
226 new StepFEA_HSequenceOfElementGeometricRelationship;
227 Handle(Interface_InterfaceModel) model = Model();
228 Standard_Integer nb = model->NbEntities();
229 for(Standard_Integer i=1; i<=nb; i++) {
230 Handle(Standard_Transient) anEntity = model->Value(i);
231 if(anEntity->IsKind(STANDARD_TYPE(StepFEA_ElementGeometricRelationship))) {
232 Handle(StepFEA_ElementGeometricRelationship) EGR =
233 Handle(StepFEA_ElementGeometricRelationship)::DownCast(anEntity);
234 aSequence->Append(EGR);
235 }
236 }
237 return aSequence;
238}
239
240
241//=======================================================================
242//function : GetShReprForElem
243//purpose :
244//=======================================================================
245
246Handle(StepShape_ShapeRepresentation) StepAP209_Construct::GetShReprForElem
247 (const Handle(StepFEA_ElementRepresentation) &ElemRepr) const
248{
249 Handle(StepShape_ShapeRepresentation) SR;
250 if(ElemRepr.IsNull()) return SR;
251 Interface_EntityIterator subs = Graph().Sharings(ElemRepr);
252 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
253 Handle(StepFEA_ElementGeometricRelationship) EGR =
254 Handle(StepFEA_ElementGeometricRelationship)::DownCast(subs.Value());
255 if(EGR.IsNull()) continue;
256 Handle(StepElement_AnalysisItemWithinRepresentation) AIWR = EGR->Item();
257 if(AIWR.IsNull()) continue;
258 Handle(StepRepr_Representation) Repr = AIWR->Rep();
259 if(Repr.IsNull()) continue;
260 SR = Handle(StepShape_ShapeRepresentation)::DownCast(Repr);
261 }
262 return SR;
263}
264
265
266
267// methods for getting fea_model
268
269
270//=======================================================================
271//function : FeaModel
272//purpose :
273//=======================================================================
274
275Handle(StepFEA_FeaModel) StepAP209_Construct::FeaModel (const Handle(StepBasic_Product) &Prod) const
276{
277 Handle(StepFEA_FeaModel) FM;
278 if(Prod.IsNull()) return FM;
279 Interface_EntityIterator subs = Graph().Sharings(Prod);
280 for (subs.Start(); subs.More() && FM.IsNull() ; subs.Next()) {
281 Handle(StepBasic_ProductDefinitionFormation) PDF =
282 Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
283 if ( PDF.IsNull() ) continue;
284 FM = FeaModel(PDF);
285 }
286 return FM;
287}
288
289
290//=======================================================================
291//function : FeaModel
292//purpose :
293//=======================================================================
294
295Handle(StepFEA_FeaModel) StepAP209_Construct::FeaModel (const Handle(StepBasic_ProductDefinition) &PD) const
296{
297 //Handle(Interface_InterfaceModel) model = Model();
298 //Standard_Integer nb = model->NbEntities();
299 Handle(StepFEA_FeaModel) FM;
300 if(PD.IsNull()) return FM;
301 Interface_EntityIterator subs = Graph().Shareds(PD);
302 for (subs.Start(); subs.More() && FM.IsNull() ; subs.Next()) {
303 Handle(StepBasic_ProductDefinitionFormation) PDF =
304 Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
305 if ( PDF.IsNull() ) continue;
306 FM = FeaModel(PDF);
307 }
308 return FM;
309}
310
311
312//=======================================================================
313//function : FeaModel
314//purpose :
315//=======================================================================
316
317Handle(StepFEA_FeaModel) StepAP209_Construct::FeaModel (const Handle(StepBasic_ProductDefinitionFormation) &PDF) const
318{
319 Handle(StepFEA_FeaModel) FM;
320 if(PDF.IsNull()) return FM;
321 Handle(StepBasic_ProductDefinitionFormation) PDF2;
322 Interface_EntityIterator subs = Graph().Sharings(PDF);
323 for (subs.Start(); subs.More(); subs.Next()) {
324 Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR =
325 Handle(StepBasic_ProductDefinitionFormationRelationship)::DownCast(subs.Value());
326 if(PDFR.IsNull()) continue;
327 PDF2 = PDFR->RelatedProductDefinitionFormation();
328 }
329 if(PDF2.IsNull() ) return FM;
330 subs = Graph().Sharings(PDF2);
331 for (subs.Start(); subs.More() && FM.IsNull() ; subs.Next()) {
332 Handle(StepBasic_ProductDefinition) PD =
333 Handle(StepBasic_ProductDefinition)::DownCast(subs.Value());
334 if(PD.IsNull()) continue;
335 Interface_EntityIterator subs2 = Graph().Sharings(PD);
336 for (subs2.Start(); subs2.More() && FM.IsNull() ; subs2.Next()) {
337 Handle(StepRepr_ProductDefinitionShape) PDS =
338 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs2.Value());
339 if(PDS.IsNull()) continue;
340 FM = FeaModel(PDS);
341 }
342 }
343 return FM;
344}
345
346
347//=======================================================================
348//function : FeaModel
349//purpose :
350//=======================================================================
351
352Handle(StepFEA_FeaModel) StepAP209_Construct::FeaModel (const Handle(StepRepr_ProductDefinitionShape)& PDS) const
353{
354 Handle(StepFEA_FeaModel) FM;
355 Interface_EntityIterator subs = Graph().Sharings(PDS);
356 for (subs.Start(); subs.More() && FM.IsNull() ; subs.Next()) {
357 Handle(StepFEA_FeaModelDefinition) FMD = Handle(StepFEA_FeaModelDefinition)::DownCast(subs.Value());
358 if(FMD.IsNull()) continue;
359 Interface_EntityIterator subs2 = Graph().Sharings(FMD);
360 for (subs2.Start(); subs2.More() && FM.IsNull() ; subs2.Next()) {
361 //ENTITY structural_response_property - SUBTYPE OF (property_definition);
362 Handle(StepRepr_StructuralResponseProperty) SRP =
363 Handle(StepRepr_StructuralResponseProperty)::DownCast(subs2.Value());
364 if(SRP.IsNull()) continue;
365 Interface_EntityIterator subs3 = Graph().Sharings(SRP);
366 for (subs3.Start(); subs3.More() && FM.IsNull() ; subs3.Next()) {
367 //ENTITY structural_response_property_definition_representation -
368 //SUBTYPE OF (property_definition_representation);
369 Handle(StepRepr_StructuralResponsePropertyDefinitionRepresentation) SRPDR =
370 Handle(StepRepr_StructuralResponsePropertyDefinitionRepresentation)::DownCast(subs3.Value());
371 if(SRPDR.IsNull()) continue;
372 Handle(StepRepr_Representation) Repr = SRPDR->UsedRepresentation();
373 if ( Repr.IsNull() ) continue;
374 if (Repr->IsKind(STANDARD_TYPE(StepFEA_FeaModel)))
375 FM = Handle(StepFEA_FeaModel)::DownCast(Repr);
376 }
377 }
378 }
379 return FM;
380}
381
382
383//=======================================================================
384//function : GetFeaAxis2Placement3D
385//purpose :
386//=======================================================================
387
388Handle(StepFEA_FeaAxis2Placement3d) StepAP209_Construct::GetFeaAxis2Placement3d
389 (const Handle(StepFEA_FeaModel)& theFeaModel) const
390{
391 Handle(StepFEA_FeaAxis2Placement3d) FA2P3D = new StepFEA_FeaAxis2Placement3d;
392 if(theFeaModel.IsNull()) return FA2P3D;
393 Interface_EntityIterator subs = Graph().Shareds(theFeaModel);
394 for (subs.Start(); subs.More(); subs.Next()) {
395 FA2P3D = Handle(StepFEA_FeaAxis2Placement3d)::DownCast(subs.Value());
396 if(FA2P3D.IsNull()) continue;
397 return FA2P3D;
398 }
399 return FA2P3D;
400}
401
402
403// methods for getting idealized_analysis_shape
404
405
406//=======================================================================
407//function : IdealShape
408//purpose :
409//=======================================================================
410
411Handle(StepShape_ShapeRepresentation) StepAP209_Construct::IdealShape (const Handle(StepBasic_Product) &Prod) const
412{
413 Handle(StepShape_ShapeRepresentation) SR;
414 if(Prod.IsNull()) return SR;
415 Interface_EntityIterator subs = Graph().Sharings(Prod);
416 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
417 Handle(StepBasic_ProductDefinitionFormation) PDF =
418 Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
419 if ( PDF.IsNull() ) continue;
420 SR = IdealShape(PDF);
421 }
422 return SR;
423}
424
425
426//=======================================================================
427//function : IdealShape
428//purpose :
429//=======================================================================
430
431Handle(StepShape_ShapeRepresentation) StepAP209_Construct::IdealShape (const Handle(StepBasic_ProductDefinition) &PD) const
432{
433 Handle(StepShape_ShapeRepresentation) SR;
434 if(PD.IsNull()) return SR;
435 Interface_EntityIterator subs = Graph().Shareds(PD);
436 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
437 Handle(StepBasic_ProductDefinitionFormation) PDF =
438 Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
439 if ( PDF.IsNull() ) continue;
440 SR = IdealShape(PDF);
441 }
442 return SR;
443}
444
445
446//=======================================================================
447//function : IdealShape
448//purpose :
449//=======================================================================
450
451Handle(StepShape_ShapeRepresentation) StepAP209_Construct::IdealShape (const Handle(StepBasic_ProductDefinitionFormation) &PDF) const
452{
453 Handle(StepShape_ShapeRepresentation) SR;
454 if(PDF.IsNull()) return SR;
455 Handle(StepBasic_ProductDefinitionFormation) PDF2;
456 Interface_EntityIterator subs = Graph().Sharings(PDF);
457 for (subs.Start(); subs.More(); subs.Next()) {
458 Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR =
459 Handle(StepBasic_ProductDefinitionFormationRelationship)::DownCast(subs.Value());
460 if(PDFR.IsNull()) continue;
461 PDF2 = PDFR->RelatedProductDefinitionFormation();
462 }
463 if(PDF2.IsNull() ) return SR;
464 subs = Graph().Sharings(PDF2);
465 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
466 Handle(StepBasic_ProductDefinition) PD =
467 Handle(StepBasic_ProductDefinition)::DownCast(subs.Value());
468 if(PD.IsNull()) continue;
469 Interface_EntityIterator subs2 = Graph().Sharings(PD);
470 for (subs2.Start(); subs2.More() && SR.IsNull() ; subs2.Next()) {
471 Handle(StepRepr_ProductDefinitionShape) PDS =
472 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs2.Value());
473 if(PDS.IsNull()) continue;
474 SR = IdealShape(PDS);
475 }
476 }
477 return SR;
478}
479
480
481//=======================================================================
482//function : IdealShape
483//purpose :
484//=======================================================================
485
486Handle(StepShape_ShapeRepresentation) StepAP209_Construct::IdealShape (const Handle(StepRepr_ProductDefinitionShape)& PDS) const
487{
488 Handle(StepShape_ShapeRepresentation) SR;
489 Interface_EntityIterator subs = Graph().Sharings(PDS);
490 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
491 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
492 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
493 if(SDR.IsNull()) continue;
494 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
495 }
496 return SR;
497}
498
499
500// methods for getting nominal_design_shape
501
502
503//=======================================================================
504//function : NominShape
505//purpose :
506//=======================================================================
507
508Handle(StepShape_ShapeRepresentation) StepAP209_Construct::NominShape (const Handle(StepBasic_Product) &Prod) const
509{
510 Handle(StepShape_ShapeRepresentation) SR;
511 if(Prod.IsNull()) return SR;
512 Interface_EntityIterator subs = Graph().Sharings(Prod);
513 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
514 Handle(StepBasic_ProductDefinitionFormation) PDF =
515 Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
516 if ( PDF.IsNull() ) continue;
517 SR = NominShape(PDF);
518 }
519 return SR;
520}
521
522
523//=======================================================================
524//function : NominShape
525//purpose :
526//=======================================================================
527
528Handle(StepShape_ShapeRepresentation) StepAP209_Construct::NominShape (const Handle(StepBasic_ProductDefinitionFormation) &PDF) const
529{
530 Handle(StepShape_ShapeRepresentation) SR;
531 if(PDF.IsNull()) return SR;
532 Handle(StepBasic_ProductDefinitionFormation) PDF2;
533 Interface_EntityIterator subs = Graph().Sharings(PDF);
534 for (subs.Start(); subs.More(); subs.Next()) {
535 Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR =
536 Handle(StepBasic_ProductDefinitionFormationRelationship)::DownCast(subs.Value());
537 if(PDFR.IsNull()) continue;
538 PDF2 = PDFR->RelatingProductDefinitionFormation();
539 }
540 if(PDF2.IsNull() ) return SR;
541 subs = Graph().Sharings(PDF2);
542 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
543 Handle(StepBasic_ProductDefinition) PD =
544 Handle(StepBasic_ProductDefinition)::DownCast(subs.Value());
545 if(PD.IsNull()) continue;
546 Interface_EntityIterator subs2 = Graph().Sharings(PD);
547 for (subs2.Start(); subs2.More() && SR.IsNull() ; subs2.Next()) {
548 Handle(StepRepr_ProductDefinitionShape) PDS =
549 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs2.Value());
550 if(PDS.IsNull()) continue;
551 Interface_EntityIterator subs3 = Graph().Sharings(PDS);
552 for (subs3.Start(); subs3.More() && SR.IsNull() ; subs3.Next()) {
553 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
554 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs3.Value());
555 if(SDR.IsNull()) continue;
556 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
557 }
558 }
559 }
560 return SR;
561}
562
563
564
565//=======================================================================
566//function : GetElements1D
567//purpose :
568//=======================================================================
569
570Handle(StepFEA_HSequenceOfElementRepresentation) StepAP209_Construct::GetElements1D
571 (const Handle(StepFEA_FeaModel)& theFeaModel) const
572{
573 return GetFeaElements(theFeaModel,STANDARD_TYPE(StepFEA_Curve3dElementRepresentation));
574}
575
576
577//=======================================================================
578//function : GetElements2D
579//purpose :
580//=======================================================================
581
582Handle(StepFEA_HSequenceOfElementRepresentation) StepAP209_Construct::GetElements2D
583 (const Handle(StepFEA_FeaModel)& theFeaModel) const
584{
585 return GetFeaElements(theFeaModel,STANDARD_TYPE(StepFEA_Surface3dElementRepresentation));
586}
587
588
589//=======================================================================
590//function : GetElements3D
591//purpose :
592//=======================================================================
593
594Handle(StepFEA_HSequenceOfElementRepresentation) StepAP209_Construct::GetElements3D
595 (const Handle(StepFEA_FeaModel)& theFeaModel) const
596{
597 return GetFeaElements(theFeaModel,STANDARD_TYPE(StepFEA_Volume3dElementRepresentation));
598}
599
600
601//=======================================================================
602//function : GetFeaElements
603//purpose :
604//=======================================================================
605
606Handle(StepFEA_HSequenceOfElementRepresentation) StepAP209_Construct::GetFeaElements
607 (const Handle(StepFEA_FeaModel)& theFeaModel,
608 const Handle(Standard_Type)& theType) const
609{
610 Handle(StepFEA_HSequenceOfElementRepresentation) aSequence;
611 if( !theType->SubType(STANDARD_TYPE(StepFEA_ElementRepresentation)))
612 return aSequence;
613
614 Interface_EntityIterator anIter = Graph().Sharings(theFeaModel);
615 anIter.Start();
616 if(anIter.More())
617 aSequence = new StepFEA_HSequenceOfElementRepresentation;
618
619 for (; anIter.More(); anIter.Next()) {
620 Handle(Standard_Transient) anEntity = anIter.Value();
621 if(anEntity->IsKind(theType)) {
622 Handle(StepFEA_ElementRepresentation) anElement =
623 Handle(StepFEA_ElementRepresentation)::DownCast(anEntity);
624 aSequence->Append(anElement);
625 }
626 }
627 return aSequence;
628
629}
630
631
632//=======================================================================
633//function : GetFeaElements
634//purpose :
635//=======================================================================
636
637Handle(StepElement_HSequenceOfCurveElementSectionDefinition) StepAP209_Construct::GetCurElemSection
638 (const Handle(StepFEA_Curve3dElementRepresentation)& ElemRepr) const
639{
640 Handle(StepElement_HSequenceOfCurveElementSectionDefinition) aSequence =
641 new StepElement_HSequenceOfCurveElementSectionDefinition;
642 if(ElemRepr.IsNull()) return aSequence;
643
644 Handle(StepFEA_Curve3dElementProperty) C3dEP = ElemRepr->Property();
645 if(C3dEP.IsNull()) return aSequence;
646
647 Handle(StepFEA_HArray1OfCurveElementInterval) ACEI = C3dEP->IntervalDefinitions();
648 if(ACEI.IsNull()) return aSequence;
649
650 for(Standard_Integer i=1; i<=ACEI->Length(); i++) {
651 Handle(StepFEA_CurveElementIntervalConstant) CEIC =
652 Handle(StepFEA_CurveElementIntervalConstant)::DownCast(ACEI->Value(i));
653 if(CEIC.IsNull()) continue;
654 aSequence->Append(CEIC->Section());
655 }
656 return aSequence;
657}
658
659
660//=======================================================================
661//function : CreateAnalysStructure
662//purpose :
663//=======================================================================
664
665Standard_Boolean StepAP209_Construct::CreateAnalysStructure (const Handle(StepBasic_Product) &Prod) const
666{
667 if(Prod.IsNull()) return Standard_False;
668 Interface_EntityIterator subs = Graph().Sharings(Prod);
669 Handle(StepBasic_ProductDefinitionFormation) PDF;
670 for (subs.Start(); subs.More() && PDF.IsNull() ; subs.Next()) {
671 PDF = Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
672 if(PDF.IsNull()) continue;
673 }
674 if(PDF.IsNull()) return Standard_False;
675 //if( IsDesing(PDF) || IsAnalys(PDF) ) return Standard_False;
676
677 // find nominal_design_shape:
678 Handle(StepShape_ShapeRepresentation) SR;
679 Handle(StepBasic_ProductDefinition) PD;
680 subs = Graph().Sharings(PDF);
681 for (subs.Start(); subs.More() && SR.IsNull() ; subs.Next()) {
682 PD = Handle(StepBasic_ProductDefinition)::DownCast(subs.Value());
683 if(PD.IsNull()) continue;
684 Interface_EntityIterator subs2 = Graph().Sharings(PD);
685 for (subs2.Start(); subs2.More() && SR.IsNull() ; subs2.Next()) {
686 Handle(StepRepr_ProductDefinitionShape) PDS =
687 Handle(StepRepr_ProductDefinitionShape)::DownCast(subs2.Value());
688 if(PDS.IsNull()) continue;
689 Interface_EntityIterator subs3 = Graph().Sharings(PDS);
690 for (subs3.Start(); subs3.More() && SR.IsNull() ; subs3.Next()) {
691 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
692 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs3.Value());
693 if(SDR.IsNull()) continue;
694 SR = Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
695 }
696 }
697 }
698 if(SR.IsNull()) return Standard_False; // no nominal_design_shape
699
700 // create structure:
701 ReplaceCcDesingToApplied();
702 Handle(StepData_StepModel) smodel = Handle(StepData_StepModel)::DownCast(Model());
703
704 // replace existing contexts for using AP209
705 Handle(StepBasic_ProductContext) OldProdCtx =
706 Handle(StepBasic_ProductContext)::DownCast(Prod->FrameOfReferenceValue(1));
707 if(!OldProdCtx.IsNull()) {
708 Handle(StepBasic_ProductContext) ProdCtx = new StepBasic_ProductContext;
709 ProdCtx->Init(OldProdCtx->Name(),
710 OldProdCtx->FrameOfReference(),
711 OldProdCtx->DisciplineType());
712 smodel->ReplaceEntity(smodel->Number(OldProdCtx),ProdCtx);
713 smodel->SetIdentLabel(ProdCtx, smodel->Number(ProdCtx));
714 Handle(StepBasic_HArray1OfProductContext) HAPC = Prod->FrameOfReference();
715 HAPC->SetValue(1,ProdCtx);
716 Prod->SetFrameOfReference(HAPC);
717 }
718 Handle(StepBasic_ProductDefinitionContext) OldPDCtx =
719 Handle(StepBasic_ProductDefinitionContext)::DownCast(PD->FrameOfReference());
720 if(!OldPDCtx.IsNull()) {
721 Handle(StepBasic_ProductDefinitionContext) PDCtx = new StepBasic_ProductDefinitionContext;
722 PDCtx->Init(OldPDCtx->Name(),
723 OldPDCtx->FrameOfReference(),
724 OldPDCtx->LifeCycleStage());
725 smodel->ReplaceEntity(smodel->Number(OldPDCtx),PDCtx);
726 smodel->SetIdentLabel(PDCtx, smodel->Number(PDCtx));
727 PD->SetFrameOfReference(PDCtx);
728 }
729
730 // add idealized_analys_shape:
731 Handle(StepShape_ShapeRepresentation) AnaSR = new StepShape_ShapeRepresentation;
732 Handle(StepRepr_RepresentationItem) RI = new StepRepr_RepresentationItem;
733 RI = SR->ItemsValue(1);
734 smodel->AddWithRefs(RI); // add new representation_item
735 smodel->SetIdentLabel(RI, smodel->Number(RI));
736 Handle(StepRepr_HArray1OfRepresentationItem) ARI = new StepRepr_HArray1OfRepresentationItem(1,1);
737 ARI->SetValue(1,RI);
738 AnaSR->Init(new TCollection_HAsciiString("idealized_analysis_shape"),
739 ARI, SR->ContextOfItems());
740 smodel->AddWithRefs(AnaSR); // add idealized_analys_shape
741 smodel->SetIdentLabel(AnaSR, smodel->Number(AnaSR));
742
743 // add product:
744 Handle(StepBasic_Product) AnaProd = new StepBasic_Product;
745 AnaProd->Init(new TCollection_HAsciiString(""), new TCollection_HAsciiString("analysis"),
746 new TCollection_HAsciiString("analysis product"), Prod->FrameOfReference());
747 smodel->AddWithRefs(AnaProd);
748 smodel->SetIdentLabel(AnaProd, smodel->Number(AnaProd));
749
750 // add product_definition_formation:
751 Handle(StepBasic_ProductDefinitionFormation) AnaPDF =
752 new StepBasic_ProductDefinitionFormation;
753 AnaPDF->Init(new TCollection_HAsciiString(""),
754 new TCollection_HAsciiString("analysis version"), AnaProd);
755 smodel->AddWithRefs(AnaPDF);
756 smodel->SetIdentLabel(AnaPDF, smodel->Number(AnaPDF));
757
758 // add product_definition_formation_relationship:
759 Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR =
760 new StepBasic_ProductDefinitionFormationRelationship;
761 PDFR->Init(new TCollection_HAsciiString(""),
762 new TCollection_HAsciiString("analysis design version relationship"),
763 new TCollection_HAsciiString(""), PDF, AnaPDF);
764 smodel->AddWithRefs(PDFR);
765 smodel->SetIdentLabel(PDFR, smodel->Number(PDFR));
766
767 // add product_definition:
768 Handle(StepBasic_ProductDefinition) AnaPD = new StepBasic_ProductDefinition;
769 Handle(StepBasic_ProductDefinitionContext) AnaPDC =
770 new StepBasic_ProductDefinitionContext;
771 Handle(StepBasic_ApplicationContext) AC = Prod->FrameOfReferenceValue(1)->FrameOfReference();
772 AnaPDC->Init(new TCollection_HAsciiString("analysis"), AC,
773 new TCollection_HAsciiString("analysis") );
774 smodel->AddWithRefs(AnaPDC); // add new product_definition_context
775 smodel->SetIdentLabel(AnaPDC, smodel->Number(AnaPDC));
776 AnaPD->Init(new TCollection_HAsciiString("analysis"),
777 new TCollection_HAsciiString("analysis discipline product definition"),
778 AnaPDF, AnaPDC);
779 smodel->AddWithRefs(AnaPD); // add new product_definition
780 smodel->SetIdentLabel(AnaPD, smodel->Number(AnaPD));
781
782 // add product_definition_shape:
783 Handle(StepRepr_ProductDefinitionShape) AnaPDS = new StepRepr_ProductDefinitionShape;
784 StepRepr_CharacterizedDefinition ChDef;
785 ChDef.SetValue(AnaPD);
786 AnaPDS->Init(new TCollection_HAsciiString(""), Standard_True,
787 new TCollection_HAsciiString("analysis shape"), ChDef);
788 smodel->AddWithRefs(AnaPDS);
789 smodel->SetIdentLabel(AnaPDS, smodel->Number(AnaPDS));
790
791 // add shape_definition_representation:
792 Handle(StepShape_ShapeDefinitionRepresentation) AnaSDR = new StepShape_ShapeDefinitionRepresentation;
793 StepRepr_RepresentedDefinition RepDef;
794 RepDef.SetValue(AnaPDS);
795 AnaSDR->Init(RepDef, AnaSR);
796 smodel->AddWithRefs(AnaSDR);
797 smodel->SetIdentLabel(AnaSDR, smodel->Number(AnaSDR));
798
799 // add shape_representation_relationship:
800 Handle(StepRepr_ShapeRepresentationRelationship) SRR =
801 new StepRepr_ShapeRepresentationRelationship;
802 SRR->Init(new TCollection_HAsciiString("basis"), new TCollection_HAsciiString(""), AnaSR, SR);
803 smodel->AddWithRefs(SRR);
804 smodel->SetIdentLabel(SRR, smodel->Number(SRR));
805
806 CreateAddingEntities(AnaPD);
807
808
809 WS()->ComputeGraph(Standard_True);
810 WS()->ComputeCheck(Standard_True);
811
812 return Standard_True;
813}
814
815
816//=======================================================================
817//function : CreateFeaStructure
818//purpose :
819//=======================================================================
820
821Standard_Boolean StepAP209_Construct::CreateFeaStructure (const Handle(StepBasic_Product) &Prod) const
822{
823 if(Prod.IsNull()) {
0797d9d3 824#ifdef OCCT_DEBUG
7fd59977 825 cout<<"Prod.IsNull()"<<endl;
826#endif
827 return Standard_False;
828 }
829 Handle(StepShape_ShapeRepresentation) AnaSR = IdealShape(Prod);
830 if(AnaSR.IsNull()) {
0797d9d3 831#ifdef OCCT_DEBUG
7fd59977 832 cout<<"AnaSR.IsNull()"<<endl;
833#endif
834 return Standard_False;
835 }
836 Handle(StepRepr_ProductDefinitionShape) AnaPDS;
837 Interface_EntityIterator subs = Graph().Sharings(AnaSR);
838 for (subs.Start(); subs.More() && AnaPDS.IsNull(); subs.Next()) {
839 Handle(StepShape_ShapeDefinitionRepresentation) SDR =
840 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
841 if ( SDR.IsNull() ) continue;
842 AnaPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(SDR->Definition().Value());
843 }
844
845 //Handle(Interface_InterfaceModel) model = Model();
846 Handle(StepData_StepModel) smodel = Handle(StepData_StepModel)::DownCast(Model());
847
848 // add fea_model_definition
849 Handle(StepFEA_FeaModelDefinition) FMD = new StepFEA_FeaModelDefinition;
850 FMD->Init(new TCollection_HAsciiString("FEA_MODEL"),
851 new TCollection_HAsciiString("FEA_MODEL"), AnaPDS, StepData_LFalse);
852 smodel->AddWithRefs(FMD);
853 smodel->SetIdentLabel(FMD, smodel->Number(FMD));
854
855 // add fea_axis2_placement_3d
856 Handle(StepFEA_FeaAxis2Placement3d) FA2P3D = new StepFEA_FeaAxis2Placement3d;
857 Handle(StepGeom_CartesianPoint) SGCP = new StepGeom_CartesianPoint;
858 SGCP->Init3D(new TCollection_HAsciiString(""), 0., 0., 0.);
859 Handle(TColStd_HArray1OfReal) ArrTmp = new TColStd_HArray1OfReal(1,3);
860 ArrTmp->SetValue(1,0.);
861 ArrTmp->SetValue(2,0.);
862 ArrTmp->SetValue(3,1.);
863 Handle(StepGeom_Direction) SGD1 = new StepGeom_Direction;
864 SGD1->Init(new TCollection_HAsciiString(""), ArrTmp);
865 ArrTmp->SetValue(1,1.);
866 ArrTmp->SetValue(2,0.);
867 ArrTmp->SetValue(3,0.);
868 Handle(StepGeom_Direction) SGD2 = new StepGeom_Direction;
869 SGD2->Init(new TCollection_HAsciiString(""), ArrTmp);
870 FA2P3D->Init(new TCollection_HAsciiString("FEA_BASIC_COORD_SYSTEM"),
871 SGCP, Standard_True, SGD1, Standard_True, SGD2, StepFEA_Cartesian,
872 new TCollection_HAsciiString("FEA_BASIC_COORD_SYSTEM"));
873 smodel->AddWithRefs(FA2P3D);
874 smodel->SetIdentLabel(FA2P3D, smodel->Number(FA2P3D));
875
876 // create context for fea_model
877 Handle(StepShape_ShapeRepresentation) NS = NominShape(Prod);
878 Handle(StepRepr_RepresentationContext) RC = NS->ContextOfItems();
879 Handle(StepGeom_GeometricRepresentationContext) GeoCtx;
880 Handle(StepBasic_HArray1OfNamedUnit) OldHANU;
881 if(RC->IsKind(STANDARD_TYPE(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx))) {
882 Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) GeoUnitCtxNS =
883 Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(RC);
884 GeoCtx = GeoUnitCtxNS->GeometricRepresentationContext();
885 OldHANU = GeoUnitCtxNS->GlobalUnitAssignedContext()->Units();
886 }
887 if(RC->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext))) {
888 Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) GeoUnitCtxNS =
889 Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(RC);
890 GeoCtx = GeoUnitCtxNS->GeometricRepresentationContext();
891 OldHANU = GeoUnitCtxNS->GlobalUnitAssignedContext()->Units();
892 }
893 Handle(StepBasic_HArray1OfNamedUnit) NewHANU = new StepBasic_HArray1OfNamedUnit(1,OldHANU->Length()+3);
894 for(Standard_Integer i=1; i<=OldHANU->Length(); i++)
895 NewHANU->SetValue(i,OldHANU->Value(i));
896 // create SiUnitAndTimeUnit
897 Handle(StepBasic_DimensionalExponents) DimExpT = new StepBasic_DimensionalExponents;
898 DimExpT->Init(0.,0.,1.,0.,0.,0.,0.);
899 smodel->AddWithRefs(DimExpT);
900 smodel->SetIdentLabel(DimExpT, smodel->Number(DimExpT));
901 Handle(StepBasic_SiUnitAndTimeUnit) SUTU = new StepBasic_SiUnitAndTimeUnit;
902 SUTU->Init(DimExpT);
903 SUTU->SetName(StepBasic_sunSecond);
904 smodel->AddWithRefs(SUTU);
905 smodel->SetIdentLabel(SUTU, smodel->Number(SUTU));
906 NewHANU->SetValue(OldHANU->Length()+1,SUTU);
907 //create SiUnitAndMassUnit
908 Handle(StepBasic_DimensionalExponents) DimExpM = new StepBasic_DimensionalExponents;
909 DimExpM->Init(0.,1.,0.,0.,0.,0.,0.);
910 smodel->AddWithRefs(DimExpM);
911 smodel->SetIdentLabel(DimExpM, smodel->Number(DimExpM));
912 Handle(StepBasic_SiUnitAndMassUnit) SUMU = new StepBasic_SiUnitAndMassUnit;
913 SUMU->Init(DimExpM);
914 SUMU->SetName(StepBasic_sunGram);
915 SUMU->SetPrefix(StepBasic_spKilo);
916 smodel->AddWithRefs(SUMU);
917 smodel->SetIdentLabel(SUMU, smodel->Number(SUMU));
918 NewHANU->SetValue(OldHANU->Length()+2,SUMU);
919 // create SiUnitAndThermodynamicTemperatureUnit
920 Handle(StepBasic_DimensionalExponents) DimExpTT = new StepBasic_DimensionalExponents;
921 DimExpTT->Init(0.,0.,0.,0.,1.,0.,0.);
922 smodel->AddWithRefs(DimExpTT);
923 smodel->SetIdentLabel(DimExpTT, smodel->Number(DimExpTT));
924 Handle(StepBasic_SiUnitAndThermodynamicTemperatureUnit) SUTTU =
925 new StepBasic_SiUnitAndThermodynamicTemperatureUnit;
926 SUTTU->Init(DimExpTT);
927 SUTTU->SetName(StepBasic_sunDegreeCelsius);
928 smodel->AddWithRefs(SUTTU);
929 smodel->SetIdentLabel(SUTTU, smodel->Number(SUTTU));
930 NewHANU->SetValue(OldHANU->Length()+3,SUTTU);
931
932 Handle(StepRepr_GlobalUnitAssignedContext) NewUnitCtx = new StepRepr_GlobalUnitAssignedContext;
933 NewUnitCtx->Init(new TCollection_HAsciiString(""), new TCollection_HAsciiString(""),NewHANU);
934 Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) NewGeoCtx =
935 new StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext;
936 NewGeoCtx->Init(new TCollection_HAsciiString("REP_CONTEXT_FEA"),
937 new TCollection_HAsciiString("3D"), GeoCtx, NewUnitCtx);
938 smodel->AddWithRefs(NewGeoCtx);
939 smodel->SetIdentLabel(NewGeoCtx, smodel->Number(NewGeoCtx));
940
941 // create fea_model_3d
942 Handle(StepFEA_FeaModel3d) FM = new StepFEA_FeaModel3d;
943 FM->SetName(new TCollection_HAsciiString("FEA_MODEL"));
944 Handle(StepRepr_HArray1OfRepresentationItem) HARI =
945 new StepRepr_HArray1OfRepresentationItem(1,1);
946 HARI->SetValue(1,FA2P3D);
947 Handle(TColStd_HArray1OfAsciiString) HAAS = new TColStd_HArray1OfAsciiString(1,1);
948 HAAS->SetValue(1,"FEA_SOLVER");
949 FM->Init(new TCollection_HAsciiString("FEA_MODEL"), HARI,
950 NewGeoCtx, new TCollection_HAsciiString(""),
951 HAAS, new TCollection_HAsciiString("ANALYSIS_MODEL"),
952 new TCollection_HAsciiString("LINEAR_STATIC"));
953 smodel->AddWithRefs(FM);
954 smodel->SetIdentLabel(FM, smodel->Number(FM));
955
956 // add structural_response_property
957 Handle(StepRepr_StructuralResponseProperty) SRP =
958 new StepRepr_StructuralResponseProperty;
959 StepRepr_CharacterizedDefinition ChDef2;
960 ChDef2.SetValue(FMD);
961 SRP->Init(new TCollection_HAsciiString("STRUCT_RESP_PROP"), Standard_True,
962 new TCollection_HAsciiString("STRUCTURAL_RESPONSE_PROPERTY"),ChDef2);
963 smodel->AddWithRefs(SRP);
964 smodel->SetIdentLabel(SRP, smodel->Number(SRP));
965
966 // add structural_response_property_definition_representation
967 Handle(StepRepr_StructuralResponsePropertyDefinitionRepresentation) SRPDR =
968 new StepRepr_StructuralResponsePropertyDefinitionRepresentation;
969 StepRepr_RepresentedDefinition RepDef2;
970 RepDef2.SetValue(SRP);
971 SRPDR->Init(RepDef2,FM);
972 smodel->AddWithRefs(SRPDR);
973 smodel->SetIdentLabel(SRPDR, smodel->Number(SRPDR));
974
975 WS()->ComputeGraph(Standard_True);
976 WS()->ComputeCheck(Standard_True);
977
978 return Standard_True;
979}
980
981
982//=======================================================================
983//function : ReplaceCcDesingToApplied
984//purpose : Put into model entities Applied... for AP209 instead of
985// entities CcDesing... from AP203
986//=======================================================================
987
988Standard_Boolean StepAP209_Construct::ReplaceCcDesingToApplied() const
989{
990 Handle(StepData_StepModel) smodel = Handle(StepData_StepModel)::DownCast(Model());
991 Standard_Integer nb = smodel->NbEntities();
992 for(Standard_Integer i=1; i<=nb; i++) {
993 Handle(Standard_Transient) anEntity = smodel->Value(i);
994 if(anEntity->IsKind(STANDARD_TYPE(StepAP203_CcDesignApproval))) {
995 Handle(StepAP203_CcDesignApproval) ent = Handle(StepAP203_CcDesignApproval)::DownCast(anEntity);
996 Handle(StepAP214_AppliedApprovalAssignment) nent = new StepAP214_AppliedApprovalAssignment;
997 Handle(StepAP203_HArray1OfApprovedItem) HAAI203 = ent->Items();
998 Handle(StepAP214_HArray1OfApprovalItem) HAAI214 =
999 new StepAP214_HArray1OfApprovalItem(1,HAAI203->Length());
1000 for(Standard_Integer j=1; j<=HAAI203->Length(); j++) {
1001 StepAP214_ApprovalItem AI214;
1002 AI214.SetValue(HAAI203->Value(j).Value());
1003 HAAI214->SetValue(j,AI214);
1004 }
1005 nent->Init(ent->AssignedApproval(), HAAI214);
1006 smodel->ReplaceEntity(i,nent);
1007 smodel->SetIdentLabel(nent, smodel->Number(nent));
1008 }
1009 else if(anEntity->IsKind(STANDARD_TYPE(StepAP203_CcDesignPersonAndOrganizationAssignment))) {
1010 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) ent =
1011 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment)::DownCast(anEntity);
1012 Handle(StepAP214_AppliedPersonAndOrganizationAssignment) nent =
1013 new StepAP214_AppliedPersonAndOrganizationAssignment;
1014 Handle(StepAP203_HArray1OfPersonOrganizationItem) HAPOI203 = ent->Items();
1015 Handle(StepAP214_HArray1OfPersonAndOrganizationItem) HAPOI214 =
1016 new StepAP214_HArray1OfPersonAndOrganizationItem(1,HAPOI203->Length());
1017 for(Standard_Integer j=1; j<=HAPOI203->Length(); j++) {
1018 StepAP214_PersonAndOrganizationItem POI214;
1019 POI214.SetValue(HAPOI203->Value(j).Value());
1020 HAPOI214->SetValue(j,POI214);
1021 }
1022 nent->Init(ent->AssignedPersonAndOrganization(), ent->Role(), HAPOI214);
1023 smodel->ReplaceEntity(i,nent);
1024 smodel->SetIdentLabel(nent, smodel->Number(nent));
1025 }
1026 else if(anEntity->IsKind(STANDARD_TYPE(StepAP203_CcDesignDateAndTimeAssignment))) {
1027 Handle(StepAP203_CcDesignDateAndTimeAssignment) ent =
1028 Handle(StepAP203_CcDesignDateAndTimeAssignment)::DownCast(anEntity);
1029 Handle(StepAP214_AppliedDateAndTimeAssignment) nent = new StepAP214_AppliedDateAndTimeAssignment;
1030 Handle(StepAP203_HArray1OfDateTimeItem) HADTI203 = ent->Items();
1031 Handle(StepAP214_HArray1OfDateAndTimeItem) HADTI214 =
1032 new StepAP214_HArray1OfDateAndTimeItem(1,HADTI203->Length());
1033 for(Standard_Integer j=1; j<=HADTI203->Length(); j++) {
1034 StepAP214_DateAndTimeItem DTI214;
1035 DTI214.SetValue(HADTI203->Value(j).Value());
1036 HADTI214->SetValue(j,DTI214);
1037 }
1038 nent->Init(ent->AssignedDateAndTime(), ent->Role(), HADTI214);
1039 smodel->ReplaceEntity(i,nent);
1040 smodel->SetIdentLabel(nent, smodel->Number(nent));
1041 }
1042 else if(anEntity->IsKind(STANDARD_TYPE(StepAP203_CcDesignSecurityClassification))) {
1043 Handle(StepAP203_CcDesignSecurityClassification) ent =
1044 Handle(StepAP203_CcDesignSecurityClassification)::DownCast(anEntity);
1045 Handle(StepAP214_AppliedSecurityClassificationAssignment) nent =
1046 new StepAP214_AppliedSecurityClassificationAssignment;
1047 Handle(StepAP203_HArray1OfClassifiedItem) HACI203 = ent->Items();
1048 Handle(StepAP214_HArray1OfSecurityClassificationItem) HASCI214 =
1049 new StepAP214_HArray1OfSecurityClassificationItem(1,HACI203->Length());
1050 for(Standard_Integer j=1; j<=HACI203->Length(); j++) {
1051 StepAP214_SecurityClassificationItem SCI214;
1052 SCI214.SetValue(HACI203->Value(j).Value());
1053 HASCI214->SetValue(j,SCI214);
1054 }
1055 nent->Init(ent->AssignedSecurityClassification(), HASCI214);
1056 smodel->ReplaceEntity(i,nent);
1057 smodel->SetIdentLabel(nent, smodel->Number(nent));
1058 }
1059 }
1060
1061 return Standard_True;
1062}
1063
1064
1065//=======================================================================
1066//function : CreateAddingEntities
1067//purpose : create approval.. , date.. , time.. , person.. and
1068// organization.. entities for analysis structure
1069//=======================================================================
1070
1071Standard_Boolean StepAP209_Construct::CreateAddingEntities
1072 (const Handle(StepBasic_ProductDefinition) &AnaPD) const
1073{
1074 Handle(StepData_StepModel) smodel = Handle(StepData_StepModel)::DownCast(Model());
1075 Handle(StepBasic_ProductDefinitionFormation) AnaPDF = AnaPD->Formation();
1076 Handle(StepBasic_Product) AnaProd = AnaPDF->OfProduct();
1077
1078 Handle(StepBasic_ApprovalStatus) AS = new StepBasic_ApprovalStatus;
1079 AS->Init(new TCollection_HAsciiString("approved"));
1080 smodel->AddEntity(AS);
1081 smodel->SetIdentLabel(AS, smodel->Number(AS));
1082 Handle(StepBasic_Approval) Appr = new StepBasic_Approval;
1083 Appr->Init(AS, new TCollection_HAsciiString("approved"));
1084 smodel->AddWithRefs(Appr);
1085 smodel->SetIdentLabel(Appr, smodel->Number(Appr));
1086
1087 Handle(StepBasic_SecurityClassificationLevel) SCL = new StepBasic_SecurityClassificationLevel;
1088 SCL->Init(new TCollection_HAsciiString("unclassified"));
1089 smodel->AddEntity(SCL);
1090 smodel->SetIdentLabel(SCL, smodel->Number(SCL));
1091 Handle(StepBasic_SecurityClassification) SC = new StepBasic_SecurityClassification;
1092 SC->Init(new TCollection_HAsciiString(""), new TCollection_HAsciiString(""), SCL);
1093 smodel->AddWithRefs(SC);
1094 smodel->SetIdentLabel(SC, smodel->Number(SC));
1095
1096 Handle(StepAP214_AppliedApprovalAssignment) AAA = new StepAP214_AppliedApprovalAssignment;
1097 Handle(StepAP214_HArray1OfApprovalItem) HAAI = new StepAP214_HArray1OfApprovalItem(1,3);
1098 StepAP214_ApprovalItem AI1;
1099 AI1.SetValue(AnaPD);
1100 HAAI->SetValue(1,AI1);
1101 StepAP214_ApprovalItem AI2;
1102 AI2.SetValue(AnaPDF);
1103 HAAI->SetValue(2,AI2);
1104 StepAP214_ApprovalItem AI3;
1105 AI3.SetValue(SC);
1106 HAAI->SetValue(3,AI3);
1107 AAA->Init(Appr, HAAI);
1108 smodel->AddWithRefs(AAA);
1109 smodel->SetIdentLabel(AAA, smodel->Number(AAA));
1110
1111 Handle(StepAP214_AppliedSecurityClassificationAssignment) ASCA =
1112 new StepAP214_AppliedSecurityClassificationAssignment;
1113 Handle(StepAP214_HArray1OfSecurityClassificationItem) HASCI =
1114 new StepAP214_HArray1OfSecurityClassificationItem(1,1);
1115 StepAP214_SecurityClassificationItem SCI;
1116 SCI.SetValue(AnaPDF);
1117 HASCI->SetValue(1,SCI);
1118 ASCA->Init(SC,HASCI);
1119 smodel->AddWithRefs(ASCA);
1120 smodel->SetIdentLabel(ASCA, smodel->Number(ASCA));
1121
1122 OSD_Process sys;
1123 Quantity_Date date = sys.SystemDate ();
1124
1125 Handle(StepBasic_CalendarDate) CDate = new StepBasic_CalendarDate;
1126 CDate->Init(date.Year(), date.Day(), date.Month());
1127 smodel->AddEntity(CDate);
1128 smodel->SetIdentLabel(CDate, smodel->Number(CDate));
1129 Handle(StepBasic_CoordinatedUniversalTimeOffset) CUTO = new StepBasic_CoordinatedUniversalTimeOffset;
1130 CUTO->Init(0, Standard_True, 0, StepBasic_aobAhead);
1131 smodel->AddEntity(CUTO);
1132 smodel->SetIdentLabel(CUTO, smodel->Number(CUTO));
1133 Handle(StepBasic_LocalTime) LT = new StepBasic_LocalTime;
1134 LT->Init(date.Hour(), Standard_True, date.Minute(), Standard_True,
1135 (Standard_Real)date.Second(), CUTO);
1136 smodel->AddWithRefs(LT);
1137 smodel->SetIdentLabel(LT, smodel->Number(LT));
1138 Handle(StepBasic_DateAndTime) DAT = new StepBasic_DateAndTime;
1139 DAT->Init(CDate,LT);
1140 smodel->AddWithRefs(DAT);
1141 smodel->SetIdentLabel(DAT, smodel->Number(DAT));
1142
1143 Handle(StepBasic_DateTimeRole) DTR = new StepBasic_DateTimeRole;
1144 DTR->Init(new TCollection_HAsciiString("classification_date"));
1145 smodel->AddEntity(DTR);
1146 smodel->SetIdentLabel(DTR, smodel->Number(DTR));
1147 Handle(StepAP214_AppliedDateAndTimeAssignment) ADTA = new StepAP214_AppliedDateAndTimeAssignment;
1148 Handle(StepAP214_HArray1OfDateAndTimeItem) HADTI = new StepAP214_HArray1OfDateAndTimeItem(1,1);
1149 StepAP214_DateAndTimeItem DTI1;
1150 DTI1.SetValue(SC);
1151 HADTI->SetValue(1,DTI1);
1152 ADTA->Init(DAT,DTR,HADTI);
1153 smodel->AddWithRefs(ADTA);
1154 smodel->SetIdentLabel(ADTA, smodel->Number(ADTA));
1155
1156 DTR = new StepBasic_DateTimeRole;
1157 DTR->Init(new TCollection_HAsciiString("creation_date"));
1158 smodel->AddEntity(DTR);
1159 smodel->SetIdentLabel(DTR, smodel->Number(DTR));
1160 ADTA = new StepAP214_AppliedDateAndTimeAssignment;
1161 HADTI = new StepAP214_HArray1OfDateAndTimeItem(1,1);
1162 StepAP214_DateAndTimeItem DTI2;
1163 DTI2.SetValue(AnaPD);
1164 HADTI->SetValue(1,DTI2);
1165 ADTA->Init(DAT,DTR,HADTI);
1166 smodel->AddWithRefs(ADTA);
1167 smodel->SetIdentLabel(ADTA, smodel->Number(ADTA));
1168
1169 Handle(StepBasic_ApprovalDateTime) ADT = new StepBasic_ApprovalDateTime;
1170 StepBasic_DateTimeSelect DTS;
1171 DTS.SetValue(DAT);
1172 ADT->Init(DTS,Appr);
1173 smodel->AddWithRefs(ADT);
1174 smodel->SetIdentLabel(ADT, smodel->Number(ADT));
1175
1176 Handle(StepBasic_Person) Pers = new StepBasic_Person;
1177 Handle(Interface_HArray1OfHAsciiString) HAHAS = new Interface_HArray1OfHAsciiString(1,1);
1178 HAHAS->SetValue(1,new TCollection_HAsciiString(""));
1179 Pers->Init(new TCollection_HAsciiString("1"), Standard_True,
1180 new TCollection_HAsciiString("last_name"), Standard_True,
1181 new TCollection_HAsciiString("first_name"), Standard_True,
1182 HAHAS, Standard_True, HAHAS, Standard_True, HAHAS);
1183 smodel->AddEntity(Pers);
1184 smodel->SetIdentLabel(Pers, smodel->Number(Pers));
1185 Handle(StepBasic_Organization) Org = new StepBasic_Organization;
1186 Org->Init(Standard_True, new TCollection_HAsciiString("1"),
1187 new TCollection_HAsciiString("organisation"),
1188 new TCollection_HAsciiString("organisation_description"));
1189 smodel->AddEntity(Org);
1190 smodel->SetIdentLabel(Org, smodel->Number(Org));
1191 Handle(StepBasic_PersonAndOrganization) PO = new StepBasic_PersonAndOrganization;
1192 PO->Init(Pers,Org);
1193 smodel->AddWithRefs(PO);
1194 smodel->SetIdentLabel(PO, smodel->Number(PO));
1195
1196 Handle(StepBasic_PersonAndOrganizationRole) POR = new StepBasic_PersonAndOrganizationRole;
1197 POR->Init(new TCollection_HAsciiString("analysis_owner"));
1198 smodel->AddEntity(POR);
1199 smodel->SetIdentLabel(POR, smodel->Number(POR));
1200 Handle(StepAP214_AppliedPersonAndOrganizationAssignment) APOA =
1201 new StepAP214_AppliedPersonAndOrganizationAssignment;
1202 Handle(StepAP214_HArray1OfPersonAndOrganizationItem) HAPOI =
1203 new StepAP214_HArray1OfPersonAndOrganizationItem(1,1);
1204 StepAP214_PersonAndOrganizationItem POI1;
1205 POI1.SetValue(AnaProd);
1206 HAPOI->SetValue(1,POI1);
1207 APOA->Init(PO,POR,HAPOI);
1208 smodel->AddWithRefs(APOA);
1209 smodel->SetIdentLabel(APOA, smodel->Number(APOA));
1210
1211 POR = new StepBasic_PersonAndOrganizationRole;
1212 POR->Init(new TCollection_HAsciiString("creator"));
1213 smodel->AddEntity(POR);
1214 smodel->SetIdentLabel(POR, smodel->Number(POR));
1215 APOA = new StepAP214_AppliedPersonAndOrganizationAssignment;
1216 HAPOI = new StepAP214_HArray1OfPersonAndOrganizationItem(1,1);
1217 StepAP214_PersonAndOrganizationItem POI2;
1218 POI2.SetValue(AnaPD);
1219 HAPOI->SetValue(1,POI2);
1220 APOA->Init(PO,POR,HAPOI);
1221 smodel->AddWithRefs(APOA);
1222 smodel->SetIdentLabel(APOA, smodel->Number(APOA));
1223
1224 POR = new StepBasic_PersonAndOrganizationRole;
1225 POR->Init(new TCollection_HAsciiString("analysis_owner"));
1226 smodel->AddEntity(POR);
1227 smodel->SetIdentLabel(POR, smodel->Number(POR));
1228 APOA = new StepAP214_AppliedPersonAndOrganizationAssignment;
1229 HAPOI = new StepAP214_HArray1OfPersonAndOrganizationItem(1,1);
1230 StepAP214_PersonAndOrganizationItem POI3;
1231 POI3.SetValue(AnaPD);
1232 HAPOI->SetValue(1,POI3);
1233 APOA->Init(PO,POR,HAPOI);
1234 smodel->AddWithRefs(APOA);
1235 smodel->SetIdentLabel(APOA, smodel->Number(APOA));
1236
1237 POR = new StepBasic_PersonAndOrganizationRole;
1238 POR->Init(new TCollection_HAsciiString("classification_officer"));
1239 smodel->AddEntity(POR);
1240 smodel->SetIdentLabel(POR, smodel->Number(POR));
1241 APOA = new StepAP214_AppliedPersonAndOrganizationAssignment;
1242 HAPOI = new StepAP214_HArray1OfPersonAndOrganizationItem(1,1);
1243 StepAP214_PersonAndOrganizationItem POI4;
1244 POI4.SetValue(SC);
1245 HAPOI->SetValue(1,POI4);
1246 APOA->Init(PO,POR,HAPOI);
1247 smodel->AddWithRefs(APOA);
1248 smodel->SetIdentLabel(APOA, smodel->Number(APOA));
1249
1250 POR = new StepBasic_PersonAndOrganizationRole;
1251 POR->Init(new TCollection_HAsciiString("creator"));
1252 smodel->AddEntity(POR);
1253 smodel->SetIdentLabel(POR, smodel->Number(POR));
1254 APOA = new StepAP214_AppliedPersonAndOrganizationAssignment;
1255 HAPOI = new StepAP214_HArray1OfPersonAndOrganizationItem(1,1);
1256 StepAP214_PersonAndOrganizationItem POI5;
1257 POI5.SetValue(AnaPDF);
1258 HAPOI->SetValue(1,POI5);
1259 APOA->Init(PO,POR,HAPOI);
1260 smodel->AddWithRefs(APOA);
1261 smodel->SetIdentLabel(APOA, smodel->Number(APOA));
1262
1263 Handle(StepBasic_ApprovalRole) AR = new StepBasic_ApprovalRole;
1264 AR->Init(new TCollection_HAsciiString("approver"));
1265 smodel->AddEntity(AR);
1266 smodel->SetIdentLabel(AR, smodel->Number(AR));
1267 Handle(StepBasic_ApprovalPersonOrganization) APO = new StepBasic_ApprovalPersonOrganization;
1268 StepBasic_PersonOrganizationSelect POS;
1269 POS.SetValue(PO);
1270 APO->Init(POS,Appr,AR);
1271 smodel->AddWithRefs(APO);
1272 smodel->SetIdentLabel(APO, smodel->Number(APO));
1273
1274
1275 return Standard_True;
1276}
1277
1278
1279//=======================================================================
1280//function : CreateAP203Structure
1281//purpose :
1282//=======================================================================
1283
1284Handle(StepData_StepModel) StepAP209_Construct::CreateAP203Structure() const
1285{
1286 Handle(StepData_StepModel) smodel = Handle(StepData_StepModel)::DownCast(Model());
1287 Handle(StepData_StepModel) nmodel;// = new StepData_StepModel;
1288 if(smodel.IsNull()) return nmodel;
1289 //nmodel->SetProtocol(smodel->Protocol());
1290 Handle(StepBasic_ProductDefinitionFormation) PDF;
1291 Handle(StepBasic_ProductDefinition) PD;
1292 Handle(StepRepr_ProductDefinitionShape) PDS;
1293 Handle(StepShape_ShapeDefinitionRepresentation) SDR;
1294 Standard_Integer nb = smodel->NbEntities();
1295 for(Standard_Integer i=1; i<=nb; i++) {
1296 if(smodel->Value(i)->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
1297 SDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(smodel->Value(i));
1298 PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(SDR->Definition().Value());
1299 if(PDS.IsNull()) continue;
1300 PD = Handle(StepBasic_ProductDefinition)::DownCast(PDS->Definition().Value());
1301 if(PD.IsNull()) continue;
1302 Handle(StepBasic_ProductDefinitionFormation) PDF1 = PD->Formation();
1303 if(IsDesing(PDF1)) {
1304 PDF = PDF1;
1305 i = nb;
1306 }
1307 }
1308 }
1309 if(PDF.IsNull()) return nmodel;
1310 nmodel = new StepData_StepModel;
1311 nmodel->SetProtocol(smodel->Protocol());
1312
1313 Handle(StepBasic_Product) Prod = PDF->OfProduct();
1314 nmodel->AddWithRefs(Prod);
1315
1316 // adding categories:
1317 Handle(StepBasic_HArray1OfProduct) HAProd = new StepBasic_HArray1OfProduct(1,1);
1318 HAProd->SetValue(1,Prod);
1319 Handle(StepBasic_ProductRelatedProductCategory) PRPC = new StepBasic_ProductRelatedProductCategory;
1320 PRPC->Init(new TCollection_HAsciiString("design"),
1321 Standard_True, Prod->Name(), HAProd); // may be Prod->Description() - ???
1322 nmodel->AddEntity(PRPC);
1323 Handle(StepBasic_ProductCategory) PCat = new StepBasic_ProductCategory;
1324 PCat->Init(new TCollection_HAsciiString("part"),
1325 Standard_True, Prod->Name()); // may be Prod->Description() - ???
1326 nmodel->AddEntity(PCat);
1327 //nmodel->SetIdentLabel(PCat, smodel->Number(PCat));
1328 Handle(StepBasic_ProductCategoryRelationship) PCR = new StepBasic_ProductCategoryRelationship;
1329 PCR->Init(new TCollection_HAsciiString(""), Standard_True,
1330 Prod->Name(), PCat, PRPC); // may be Prod->Description() - ???
1331 nmodel->AddWithRefs(PCR);
1332
1333 nmodel->AddWithRefs(PDF);
1334 nmodel->AddWithRefs(PD);
1335
1336 // replacing contexts:
1337 Handle(StepBasic_ApplicationContext) ApplCtx;
1338 Handle(StepBasic_ProductContext) ProdCtx =
1339 Handle(StepBasic_ProductContext)::DownCast(Prod->FrameOfReferenceValue(1));
1340 if(!ProdCtx.IsNull()) {
1341 Handle(StepBasic_MechanicalContext) MechCtx = new StepBasic_MechanicalContext;
1342 MechCtx->Init(ProdCtx->Name(), ProdCtx->FrameOfReference(),
1343 ProdCtx->DisciplineType());
1344 nmodel->ReplaceEntity(nmodel->Number(ProdCtx),MechCtx);
1345 Handle(StepBasic_HArray1OfProductContext) HAPC = new StepBasic_HArray1OfProductContext(1,1);
1346 HAPC->SetValue(1,MechCtx);
1347 Prod->SetFrameOfReference(HAPC);
1348 ApplCtx = MechCtx->FrameOfReference();
1349 }
1350 Handle(StepBasic_ProductDefinitionContext) PDCtx =
1351 Handle(StepBasic_ProductDefinitionContext)::DownCast(PD->FrameOfReference());
1352 if(!PDCtx.IsNull()) {
1353 Handle(StepBasic_DesignContext) DesCtx = new StepBasic_DesignContext;
1354 DesCtx->Init(PDCtx->Name(), PDCtx->FrameOfReference(),
1355 PDCtx->LifeCycleStage());
1356 nmodel->ReplaceEntity(nmodel->Number(PDCtx),DesCtx);
1357 PD->SetFrameOfReference(DesCtx);
1358 ApplCtx = DesCtx->FrameOfReference();
1359 }
1360 if(!ApplCtx.IsNull()) {
1361 Handle(StepBasic_ApplicationProtocolDefinition) APD;
1362 Interface_EntityIterator subs = Graph().Sharings(ApplCtx);
1363 for (subs.Start(); subs.More() && APD.IsNull(); subs.Next()) {
1364 APD = Handle(StepBasic_ApplicationProtocolDefinition)::DownCast(subs.Value());
1365 if(APD.IsNull()) continue;
1366 nmodel->AddWithRefs(APD);
1367 }
1368 }
1369
1370 CreateAdding203Entities(PD,nmodel);
1371
1372 // adding geometry part
1373 nmodel->AddWithRefs(SDR);
1374
1375 // adding DimensionalExponents
1376 Handle(StepBasic_DimensionalExponents) DimExp = new StepBasic_DimensionalExponents;
1377 DimExp->Init(1.,0.,0.,0.,0.,0.,0.);
1378 nmodel->AddWithRefs(DimExp);
1379 DimExp = new StepBasic_DimensionalExponents;
1380 DimExp->Init(0.,0.,0.,0.,0.,0.,0.);
1381 nmodel->AddWithRefs(DimExp);
1382
1383 // writing HeaderSection
1384 nmodel->ClearHeader();
1385 Handle(HeaderSection_FileName) FN = Handle(HeaderSection_FileName)::
1386 DownCast(smodel->HeaderEntity(STANDARD_TYPE(HeaderSection_FileName)));
1387 if(!FN.IsNull()) {
1388 FN->SetPreprocessorVersion(new TCollection_HAsciiString("AP209 -> SDRB Convertor"));
1389 nmodel->AddHeaderEntity(FN);
1390 }
1391 Handle(HeaderSection_FileSchema) FS = Handle(HeaderSection_FileSchema)::
1392 DownCast(smodel->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)));
1393 if(!FS.IsNull())
1394 nmodel->AddHeaderEntity(FS);
1395 Handle(HeaderSection_FileDescription) FD = Handle(HeaderSection_FileDescription)::
1396 DownCast(smodel->HeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription)));
1397 if(!FD.IsNull()) {
1398 Handle(Interface_HArray1OfHAsciiString) HAAS = new Interface_HArray1OfHAsciiString(1,1);
1399 HAAS->SetValue(1,new TCollection_HAsciiString("STEP AP203 file generated from STEP AP209"));
1400 FD->SetDescription(HAAS);
1401 nmodel->AddHeaderEntity(FD);
1402 }
1403
1404// WS()->SetModel(nmodel);
1405
1406 return nmodel;
1407}
1408
1409
1410//=======================================================================
1411//function : CreateAdding203Entities
1412//purpose : create approval.. , date.. , time.. , person.. and
1413// organization.. entities for analysis structure
1414//=======================================================================
1415
1416Standard_Boolean StepAP209_Construct::CreateAdding203Entities
1417 (const Handle(StepBasic_ProductDefinition) &PD,
1418 Handle(StepData_StepModel) &aModel) const
1419{
1420 Handle(StepData_StepModel) smodel = Handle(StepData_StepModel)::DownCast(Model());
1421 Handle(StepBasic_ProductDefinitionFormation) PDF = PD->Formation();
1422 Handle(StepBasic_Product) Prod = PDF->OfProduct();
1423
1424 // create SecurityClassification
1425 Handle(StepBasic_SecurityClassification) SC;
1426 Interface_EntityIterator subs = Graph().Sharings(PDF);
1427 for (subs.Start(); subs.More() && SC.IsNull(); subs.Next()) {
1428 Handle(StepAP214_AppliedSecurityClassificationAssignment) ASCA =
1429 Handle(StepAP214_AppliedSecurityClassificationAssignment)::DownCast(subs.Value());
1430 if(ASCA.IsNull()) continue;
1431 SC = ASCA->AssignedSecurityClassification();
1432 }
1433 if(SC.IsNull()) {
1434 // create new
1435 Handle(StepBasic_SecurityClassificationLevel) SCL = new StepBasic_SecurityClassificationLevel;
1436 SCL->Init(new TCollection_HAsciiString("unclassified"));
1437 SC = new StepBasic_SecurityClassification;
1438 SC->Init(new TCollection_HAsciiString(""), new TCollection_HAsciiString(""), SCL);
1439 }
1440 aModel->AddWithRefs(SC);
1441 Handle(StepAP203_CcDesignSecurityClassification) DSC =
1442 new StepAP203_CcDesignSecurityClassification;
1443 Handle(StepAP203_HArray1OfClassifiedItem) HACI = new StepAP203_HArray1OfClassifiedItem(1,1);
1444 StepAP203_ClassifiedItem CI;
1445 CI.SetValue(PDF);
1446 HACI->SetValue(1,CI);
1447 DSC->Init(SC,HACI);
1448 aModel->AddWithRefs(DSC);
1449
1450 // create CcDesignApproval
1451 Handle(StepBasic_DateAndTime) DT;
1452 subs = Graph().Sharings(PD);
1453 for (subs.Start(); subs.More(); subs.Next()) {
1454 Handle(StepAP214_AppliedApprovalAssignment) AAA =
1455 Handle(StepAP214_AppliedApprovalAssignment)::DownCast(subs.Value());
1456 if(!AAA.IsNull()) {
1457 Handle(StepAP214_HArray1OfApprovalItem) HAAI214 = AAA->Items();
1458 Handle(StepAP203_HArray1OfApprovedItem) HAAI =
1459 new StepAP203_HArray1OfApprovedItem(1,HAAI214->Length());
1460 for(Standard_Integer i=1; i<=HAAI214->Length(); i++) {
1461 StepAP203_ApprovedItem AI;
1462 AI.SetValue(AAA->ItemsValue(i).Value());
1463 HAAI->SetValue(i,AI);
1464 }
1465 Handle(StepAP203_CcDesignApproval) DA = new StepAP203_CcDesignApproval;
1466 DA->Init(AAA->AssignedApproval(),HAAI);
1467 aModel->AddWithRefs(DA);
1468 // find ApprovalDateTime for Approval
1469 Interface_EntityIterator subs2 = Graph().Sharings(AAA->AssignedApproval());
1470 for (subs2.Start(); subs2.More(); subs2.Next()) {
1471 Handle(StepBasic_ApprovalDateTime) ADT =
1472 Handle(StepBasic_ApprovalDateTime)::DownCast(subs2.Value());
1473 if(ADT.IsNull()) continue;
1474 aModel->AddWithRefs(ADT);
1475 Handle(StepBasic_DateAndTime) DT1 =
1476 Handle(StepBasic_DateAndTime)::DownCast(ADT->DateTime().Value());
1477 if(DT1.IsNull()) continue;
1478 DT = DT1;
1479 }
1480 }
1481 }
1482 subs = Graph().Sharings(PDF);
1483 for (subs.Start(); subs.More(); subs.Next()) {
1484 Handle(StepAP214_AppliedApprovalAssignment) AAA =
1485 Handle(StepAP214_AppliedApprovalAssignment)::DownCast(subs.Value());
1486 if(!AAA.IsNull()) {
1487 Handle(StepAP214_HArray1OfApprovalItem) HAAI214 = AAA->Items();
1488 Handle(StepAP203_HArray1OfApprovedItem) HAAI =
1489 new StepAP203_HArray1OfApprovedItem(1,HAAI214->Length());
1490 for(Standard_Integer i=1; i<=HAAI214->Length(); i++) {
1491 StepAP203_ApprovedItem AI;
1492 AI.SetValue(AAA->ItemsValue(i).Value());
1493 HAAI->SetValue(i,AI);
1494 }
1495 Handle(StepAP203_CcDesignApproval) DA = new StepAP203_CcDesignApproval;
1496 DA->Init(AAA->AssignedApproval(),HAAI);
1497 aModel->AddWithRefs(DA);
1498 // find ApprovalDateTime for Approval
1499 Interface_EntityIterator subs2 = Graph().Sharings(AAA->AssignedApproval());
1500 for (subs2.Start(); subs2.More(); subs2.Next()) {
1501 Handle(StepBasic_ApprovalDateTime) ADT =
1502 Handle(StepBasic_ApprovalDateTime)::DownCast(subs2.Value());
1503 if(ADT.IsNull()) continue;
1504 aModel->AddWithRefs(ADT);
1505 Handle(StepBasic_DateAndTime) DT1 =
1506 Handle(StepBasic_DateAndTime)::DownCast(ADT->DateTime().Value());
1507 if(DT1.IsNull()) continue;
1508 DT = DT1;
1509 }
1510 }
1511 }
1512 subs = Graph().Sharings(SC);
1513 for (subs.Start(); subs.More(); subs.Next()) {
1514 Handle(StepAP214_AppliedApprovalAssignment) AAA =
1515 Handle(StepAP214_AppliedApprovalAssignment)::DownCast(subs.Value());
1516 if(!AAA.IsNull()) {
1517 Handle(StepAP214_HArray1OfApprovalItem) HAAI214 = AAA->Items();
1518 Handle(StepAP203_HArray1OfApprovedItem) HAAI =
1519 new StepAP203_HArray1OfApprovedItem(1,HAAI214->Length());
1520 for(Standard_Integer i=1; i<=HAAI214->Length(); i++) {
1521 StepAP203_ApprovedItem AI;
1522 AI.SetValue(AAA->ItemsValue(i).Value());
1523 HAAI->SetValue(i,AI);
1524 }
1525 Handle(StepAP203_CcDesignApproval) DA = new StepAP203_CcDesignApproval;
1526 DA->Init(AAA->AssignedApproval(),HAAI);
1527 aModel->AddWithRefs(DA);
1528 // find ApprovalDateTime for Approval
1529 Interface_EntityIterator subs2 = Graph().Sharings(AAA->AssignedApproval());
1530 for (subs2.Start(); subs2.More(); subs2.Next()) {
1531 Handle(StepBasic_ApprovalDateTime) ADT =
1532 Handle(StepBasic_ApprovalDateTime)::DownCast(subs2.Value());
1533 if(ADT.IsNull()) continue;
1534 aModel->AddWithRefs(ADT);
1535 Handle(StepBasic_DateAndTime) DT1 =
1536 Handle(StepBasic_DateAndTime)::DownCast(ADT->DateTime().Value());
1537 if(DT1.IsNull()) continue;
1538 DT = DT1;
1539 }
1540 }
1541 }
1542
1543 if(aModel->Number(DT)>0) {
1544 // create CcDesignDateAndTimeAssignment
1545 subs = Graph().Sharings(DT);
1546 for (subs.Start(); subs.More(); subs.Next()) {
1547 Handle(StepAP214_AppliedDateAndTimeAssignment)ADTA =
1548 Handle(StepAP214_AppliedDateAndTimeAssignment)::DownCast(subs.Value());
1549 if(ADTA.IsNull()) continue;
1550 Handle(StepAP214_HArray1OfDateAndTimeItem) HADTI214 = ADTA->Items();
1551 Handle(StepAP203_HArray1OfDateTimeItem) HADTI =
1552 new StepAP203_HArray1OfDateTimeItem(1,HADTI214->Length());
1553 for(Standard_Integer i=1; i<=HADTI214->Length(); i++) {
1554 StepAP203_DateTimeItem DTI;
1555 DTI.SetValue(ADTA->ItemsValue(i).Value());
1556 HADTI->SetValue(i,DTI);
1557 }
1558 Handle(StepAP203_CcDesignDateAndTimeAssignment) DDTA =
1559 new StepAP203_CcDesignDateAndTimeAssignment;
1560 DDTA->Init(DT, ADTA->Role(), HADTI);
1561 aModel->AddWithRefs(DDTA);
1562 }
1563 }
1564
1565 // create Person.. and Organization.. entities
1566 subs = Graph().Sharings(Prod);
1567 for (subs.Start(); subs.More(); subs.Next()) {
1568 Handle(StepAP214_AppliedPersonAndOrganizationAssignment) APOA =
1569 Handle(StepAP214_AppliedPersonAndOrganizationAssignment)::DownCast(subs.Value());
1570 if(APOA.IsNull()) continue;
1571 Handle(StepAP214_HArray1OfPersonAndOrganizationItem) HAPOI214 = APOA->Items();
1572 Handle(StepAP203_HArray1OfPersonOrganizationItem) HAPOI =
1573 new StepAP203_HArray1OfPersonOrganizationItem(1,HAPOI214->Length());
1574 for(Standard_Integer i=1; i<=HAPOI214->Length(); i++) {
1575 StepAP203_PersonOrganizationItem POI;
1576 POI.SetValue(HAPOI214->Value(i).Value());
1577 HAPOI->SetValue(i,POI);
1578 }
1579 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) DPOA =
1580 new StepAP203_CcDesignPersonAndOrganizationAssignment;
1581 DPOA->Init(APOA->AssignedPersonAndOrganization(), APOA->Role(), HAPOI);
1582 aModel->AddWithRefs(DPOA);
1583 }
1584 subs = Graph().Sharings(PD);
1585 for (subs.Start(); subs.More(); subs.Next()) {
1586 Handle(StepAP214_AppliedPersonAndOrganizationAssignment) APOA =
1587 Handle(StepAP214_AppliedPersonAndOrganizationAssignment)::DownCast(subs.Value());
1588 if(APOA.IsNull()) continue;
1589 Handle(StepAP214_HArray1OfPersonAndOrganizationItem) HAPOI214 = APOA->Items();
1590 Handle(StepAP203_HArray1OfPersonOrganizationItem) HAPOI =
1591 new StepAP203_HArray1OfPersonOrganizationItem(1,HAPOI214->Length());
1592 for(Standard_Integer i=1; i<=HAPOI214->Length(); i++) {
1593 StepAP203_PersonOrganizationItem POI;
1594 POI.SetValue(HAPOI214->Value(i).Value());
1595 HAPOI->SetValue(i,POI);
1596 }
1597 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) DPOA =
1598 new StepAP203_CcDesignPersonAndOrganizationAssignment;
1599 DPOA->Init(APOA->AssignedPersonAndOrganization(), APOA->Role(), HAPOI);
1600 aModel->AddWithRefs(DPOA);
1601 }
1602 subs = Graph().Sharings(PDF);
1603 for (subs.Start(); subs.More(); subs.Next()) {
1604 Handle(StepAP214_AppliedPersonAndOrganizationAssignment) APOA =
1605 Handle(StepAP214_AppliedPersonAndOrganizationAssignment)::DownCast(subs.Value());
1606 if(APOA.IsNull()) continue;
1607 Handle(StepAP214_HArray1OfPersonAndOrganizationItem) HAPOI214 = APOA->Items();
1608 Handle(StepAP203_HArray1OfPersonOrganizationItem) HAPOI =
1609 new StepAP203_HArray1OfPersonOrganizationItem(1,HAPOI214->Length());
1610 for(Standard_Integer i=1; i<=HAPOI214->Length(); i++) {
1611 StepAP203_PersonOrganizationItem POI;
1612 POI.SetValue(HAPOI214->Value(i).Value());
1613 HAPOI->SetValue(i,POI);
1614 }
1615 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) DPOA =
1616 new StepAP203_CcDesignPersonAndOrganizationAssignment;
1617 DPOA->Init(APOA->AssignedPersonAndOrganization(), APOA->Role(), HAPOI);
1618 aModel->AddWithRefs(DPOA);
1619 }
1620 subs = Graph().Sharings(SC);
1621 for (subs.Start(); subs.More(); subs.Next()) {
1622 Handle(StepAP214_AppliedPersonAndOrganizationAssignment) APOA =
1623 Handle(StepAP214_AppliedPersonAndOrganizationAssignment)::DownCast(subs.Value());
1624 if(APOA.IsNull()) continue;
1625 Handle(StepAP214_HArray1OfPersonAndOrganizationItem) HAPOI214 = APOA->Items();
1626 Handle(StepAP203_HArray1OfPersonOrganizationItem) HAPOI =
1627 new StepAP203_HArray1OfPersonOrganizationItem(1,HAPOI214->Length());
1628 for(Standard_Integer i=1; i<=HAPOI214->Length(); i++) {
1629 StepAP203_PersonOrganizationItem POI;
1630 POI.SetValue(HAPOI214->Value(i).Value());
1631 HAPOI->SetValue(i,POI);
1632 }
1633 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) DPOA =
1634 new StepAP203_CcDesignPersonAndOrganizationAssignment;
1635 DPOA->Init(APOA->AssignedPersonAndOrganization(), APOA->Role(), HAPOI);
1636 aModel->AddWithRefs(DPOA);
1637 }
1638
1639 return Standard_True;
1640}
1641