Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-18 08:30:55

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