Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:22:12

0001 // Created on: 1996-12-24
0002 // Created by: Yves FRICAUD
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _TNaming_Tool_HeaderFile
0018 #define _TNaming_Tool_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TDF_Label.hxx>
0025 #include <NCollection_Map.hxx>
0026 #include <TNaming_NamedShape.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <NCollection_List.hxx>
0029 #include <TopTools_ShapeMapHasher.hxx>
0030 #include <NCollection_IndexedMap.hxx>
0031 class TNaming_NamedShape;
0032 class TNaming_OldShapeIterator;
0033 class TopoDS_Shape;
0034 class TDF_Label;
0035 class TNaming_UsedShapes;
0036 
0037 //! A tool to get information on the topology of a
0038 //! named shape attribute.
0039 //! This information is typically a TopoDS_Shape object.
0040 //! Using this tool, relations between named shapes
0041 //! are also accessible.
0042 class TNaming_Tool
0043 {
0044 public:
0045   DEFINE_STANDARD_ALLOC
0046 
0047   //! Returns the last Modification of <NS>.
0048   //! Returns the shape CurrentShape contained in
0049   //! the named shape attribute NS.
0050   //! CurrentShape is the current state of the entities
0051   //! if they have been modified in other attributes of the same data structure.
0052   //! Each call to this function creates a new compound.
0053   Standard_EXPORT static TopoDS_Shape CurrentShape(const occ::handle<TNaming_NamedShape>& NS);
0054 
0055   //! Returns the shape CurrentShape contained in
0056   //! the named shape attribute NS, and present in
0057   //! the updated attribute map Updated.
0058   //! CurrentShape is the current state of the entities
0059   //! if they have been modified in other attributes of the same data structure.
0060   //! Each call to this function creates a new compound.
0061   //! Warning
0062   //! Only the contents of Updated are searched.R
0063   Standard_EXPORT static TopoDS_Shape CurrentShape(const occ::handle<TNaming_NamedShape>& NS,
0064                                                    const NCollection_Map<TDF_Label>&      Updated);
0065 
0066   //! Returns the NamedShape of the last Modification of <NS>.
0067   //! This shape is identified by a label.
0068   Standard_EXPORT static occ::handle<TNaming_NamedShape> CurrentNamedShape(
0069     const occ::handle<TNaming_NamedShape>& NS,
0070     const NCollection_Map<TDF_Label>&      Updated);
0071 
0072   //! Returns NamedShape the last Modification of <NS>.
0073   Standard_EXPORT static occ::handle<TNaming_NamedShape> CurrentNamedShape(
0074     const occ::handle<TNaming_NamedShape>& NS);
0075 
0076   //! Returns the named shape attribute defined by
0077   //! the shape aShape and the label anAccess.
0078   //! This attribute is returned as a new shape.
0079   //! You call this function, if you need to create a
0080   //! topological attribute for existing data.
0081   //! Example
0082   //! class MyPkg_MyClass
0083   //! {
0084   //! public: bool
0085   //! SameEdge(const
0086   //! occ::handle<OCafTest_Line>& , const
0087   //! occ::handle<CafTest_Line>& );
0088   //! };
0089   //!
0090   //! bool
0091   //! MyPkg_MyClass::SameEdge
0092   //! (const occ::handle<OCafTest_Line>& L1
0093   //! const occ::handle<OCafTest_Line>& L2)
0094   //! { occ::handle<TNaming_NamedShape>
0095   //! NS1 = L1->NamedShape();
0096   //! occ::handle<TNaming_NamedShape>
0097   //! NS2 = L2->NamedShape();
0098   //!
0099   //! return
0100   //! BRepTools::Compare(NS1->Get(),NS2->Get());
0101   //! }
0102   //! In the example above, the function SameEdge is
0103   //! created to compare the edges having two lines
0104   //! for geometric supports. If these edges are found
0105   //! by BRepTools::Compare to be within the same
0106   //! tolerance, they are considered to be the same.
0107   //! Warning
0108   //! To avoid sharing of names, a SELECTED
0109   //! attribute will not be returned. Sharing of names
0110   //! makes it harder to manage the data structure.
0111   //! When the user of the name is removed, for
0112   //! example, it is difficult to know whether the name
0113   //! should be destroyed.
0114   Standard_EXPORT static occ::handle<TNaming_NamedShape> NamedShape(const TopoDS_Shape& aShape,
0115                                                                     const TDF_Label&    anAcces);
0116 
0117   //! Returns the entities stored in the named shape attribute NS.
0118   //! If there is only one old-new pair, the new shape
0119   //! is returned. Otherwise, a Compound is returned.
0120   //! This compound is made out of all the new shapes found.
0121   //! Each call to this function creates a new compound.
0122   Standard_EXPORT static TopoDS_Shape GetShape(const occ::handle<TNaming_NamedShape>& NS);
0123 
0124   //! Returns the shape contained as OldShape in <NS>
0125   Standard_EXPORT static TopoDS_Shape OriginalShape(const occ::handle<TNaming_NamedShape>& NS);
0126 
0127   //! Returns the shape generated from S or by a
0128   //! modification of S and contained in the named
0129   //! shape Generation.
0130   Standard_EXPORT static TopoDS_Shape GeneratedShape(
0131     const TopoDS_Shape&                    S,
0132     const occ::handle<TNaming_NamedShape>& Generation);
0133 
0134   Standard_EXPORT static void Collect(const occ::handle<TNaming_NamedShape>&            NS,
0135                                       NCollection_Map<occ::handle<TNaming_NamedShape>>& Labels,
0136                                       const bool OnlyModif = true);
0137 
0138   //! Returns True if <aShape> appears under a label.(DP)
0139   Standard_EXPORT static bool HasLabel(const TDF_Label& access, const TopoDS_Shape& aShape);
0140 
0141   //! Returns the label of the first apparition  of
0142   //! <aShape>. Transdef is a value of the transaction
0143   //! of the first apparition of <aShape>.
0144   Standard_EXPORT static TDF_Label Label(const TDF_Label&    access,
0145                                          const TopoDS_Shape& aShape,
0146                                          int&                TransDef);
0147 
0148   //! Returns the shape created from the shape
0149   //! aShape contained in the attribute anAcces.
0150   Standard_EXPORT static TopoDS_Shape InitialShape(const TopoDS_Shape&          aShape,
0151                                                    const TDF_Label&             anAcces,
0152                                                    NCollection_List<TDF_Label>& Labels);
0153 
0154   //! Returns the last transaction where the creation of S
0155   //! is valid.
0156   Standard_EXPORT static int ValidUntil(const TDF_Label& access, const TopoDS_Shape& S);
0157 
0158   //! Returns the current shape (a Wire or a Shell) built (in the data framework)
0159   //! from the shapes of the argument named shape.
0160   //! It is used for IDENTITY name type computation.
0161   Standard_EXPORT static void FindShape(const NCollection_Map<TDF_Label>&      Valid,
0162                                         const NCollection_Map<TDF_Label>&      Forbiden,
0163                                         const occ::handle<TNaming_NamedShape>& Arg,
0164                                         TopoDS_Shape&                          S);
0165 
0166   friend class TNaming_Localizer;
0167   friend class TNaming_NamedShape;
0168   friend class TNaming_OldShapeIterator;
0169 
0170 private:
0171   //! Returns True if <aShape> appears under a label.
0172   Standard_EXPORT static bool HasLabel(const occ::handle<TNaming_UsedShapes>& Shapes,
0173                                        const TopoDS_Shape&                    aShape);
0174 
0175   //! Returns the last transaction where the creation of S
0176   //! is valid.
0177   Standard_EXPORT static int ValidUntil(const TopoDS_Shape&                    S,
0178                                         const occ::handle<TNaming_UsedShapes>& US);
0179 
0180   //! Returns the label of the first apparition of
0181   //! <aShape>. Transdef is a value of the transaction
0182   //! of the first apparition of <aShape>.
0183   Standard_EXPORT static TDF_Label Label(const occ::handle<TNaming_UsedShapes>& Shapes,
0184                                          const TopoDS_Shape&                    aShape,
0185                                          int&                                   TransDef);
0186 
0187   Standard_EXPORT static void FirstOlds(
0188     const occ::handle<TNaming_UsedShapes>&                         Shapes,
0189     const TopoDS_Shape&                                            S,
0190     TNaming_OldShapeIterator&                                      it,
0191     NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& MS,
0192     NCollection_List<TDF_Label>&                                   Labels);
0193 };
0194 
0195 #endif // _TNaming_Tool_HeaderFile