1 // Created on: 2000-09-29
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _STEPConstruct_ExternRefs_HeaderFile
17 #define _STEPConstruct_ExternRefs_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
23 #include <TColStd_SequenceOfTransient.hxx>
24 #include <TColStd_SequenceOfInteger.hxx>
25 #include <STEPConstruct_Tool.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Standard_CString.hxx>
29 class StepBasic_ProductRelatedProductCategory;
30 class StepBasic_DocumentType;
31 class StepBasic_ProductDefinitionContext;
32 class StepBasic_ProductContext;
33 class StepBasic_ApplicationProtocolDefinition;
34 class XSControl_WorkSession;
35 class StepBasic_ProductDefinition;
36 class TCollection_HAsciiString;
37 class StepAP214_AppliedDocumentReference;
38 class StepBasic_DocumentFile;
41 //! Provides a tool for analyzing (reading) and creating (writing)
42 //! references to external files in STEP
44 //! It maintains a data structure in the form of sequences
45 //! of relevant STEP entities (roots), allowing either to create
46 //! them by convenient API, or load from existing model and
48 class STEPConstruct_ExternRefs : public STEPConstruct_Tool
55 //! Creates an empty tool
56 Standard_EXPORT STEPConstruct_ExternRefs();
58 //! Creates a tool and initializes it
59 Standard_EXPORT STEPConstruct_ExternRefs(const Handle(XSControl_WorkSession)& WS);
61 //! Initializes tool; returns True if succeeded
62 Standard_EXPORT Standard_Boolean Init (const Handle(XSControl_WorkSession)& WS);
64 //! Clears internal fields (list of defined extern refs)
65 Standard_EXPORT void Clear();
67 //! Searches current STEP model for external references
68 //! and loads them to the internal data structures
69 //! NOTE: does not clear data structures before loading
70 Standard_EXPORT Standard_Boolean LoadExternRefs();
72 //! Returns number of defined extern references
73 Standard_EXPORT Standard_Integer NbExternRefs() const;
75 //! Returns filename for numth extern reference
76 //! Returns Null if FileName is not defined or bad
77 Standard_EXPORT Standard_CString FileName (const Standard_Integer num) const;
79 //! Returns ProductDefinition to which numth extern reference
81 //! Returns Null if cannot be detected or if extern reference
82 //! is not associated to SDR in a proper way.
83 Standard_EXPORT Handle(StepBasic_ProductDefinition) ProdDef (const Standard_Integer num) const;
85 //! Returns format identification string for the extern document
86 //! Returns Null handle if format is not defined
87 Standard_EXPORT Handle(TCollection_HAsciiString) Format (const Standard_Integer num) const;
89 //! Create a new external reference with specified attributes
90 //! attached to a given SDR
91 //! <format> can be Null string, in that case this information
92 //! is not written. Else, it can be "STEP AP214" or "STEP AP203"
93 //! Returns index of a new extern ref
94 Standard_EXPORT Standard_Integer AddExternRef (const Standard_CString filename, const Handle(StepBasic_ProductDefinition)& PD, const Standard_CString format);
96 //! Check (create if it is null) all shared entities for the model
97 Standard_EXPORT void checkAP214Shared();
99 //! Adds all the currently defined external refs to the model
100 //! Returns number of written extern refs
101 Standard_EXPORT Standard_Integer WriteExternRefs (const Standard_Integer num) const;
103 //! Set the ApplicationProtocolDefinition of the PDM schema
104 Standard_EXPORT void SetAP214APD (const Handle(StepBasic_ApplicationProtocolDefinition)& APD);
106 //! Returns the ApplicationProtocolDefinition of the PDM schema
107 //! NOTE: if not defined then create new APD with new Application Context
108 Standard_EXPORT Handle(StepBasic_ApplicationProtocolDefinition) GetAP214APD();
116 //! Create a new additional structure entities and add ncessary references
117 //! Note: do not refer from ADR to DF directly in AP214 (TRJ11).
118 Standard_EXPORT Standard_Boolean addAP214ExterRef (const Handle(StepAP214_AppliedDocumentReference)& ADR, const Handle(StepBasic_ProductDefinition)& PD, const Handle(StepBasic_DocumentFile)& DF, const Standard_CString filename);
127 TColStd_SequenceOfTransient myAEIAs;
128 TColStd_SequenceOfTransient myRoles;
129 TColStd_SequenceOfTransient myFormats;
130 TColStd_SequenceOfTransient myShapes;
131 TColStd_SequenceOfTransient myTypes;
132 TColStd_SequenceOfInteger myIsAP214;
133 TColStd_SequenceOfInteger myReplaceNum;
134 TColStd_SequenceOfTransient myDocFiles;
135 Handle(StepBasic_ProductRelatedProductCategory) mySharedPRPC;
136 Handle(StepBasic_DocumentType) mySharedDocType;
137 Handle(StepBasic_ProductDefinitionContext) mySharedPDC;
138 Handle(StepBasic_ProductContext) mySharedPC;
139 Handle(StepBasic_ApplicationProtocolDefinition) myAPD;
150 #endif // _STEPConstruct_ExternRefs_HeaderFile