1 // Created on: 1996-12-24
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _TNaming_Tool_HeaderFile
18 #define _TNaming_Tool_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TDF_LabelMap.hxx>
25 #include <TNaming_MapOfNamedShape.hxx>
26 #include <Standard_Integer.hxx>
27 #include <TDF_LabelList.hxx>
28 #include <TopTools_IndexedMapOfShape.hxx>
29 class TNaming_NamedShape;
30 class TNaming_OldShapeIterator;
33 class TNaming_UsedShapes;
36 //! A tool to get information on the topology of a
37 //! named shape attribute.
38 //! This information is typically a TopoDS_Shape object.
39 //! Using this tool, relations between named shapes
40 //! are also accessible.
48 //! Returns the last Modification of <NS>.
49 //! Returns the shape CurrentShape contained in
50 //! the named shape attribute NS.
51 //! CurrentShape is the current state of the entities
52 //! if they have been modified in other attributes of the same data structure.
53 //! Each call to this function creates a new compound.
54 Standard_EXPORT static TopoDS_Shape CurrentShape (const Handle(TNaming_NamedShape)& NS);
56 //! Returns the shape CurrentShape contained in
57 //! the named shape attribute NS, and present in
58 //! the updated attribute map Updated.
59 //! CurrentShape is the current state of the entities
60 //! if they have been modified in other attributes of the same data structure.
61 //! Each call to this function creates a new compound.
63 //! Only the contents of Updated are searched.R
64 Standard_EXPORT static TopoDS_Shape CurrentShape (const Handle(TNaming_NamedShape)& NS, const TDF_LabelMap& Updated);
66 //! Returns the NamedShape of the last Modification of <NS>.
67 //! This shape is identified by a label.
68 Standard_EXPORT static Handle(TNaming_NamedShape) CurrentNamedShape (const Handle(TNaming_NamedShape)& NS, const TDF_LabelMap& Updated);
70 //! Returns NamedShape the last Modification of <NS>.
71 Standard_EXPORT static Handle(TNaming_NamedShape) CurrentNamedShape (const Handle(TNaming_NamedShape)& NS);
73 //! Returns the named shape attribute defined by
74 //! the shape aShape and the label anAccess.
75 //! This attribute is returned as a new shape.
76 //! You call this function, if you need to create a
77 //! topological attribute for existing data.
79 //! class MyPkg_MyClass
81 //! public: Standard_Boolean
83 //! Handle(OCafTest_Line)& , const
84 //! Handle(CafTest_Line)& );
88 //! MyPkg_MyClass::SameEdge
89 //! (const Handle(OCafTest_Line)& L1
90 //! const Handle(OCafTest_Line)& L2)
91 //! { Handle(TNaming_NamedShape)
92 //! NS1 = L1->NamedShape();
93 //! Handle(TNaming_NamedShape)
94 //! NS2 = L2->NamedShape();
97 //! BRepTools::Compare(NS1->Get(),NS2->Get());
99 //! In the example above, the function SameEdge is
100 //! created to compare the edges having two lines
101 //! for geometric supports. If these edges are found
102 //! by BRepTools::Compare to be within the same
103 //! tolerance, they are considered to be the same.
105 //! To avoid sharing of names, a SELECTED
106 //! attribute will not be returned. Sharing of names
107 //! makes it harder to manage the data structure.
108 //! When the user of the name is removed, for
109 //! example, it is difficult to know whether the name
110 //! should be destroyed.
111 Standard_EXPORT static Handle(TNaming_NamedShape) NamedShape (const TopoDS_Shape& aShape, const TDF_Label& anAcces);
113 //! Returns the entities stored in the named shape attribute NS.
114 //! If there is only one old-new pair, the new shape
115 //! is returned. Otherwise, a Compound is returned.
116 //! This compound is made out of all the new shapes found.
117 //! Each call to this function creates a new compound.
118 Standard_EXPORT static TopoDS_Shape GetShape (const Handle(TNaming_NamedShape)& NS);
120 //! Returns the shape contained as OldShape in <NS>
121 Standard_EXPORT static TopoDS_Shape OriginalShape (const Handle(TNaming_NamedShape)& NS);
123 //! Returns the shape generated from S or by a
124 //! modification of S and contained in the named
125 //! shape Generation.
126 Standard_EXPORT static TopoDS_Shape GeneratedShape (const TopoDS_Shape& S, const Handle(TNaming_NamedShape)& Generation);
128 Standard_EXPORT static void Collect (const Handle(TNaming_NamedShape)& NS, TNaming_MapOfNamedShape& Labels, const Standard_Boolean OnlyModif = Standard_True);
130 //! Returns True if <aShape> appears under a label.(DP)
131 Standard_EXPORT static Standard_Boolean HasLabel (const TDF_Label& access, const TopoDS_Shape& aShape);
133 //! Returns the label of the first apparition of
134 //! <aShape>. Transdef is a value of the transaction
135 //! of the first apparition of <aShape>.
136 Standard_EXPORT static TDF_Label Label (const TDF_Label& access, const TopoDS_Shape& aShape, Standard_Integer& TransDef);
139 //! Returns the shape created from the shape
140 //! aShape contained in the attribute anAcces.
141 Standard_EXPORT static TopoDS_Shape InitialShape (const TopoDS_Shape& aShape, const TDF_Label& anAcces, TDF_LabelList& Labels);
143 //! Returns the last transaction where the creation of S
145 Standard_EXPORT static Standard_Integer ValidUntil (const TDF_Label& access, const TopoDS_Shape& S);
147 //! Returns the current shape (a Wire or a Shell) built (in the data framework)
148 //! from the shapes of the argument named shape.
149 //! It is used for IDENTITY name type computation.
150 Standard_EXPORT static void FindShape (const TDF_LabelMap& Valid, const TDF_LabelMap& Forbiden, const Handle(TNaming_NamedShape)& Arg, TopoDS_Shape& S);
153 friend class TNaming_Localizer;
154 friend class TNaming_NamedShape;
155 friend class TNaming_OldShapeIterator;
167 //! Returns True if <aShape> appears under a label.
168 Standard_EXPORT static Standard_Boolean HasLabel (const Handle(TNaming_UsedShapes)& Shapes, const TopoDS_Shape& aShape);
170 //! Returns the last transaction where the creation of S
172 Standard_EXPORT static Standard_Integer ValidUntil (const TopoDS_Shape& S, const Handle(TNaming_UsedShapes)& US);
174 //! Returns the label of the first apparition of
175 //! <aShape>. Transdef is a value of the transaction
176 //! of the first apparition of <aShape>.
177 Standard_EXPORT static TDF_Label Label (const Handle(TNaming_UsedShapes)& Shapes, const TopoDS_Shape& aShape, Standard_Integer& TransDef);
179 Standard_EXPORT static void FirstOlds (const Handle(TNaming_UsedShapes)& Shapes, const TopoDS_Shape& S, TNaming_OldShapeIterator& it, TopTools_IndexedMapOfShape& MS, TDF_LabelList& Labels);
192 #endif // _TNaming_Tool_HeaderFile