Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:21

0001 // Created by: DAUTRY Philippe
0002 // Copyright (c) 1997-1999 Matra Datavision
0003 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _TDF_RelocationTable_HeaderFile
0017 #define _TDF_RelocationTable_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 
0021 #include <TDF_LabelDataMap.hxx>
0022 #include <TDF_AttributeDataMap.hxx>
0023 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <TDF_LabelMap.hxx>
0026 #include <TDF_AttributeMap.hxx>
0027 #include <Standard_OStream.hxx>
0028 class TDF_Label;
0029 class TDF_Attribute;
0030 
0031 
0032 class TDF_RelocationTable;
0033 DEFINE_STANDARD_HANDLE(TDF_RelocationTable, Standard_Transient)
0034 
0035 //! This is a relocation dictionary between source
0036 //! and target labels, attributes or any
0037 //! transient(useful for copy or paste actions).
0038 //! Note that one target value may be the
0039 //! relocation value of more than one source object.
0040 //!
0041 //! Common behaviour: it returns true and the found
0042 //! relocation value as target object; false
0043 //! otherwise.
0044 //!
0045 //! Look at SelfRelocate method for more explanation
0046 //! about self relocation behavior of this class.
0047 class TDF_RelocationTable : public Standard_Transient
0048 {
0049 
0050 public:
0051 
0052   
0053   //! Creates an relocation table. <selfRelocate> says
0054   //! if a value without explicit relocation is its own
0055   //! relocation.
0056   Standard_EXPORT TDF_RelocationTable(const Standard_Boolean selfRelocate = Standard_False);
0057   
0058   //! Sets <mySelfRelocate> to <selfRelocate>.
0059   //!
0060   //! This flag affects the HasRelocation method
0061   //! behavior like this:
0062   //!
0063   //! <mySelfRelocate> == False:
0064   //!
0065   //! If no relocation object is found in the map, a
0066   //! null object is returned
0067   //!
0068   //! <mySelfRelocate> == True:
0069   //!
0070   //! If no relocation object is found in the map, the
0071   //! method assumes the source object is relocation
0072   //! value; so the source object is returned as target
0073   //! object.
0074   Standard_EXPORT void SelfRelocate (const Standard_Boolean selfRelocate);
0075   
0076   //! Returns <mySelfRelocate>.
0077   Standard_EXPORT Standard_Boolean SelfRelocate() const;
0078   
0079   Standard_EXPORT void AfterRelocate (const Standard_Boolean afterRelocate);
0080   
0081   //! Returns <myAfterRelocate>.
0082   Standard_EXPORT Standard_Boolean AfterRelocate() const;
0083   
0084   //! Sets the relocation value of <aSourceLabel> to
0085   //! <aTargetLabel>.
0086   Standard_EXPORT void SetRelocation (const TDF_Label& aSourceLabel, const TDF_Label& aTargetLabel);
0087   
0088   //! Finds the relocation value of <aSourceLabel>
0089   //! and returns it into <aTargetLabel>.
0090   //!
0091   //! (See above SelfRelocate method for more
0092   //! explanation about the method behavior)
0093   Standard_EXPORT Standard_Boolean HasRelocation (const TDF_Label& aSourceLabel, TDF_Label& aTargetLabel) const;
0094   
0095   //! Sets the relocation value of <aSourceAttribute> to
0096   //! <aTargetAttribute>.
0097   Standard_EXPORT void SetRelocation (const Handle(TDF_Attribute)& aSourceAttribute, const Handle(TDF_Attribute)& aTargetAttribute);
0098   
0099   //! Finds the relocation value of <aSourceAttribute>
0100   //! and returns it into <aTargetAttribute>.
0101   //!
0102   //! (See above SelfRelocate method for more
0103   //! explanation about the method behavior)
0104   Standard_EXPORT Standard_Boolean HasRelocation (const Handle(TDF_Attribute)& aSourceAttribute, Handle(TDF_Attribute)& aTargetAttribute) const;
0105   
0106   //! Safe variant for arbitrary type of argument
0107   template <class T> 
0108   Standard_Boolean HasRelocation (const Handle(TDF_Attribute)& theSource, Handle(T)& theTarget) const
0109   {
0110     Handle(TDF_Attribute) anAttr = theTarget;
0111     return HasRelocation (theSource, anAttr) && ! (theTarget = Handle(T)::DownCast(anAttr)).IsNull();
0112   }
0113 
0114   //! Sets the relocation value of <aSourceTransient> to
0115   //! <aTargetTransient>.
0116   Standard_EXPORT void SetTransientRelocation (const Handle(Standard_Transient)& aSourceTransient, const Handle(Standard_Transient)& aTargetTransient);
0117   
0118   //! Finds the relocation value of <aSourceTransient>
0119   //! and returns it into <aTargetTransient>.
0120   //!
0121   //! (See above SelfRelocate method for more
0122   //! explanation about the method behavior)
0123   Standard_EXPORT Standard_Boolean HasTransientRelocation (const Handle(Standard_Transient)& aSourceTransient, Handle(Standard_Transient)& aTargetTransient) const;
0124   
0125   //! Clears the relocation dictionary, but lets the
0126   //! self relocation flag to its current value.
0127   Standard_EXPORT void Clear();
0128   
0129   //! Fills <aLabelMap> with target relocation
0130   //! labels. <aLabelMap> is not cleared before use.
0131   Standard_EXPORT void TargetLabelMap (TDF_LabelMap& aLabelMap) const;
0132   
0133   //! Fills <anAttributeMap> with target relocation
0134   //! attributes. <anAttributeMap> is not cleared before
0135   //! use.
0136   Standard_EXPORT void TargetAttributeMap (TDF_AttributeMap& anAttributeMap) const;
0137   
0138   //! Returns <myLabelTable> to be used or updated.
0139   Standard_EXPORT TDF_LabelDataMap& LabelTable();
0140   
0141   //! Returns <myAttributeTable> to be used or updated.
0142   Standard_EXPORT TDF_AttributeDataMap& AttributeTable();
0143   
0144   //! Returns <myTransientTable> to be used or updated.
0145   Standard_EXPORT TColStd_IndexedDataMapOfTransientTransient& TransientTable();
0146   
0147   //! Dumps the relocation table.
0148   Standard_EXPORT Standard_OStream& Dump (const Standard_Boolean dumpLabels, const Standard_Boolean dumpAttributes, const Standard_Boolean dumpTransients, Standard_OStream& anOS) const;
0149 
0150 
0151 
0152 
0153   DEFINE_STANDARD_RTTIEXT(TDF_RelocationTable,Standard_Transient)
0154 
0155 protected:
0156 
0157 
0158 
0159 
0160 private:
0161 
0162 
0163   Standard_Boolean mySelfRelocate;
0164   Standard_Boolean myAfterRelocate;
0165   TDF_LabelDataMap myLabelTable;
0166   TDF_AttributeDataMap myAttributeTable;
0167   TColStd_IndexedDataMapOfTransientTransient myTransientTable;
0168 
0169 
0170 };
0171 
0172 
0173 
0174 
0175 
0176 
0177 
0178 #endif // _TDF_RelocationTable_HeaderFile