| 1 | // Created on: 1997-02-04 |
| 2 | // Created by: Yves FRICAUD |
| 3 | // Copyright (c) 1997-1999 Matra Datavision |
| 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 8 | // This library is free software; you can redistribute it and/or modify it under |
| 9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 10 | // by the Free Software Foundation, with special exception defined in the file |
| 11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 12 | // distribution for complete text of the license and disclaimer of any warranty. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 17 | #ifndef _TNaming_NamedShape_HeaderFile |
| 18 | #define _TNaming_NamedShape_HeaderFile |
| 19 | |
| 20 | #include <Standard.hxx> |
| 21 | #include <Standard_Type.hxx> |
| 22 | |
| 23 | #include <TNaming_PtrNode.hxx> |
| 24 | #include <TNaming_Evolution.hxx> |
| 25 | #include <Standard_Integer.hxx> |
| 26 | #include <TDF_Attribute.hxx> |
| 27 | #include <Standard_Boolean.hxx> |
| 28 | #include <Standard_OStream.hxx> |
| 29 | class TNaming_Builder; |
| 30 | class TNaming_Iterator; |
| 31 | class TNaming_NewShapeIterator; |
| 32 | class TNaming_OldShapeIterator; |
| 33 | class Standard_GUID; |
| 34 | class TopoDS_Shape; |
| 35 | class TDF_Attribute; |
| 36 | class TDF_DeltaOnModification; |
| 37 | class TDF_DeltaOnRemoval; |
| 38 | class TDF_RelocationTable; |
| 39 | class TDF_DataSet; |
| 40 | class TDF_AttributeDelta; |
| 41 | |
| 42 | |
| 43 | class TNaming_NamedShape; |
| 44 | DEFINE_STANDARD_HANDLE(TNaming_NamedShape, TDF_Attribute) |
| 45 | |
| 46 | //! The basis to define an attribute for the storage of |
| 47 | //! topology and naming data. |
| 48 | //! This attribute contains two parts: |
| 49 | //! - The type of evolution, a term of the |
| 50 | //! enumeration TNaming_Evolution |
| 51 | //! - A list of pairs of shapes called the "old" |
| 52 | //! shape and the "new" shape. The meaning |
| 53 | //! depends on the type of evolution. |
| 54 | class TNaming_NamedShape : public TDF_Attribute |
| 55 | { |
| 56 | |
| 57 | public: |
| 58 | |
| 59 | |
| 60 | //! class method |
| 61 | //! ============ |
| 62 | //! Returns the GUID for named shapes. |
| 63 | Standard_EXPORT static const Standard_GUID& GetID(); |
| 64 | |
| 65 | Standard_EXPORT TNaming_NamedShape(); |
| 66 | |
| 67 | Standard_EXPORT Standard_Boolean IsEmpty() const; |
| 68 | |
| 69 | //! Returns the shapes contained in <NS>. Returns a null |
| 70 | //! shape if IsEmpty. |
| 71 | Standard_EXPORT TopoDS_Shape Get() const; |
| 72 | |
| 73 | //! Returns the Evolution of the attribute. |
| 74 | TNaming_Evolution Evolution() const; |
| 75 | |
| 76 | //! Returns the Version of the attribute. |
| 77 | Standard_Integer Version() const; |
| 78 | |
| 79 | //! Set the Version of the attribute. |
| 80 | void SetVersion (const Standard_Integer version); |
| 81 | |
| 82 | Standard_EXPORT void Clear(); |
| 83 | ~TNaming_NamedShape() |
| 84 | { |
| 85 | Clear(); |
| 86 | } |
| 87 | |
| 88 | //! Returns the ID of the attribute. |
| 89 | const Standard_GUID& ID() const Standard_OVERRIDE; |
| 90 | |
| 91 | //! Copies the attribute contents into a new other |
| 92 | //! attribute. It is used by Backup(). |
| 93 | Standard_EXPORT virtual Handle(TDF_Attribute) BackupCopy() const Standard_OVERRIDE; |
| 94 | |
| 95 | //! Restores the contents from <anAttribute> into this |
| 96 | //! one. It is used when aborting a transaction. |
| 97 | Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& anAttribute) Standard_OVERRIDE; |
| 98 | |
| 99 | //! Makes a DeltaOnModification between <me> and |
| 100 | //! <anOldAttribute. |
| 101 | Standard_EXPORT virtual Handle(TDF_DeltaOnModification) DeltaOnModification (const Handle(TDF_Attribute)& anOldAttribute) const Standard_OVERRIDE; |
| 102 | |
| 103 | //! Applies a DeltaOnModification to <me>. |
| 104 | Standard_EXPORT virtual void DeltaOnModification (const Handle(TDF_DeltaOnModification)& aDelta) Standard_OVERRIDE; |
| 105 | |
| 106 | //! Makes a DeltaOnRemoval on <me> because <me> has |
| 107 | //! disappeared from the DS. |
| 108 | Standard_EXPORT virtual Handle(TDF_DeltaOnRemoval) DeltaOnRemoval() const Standard_OVERRIDE; |
| 109 | |
| 110 | //! Returns an new empty attribute from the good end |
| 111 | //! type. It is used by the copy algorithm. |
| 112 | Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE; |
| 113 | |
| 114 | //! This method is different from the "Copy" one, |
| 115 | //! because it is used when copying an attribute from |
| 116 | //! a source structure into a target structure. This |
| 117 | //! method pastes the current attribute to the label |
| 118 | //! corresponding to the insertor. The pasted |
| 119 | //! attribute may be a brand new one or a new version |
| 120 | //! of the previous one. |
| 121 | Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& intoAttribute, const Handle(TDF_RelocationTable)& aRelocTationable) const Standard_OVERRIDE; |
| 122 | |
| 123 | //! Adds the directly referenced attributes and labels |
| 124 | //! to <aDataSet>. "Directly" means we have only to |
| 125 | //! look at the first level of references. |
| 126 | Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& aDataSet) const Standard_OVERRIDE; |
| 127 | |
| 128 | Standard_EXPORT virtual void BeforeRemoval() Standard_OVERRIDE; |
| 129 | |
| 130 | //! Something to do before applying <anAttDelta> |
| 131 | Standard_EXPORT virtual Standard_Boolean BeforeUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE; |
| 132 | |
| 133 | //! Something to do after applying <anAttDelta>. |
| 134 | Standard_EXPORT virtual Standard_Boolean AfterUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE; |
| 135 | |
| 136 | //! Dumps the attribute on <aStream>. |
| 137 | Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE; |
| 138 | |
| 139 | //! Dumps the content of me into the stream |
| 140 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
| 141 | |
| 142 | friend class TNaming_Builder; |
| 143 | friend class TNaming_Iterator; |
| 144 | friend class TNaming_NewShapeIterator; |
| 145 | friend class TNaming_OldShapeIterator; |
| 146 | |
| 147 | |
| 148 | DEFINE_STANDARD_RTTIEXT(TNaming_NamedShape,TDF_Attribute) |
| 149 | |
| 150 | protected: |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | private: |
| 156 | |
| 157 | |
| 158 | //! Adds an evolution |
| 159 | Standard_EXPORT void Add (TNaming_PtrNode& Evolution); |
| 160 | |
| 161 | TNaming_PtrNode myNode; |
| 162 | TNaming_Evolution myEvolution; |
| 163 | Standard_Integer myVersion; |
| 164 | |
| 165 | |
| 166 | }; |
| 167 | |
| 168 | |
| 169 | #include <TNaming_NamedShape.lxx> |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | #endif // _TNaming_NamedShape_HeaderFile |