0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / TDF / TDF_RelocationTable.hxx
CommitLineData
42cf5bc1 1// Created by: DAUTRY Philippe
2// Copyright (c) 1997-1999 Matra Datavision
3// Copyright (c) 1999-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#ifndef _TDF_RelocationTable_HeaderFile
17#define _TDF_RelocationTable_HeaderFile
18
19#include <Standard.hxx>
42cf5bc1 20
42cf5bc1 21#include <TDF_LabelDataMap.hxx>
22#include <TDF_AttributeDataMap.hxx>
23#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
25e59720 24#include <Standard_Transient.hxx>
42cf5bc1 25#include <TDF_LabelMap.hxx>
26#include <TDF_AttributeMap.hxx>
27#include <Standard_OStream.hxx>
28class TDF_Label;
29class TDF_Attribute;
42cf5bc1 30
31
32class TDF_RelocationTable;
25e59720 33DEFINE_STANDARD_HANDLE(TDF_RelocationTable, Standard_Transient)
42cf5bc1 34
03ca365a 35//! This is a relocation dictionary between source
42cf5bc1 36//! and target labels, attributes or any
37//! transient(useful for copy or paste actions).
38//! Note that one target value may be the
39//! relocation value of more than one source object.
40//!
41//! Common behaviour: it returns true and the found
42//! relocation value as target object; false
43//! otherwise.
44//!
45//! Look at SelfRelocate method for more explanation
46//! about self relocation behavior of this class.
25e59720 47class TDF_RelocationTable : public Standard_Transient
42cf5bc1 48{
49
50public:
51
52
53 //! Creates an relocation table. <selfRelocate> says
54 //! if a value without explicit relocation is its own
55 //! relocation.
56 Standard_EXPORT TDF_RelocationTable(const Standard_Boolean selfRelocate = Standard_False);
57
58 //! Sets <mySelfRelocate> to <selfRelocate>.
59 //!
60 //! This flag affects the HasRelocation method
61 //! behavior like this:
62 //!
63 //! <mySelfRelocate> == False:
64 //!
65 //! If no relocation object is found in the map, a
66 //! null object is returned
67 //!
68 //! <mySelfRelocate> == True:
69 //!
70 //! If no relocation object is found in the map, the
71 //! method assumes the source object is relocation
72 //! value; so the source object is returned as target
73 //! object.
74 Standard_EXPORT void SelfRelocate (const Standard_Boolean selfRelocate);
75
76 //! Returns <mySelfRelocate>.
77 Standard_EXPORT Standard_Boolean SelfRelocate() const;
78
79 Standard_EXPORT void AfterRelocate (const Standard_Boolean afterRelocate);
80
81 //! Returns <myAfterRelocate>.
82 Standard_EXPORT Standard_Boolean AfterRelocate() const;
83
84 //! Sets the relocation value of <aSourceLabel> to
85 //! <aTargetLabel>.
86 Standard_EXPORT void SetRelocation (const TDF_Label& aSourceLabel, const TDF_Label& aTargetLabel);
87
88 //! Finds the relocation value of <aSourceLabel>
89 //! and returns it into <aTargetLabel>.
90 //!
91 //! (See above SelfRelocate method for more
92 //! explanation about the method behavior)
93 Standard_EXPORT Standard_Boolean HasRelocation (const TDF_Label& aSourceLabel, TDF_Label& aTargetLabel) const;
94
95 //! Sets the relocation value of <aSourceAttribute> to
96 //! <aTargetAttribute>.
97 Standard_EXPORT void SetRelocation (const Handle(TDF_Attribute)& aSourceAttribute, const Handle(TDF_Attribute)& aTargetAttribute);
98
99 //! Finds the relocation value of <aSourceAttribute>
100 //! and returns it into <aTargetAttribute>.
101 //!
102 //! (See above SelfRelocate method for more
103 //! explanation about the method behavior)
104 Standard_EXPORT Standard_Boolean HasRelocation (const Handle(TDF_Attribute)& aSourceAttribute, Handle(TDF_Attribute)& aTargetAttribute) const;
105
aa00364d 106 //! Safe variant for arbitrary type of argument
107 template <class T>
108 Standard_Boolean HasRelocation (const Handle(TDF_Attribute)& theSource, Handle(T)& theTarget) const
109 {
110 Handle(TDF_Attribute) anAttr = theTarget;
111 return HasRelocation (theSource, anAttr) && ! (theTarget = Handle(T)::DownCast(anAttr)).IsNull();
112 }
113
42cf5bc1 114 //! Sets the relocation value of <aSourceTransient> to
115 //! <aTargetTransient>.
116 Standard_EXPORT void SetTransientRelocation (const Handle(Standard_Transient)& aSourceTransient, const Handle(Standard_Transient)& aTargetTransient);
117
118 //! Finds the relocation value of <aSourceTransient>
119 //! and returns it into <aTargetTransient>.
120 //!
121 //! (See above SelfRelocate method for more
122 //! explanation about the method behavior)
123 Standard_EXPORT Standard_Boolean HasTransientRelocation (const Handle(Standard_Transient)& aSourceTransient, Handle(Standard_Transient)& aTargetTransient) const;
124
03ca365a 125 //! Clears the relocation dictionary, but lets the
42cf5bc1 126 //! self relocation flag to its current value.
127 Standard_EXPORT void Clear();
128
129 //! Fills <aLabelMap> with target relocation
130 //! labels. <aLabelMap> is not cleared before use.
131 Standard_EXPORT void TargetLabelMap (TDF_LabelMap& aLabelMap) const;
132
133 //! Fills <anAttributeMap> with target relocation
134 //! attributes. <anAttributeMap> is not cleared before
135 //! use.
136 Standard_EXPORT void TargetAttributeMap (TDF_AttributeMap& anAttributeMap) const;
137
138 //! Returns <myLabelTable> to be used or updated.
139 Standard_EXPORT TDF_LabelDataMap& LabelTable();
140
141 //! Returns <myAttributeTable> to be used or updated.
142 Standard_EXPORT TDF_AttributeDataMap& AttributeTable();
143
144 //! Returns <myTransientTable> to be used or updated.
145 Standard_EXPORT TColStd_IndexedDataMapOfTransientTransient& TransientTable();
146
147 //! Dumps the relocation table.
148 Standard_EXPORT Standard_OStream& Dump (const Standard_Boolean dumpLabels, const Standard_Boolean dumpAttributes, const Standard_Boolean dumpTransients, Standard_OStream& anOS) const;
149
150
151
152
25e59720 153 DEFINE_STANDARD_RTTIEXT(TDF_RelocationTable,Standard_Transient)
42cf5bc1 154
155protected:
156
157
158
159
160private:
161
162
163 Standard_Boolean mySelfRelocate;
164 Standard_Boolean myAfterRelocate;
165 TDF_LabelDataMap myLabelTable;
166 TDF_AttributeDataMap myAttributeTable;
167 TColStd_IndexedDataMapOfTransientTransient myTransientTable;
168
169
170};
171
172
173
174
175
176
177
178#endif // _TDF_RelocationTable_HeaderFile