0022972: Eliminate macro definitions that has compiler-provided analogs (WNT and...
[occt.git] / src / STEPConstruct / STEPConstruct_AP203Context.cxx
1 // Created on: 1999-11-19
2 // Created by: Andrey BETENEV
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <StepAP203_CcDesignApproval.hxx>
19 #include <StepAP203_CcDesignDateAndTimeAssignment.hxx>
20 #include <StepAP203_CcDesignPersonAndOrganizationAssignment.hxx>
21 #include <StepAP203_CcDesignSecurityClassification.hxx>
22 #include <StepBasic_Approval.hxx>
23 #include <StepBasic_ApprovalDateTime.hxx>
24 #include <StepBasic_ApprovalPersonOrganization.hxx>
25 #include <StepBasic_ApprovalRole.hxx>
26 #include <StepBasic_DateAndTime.hxx>
27 #include <StepBasic_DateTimeRole.hxx>
28 #include <StepBasic_PersonAndOrganization.hxx>
29 #include <StepBasic_PersonAndOrganizationRole.hxx>
30 #include <StepBasic_ProductCategoryRelationship.hxx>
31 #include <StepBasic_SecurityClassificationLevel.hxx>
32 #include <STEPConstruct_AP203Context.hxx>
33 #include <STEPConstruct_Part.hxx>
34 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
35 #include <StepShape_ShapeDefinitionRepresentation.hxx>
36
37 #ifndef _WIN32
38 # include <pwd.h>
39 # include <netdb.h>
40 #else
41 # include <winsock2.h>
42 #endif
43
44 #include <stdio.h>
45
46 #include <OSD_Process.hxx>
47 #include <Quantity_Date.hxx>
48
49 #include <TCollection_HAsciiString.hxx>
50 #include <TColStd_SequenceOfAsciiString.hxx>
51 #include <Interface_HArray1OfHAsciiString.hxx>
52
53 #include <StepBasic_CalendarDate.hxx>
54 #include <StepBasic_LocalTime.hxx>
55 #include <StepBasic_ApprovalStatus.hxx>
56 #include <StepBasic_CoordinatedUniversalTimeOffset.hxx>
57 #include <StepBasic_AheadOrBehind.hxx>
58 #include <StepBasic_Person.hxx>
59 #include <StepBasic_Organization.hxx>
60 #include <StepBasic_SecurityClassification.hxx>
61 #include <StepBasic_Product.hxx>
62 #include <StepBasic_ProductDefinition.hxx>
63 #include <StepBasic_ProductDefinitionFormation.hxx>
64 #include <StepBasic_ProductRelatedProductCategory.hxx>
65 #include <StepAP203_HArray1OfPersonOrganizationItem.hxx>
66 #include <StepAP203_HArray1OfClassifiedItem.hxx>
67 #include <StepAP203_HArray1OfDateTimeItem.hxx>
68 #include <StepAP203_HArray1OfApprovedItem.hxx>
69 #include <StepBasic_ProductCategory.hxx>
70
71 //=======================================================================
72 //function : STEPConstruct_AP203Context
73 //purpose  : 
74 //=======================================================================
75
76 STEPConstruct_AP203Context::STEPConstruct_AP203Context ()
77 {
78   InitRoles();
79 }
80             
81 //=======================================================================
82 //function : DefaultApproval
83 //purpose  : 
84 //=======================================================================
85
86 Handle(StepBasic_Approval) STEPConstruct_AP203Context::DefaultApproval ()
87 {
88   if ( defApproval.IsNull() ) {
89     Handle(StepBasic_ApprovalStatus) aStatus = new StepBasic_ApprovalStatus;
90     Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString ("not_yet_approved");
91     aStatus->Init ( aName );
92
93     Handle(TCollection_HAsciiString) aLevel = new TCollection_HAsciiString ("");
94     defApproval = new StepBasic_Approval;
95     defApproval->Init ( aStatus, aLevel );
96   }
97   return defApproval;
98 }
99
100 //=======================================================================
101 //function : SetDefaultApproval
102 //purpose  : 
103 //=======================================================================
104
105 void STEPConstruct_AP203Context::SetDefaultApproval (const Handle(StepBasic_Approval) &app)
106 {
107   defApproval = app;
108 }
109     
110 //=======================================================================
111 //function : DefaultDateAndTime
112 //purpose  : 
113 //=======================================================================
114
115 Handle(StepBasic_DateAndTime) STEPConstruct_AP203Context::DefaultDateAndTime ()
116 {
117   if ( defDateAndTime.IsNull() ) {
118     OSD_Process sys;
119     Quantity_Date date = sys.SystemDate ();
120
121     Handle(StepBasic_CalendarDate) aDate = new StepBasic_CalendarDate;
122     aDate->Init ( date.Year(), date.Day(), date.Month() );
123
124     Handle(StepBasic_CoordinatedUniversalTimeOffset) zone = 
125       new StepBasic_CoordinatedUniversalTimeOffset;
126   #if defined(_MSC_VER) && _MSC_VER >= 1600
127     long shift = 0;
128     _get_timezone (&shift);
129   #else
130     Standard_Integer shift = Standard_Integer(timezone);
131   #endif
132     Standard_Integer shifth = abs ( shift ) / 3600;
133     Standard_Integer shiftm = ( abs ( shift ) - shifth * 3600 ) / 60;
134     StepBasic_AheadOrBehind sense = ( shift >0 ? StepBasic_aobBehind : 
135                                       shift <0 ? StepBasic_aobAhead : 
136                                                  StepBasic_aobExact );
137     zone->Init ( shifth, ( shiftm != 0 ), shiftm, sense );
138     
139     Handle(StepBasic_LocalTime) aTime = new StepBasic_LocalTime;
140     aTime->Init ( date.Hour(), Standard_True, date.Minute(), Standard_False, 0., zone );
141
142     defDateAndTime = new StepBasic_DateAndTime;
143     defDateAndTime->Init ( aDate, aTime );
144   }
145   return defDateAndTime;
146 }
147
148 //=======================================================================
149 //function : SetDefaultDateAndTime
150 //purpose  : 
151 //=======================================================================
152
153 void STEPConstruct_AP203Context::SetDefaultDateAndTime (const Handle(StepBasic_DateAndTime) &dt)
154 {
155   defDateAndTime = dt;
156 }
157     
158 //=======================================================================
159 //function : DefaultPersonAndOrganization
160 //purpose  : 
161 //=======================================================================
162
163 Handle(StepBasic_PersonAndOrganization) STEPConstruct_AP203Context::DefaultPersonAndOrganization ()
164 {
165   if ( defPersonAndOrganization.IsNull() ) {
166     // get IP address as a unique id of organization
167 #ifdef _WIN32 // adapted for NT which lacks gethostent()
168     char hostname[1024];
169     hostname[0] = '\0';
170     gethostname ( hostname, 1020 );
171     hostname[1020] = '\0';
172     struct hostent *he = gethostbyname ( hostname );
173 #else // adapted for Sun2.5, which lacks definition of gethostname()
174     struct hostent *he = gethostent();
175     while ( he && he->h_name && (unsigned char)he->h_addr_list[0][0] == 127 )
176       he = gethostent();
177 #endif
178     Handle(TCollection_HAsciiString) orgId = new TCollection_HAsciiString ( "" );
179     if ( he && he->h_addr_list && he->h_length >0 ) {
180       char str[100];
181       unsigned i1 = (unsigned char)he->h_addr_list[0][0];
182       unsigned i2 = (unsigned char)he->h_addr_list[0][1];
183       unsigned i3 = (unsigned char)he->h_addr_list[0][2];
184       sprintf ( str, "IP%03u.%03u.%03u.000", i1, i2, i3 );
185       orgId->AssignCat ( str );
186     }
187     
188     // create organization
189     Handle(StepBasic_Organization) aOrg = new StepBasic_Organization;
190     Handle(TCollection_HAsciiString) oName = new TCollection_HAsciiString ( "Unspecified" );
191     Handle(TCollection_HAsciiString) oDescr = new TCollection_HAsciiString ( "" );
192     aOrg->Init ( Standard_True, orgId, oName, oDescr );
193     
194     // construct person`s name
195     OSD_Process sys;
196     Standard_CString usr = sys.UserName().ToCString();
197 #if !defined(_WIN32) && !defined(__ANDROID__)
198     if ( usr ) {
199       struct passwd *pwd = getpwnam ( usr );
200       if ( pwd ) usr = pwd->pw_gecos;
201     }
202     else usr = "Unknown";
203 #endif
204     TCollection_AsciiString user ( usr );
205     Handle(TCollection_HAsciiString) fname = new TCollection_HAsciiString ("");
206     Handle(TCollection_HAsciiString) lname = new TCollection_HAsciiString ("");
207     Handle(Interface_HArray1OfHAsciiString) mname;
208     TColStd_SequenceOfAsciiString names;
209     Standard_Integer i; // svv Jan11 2000 : porting on DEC
210     for ( i=1; ; i++ ) {
211       TCollection_AsciiString token = user.Token ( " \t", i );
212       if ( ! token.Length() ) break;
213       names.Append ( token );
214     }
215     if ( names.Length() >0 ) fname->AssignCat ( names.Value(1).ToCString() );
216     if ( names.Length() >1 ) lname->AssignCat ( names.Value(names.Length()).ToCString() );
217     if ( names.Length() >2 ) {
218       mname = new Interface_HArray1OfHAsciiString ( 1, names.Length()-2 );
219       for ( i=2; i < names.Length(); i++ ) 
220         mname->SetValue ( i-1, new TCollection_HAsciiString ( names.Value(i) ) );
221     }
222     
223     // create a person
224     Handle(StepBasic_Person) aPerson = new StepBasic_Person;
225     Handle(TCollection_HAsciiString) uid = new TCollection_HAsciiString ( orgId );
226     uid->AssignCat ( "," );
227     uid->AssignCat ( TCollection_AsciiString ( sys.UserId() ).ToCString() );
228     Handle(Interface_HArray1OfHAsciiString) suffix, prefix;
229     aPerson->Init ( uid, Standard_True, lname, Standard_True, fname, ( ! mname.IsNull() ),
230                     mname, Standard_False, suffix, Standard_False, prefix );
231  
232     defPersonAndOrganization = new StepBasic_PersonAndOrganization;
233     defPersonAndOrganization->Init ( aPerson, aOrg );
234   }
235   return defPersonAndOrganization;  
236 }
237
238 //=======================================================================
239 //function : SetDefaultPersonAndOrganization
240 //purpose  : 
241 //=======================================================================
242
243 void STEPConstruct_AP203Context::SetDefaultPersonAndOrganization (const Handle(StepBasic_PersonAndOrganization) &po)
244 {
245   defPersonAndOrganization = po;
246 }
247     
248 //=======================================================================
249 //function : DefaultSecurityClassificationLevel
250 //purpose  : 
251 //=======================================================================
252
253 Handle(StepBasic_SecurityClassificationLevel) STEPConstruct_AP203Context::DefaultSecurityClassificationLevel ()
254 {
255   if ( defSecurityClassificationLevel.IsNull() ) {
256     defSecurityClassificationLevel = new StepBasic_SecurityClassificationLevel;
257     Handle(TCollection_HAsciiString) levName = new TCollection_HAsciiString ( "unclassified" );
258     defSecurityClassificationLevel->Init ( levName );
259   }
260   return defSecurityClassificationLevel;  
261 }
262
263 //=======================================================================
264 //function : SetDefaultSecurityClassificationLevel
265 //purpose  : 
266 //=======================================================================
267
268 void STEPConstruct_AP203Context::SetDefaultSecurityClassificationLevel (const Handle(StepBasic_SecurityClassificationLevel) &scl)
269 {
270   defSecurityClassificationLevel = scl;
271 }
272
273 //=======================================================================
274 //function : RoleCreator
275 //purpose  : 
276 //=======================================================================
277
278 Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleCreator () const 
279 {
280   return roleCreator;
281 }
282
283 //=======================================================================
284 //function : RoleDesignOwner
285 //purpose  : 
286 //=======================================================================
287
288 Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleDesignOwner () const
289 {
290   return roleDesignOwner;
291 }
292
293 //=======================================================================
294 //function : RoleDesignSupplier
295 //purpose  : 
296 //=======================================================================
297
298 Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleDesignSupplier () const
299 {
300   return roleDesignSupplier;
301 }
302
303 //=======================================================================
304 //function : RoleClassificationOfficer
305 //purpose  : 
306 //=======================================================================
307
308 Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleClassificationOfficer () const
309 {
310   return roleClassificationOfficer;
311 }
312
313 //=======================================================================
314 //function : RoleCreationDate
315 //purpose  : 
316 //=======================================================================
317
318 Handle(StepBasic_DateTimeRole) STEPConstruct_AP203Context::RoleCreationDate () const
319 {
320   return roleCreationDate;
321 }
322
323 //=======================================================================
324 //function : RoleClassificationDate
325 //purpose  : 
326 //=======================================================================
327
328 Handle(StepBasic_DateTimeRole) STEPConstruct_AP203Context::RoleClassificationDate () const
329 {
330   return roleClassificationDate;
331 }
332
333 //=======================================================================
334 //function : RoleApprover
335 //purpose  : 
336 //=======================================================================
337
338 Handle(StepBasic_ApprovalRole) STEPConstruct_AP203Context::RoleApprover () const
339 {
340   return roleApprover;
341 }
342
343 //=======================================================================
344 //function : Init
345 //purpose  : 
346 //=======================================================================
347
348 void STEPConstruct_AP203Context::Init (const Handle(StepShape_ShapeDefinitionRepresentation) &sdr)
349 {
350   Clear();
351   STEPConstruct_Part SDRTool;
352   SDRTool.ReadSDR ( sdr );
353   InitPart ( SDRTool );
354 }
355
356 //=======================================================================
357 //function : Init
358 //purpose  : 
359 //=======================================================================
360
361 void STEPConstruct_AP203Context::Init (const STEPConstruct_Part &SDRTool)
362 {
363   Clear();
364   InitPart ( SDRTool );
365 }
366
367 //=======================================================================
368 //function : Init
369 //purpose  : 
370 //=======================================================================
371
372 //void STEPConstruct_AP203Context::Init (const STEPConstruct_Part &SDRTool, const Handle(Interface_Model) &Model) {}
373
374 //=======================================================================
375 //function : Init
376 //purpose  : 
377 //=======================================================================
378
379 void STEPConstruct_AP203Context::Init (const Handle(StepRepr_NextAssemblyUsageOccurrence) &NAUO)
380 {
381   Clear();
382   InitAssembly ( NAUO );
383 }
384
385 //=======================================================================
386 //function : GetCreator
387 //purpose  : 
388 //=======================================================================
389
390 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetCreator () const
391 {
392   return myCreator;
393 }
394
395 //=======================================================================
396 //function : GetDesignOwner
397 //purpose  : 
398 //=======================================================================
399
400 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetDesignOwner () const
401 {
402   return myDesignOwner;
403 }
404
405 //=======================================================================
406 //function : GetDesignSupplier
407 //purpose  : 
408 //=======================================================================
409
410 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetDesignSupplier () const
411 {
412   return myDesignSupplier;
413 }
414
415 //=======================================================================
416 //function : GetClassificationOfficer
417 //purpose  : 
418 //=======================================================================
419
420 Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetClassificationOfficer () const
421 {
422   return myClassificationOfficer;
423 }
424
425 //=======================================================================
426 //function : GetSecurity
427 //purpose  : 
428 //=======================================================================
429
430 Handle(StepAP203_CcDesignSecurityClassification) STEPConstruct_AP203Context::GetSecurity () const
431 {
432   return mySecurity;
433 }
434
435 //=======================================================================
436 //function : GetCreationDate
437 //purpose  : 
438 //=======================================================================
439
440 Handle(StepAP203_CcDesignDateAndTimeAssignment) STEPConstruct_AP203Context::GetCreationDate () const
441 {
442   return myCreationDate;
443 }
444
445 //=======================================================================
446 //function : GetClassificationDate
447 //purpose  : 
448 //=======================================================================
449
450 Handle(StepAP203_CcDesignDateAndTimeAssignment) STEPConstruct_AP203Context::GetClassificationDate () const
451 {
452   return myClassificationDate;
453 }
454
455 //=======================================================================
456 //function : GetApproval
457 //purpose  : 
458 //=======================================================================
459
460 Handle(StepAP203_CcDesignApproval) STEPConstruct_AP203Context::GetApproval () const
461 {
462   return myApproval;
463 }
464
465 //=======================================================================
466 //function : GetApprover
467 //purpose  : 
468 //=======================================================================
469
470 Handle(StepBasic_ApprovalPersonOrganization) STEPConstruct_AP203Context::GetApprover () const
471 {
472   return myApprover;
473 }
474
475 //=======================================================================
476 //function : GetApprovalDateTime
477 //purpose  : 
478 //=======================================================================
479
480 Handle(StepBasic_ApprovalDateTime) STEPConstruct_AP203Context::GetApprovalDateTime () const
481 {
482   return myApprovalDateTime;
483 }
484
485 //=======================================================================
486 //function : GetProductCategoryRelationship
487 //purpose  : 
488 //=======================================================================
489
490 Handle(StepBasic_ProductCategoryRelationship) STEPConstruct_AP203Context::GetProductCategoryRelationship () const
491 {
492   return myProductCategoryRelationship;
493 }
494
495 //=======================================================================
496 //function : Clear
497 //purpose  : 
498 //=======================================================================
499
500 void STEPConstruct_AP203Context::Clear ()
501 {
502   myCreator.Nullify();
503   myDesignOwner.Nullify();
504   myDesignSupplier.Nullify();
505   myClassificationOfficer.Nullify();
506   mySecurity.Nullify();
507   myCreationDate.Nullify();
508   myClassificationDate.Nullify();
509   myApproval.Nullify();
510   
511 //  myApprover.Nullify();
512 //  myApprovalDateTime.Nullify();
513   
514   myProductCategoryRelationship.Nullify();
515 }
516
517 //=======================================================================
518 //function : InitRoles
519 //purpose  : 
520 //=======================================================================
521
522 void STEPConstruct_AP203Context::InitRoles ()
523 {
524   roleCreator = new StepBasic_PersonAndOrganizationRole;
525   roleDesignOwner = new StepBasic_PersonAndOrganizationRole;
526   roleDesignSupplier = new StepBasic_PersonAndOrganizationRole;
527   roleClassificationOfficer = new StepBasic_PersonAndOrganizationRole;
528   roleCreationDate = new StepBasic_DateTimeRole;
529   roleClassificationDate = new StepBasic_DateTimeRole;
530   roleApprover = new StepBasic_ApprovalRole;
531   
532   roleCreator->Init ( new TCollection_HAsciiString ( "creator" ) );
533   roleDesignOwner->Init ( new TCollection_HAsciiString ( "design_owner" ) );
534   roleDesignSupplier->Init ( new TCollection_HAsciiString ( "design_supplier" ) );
535   roleClassificationOfficer->Init ( new TCollection_HAsciiString ( "classification_officer" ) );
536   roleCreationDate->Init ( new TCollection_HAsciiString ( "creation_date" ) );
537   roleClassificationDate->Init ( new TCollection_HAsciiString ( "classification_date" ) );
538   roleApprover->Init ( new TCollection_HAsciiString ( "approver" ) );
539 }
540
541 //=======================================================================
542 //function : InitPart
543 //purpose  : 
544 //=======================================================================
545
546 void STEPConstruct_AP203Context::InitPart (const STEPConstruct_Part &SDRTool)
547 {
548   if ( myCreator.IsNull() ) {
549     myCreator = new StepAP203_CcDesignPersonAndOrganizationAssignment;
550     Handle(StepAP203_HArray1OfPersonOrganizationItem) items = 
551       new StepAP203_HArray1OfPersonOrganizationItem (1, 2);
552     items->ChangeValue(1).SetValue ( SDRTool.PDF() );
553     items->ChangeValue(2).SetValue ( SDRTool.PD() );
554     myCreator->Init ( DefaultPersonAndOrganization(), RoleCreator(), items );
555   }
556   
557   if ( myDesignOwner.IsNull() ) {
558     myDesignOwner = new StepAP203_CcDesignPersonAndOrganizationAssignment;
559     Handle(StepAP203_HArray1OfPersonOrganizationItem) items = 
560       new StepAP203_HArray1OfPersonOrganizationItem (1, 1);
561     items->ChangeValue(1).SetValue ( SDRTool.Product() );
562     myDesignOwner->Init ( DefaultPersonAndOrganization(), RoleDesignOwner(), items );
563   }
564   
565   if ( myDesignSupplier.IsNull() ) {
566     myDesignSupplier = new StepAP203_CcDesignPersonAndOrganizationAssignment;
567     Handle(StepAP203_HArray1OfPersonOrganizationItem) items = 
568       new StepAP203_HArray1OfPersonOrganizationItem (1, 1);
569     items->ChangeValue(1).SetValue ( SDRTool.PDF() );
570     myDesignSupplier->Init ( DefaultPersonAndOrganization(), RoleDesignSupplier(), items );
571   }
572   
573   if ( myCreationDate.IsNull() ) {
574     myCreationDate = new StepAP203_CcDesignDateAndTimeAssignment;
575     Handle(StepAP203_HArray1OfDateTimeItem) items = 
576       new StepAP203_HArray1OfDateTimeItem (1, 1);
577     items->ChangeValue(1).SetValue ( SDRTool.PD() );
578     myCreationDate->Init ( DefaultDateAndTime(), RoleCreationDate(), items );
579   }
580   
581   if ( mySecurity.IsNull() ) {
582     
583     Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString ( "" );
584     Handle(TCollection_HAsciiString) aPurpose = new TCollection_HAsciiString ( "" );
585     Handle(StepBasic_SecurityClassification) sc = new StepBasic_SecurityClassification;
586     sc->Init ( aName, aPurpose, DefaultSecurityClassificationLevel() );
587
588     mySecurity = new StepAP203_CcDesignSecurityClassification;
589     Handle(StepAP203_HArray1OfClassifiedItem) items = 
590       new StepAP203_HArray1OfClassifiedItem (1, 1);
591     items->ChangeValue(1).SetValue ( SDRTool.PDF() );
592     mySecurity->Init ( sc, items );
593   }
594   InitSecurityRequisites();
595   
596   if ( myApproval.IsNull() ) {
597     myApproval = new StepAP203_CcDesignApproval;
598     Handle(StepAP203_HArray1OfApprovedItem) items = 
599       new StepAP203_HArray1OfApprovedItem (1, 3);
600     items->ChangeValue(1).SetValue ( SDRTool.PDF() );
601     items->ChangeValue(2).SetValue ( SDRTool.PD() );
602     items->ChangeValue(3).SetValue ( mySecurity->AssignedSecurityClassification() );
603     myApproval->Init ( DefaultApproval(), items );
604   }
605   InitApprovalRequisites();
606
607   if ( myProductCategoryRelationship.IsNull() ) {
608     Handle(StepBasic_ProductCategory) PC = new StepBasic_ProductCategory;
609     Handle(TCollection_HAsciiString) PCName = new TCollection_HAsciiString ( "part" );
610     PC->Init ( PCName, Standard_False, 0 );
611     
612     myProductCategoryRelationship = new StepBasic_ProductCategoryRelationship;
613     Handle(TCollection_HAsciiString) PCRName = new TCollection_HAsciiString ( "" );
614     Handle(TCollection_HAsciiString) PCRDescr = new TCollection_HAsciiString ( "" );
615     myProductCategoryRelationship->Init ( PCRName, Standard_True, PCRDescr, PC, SDRTool.PRPC() );
616   }
617 }
618
619 //=======================================================================
620 //function : InitAssembly
621 //purpose  : 
622 //=======================================================================
623
624 void STEPConstruct_AP203Context::InitAssembly (const Handle(StepRepr_NextAssemblyUsageOccurrence) &NAUO)
625 {
626   if ( mySecurity.IsNull() ) {
627     
628     Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString ( "" );
629     Handle(TCollection_HAsciiString) aPurpose = new TCollection_HAsciiString ( "" );
630     Handle(StepBasic_SecurityClassification) sc = new StepBasic_SecurityClassification;
631     sc->Init ( aName, aPurpose, DefaultSecurityClassificationLevel() );
632
633     mySecurity = new StepAP203_CcDesignSecurityClassification;
634     Handle(StepAP203_HArray1OfClassifiedItem) items = 
635       new StepAP203_HArray1OfClassifiedItem (1, 1);
636     items->ChangeValue(1).SetValue ( NAUO );
637     mySecurity->Init ( sc, items );
638   }
639   InitSecurityRequisites();
640   
641   if ( myApproval.IsNull() ) {
642     myApproval = new StepAP203_CcDesignApproval;
643     Handle(StepAP203_HArray1OfApprovedItem) items = 
644       new StepAP203_HArray1OfApprovedItem (1, 1);
645     items->ChangeValue(1).SetValue ( mySecurity->AssignedSecurityClassification() );
646     myApproval->Init ( DefaultApproval(), items );
647   }  
648   InitApprovalRequisites();
649 }
650
651 //=======================================================================
652 //function : InitSecurityRequisites
653 //purpose  : 
654 //=======================================================================
655
656 void STEPConstruct_AP203Context::InitSecurityRequisites ()
657 {
658   if ( myClassificationOfficer.IsNull() ||
659        myClassificationOfficer->Items()->Value(1).Value() != mySecurity->AssignedSecurityClassification() ) {
660     myClassificationOfficer = new StepAP203_CcDesignPersonAndOrganizationAssignment;
661     Handle(StepAP203_HArray1OfPersonOrganizationItem) items = 
662       new StepAP203_HArray1OfPersonOrganizationItem (1, 1);
663     items->ChangeValue(1).SetValue ( mySecurity->AssignedSecurityClassification() );
664     myClassificationOfficer->Init ( DefaultPersonAndOrganization(), RoleClassificationOfficer(), items );
665   }
666   
667   if ( myClassificationDate.IsNull() ||
668        myClassificationDate->Items()->Value(1).Value() != mySecurity->AssignedSecurityClassification() ) {
669     myClassificationDate = new StepAP203_CcDesignDateAndTimeAssignment;
670     Handle(StepAP203_HArray1OfDateTimeItem) items = 
671       new StepAP203_HArray1OfDateTimeItem (1, 1);
672     items->ChangeValue(1).SetValue ( mySecurity->AssignedSecurityClassification() );
673     myClassificationDate->Init ( DefaultDateAndTime(), RoleClassificationDate(), items );
674   }
675 }
676   
677 //=======================================================================
678 //function : InitApprovalRequisites
679 //purpose  : 
680 //=======================================================================
681
682 void STEPConstruct_AP203Context::InitApprovalRequisites ()
683 {
684   if ( myApprover.IsNull() || 
685        myApprover->AuthorizedApproval() != myApproval->AssignedApproval() ) {
686     myApprover = new StepBasic_ApprovalPersonOrganization;
687     StepBasic_PersonOrganizationSelect po;
688     po.SetValue ( DefaultPersonAndOrganization() );
689     myApprover->Init ( po, myApproval->AssignedApproval(), RoleApprover() );
690   }
691   
692   if ( myApprovalDateTime.IsNull() || 
693        myApprovalDateTime->DatedApproval() != myApproval->AssignedApproval() ) {
694     myApprovalDateTime = new StepBasic_ApprovalDateTime;
695     StepBasic_DateTimeSelect dt;
696     dt.SetValue ( DefaultDateAndTime() );
697     myApprovalDateTime->Init ( dt, myApproval->AssignedApproval() );
698   }
699 }