1 // Created on: 2000-09-29
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15 
16 
17 #include <Interface_EntityIterator.hxx>
18 #include <StepAP203_ApprovedItem.hxx>
19 #include <StepAP203_CcDesignApproval.hxx>
20 #include <StepAP203_CcDesignDateAndTimeAssignment.hxx>
21 #include <StepAP203_CcDesignPersonAndOrganizationAssignment.hxx>
22 #include <StepAP203_DateTimeItem.hxx>
23 #include <StepAP203_HArray1OfApprovedItem.hxx>
24 #include <StepAP203_HArray1OfDateTimeItem.hxx>
25 #include <StepAP203_HArray1OfPersonOrganizationItem.hxx>
26 #include <StepAP203_PersonOrganizationItem.hxx>
27 #include <StepAP214_AppliedDocumentReference.hxx>
28 #include <StepAP214_AppliedExternalIdentificationAssignment.hxx>
29 #include <StepAP214_ExternalIdentificationItem.hxx>
30 #include <StepAP214_HArray1OfDocumentReferenceItem.hxx>
31 #include <StepAP214_HArray1OfExternalIdentificationItem.hxx>
32 #include <StepBasic_ApplicationContext.hxx>
33 #include <StepBasic_ApplicationProtocolDefinition.hxx>
34 #include <StepBasic_Document.hxx>
35 #include <StepBasic_DocumentFile.hxx>
36 #include <StepBasic_DocumentProductEquivalence.hxx>
37 #include <StepBasic_DocumentRepresentationType.hxx>
38 #include <StepBasic_DocumentType.hxx>
39 #include <StepBasic_ExternalSource.hxx>
40 #include <StepBasic_HArray1OfDocument.hxx>
41 #include <StepBasic_HArray1OfProduct.hxx>
42 #include <StepBasic_HArray1OfProductContext.hxx>
43 #include <StepBasic_IdentificationRole.hxx>
44 #include <StepBasic_ObjectRole.hxx>
45 #include <StepBasic_Product.hxx>
46 #include <StepBasic_ProductContext.hxx>
47 #include <StepBasic_ProductDefinition.hxx>
48 #include <StepBasic_ProductDefinitionContext.hxx>
49 #include <StepBasic_ProductDefinitionFormation.hxx>
50 #include <StepBasic_ProductDefinitionWithAssociatedDocuments.hxx>
51 #include <StepBasic_ProductOrFormationOrDefinition.hxx>
52 #include <StepBasic_ProductRelatedProductCategory.hxx>
53 #include <StepBasic_RoleAssociation.hxx>
54 #include <StepBasic_SourceItem.hxx>
55 #include <STEPConstruct_ExternRefs.hxx>
56 #include <StepData_SelectNamed.hxx>
57 #include <StepRepr_CharacterizedDefinition.hxx>
58 #include <StepRepr_DescriptiveRepresentationItem.hxx>
59 #include <StepRepr_HArray1OfRepresentationItem.hxx>
60 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
61 #include <StepRepr_ProductDefinitionShape.hxx>
62 #include <StepRepr_PropertyDefinition.hxx>
63 #include <StepRepr_PropertyDefinitionRepresentation.hxx>
64 #include <StepRepr_RepresentationContext.hxx>
65 #include <StepRepr_RepresentedDefinition.hxx>
66 #include <StepShape_ShapeRepresentation.hxx>
67 #include <TCollection_HAsciiString.hxx>
68 #include <XSControl_WorkSession.hxx>
69 #include <XSControl_TransferReader.hxx>
70 #include <OSD_File.hxx>
71 #include <OSD_Path.hxx>
72 
73 //=======================================================================
74 //function : STEPConstruct_ExternRefs
75 //purpose  :
76 //=======================================================================
STEPConstruct_ExternRefs()77 STEPConstruct_ExternRefs::STEPConstruct_ExternRefs ()
78 {
79 }
80 
81 //=======================================================================
82 //function : STEPConstruct_ExternRefs
83 //purpose  :
84 //=======================================================================
85 
STEPConstruct_ExternRefs(const Handle (XSControl_WorkSession)& WS)86 STEPConstruct_ExternRefs::STEPConstruct_ExternRefs (const Handle(XSControl_WorkSession) &WS)
87      : STEPConstruct_Tool ( WS )
88 {
89 }
90 
91 //=======================================================================
92 //function : Init
93 //purpose  :
94 //=======================================================================
95 
Init(const Handle (XSControl_WorkSession)& WS)96 Standard_Boolean STEPConstruct_ExternRefs::Init (const Handle(XSControl_WorkSession) &WS)
97 {
98   Clear();
99   return SetWS ( WS );
100 }
101 
102 //=======================================================================
103 //function : Clear
104 //purpose  :
105 //=======================================================================
106 
Clear()107 void STEPConstruct_ExternRefs::Clear ()
108 {
109   myAEIAs.Clear();
110   myRoles.Clear();
111   myFormats.Clear();
112   myShapes.Clear();
113   myTypes.Clear();
114   myIsAP214.Clear();
115   // PTV 30.01.2003 TRJ11
116   myDocFiles.Clear();
117   mySharedPRPC.Nullify();
118   mySharedDocType.Nullify();
119   mySharedPDC.Nullify();
120   mySharedPC.Nullify();
121   myAPD.Nullify();
122 }
123 
124 //=======================================================================
125 //function : LoadExternRefs
126 //purpose  :
127 //=======================================================================
128 
findPDWADandExcludeExcess(Handle (StepAP214_AppliedDocumentReference)& ADR,TColStd_SequenceOfTransient & aSeqOfPDWAD,const Interface_Graph & Graph,Handle (StepBasic_ProductDefinitionWithAssociatedDocuments)& aPDWAD)129 static Standard_Boolean findPDWADandExcludeExcess (Handle(StepAP214_AppliedDocumentReference)& ADR,
130                                                    TColStd_SequenceOfTransient& aSeqOfPDWAD,
131                                                    const Interface_Graph& Graph,
132                                                    Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)& aPDWAD)
133 {
134   // WARNING! do not add check for aSeqOfPDWAD.Length() and exit if it < 1,
135   // because this methods invokes with an empty sequence too to find PDWAD by ADR
136   Interface_EntityIterator subsADR = Graph.Shareds(ADR);
137   for ( subsADR.Start(); subsADR.More(); subsADR.Next() ) {
138     if ( !subsADR.Value()->IsKind (STANDARD_TYPE(StepBasic_Document)) )
139       continue;
140     Handle(StepBasic_Document) aDoc = Handle(StepBasic_Document)::DownCast(subsADR.Value());
141     // looking for Document Product Equivalence
142     Interface_EntityIterator subsD = Graph.Sharings(aDoc);
143     for ( subsD.Start(); subsD.More(); subsD.Next() ) {
144       if ( !subsD.Value()->IsKind (STANDARD_TYPE(StepBasic_DocumentProductEquivalence)) )
145         continue;
146       Handle(StepBasic_DocumentProductEquivalence) aDPE =
147         Handle(StepBasic_DocumentProductEquivalence)::DownCast(subsD.Value());
148       // take PDF and search the same PDF by PDWAD chain
149       Interface_EntityIterator subsDPE = Graph.Shareds(aDPE);
150       for ( subsDPE.Start(); subsDPE.More(); subsDPE.Next() ) {
151         if ( !subsDPE.Value()->IsKind (STANDARD_TYPE(StepBasic_ProductDefinitionFormation)) )
152           continue;
153         Handle(StepBasic_ProductDefinitionFormation) aPDF =
154           Handle(StepBasic_ProductDefinitionFormation)::DownCast(subsDPE.Value());
155         Interface_EntityIterator subs = Graph.Sharings(aPDF);
156         for ( subs.Start(); subs.More(); subs.Next() ) {
157           if ( !subs.Value()->IsKind (STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments)) )
158             continue;
159           aPDWAD = Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(subs.Value());
160         }
161         // now searching for PDWAD that refer to the same PDF
162         for (Standard_Integer pdwadi = 1; pdwadi <= aSeqOfPDWAD.Length(); pdwadi++) {
163           Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aCurPDWAD =
164             Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(aSeqOfPDWAD(pdwadi));
165           if ( !aCurPDWAD.IsNull() && aPDWAD == aCurPDWAD ) {
166             // found the same Product Definition Formation
167             aSeqOfPDWAD.Remove( pdwadi );
168             return Standard_True;
169           }
170         }
171       } // end of looking for PDF by ADR chain
172     } // end of looking for DPE
173   } // end iterations on Shareds(ADR)
174   return Standard_False;
175 }
176 
177 
LoadExternRefs()178 Standard_Boolean STEPConstruct_ExternRefs::LoadExternRefs ()
179 {
180   // iterate on entities in the model and find AEIAs
181   // or PDWADs (for AP203)
182   Handle(Interface_InterfaceModel) model = Model();
183   Handle(Standard_Type) tADR = STANDARD_TYPE(StepAP214_AppliedDocumentReference);
184   Handle(Standard_Type) tPDWAD = STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments);
185   Standard_Integer nb = model->NbEntities();
186 
187   // PTV 28.01.2003 CAX-IF TRJ11, file ext_ref_master.stp
188   // search all ADR and PDWAD and exclude excess PDWADs
189   TColStd_SequenceOfTransient aSeqOfADR, aSeqOfPDWAD;
190   for (Standard_Integer ient = 1; ient <= nb; ient ++) {
191     Handle(Standard_Transient) enti = model->Value(ient);
192     if ( enti->DynamicType() == tPDWAD )
193       aSeqOfPDWAD.Append( enti );
194     else if ( enti->DynamicType() == tADR )
195       aSeqOfADR.Append( enti );
196   }
197   Standard_Integer IsAP214 = 0;
198   // run on sequence aSeqOfADR of ADR and remove excess PDWAD from aSeqOfPDWAD
199   for (Standard_Integer adri = 1; adri <= aSeqOfADR.Length(); adri++) {
200     Handle(StepAP214_AppliedDocumentReference) ADR =
201       Handle(StepAP214_AppliedDocumentReference)::DownCast(aSeqOfADR.Value(adri));
202     // looking for Product Definition Formation and exclude excess PDWAD from aSeqOfPDWAD
203     Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD;
204     findPDWADandExcludeExcess( ADR, aSeqOfPDWAD, Graph(), aPDWAD );
205 
206     // now add all necessary information as original implementation.
207     IsAP214 = 1;
208     Handle(StepBasic_RoleAssociation) Role;
209     Handle(StepBasic_ProductDefinition) Shape;
210     Handle(StepRepr_PropertyDefinitionRepresentation) Format;
211     Handle(StepBasic_DocumentRepresentationType) Type;
212     // AppliedDocumentReference with RoleAssociation...
213     Interface_EntityIterator subs4 = Graph().Sharings(ADR);
214     for (subs4.Start(); subs4.More(); subs4.Next()) {
215       if ( subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_RoleAssociation) ) )
216         Role = Handle(StepBasic_RoleAssociation)::DownCast(subs4.Value());
217     }
218 
219     subs4 = Graph().Shareds(ADR);
220     for (subs4.Start(); subs4.More(); subs4.Next()) {
221       if ( subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_ProductDefinition) ) )
222         Shape = Handle(StepBasic_ProductDefinition)::DownCast(subs4.Value());
223     }
224     // search for Document file
225     Handle(StepBasic_DocumentFile) DocFile;
226     if ( aPDWAD.IsNull() ) { // shouldn't begin from TRJ11
227       // lookinf from ADR
228       subs4 = Graph().Shareds(ADR);
229     } else
230       // looking from PDWAD
231       subs4 = Graph().Shareds(aPDWAD);
232 
233     for (subs4.Start(); subs4.More(); subs4.Next()) {
234       if ( !subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_DocumentFile) ) )
235         continue;
236       DocFile = Handle(StepBasic_DocumentFile)::DownCast(subs4.Value());
237       if ( DocFile.IsNull() )
238         continue;
239       // for each DocumentFile, find associated with it data:
240       Interface_EntityIterator subs = Graph().Sharings(DocFile);
241       for (subs.Start(); subs.More(); subs.Next()) {
242         Handle(Standard_Transient) sub = subs.Value();
243 
244         // FORMAT - ???????
245         //
246         // PDRs of a shape and of a file format
247         if ( sub->IsKind ( STANDARD_TYPE(StepRepr_PropertyDefinition) ) ) {
248           Handle(StepRepr_PropertyDefinition) PD = Handle(StepRepr_PropertyDefinition)::DownCast(sub);
249           Interface_EntityIterator subs2 = Graph().Sharings(PD);
250           for (subs2.Start(); subs2.More(); subs2.Next()) {
251             Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
252               Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast(subs2.Value());
253             if ( PDR.IsNull() ) continue;
254             if (  PDR->UsedRepresentation()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation)) )
255               Format = PDR;
256           }
257         }
258         // DocumentRepresentationType
259         if ( sub->IsKind ( STANDARD_TYPE(StepBasic_DocumentRepresentationType) ) ) {
260           Type = Handle(StepBasic_DocumentRepresentationType)::DownCast(sub);
261         }
262         if ( !Type.IsNull() && !Format.IsNull() )
263           break;
264       }
265       if ( !Type.IsNull() && !Format.IsNull() )
266         break;
267     }
268     if ( DocFile.IsNull() )
269       continue;
270     myAEIAs.Append ( ADR );
271     myRoles.Append ( Role );
272     myFormats.Append ( Format );
273     myShapes.Append ( Shape );
274     myTypes.Append ( Type );
275     myIsAP214.Append ( IsAP214 );
276     myDocFiles.Append( DocFile );
277   } // end iterations on aSeqOfADR
278 
279   // now iterates on sequence aSeqOfPDWAD of Product Definition With Associated Documents
280   for (Standard_Integer pdwadi = 1; pdwadi <= aSeqOfPDWAD.Length(); pdwadi++) {
281     IsAP214 = 0;
282     Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD =
283       Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(aSeqOfPDWAD(pdwadi));
284     myShapes.Append(aPDWAD);
285     myIsAP214.Append ( IsAP214 );
286     Handle(StepAP214_AppliedExternalIdentificationAssignment) AEIA;
287     Handle(StepBasic_RoleAssociation) Role;
288     Handle(StepRepr_PropertyDefinitionRepresentation) Format;
289     Handle(StepBasic_DocumentRepresentationType) Type;
290     Handle(StepBasic_DocumentFile) DocFile;
291     myAEIAs.Append ( AEIA );
292     myRoles.Append ( Role );
293     myFormats.Append ( Format );
294     myTypes.Append ( Type );
295     myDocFiles.Append( DocFile );
296   }
297 
298   return myShapes.Length() >0;
299 }
300 
301 //=======================================================================
302 //function : NbExternRefs
303 //purpose  :
304 //=======================================================================
305 
NbExternRefs() const306 Standard_Integer STEPConstruct_ExternRefs::NbExternRefs () const
307 {
308   return myShapes.Length();
309 }
310 
311 //=======================================================================
312 //function : FileName
313 //purpose  :
314 //=======================================================================
315 
FileName(const Standard_Integer num) const316 Standard_CString STEPConstruct_ExternRefs::FileName (const Standard_Integer num) const
317 {
318   Handle(StepBasic_DocumentFile) DocFile;
319   Handle(StepAP214_AppliedExternalIdentificationAssignment) AEIA;
320   Standard_CString aCStringFileName = 0;
321   if ( myDocFiles.Length() >= num && !myDocFiles.Value(num).IsNull() )
322     DocFile = Handle(StepBasic_DocumentFile)::DownCast(myDocFiles.Value( num ));
323   else if (myIsAP214(num)==1)
324   {
325     Handle(StepAP214_AppliedDocumentReference) ADR =
326       Handle(StepAP214_AppliedDocumentReference)::DownCast ( myAEIAs(num) );
327 
328     // PTV 28.01.2003 CAX-IF TRJ11, file ext_ref_master.stp
329     // search document file name by long chain ADR->D<-DPE->PDF<-PDWAD->DF
330     Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD;
331     // create an empty aSeqOfPDWAD
332     TColStd_SequenceOfTransient aSeqOfPDWAD;
333     // we do not need to exclude, just find PDWAD
334     findPDWADandExcludeExcess( ADR, aSeqOfPDWAD, Graph(), aPDWAD );
335 
336     // search for Document file
337     Interface_EntityIterator subs4;
338     if ( aPDWAD.IsNull() ) { // shouldn't begin from TRJ11
339       // lookinf from ADR
340       subs4 = Graph().Shareds(ADR);
341     } else
342       // looking from PDWAD
343       subs4 = Graph().Shareds(aPDWAD);
344     for (subs4.Start(); subs4.More(); subs4.Next()) {
345       if ( !subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_DocumentFile) ) )
346         continue;
347       DocFile = Handle(StepBasic_DocumentFile)::DownCast(subs4.Value());
348       if ( DocFile.IsNull() ) continue;
349     }
350   }
351   else  {
352     Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD =
353       Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(myShapes(num));
354     if ( aPDWAD.IsNull() || aPDWAD->DocIds().IsNull() )
355       return "";
356     Standard_Integer i;
357     for ( i=1; i <= aPDWAD->NbDocIds(); i++ ) {
358       Handle(StepBasic_Document) Doc = aPDWAD->DocIdsValue(i);
359       Handle(TCollection_HAsciiString) aFilename = Doc->Name();
360       if (!aFilename.IsNull() && !aFilename->IsEmpty()) return aFilename->ToCString();
361     }
362     return "";
363   }
364   // take name from AEIA and from DF
365   if(!DocFile.IsNull()) {
366     Interface_EntityIterator subs3 = Graph().Sharings(DocFile);
367     for (subs3.Start(); subs3.More(); subs3.Next()) {
368       if (subs3.Value()->IsKind(STANDARD_TYPE(StepAP214_AppliedExternalIdentificationAssignment))) {
369         AEIA = Handle(StepAP214_AppliedExternalIdentificationAssignment)::DownCast(subs3.Value());
370         if (!AEIA.IsNull())
371           break;
372       }
373     }
374   }
375   if(!AEIA.IsNull()) {
376     Handle(TCollection_HAsciiString) aFilename;
377     aFilename = AEIA->AssignedId();
378     if (!aFilename.IsNull() && !aFilename->IsEmpty()) {
379       aCStringFileName = aFilename->ToCString();
380       // ptv 29.01.2003 file trj4_xr1-tc-214.stp entity #71 have id "#71"
381       if ( aCStringFileName && aCStringFileName[0] == '#')
382         aCStringFileName = 0;
383     }
384     if ( ! aCStringFileName || ! aCStringFileName[0] ) {
385       // try to take name from external source
386       Handle(StepBasic_ExternalSource) theSource = AEIA->Source();
387       if (!theSource.IsNull()) {
388         StepBasic_SourceItem theSourceId = theSource->SourceId();
389         if (!theSourceId.IsNull()) {
390           Handle(StepData_SelectNamed) theFileName;
391           theFileName = Handle(StepData_SelectNamed)::DownCast (theSourceId.Value());
392           if (theFileName.IsNull() || theFileName->Kind()!=6 ) {
393             // nothing to do, hope could take name later.
394           }
395           else
396             aCStringFileName = theFileName->String();
397         }
398       }
399     }
400   }
401   Standard_CString oldFileName = 0;
402   // compute true path to the extern file
403   OSD_Path mainfile(WS()->LoadedFile());
404   mainfile.SetName("");
405   mainfile.SetExtension("");
406   TCollection_AsciiString dpath;
407   mainfile.SystemName(dpath);
408   if (aCStringFileName && aCStringFileName[0]) {
409     TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, aCStringFileName);
410     if (fullname.Length() <= 0) fullname = aCStringFileName;
411     if (!OSD_File(fullname).Exists()) {
412       oldFileName = aCStringFileName;
413       aCStringFileName = 0;
414     }
415   }
416   if (!aCStringFileName || !aCStringFileName[0]) {
417     // try to find name of the directory from DocFile
418     if ( !DocFile.IsNull() ) {
419       Handle(TCollection_HAsciiString) aFilename = DocFile->Id();
420       if (!aFilename.IsNull() && !aFilename->IsEmpty())
421         aCStringFileName = aFilename->ToCString();
422       if ( ! aCStringFileName || ! aCStringFileName[0] ) {
423         aFilename = DocFile->Name();
424       if (!aFilename.IsNull() && !aFilename->IsEmpty())
425         aCStringFileName = aFilename->ToCString();
426       }
427       if ( ! aCStringFileName || ! aCStringFileName[0] ) {
428         if (oldFileName) {
429           aCStringFileName = oldFileName;
430         }
431         else {
432           return "";
433         }
434       }
435     }
436   }
437   TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, aCStringFileName);
438   if (fullname.Length() <= 0) fullname = aCStringFileName;
439   if (!OSD_File(fullname).Exists()) {
440     if (oldFileName) {
441       aCStringFileName = oldFileName;
442     }
443     Handle(Transfer_TransientProcess) aTP = WS()->TransferReader()->TransientProcess();
444     TCollection_AsciiString aMess("Can not read external file ");
445     aMess.AssignCat(aCStringFileName);
446     aTP->AddFail(DocFile, aMess.ToCString());
447   }
448   else {
449     if (oldFileName && strcmp(oldFileName, aCStringFileName) != 0) {
450       Handle(Transfer_TransientProcess) aTP = WS()->TransferReader()->TransientProcess();
451       TCollection_AsciiString aMess("External file with name from entity AEIA (");
452       aMess.AssignCat(oldFileName);
453       aMess.AssignCat(") not existed => use file name from DocumentFile entity - ");
454       aMess.AssignCat(aCStringFileName);
455       aTP->AddWarning(DocFile, aMess.ToCString());
456     }
457   }
458   return aCStringFileName;
459 }
460 
461 //=======================================================================
462 //function : ProdDef
463 //purpose  :
464 //=======================================================================
465 
Handle(StepBasic_ProductDefinition)466 Handle(StepBasic_ProductDefinition) STEPConstruct_ExternRefs::ProdDef (const Standard_Integer num) const
467 {
468   return Handle(StepBasic_ProductDefinition)::DownCast( myShapes(num) );
469 }
470 
471 //=======================================================================
472 //function : DocFile
473 //purpose  :
474 //=======================================================================
475 
Handle(StepBasic_DocumentFile)476 Handle(StepBasic_DocumentFile) STEPConstruct_ExternRefs::DocFile(const Standard_Integer num) const
477 {
478   return Handle(StepBasic_DocumentFile)::DownCast(myDocFiles.Value(num));
479 }
480 
481 //=======================================================================
482 //function : Format
483 //purpose  :
484 //=======================================================================
485 
Handle(TCollection_HAsciiString)486 Handle(TCollection_HAsciiString) STEPConstruct_ExternRefs::Format (const Standard_Integer num) const
487 {
488   Handle(TCollection_HAsciiString) Format;
489 
490   if (myIsAP214(num)==0) return Format;
491 
492   Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
493     Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast ( myFormats(num) );
494   if (PDR.IsNull()) return Format;
495 
496   Handle(StepRepr_Representation) rep = PDR->UsedRepresentation();
497   for ( Standard_Integer i=1; i <= rep->NbItems(); i++ ) {
498     if ( rep->ItemsValue(i)->IsKind ( STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem) ) ) {
499       Handle(StepRepr_DescriptiveRepresentationItem) DRI =
500         Handle(StepRepr_DescriptiveRepresentationItem)::DownCast ( rep->ItemsValue(i) );
501       Format = DRI->Description();
502       break;
503     }
504   }
505 
506   return Format;
507 }
508 
509 //=======================================================================
510 //function : AddExternRef
511 //purpose  :
512 //=======================================================================
513 
AddExternRef(const Standard_CString filename,const Handle (StepBasic_ProductDefinition)& PD,const Standard_CString format)514 Standard_Integer STEPConstruct_ExternRefs::AddExternRef (const Standard_CString filename,
515                                                          const Handle(StepBasic_ProductDefinition) &PD,
516                                                          const Standard_CString format)
517 {
518   Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
519   Handle(TCollection_HAsciiString) fmt = new TCollection_HAsciiString(format);
520   Handle(TCollection_HAsciiString) tmp = new TCollection_HAsciiString("203");
521   Standard_Integer np = fmt->Location(tmp,1,fmt->Length());
522 
523 //  if( !(fmt==tmp) ) {
524   if( !(np>0) ) {
525 
526     // create core entity DocumentFile
527     Handle(StepBasic_DocumentType) DT = new StepBasic_DocumentType;
528     DT->Init(EmptyString);
529     Handle(TCollection_HAsciiString) DFid = new TCollection_HAsciiString(filename);
530     // PTV 30.01.2003 TRJ11 -  copy external filename as is
531 //     DFid->AssignCat ( " file id" );
532     Handle(StepBasic_DocumentFile) DF = new StepBasic_DocumentFile;
533     DF->Init(DFid, EmptyString, Standard_False, EmptyString, DT, EmptyString, Standard_False, EmptyString);
534 
535     // create AppliedExternalIdentificationAssignment et al
536     Handle(StepBasic_IdentificationRole) IR = new StepBasic_IdentificationRole;
537     // PTV 30.01.2003 TRJ11
538     //    - set the ("external document id and location", $) without unmeaning description
539     Handle(TCollection_HAsciiString) aName =
540       new TCollection_HAsciiString("external document id and location");
541     IR->SetName( aName );
542 //     Handle(TCollection_HAsciiString) aIRdescr = new TCollection_HAsciiString("source system");
543 //     IR->Init(aName, Standard_True, aIRdescr);
544 
545     Handle(StepData_SelectNamed) SDS = new StepData_SelectNamed;
546     SDS->SetString ( filename );
547     SDS->SetName("IDENTIFIER");
548     StepBasic_SourceItem SID;
549     SID.SetValue(SDS);
550     Handle(StepBasic_ExternalSource) ES = new StepBasic_ExternalSource;
551     ES->Init(SID);
552 
553     StepAP214_ExternalIdentificationItem Item;
554     Item.SetValue(DF);
555     Handle(StepAP214_HArray1OfExternalIdentificationItem) Items =
556       new StepAP214_HArray1OfExternalIdentificationItem(1,1);
557     Items->SetValue(1, Item);
558 
559     Handle(StepAP214_AppliedExternalIdentificationAssignment) ExtIdent =
560       new StepAP214_AppliedExternalIdentificationAssignment;
561 //     ExtIdent->Init(EmptyString, IR, ES, Items);
562     // PTV 30.01.2003 TRJ11 - store filename in AEIA
563     Handle(TCollection_HAsciiString) aFName = new TCollection_HAsciiString(filename);
564     ExtIdent->Init(aFName, IR, ES, Items);
565     // create DocumentRepresentationType
566     Handle(TCollection_HAsciiString) Dig = new TCollection_HAsciiString("digital");
567     Handle(StepBasic_DocumentRepresentationType) Type = new StepBasic_DocumentRepresentationType;
568     Type->Init(Dig, DF);
569 
570     // create AppliedDocumentReference,
571     Handle(StepAP214_AppliedDocumentReference) ADR = new StepAP214_AppliedDocumentReference;
572     // PTV 30.01.2003 TRJ11 - create additional entities for AP214
573     addAP214ExterRef( ADR, PD, DF, filename );
574 
575     // create RoleAssociation etc.
576     Handle(StepBasic_ObjectRole) OR = new StepBasic_ObjectRole;
577     Handle(TCollection_HAsciiString) mandatory = new TCollection_HAsciiString("mandatory");
578     OR->Init(mandatory, Standard_False, EmptyString);
579     StepBasic_RoleSelect RS;
580     RS.SetValue(ADR);
581     Handle(StepBasic_RoleAssociation) Role = new StepBasic_RoleAssociation;
582     Role->Init(OR, RS);
583 
584     // create PDR for association with SR
585     StepRepr_CharacterizedDefinition CD;
586     CD.SetValue(DF);
587     Handle(TCollection_HAsciiString) PDname = new TCollection_HAsciiString("external definition");
588     Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition;
589     PropD->Init(PDname, Standard_True, EmptyString, CD);
590     StepRepr_RepresentedDefinition RD;
591     RD.SetValue(PropD);
592 //    Handle(StepRepr_PropertyDefinitionRepresentation) PDRshape = new StepRepr_PropertyDefinitionRepresentation;
593 //    PDRshape->Init ( RD, SDR->UsedRepresentation() );
594 
595     // create PDR for definition of document format (if defined)
596     Handle(StepRepr_PropertyDefinitionRepresentation) PDRformat;
597     if ( format && format[0] ) {
598 
599       Handle(TCollection_HAsciiString) RCftype = new TCollection_HAsciiString ( "document parameters" );
600       Handle(StepRepr_RepresentationContext) RCf = new StepRepr_RepresentationContext;
601       RCf->Init ( EmptyString, RCftype );
602 
603       Handle(TCollection_HAsciiString) DRIname = new TCollection_HAsciiString ( "data format" );
604       Handle(TCollection_HAsciiString) DRIdscr = new TCollection_HAsciiString ( format );
605       Handle(StepRepr_DescriptiveRepresentationItem) DRI = new StepRepr_DescriptiveRepresentationItem;
606       DRI->Init ( DRIname, DRIdscr );
607       Handle(StepRepr_HArray1OfRepresentationItem) fItems = new StepRepr_HArray1OfRepresentationItem(1,1);
608       fItems->SetValue ( 1, DRI );
609 
610       Handle(TCollection_HAsciiString) SRfname = new TCollection_HAsciiString ( "document format" );
611       Handle(StepRepr_Representation) SRformat = new StepRepr_Representation;
612       SRformat->Init(SRfname, fItems, RCf);
613 
614       StepRepr_CharacterizedDefinition CDf;
615       CDf.SetValue(DF);
616       Handle(TCollection_HAsciiString) PDfname = new TCollection_HAsciiString("document property");
617       Handle(StepRepr_PropertyDefinition) PDf = new StepRepr_PropertyDefinition;
618       PDf->Init(PDfname, Standard_True, EmptyString, CDf);
619       StepRepr_RepresentedDefinition RDf;
620       RDf.SetValue(PDf);
621 
622       PDRformat = new StepRepr_PropertyDefinitionRepresentation;
623       PDRformat->Init ( RDf, SRformat );
624     }
625 
626     // add all the created root entities to sequences
627     myAEIAs.Append ( ExtIdent );     //StepAP214_AppliedExternalIdentificationAssignment
628     myRoles.Append ( Role );         //StepBasic_RoleAssociation
629     myFormats.Append ( PDRformat );  //StepRepr_PropertyDefinitionRepresentation
630 //    myShapes.Append ( PDRshape );    //StepRepr_PropertyDefinitionRepresentation
631     myShapes.Append ( PD );          //StepBasic_ProductDefinition
632     myTypes.Append ( Type );         //StepBasic_DocumentRepresentationType
633 
634   }
635 
636   else { // format=="AP203"
637 
638 //    StepRepr_RepresentedDefinition aRD = SDR->Definition();
639 //    Handle(StepRepr_PropertyDefinition) aPD = aRD.PropertyDefinition();
640 //    StepRepr_CharacterizedDefinition aCD = aPD->Definition();
641 //    Handle(StepBasic_ProductDefinition) aProdDef = aCD.ProductDefinition();
642     Handle(StepBasic_ProductDefinitionFormation) ProdDefForm = PD->Formation();
643     Handle(StepBasic_ProductDefinitionContext) ProdDefCont = PD->FrameOfReference();
644 
645     // create document
646     Handle(TCollection_HAsciiString) fname = new TCollection_HAsciiString(filename);
647     Handle(StepBasic_DocumentType) aDocType = new StepBasic_DocumentType;
648     Handle(TCollection_HAsciiString) aDT = new TCollection_HAsciiString("cad_filename");
649     aDocType->Init(aDT);
650     Handle(StepBasic_Document) aDoc = new StepBasic_Document;
651     Handle(TCollection_HAsciiString) aDescription =
652       new TCollection_HAsciiString("CAD Model associated to the part");
653     aDoc->Init(EmptyString,fname,Standard_True,aDescription,aDocType);
654     Handle(StepBasic_HArray1OfDocument) aDocIds = new StepBasic_HArray1OfDocument(1,1);
655     aDocIds->SetValue(1,aDoc);
656 
657     // create ProductDefinitionWithAssociatedDocuments
658     aDescription = PD->Description();
659     Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
660       new StepBasic_ProductDefinitionWithAssociatedDocuments;
661     PDWAD->Init(EmptyString,aDescription,ProdDefForm,ProdDefCont,aDocIds);
662     //Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
663     //  Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(PD);
664 
665     // searh in graph for replace
666 //    Standard_Integer numProdDef;
667 //    Interface_EntityIterator subs = Graph().Shareds(SDR);
668 //    for (subs.Start(); subs.More(); subs.Next()) {
669 //      Handle(Standard_Transient) sub = subs.Value();
670     Interface_EntityIterator subs = Graph().Sharings(PD);
671     for (subs.Start(); subs.More(); subs.Next()) {
672       Handle(Standard_Transient) sub = subs.Value();
673       if (!sub->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) continue;
674       Handle(StepRepr_ProductDefinitionShape) ProdDefSh =
675         Handle(StepRepr_ProductDefinitionShape)::DownCast ( sub );
676       if(ProdDefSh.IsNull()) continue;
677       StepRepr_CharacterizedDefinition CDf;
678       CDf.SetValue(PDWAD);
679       ProdDefSh->SetDefinition(CDf);
680     }
681 
682 //      Interface_EntityIterator subs1 = Graph().Shareds(ProdDefSh);
683 //      for (subs1.Start(); subs1.More(); subs1.Next()) {
684 
685 //        Handle(Standard_Transient) sub1 = subs1.Value();
686 //        if (!sub1->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) continue;
687 //        Handle(StepBasic_ProductDefinition) ProdDef =
688 //          Handle(StepBasic_ProductDefinition)::DownCast ( sub1 );
689 //        numProdDef = Model()->Number(ProdDef);
690     Standard_Integer numProdDef = Model()->Number(PD);
691 
692 //        Interface_EntityIterator subs2 = Graph().Sharings(ProdDef);
693     Interface_EntityIterator subs2 = Graph().Sharings(PD);
694     for (subs2.Start(); subs2.More(); subs2.Next()) {
695       Handle(Standard_Transient) sub2 = subs2.Value();
696 
697       if (sub2->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) {
698         Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
699           Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast ( sub2 );
700         NAUO->SetRelatedProductDefinition(PDWAD);
701       }
702 
703       if (sub2->IsKind(STANDARD_TYPE(StepAP203_CcDesignPersonAndOrganizationAssignment))) {
704         Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) CDPAOA =
705           Handle(StepAP203_CcDesignPersonAndOrganizationAssignment)::DownCast ( sub2 );
706         Handle(StepAP203_HArray1OfPersonOrganizationItem) HAPOI = CDPAOA->Items();
707         for(Standard_Integer i=1; i<=HAPOI->Length(); i++) {
708           StepAP203_PersonOrganizationItem POI = HAPOI->Value(i);
709           Handle(StepBasic_ProductDefinition) PDtmp = POI.ProductDefinition();
710           Standard_Integer numPDtmp = Model()->Number(PDtmp);
711           if(numProdDef==numPDtmp) {
712             POI.SetValue(PDWAD);
713             HAPOI->SetValue(i,POI);
714           }
715         }
716       }
717 
718       if (sub2->IsKind(STANDARD_TYPE(StepAP203_CcDesignDateAndTimeAssignment))) {
719         Handle(StepAP203_CcDesignDateAndTimeAssignment) CDDATA =
720           Handle(StepAP203_CcDesignDateAndTimeAssignment)::DownCast ( sub2 );
721         Handle(StepAP203_HArray1OfDateTimeItem) HADTI = CDDATA->Items();
722         for(Standard_Integer i=1; i<=HADTI->Length(); i++) {
723           StepAP203_DateTimeItem DTI = HADTI->Value(i);
724           Handle(StepBasic_ProductDefinition) PDtmp = DTI.ProductDefinition();
725           Standard_Integer numPDtmp = Model()->Number(PDtmp);
726           if(numProdDef==numPDtmp) {
727             DTI.SetValue(PDWAD);
728             HADTI->SetValue(i,DTI);
729           }
730         }
731       }
732 
733       if (sub2->IsKind(STANDARD_TYPE(StepAP203_CcDesignApproval))) {
734         Handle(StepAP203_CcDesignApproval) CDA =
735           Handle(StepAP203_CcDesignApproval)::DownCast ( sub2 );
736         Handle(StepAP203_HArray1OfApprovedItem) HAAI = CDA->Items();
737         for(Standard_Integer i=1; i<=HAAI->Length(); i++) {
738           StepAP203_ApprovedItem AI = HAAI->Value(i);
739           Handle(StepBasic_ProductDefinition) PDtmp = AI.ProductDefinition();
740           Standard_Integer numPDtmp = Model()->Number(PDtmp);
741           if(numProdDef==numPDtmp) {
742             AI.SetValue(PDWAD);
743             HAAI->SetValue(i,AI);
744           }
745         }
746       }
747     }
748 //      }
749 //
750 //      StepRepr_CharacterizedDefinition ChartDef;
751 //      ChartDef.SetValue(PDWAD);
752 //      ProdDefSh->SetDefinition(ChartDef);
753 //    }
754 
755     myAEIAs.Append ( PDWAD );
756     myReplaceNum.Append(numProdDef);
757     myRoles.Append ( aDoc );
758     myTypes.Append ( aDocType );
759 
760   }
761 
762   return myAEIAs.Length();
763 
764 }
765 
766 //=======================================================================
767 //function : WriteExternRefs
768 //purpose  :
769 //=======================================================================
770 
WriteExternRefs(const Standard_Integer num) const771 Standard_Integer STEPConstruct_ExternRefs::WriteExternRefs (const Standard_Integer num) const
772 {
773   if(num==3) {
774     for ( Standard_Integer i=1; i <= myAEIAs.Length(); i++ ) {
775       Model()->ReplaceEntity(myReplaceNum(i),myAEIAs(i));
776       if ( ! myRoles(i).IsNull() )
777         Model()->AddWithRefs ( myRoles(i) );
778       if ( ! myTypes(i).IsNull() )
779         Model()->AddWithRefs ( myTypes(i) );
780     }
781   }
782   else {
783     for ( Standard_Integer i=1; i <= myAEIAs.Length(); i++ ) {
784       Model()->AddWithRefs ( myAEIAs(i) );
785       if ( ! myRoles(i).IsNull() )
786         Model()->AddWithRefs ( myRoles(i) );
787       if ( ! myFormats(i).IsNull() )
788         Model()->AddWithRefs ( myFormats(i) );
789       if ( ! myShapes(i).IsNull() )
790         Model()->AddWithRefs ( myShapes(i) );
791       if ( ! myTypes(i).IsNull() )
792         Model()->AddWithRefs ( myTypes(i) );
793     }
794   }
795   // PTV 30.01.2003 TRJ11
796   if ( !myAPD.IsNull() )
797     Model()->AddWithRefs( myAPD );
798   if ( !mySharedPRPC.IsNull() )
799     Model()->AddWithRefs( mySharedPRPC );
800 
801   return myAEIAs.Length();
802 }
803 
804 //=======================================================================
805 //function : addAP214ExterRef
806 //purpose  : PTV 30.01.2003 TRJ11
807 //=======================================================================
808 
addAP214ExterRef(const Handle (StepAP214_AppliedDocumentReference)& ADR,const Handle (StepBasic_ProductDefinition)& PD,const Handle (StepBasic_DocumentFile)& DF,const Standard_CString filename)809 Standard_Boolean STEPConstruct_ExternRefs::addAP214ExterRef (const Handle(StepAP214_AppliedDocumentReference)& ADR,
810                                                              const Handle(StepBasic_ProductDefinition)& PD,
811                                                              const Handle(StepBasic_DocumentFile)& DF,
812                                                              const Standard_CString filename )
813 {
814   Handle(StepAP214_HArray1OfDocumentReferenceItem) DRIs = new StepAP214_HArray1OfDocumentReferenceItem(1,1);
815   StepAP214_DocumentReferenceItem aDRI;
816   aDRI.SetValue(PD);
817   DRIs->SetValue(1, aDRI);
818   Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
819 
820   // create/get created shared entities:
821   // DocumentType, ProductDefinitionContext, ProductRelatedProductCategory, ProductContext
822   checkAP214Shared();
823 
824   // create document
825   Handle(StepBasic_Document) aDocument = new StepBasic_Document;
826   aDocument->Init( EmptyString, EmptyString, Standard_False, EmptyString, mySharedDocType );
827   ADR->Init(aDocument, EmptyString, DRIs);
828 
829   // create new product
830   Handle(StepBasic_Product) Product = new StepBasic_Product;
831   Handle(StepBasic_HArray1OfProduct) HProducts = mySharedPRPC->Products();
832   Standard_Integer nbProducts = 0;
833   if (!HProducts.IsNull())
834     nbProducts = HProducts->Length();
835   Standard_Integer intProdId = 20001 + nbProducts;
836   Handle(TCollection_HAsciiString) ProductID = new TCollection_HAsciiString( intProdId );
837   Handle(TCollection_HAsciiString) ProductName = new TCollection_HAsciiString(filename);
838   ProductName->AssignCat( "-Doc" );
839   Handle(StepBasic_HArray1OfProductContext) aHProdContext = new StepBasic_HArray1OfProductContext(1, 1);
840   aHProdContext->SetValue( 1, mySharedPC );
841   Product->Init( ProductID, ProductName, EmptyString, aHProdContext );
842 
843   // create new product definition formation
844   Handle(StepBasic_ProductDefinitionFormation) PDF = new StepBasic_ProductDefinitionFormation;
845   // name id taked from example Standard_ExtString_ref_master.stp
846   Handle(TCollection_HAsciiString) PDF_ID = new TCollection_HAsciiString("1");
847   PDF->Init( PDF_ID, EmptyString, Product );
848 
849   Handle(StepBasic_DocumentProductEquivalence) DPE = new StepBasic_DocumentProductEquivalence;
850   Handle(TCollection_HAsciiString) DPEname = new TCollection_HAsciiString("equivalence");
851   StepBasic_ProductOrFormationOrDefinition aPOFOD;
852   aPOFOD.SetValue( PDF );
853   DPE->Init( DPEname, Standard_False, EmptyString, aDocument, aPOFOD );
854   // add to the model with references
855   Model()->AddWithRefs( DPE );
856 
857   // add products to shared PRPC
858   Handle(StepBasic_HArray1OfProduct) newHProducts = new StepBasic_HArray1OfProduct(1, nbProducts + 1);
859   for (Standard_Integer pi = 1; pi <= nbProducts; pi++)
860     newHProducts->SetValue( pi, HProducts->Value( pi ) );
861   newHProducts->SetValue( nbProducts + 1, Product );
862   // set the hArray to the PRPC
863   mySharedPRPC->SetProducts( newHProducts );
864 
865   // create new PDWAD
866   Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
867     new StepBasic_ProductDefinitionWithAssociatedDocuments;
868   Handle(StepBasic_HArray1OfDocument) aDocIds = new StepBasic_HArray1OfDocument(1,1);
869   aDocIds->SetValue( 1, DF );
870   Handle(TCollection_HAsciiString) PDWAD_ID = new TCollection_HAsciiString("1");
871   PDWAD->Init( PDWAD_ID, EmptyString, PDF, mySharedPDC, aDocIds );
872   // add to the model with references
873   Model()->AddWithRefs( PDWAD );
874 
875   return Standard_True;
876 }
877 
878 //=======================================================================
879 //function : SetAP214APD
880 //purpose  :
881 //=======================================================================
882 
SetAP214APD(const Handle (StepBasic_ApplicationProtocolDefinition)& APD)883 void STEPConstruct_ExternRefs::SetAP214APD (const Handle(StepBasic_ApplicationProtocolDefinition)& APD)
884 {
885   myAPD = APD;
886 }
887 
888 //=======================================================================
889 //function : GetAP214APD
890 //purpose  :
891 //=======================================================================
892 
Handle(StepBasic_ApplicationProtocolDefinition)893 Handle(StepBasic_ApplicationProtocolDefinition) STEPConstruct_ExternRefs::GetAP214APD()
894 {
895   if (myAPD.IsNull()) {
896     // create new APD with new Application Context
897     myAPD = new StepBasic_ApplicationProtocolDefinition;
898     // examples of the values taken from ext_ref_master.stp
899     Handle(TCollection_HAsciiString) status =
900       new TCollection_HAsciiString("version 1.1");
901     Handle(TCollection_HAsciiString) appSchemaName =
902       new TCollection_HAsciiString("pdm_schema");
903     Standard_Integer intProtocolYear = 1999;
904     Handle(StepBasic_ApplicationContext) aApplication = new StepBasic_ApplicationContext;
905     Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
906     aApplication->Init( EmptyString );
907     myAPD->Init( status, appSchemaName, intProtocolYear, aApplication );
908   }
909   return myAPD;
910 }
911 
checkAP214Shared()912 void STEPConstruct_ExternRefs::checkAP214Shared ()
913 {
914   Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
915   if ( mySharedPRPC.IsNull() ) {
916     // create new ProductRelatedProductCategory for all extern files.
917     Handle(TCollection_HAsciiString) PRPCname = new TCollection_HAsciiString("document");
918     mySharedPRPC = new StepBasic_ProductRelatedProductCategory;
919     mySharedPRPC->Init( PRPCname, Standard_False, EmptyString, 0 );
920   }
921   if ( mySharedDocType.IsNull() ) {
922     // create new shared Document Type
923     mySharedDocType = new StepBasic_DocumentType;
924     Handle(TCollection_HAsciiString) prod_dat_type =
925       new TCollection_HAsciiString("configuration controlled document version");
926     mySharedDocType->Init( prod_dat_type );
927   }
928   if ( mySharedPDC.IsNull() ) {
929     // create new shared Product Definition Context
930     mySharedPDC = new StepBasic_ProductDefinitionContext;
931     Handle(TCollection_HAsciiString) aPDCname =
932       new TCollection_HAsciiString("digital document definition");
933     Handle(StepBasic_ApplicationContext) anAppContext = GetAP214APD()->Application();
934     mySharedPDC->Init( aPDCname, anAppContext, EmptyString );
935   }
936   if ( mySharedPC.IsNull() ) {
937     // create new shared ProductContext
938     mySharedPC = new StepBasic_ProductContext;
939     Handle(StepBasic_ApplicationContext) anAppContext = GetAP214APD()->Application();
940     mySharedPC->Init( EmptyString, anAppContext, EmptyString );
941   }
942 
943 }
944