Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:16:26

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_Tool_HeaderFile
0017 #define _TDF_Tool_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <TDF_Attribute.hxx>
0025 #include <NCollection_Map.hxx>
0026 #include <NCollection_List.hxx>
0027 #include <Standard_CString.hxx>
0028 #include <TDF_Label.hxx>
0029 #include <NCollection_DataMap.hxx>
0030 #include <Standard_OStream.hxx>
0031 class TDF_Label;
0032 class TDF_IDFilter;
0033 class TCollection_AsciiString;
0034 class TDF_Data;
0035 
0036 //! This class provides general services for a data framework.
0037 class TDF_Tool
0038 {
0039 public:
0040   DEFINE_STANDARD_ALLOC
0041 
0042   //! Returns the number of labels of the tree,
0043   //! including <aLabel>. aLabel is also included in this figure.
0044   //! This information is useful in setting the size of an array.
0045   Standard_EXPORT static int NbLabels(const TDF_Label& aLabel);
0046 
0047   //! Returns the total number of attributes attached
0048   //! to the labels dependent on the label aLabel.
0049   //! The attributes of aLabel are also included in this figure.
0050   //! This information is useful in setting the size of an array.
0051   Standard_EXPORT static int NbAttributes(const TDF_Label& aLabel);
0052 
0053   //! Returns the number of attributes of the tree,
0054   //! selected by a<Filter>, including those of
0055   //! <aLabel>.
0056   Standard_EXPORT static int NbAttributes(const TDF_Label& aLabel, const TDF_IDFilter& aFilter);
0057 
0058   //! Returns true if <aLabel> and its descendants
0059   //! reference only attributes or labels attached to
0060   //! themselves.
0061   Standard_EXPORT static bool IsSelfContained(const TDF_Label& aLabel);
0062 
0063   //! Returns true if <aLabel> and its descendants
0064   //! reference only attributes or labels attached to
0065   //! themselves and kept by <aFilter>.
0066   Standard_EXPORT static bool IsSelfContained(const TDF_Label& aLabel, const TDF_IDFilter& aFilter);
0067 
0068   //! Returns in <theAtts> the attributes having out
0069   //! references.
0070   //!
0071   //! Caution: <theAtts> is not cleared before use!
0072   Standard_EXPORT static void OutReferers(const TDF_Label&                             theLabel,
0073                                           NCollection_Map<occ::handle<TDF_Attribute>>& theAtts);
0074 
0075   //! Returns in <atts> the attributes having out
0076   //! references and kept by <aFilterForReferers>.
0077   //! It considers only the references kept by <aFilterForReferences>.
0078   //! Caution: <atts> is not cleared before use!
0079   Standard_EXPORT static void OutReferers(const TDF_Label&    aLabel,
0080                                           const TDF_IDFilter& aFilterForReferers,
0081                                           const TDF_IDFilter& aFilterForReferences,
0082                                           NCollection_Map<occ::handle<TDF_Attribute>>& atts);
0083 
0084   //! Returns in <atts> the referenced attributes.
0085   //! Caution: <atts> is not cleared before use!
0086   Standard_EXPORT static void OutReferences(const TDF_Label&                             aLabel,
0087                                             NCollection_Map<occ::handle<TDF_Attribute>>& atts);
0088 
0089   //! Returns in <atts> the referenced attributes and kept by <aFilterForReferences>.
0090   //! It considers only the referrers kept by <aFilterForReferers>.
0091   //! Caution: <atts> is not cleared before use!
0092   Standard_EXPORT static void OutReferences(const TDF_Label&    aLabel,
0093                                             const TDF_IDFilter& aFilterForReferers,
0094                                             const TDF_IDFilter& aFilterForReferences,
0095                                             NCollection_Map<occ::handle<TDF_Attribute>>& atts);
0096 
0097   //! Returns the label having the same sub-entry as
0098   //! <aLabel> but located as descendant as <toRoot>
0099   //! instead of <fromRoot>.
0100   //!
0101   //! Example :
0102   //!
0103   //! aLabel = 0:3:24:7:2:7
0104   //! fromRoot = 0:3:24
0105   //! toRoot = 0:5
0106   //! returned label = 0:5:7:2:7
0107   Standard_EXPORT static void RelocateLabel(const TDF_Label& aSourceLabel,
0108                                             const TDF_Label& fromRoot,
0109                                             const TDF_Label& toRoot,
0110                                             TDF_Label&       aTargetLabel,
0111                                             const bool       create = false);
0112 
0113   //! Returns the entry for the label aLabel in the form
0114   //! of the ASCII character string anEntry containing
0115   //! the tag list for aLabel.
0116   Standard_EXPORT static void Entry(const TDF_Label& aLabel, TCollection_AsciiString& anEntry);
0117 
0118   //! Returns the entry of <aLabel> as list of integers
0119   //! in <aTagList>.
0120   Standard_EXPORT static void TagList(const TDF_Label& aLabel, NCollection_List<int>& aTagList);
0121 
0122   //! Returns the entry expressed by <anEntry> as list
0123   //! of integers in <aTagList>.
0124   Standard_EXPORT static void TagList(const TCollection_AsciiString& anEntry,
0125                                       NCollection_List<int>&         aTagList);
0126 
0127   //! Returns the label expressed by <anEntry>; creates
0128   //! the label if it does not exist and if <create> is
0129   //! true.
0130   Standard_EXPORT static void Label(const occ::handle<TDF_Data>&   aDF,
0131                                     const TCollection_AsciiString& anEntry,
0132                                     TDF_Label&                     aLabel,
0133                                     const bool                     create = false);
0134 
0135   //! Returns the label expressed by <anEntry>; creates
0136   //! the label if it does not exist and if <create> is
0137   //! true.
0138   Standard_EXPORT static void Label(const occ::handle<TDF_Data>& aDF,
0139                                     const char* const            anEntry,
0140                                     TDF_Label&                   aLabel,
0141                                     const bool                   create = false);
0142 
0143   //! Returns the label expressed by <anEntry>; creates
0144   //! the label if it does not exist and if <create> is
0145   //! true.
0146   Standard_EXPORT static void Label(const occ::handle<TDF_Data>& aDF,
0147                                     const NCollection_List<int>& aTagList,
0148                                     TDF_Label&                   aLabel,
0149                                     const bool                   create = false);
0150 
0151   //! Adds the labels of <aLabelList> to <aLabelMap> if
0152   //! they are unbound, or increases their reference
0153   //! counters. At the end of the process, <aLabelList>
0154   //! contains only the ADDED labels.
0155   Standard_EXPORT static void CountLabels(NCollection_List<TDF_Label>&         aLabelList,
0156                                           NCollection_DataMap<TDF_Label, int>& aLabelMap);
0157 
0158   //! Decreases the reference counters of the labels of
0159   //! <aLabelList> to <aLabelMap>, and removes labels
0160   //! with null counter. At the end of the process,
0161   //! <aLabelList> contains only the SUPPRESSED labels.
0162   Standard_EXPORT static void DeductLabels(NCollection_List<TDF_Label>&         aLabelList,
0163                                            NCollection_DataMap<TDF_Label, int>& aLabelMap);
0164 
0165   //! Dumps <aDF> and its labels and their attributes.
0166   Standard_EXPORT static void DeepDump(Standard_OStream& anOS, const occ::handle<TDF_Data>& aDF);
0167 
0168   //! Dumps <aDF> and its labels and their attributes,
0169   //! if their IDs are kept by <aFilter>. Dumps also the
0170   //! attributes content.
0171   Standard_EXPORT static void ExtendedDeepDump(Standard_OStream&            anOS,
0172                                                const occ::handle<TDF_Data>& aDF,
0173                                                const TDF_IDFilter&          aFilter);
0174 
0175   //! Dumps <aLabel>, its children and their attributes.
0176   Standard_EXPORT static void DeepDump(Standard_OStream& anOS, const TDF_Label& aLabel);
0177 
0178   //! Dumps <aLabel>, its children and their attributes,
0179   //! if their IDs are kept by <aFilter>. Dumps also the
0180   //! attributes content.
0181   Standard_EXPORT static void ExtendedDeepDump(Standard_OStream&   anOS,
0182                                                const TDF_Label&    aLabel,
0183                                                const TDF_IDFilter& aFilter);
0184 };
0185 
0186 #endif // _TDF_Tool_HeaderFile