Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-14 10:37:14

0001 // Created on: 2017-02-16
0002 // Created by: Sergey NIKONOV
0003 // Copyright (c) 2000-2017 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 _XCAFDoc_AssemblyItemRef_HeaderFile
0017 #define _XCAFDoc_AssemblyItemRef_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <TDF_Attribute.hxx>
0021 #include <XCAFDoc_AssemblyItemId.hxx>
0022 
0023 class TDF_RelocationTable;
0024 
0025 //! An attribute that describes a weak reference to an assembly item
0026 //! or to a subshape or to an assembly label attribute.
0027 class XCAFDoc_AssemblyItemRef : public TDF_Attribute
0028 {
0029 
0030 public:
0031   DEFINE_STANDARD_RTTIEXT(XCAFDoc_AssemblyItemRef, TDF_Attribute)
0032 
0033   Standard_EXPORT static const Standard_GUID& GetID();
0034 
0035   //! Finds a reference attribute on the given label and returns it, if it is found
0036   Standard_EXPORT static occ::handle<XCAFDoc_AssemblyItemRef> Get(const TDF_Label& theLabel);
0037 
0038   //! @name Set reference attribute functions.
0039   //! @{
0040 
0041   //! Create (if not exist) a reference to an assembly item.
0042   //! \param[in]  theLabel  - label to add the attribute.
0043   //! \param[in]  theItemId - assembly item ID.
0044   //! \return A handle to the attribute instance.
0045   Standard_EXPORT static occ::handle<XCAFDoc_AssemblyItemRef> Set(
0046     const TDF_Label&              theLabel,
0047     const XCAFDoc_AssemblyItemId& theItemId);
0048 
0049   //! Create (if not exist) a reference to an assembly item's label attribute.
0050   //! \param[in]  theLabel  - label to add the attribute.
0051   //! \param[in]  theItemId - assembly item ID.
0052   //! \param[in]  theGUID   - assembly item's label attribute ID.
0053   //! \return A handle to the attribute instance.
0054   Standard_EXPORT static occ::handle<XCAFDoc_AssemblyItemRef> Set(
0055     const TDF_Label&              theLabel,
0056     const XCAFDoc_AssemblyItemId& theItemId,
0057     const Standard_GUID&          theGUID);
0058 
0059   //! Create (if not exist) a reference to an assembly item's subshape.
0060   //! \param[in]  theLabel      - label to add the attribute.
0061   //! \param[in]  theItemId     - assembly item ID.
0062   //! \param[in]  theShapeIndex - assembly item's subshape index.
0063   //! \return A handle to the attribute instance.
0064   Standard_EXPORT static occ::handle<XCAFDoc_AssemblyItemRef> Set(
0065     const TDF_Label&              theLabel,
0066     const XCAFDoc_AssemblyItemId& theItemId,
0067     const int                     theShapeIndex);
0068 
0069   //! @}
0070 
0071   //! Creates an empty reference attribute.
0072   Standard_EXPORT XCAFDoc_AssemblyItemRef();
0073 
0074   //! Checks if the reference points to a really existing item in XDE document.
0075   Standard_EXPORT bool IsOrphan() const;
0076 
0077   //! @name Extra reference functions.
0078   //! @{
0079 
0080   //! Checks if the reference points on an item's shapeindex or attribute.
0081   Standard_EXPORT bool HasExtraRef() const;
0082 
0083   //! Checks is the reference points to an item's attribute.
0084   Standard_EXPORT bool IsGUID() const;
0085 
0086   //! Checks is the reference points to an item's subshape.
0087   Standard_EXPORT bool IsSubshapeIndex() const;
0088 
0089   //! Returns the assembly item's attribute that the reference points to.
0090   //! If the reference doesn't point to an attribute, returns an empty GUID.
0091   Standard_EXPORT Standard_GUID GetGUID() const;
0092 
0093   //! Returns the assembly item's subshape that the reference points to.
0094   //! If the reference doesn't point to a subshape, returns 0.
0095   Standard_EXPORT int GetSubshapeIndex() const;
0096 
0097   //! @}
0098 
0099   //! Returns the assembly item ID that the reference points to.
0100   Standard_EXPORT const XCAFDoc_AssemblyItemId& GetItem() const;
0101 
0102   //! @name Set reference data functions.
0103   //! @{
0104 
0105   //! Sets the assembly item ID that the reference points to.
0106   //! Extra reference data (if any) will be cleared.
0107   Standard_EXPORT void SetItem(const XCAFDoc_AssemblyItemId& theItemId);
0108 
0109   //! Sets the assembly item ID from a list of label entries
0110   //! that the reference points to.
0111   //! Extra reference data (if any) will be cleared.
0112   Standard_EXPORT void SetItem(const NCollection_List<TCollection_AsciiString>& thePath);
0113 
0114   //! Sets the assembly item ID from a formatted path
0115   //! that the reference points to.
0116   //! Extra reference data (if any) will be cleared.
0117   Standard_EXPORT void SetItem(const TCollection_AsciiString& theString);
0118 
0119   //! Sets the assembly item's label attribute that the reference points to.
0120   //! The base assembly item will not change.
0121   Standard_EXPORT void SetGUID(const Standard_GUID& theAttrGUID);
0122 
0123   //! Sets the assembly item's subshape that the reference points to.
0124   //! The base assembly item will not change.
0125   Standard_EXPORT void SetSubshapeIndex(int theShapeIndex);
0126 
0127   //! @}
0128 
0129   //! Reverts the reference to empty state.
0130   Standard_EXPORT void ClearExtraRef();
0131 
0132   //! Dumps the content of me into the stream
0133   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0134 
0135 public:
0136   // Overrides TDF_Attribute pure virtuals
0137   Standard_EXPORT const Standard_GUID& ID() const override;
0138   Standard_EXPORT occ::handle<TDF_Attribute> NewEmpty() const override;
0139   Standard_EXPORT void              Restore(const occ::handle<TDF_Attribute>& theAttrFrom) override;
0140   Standard_EXPORT void              Paste(const occ::handle<TDF_Attribute>&       theAttrInto,
0141                                           const occ::handle<TDF_RelocationTable>& theRT) const override;
0142   Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const override;
0143 
0144 private:
0145   XCAFDoc_AssemblyItemId  myItemId;   ///< Assembly item ID
0146   int                     myExtraRef; ///< Type of extra reference: subshape or attribute
0147   TCollection_AsciiString myExtraId;  ///< Extra reference data
0148 };
0149 
0150 #endif // _XCAFDoc_AssemblyItemRef_HeaderFile