Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:21:58

0001 // Created on: 1999-09-28
0002 // Created by: Denis PASCAL
0003 // Copyright (c) 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_Selector_HeaderFile
0018 #define _TNaming_Selector_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 <TDF_Attribute.hxx>
0027 class TopoDS_Shape;
0028 class TNaming_NamedShape;
0029 
0030 //! This class provides a single API for selection of shapes.
0031 //! This involves both identification and selection of
0032 //! shapes in the data framework.
0033 //! If the selected shape is modified, this selector will
0034 //! solve its identifications.
0035 //! This class is the user interface for topological
0036 //! naming resources.
0037 //! * The <IsIdentified> method returns (if exists)
0038 //! the NamedShape which contains a given shape. The
0039 //! definition of an identified shape is: a Shape
0040 //! handled by a NamedShape (this shape is the only
0041 //! one stored), which has the TNaming_PRImITIVE evolution
0042 //!
0043 //! * The <Select> method returns ALWAYS a new
0044 //! NamedShape at the given label, which contains the
0045 //! argument selected shape. When calling this
0046 //! method, the sub-hierarchy of <label> is first cleared,
0047 //! then a TNaming_NamedShape is ALWAYS created at
0048 //! this <label>, with the TNaming_SELECTED evolution.
0049 //! The <Naming attribute> is associated to the selected
0050 //! shape which store the arguments of the selection.
0051 //! If the given selected shape was already identified
0052 //! (method IsIdentified), this Naming attribute
0053 //! contains the reference (Identity code) to the
0054 //! argument shape.
0055 //!
0056 //! * The <Solve> method update the current value of
0057 //! the NamedShape, according to the <Naming> attribute.
0058 //! A boolean status is returned to say if the
0059 //! algorithm succeed or not. To read the current
0060 //! value of the selected Named Shape use the
0061 //! TNaming_Tool::GetShape method, as for any
0062 //! NamedShape attribute.
0063 class TNaming_Selector
0064 {
0065 public:
0066   DEFINE_STANDARD_ALLOC
0067 
0068   //! To know if a shape is already identified (not selected)
0069   //! =======================================================
0070   //!
0071   //! The label access defines the point of access to the data framework.
0072   //! selection is the shape for which we want to know
0073   //! whether it is identified or not.
0074   //! If true, NS is returned as the identity of selection.
0075   //! If Geometry is true, NS will be the named shape
0076   //! containing the first appearance of selection and
0077   //! not any other shape. In other words, selection
0078   //! must be the only shape stored in NS.
0079   Standard_EXPORT static bool IsIdentified(const TDF_Label&                 access,
0080                                            const TopoDS_Shape&              selection,
0081                                            occ::handle<TNaming_NamedShape>& NS,
0082                                            const bool                       Geometry = false);
0083 
0084   //! Create a selector on this label
0085   //! to select a shape.
0086   //! ==================
0087   Standard_EXPORT TNaming_Selector(const TDF_Label& aLabel);
0088 
0089   //! Creates a topological naming on the label
0090   //! aLabel given as an argument at construction time.
0091   //! If successful, the shape Selection - found in the
0092   //! shape Context - is now identified in the named
0093   //! shape returned in NamedShape.
0094   //! If Geometry is true, NamedShape contains the
0095   //! first appearance of Selection.
0096   //! This syntax is more robust than the previous
0097   //! syntax for this method.
0098   Standard_EXPORT bool Select(const TopoDS_Shape& Selection,
0099                               const TopoDS_Shape& Context,
0100                               const bool          Geometry          = false,
0101                               const bool          KeepOrientatation = false) const;
0102 
0103   //! Creates a topological naming on the label
0104   //! aLabel given as an argument at construction time.
0105   //! If successful, the shape Selection is now
0106   //! identified in the named shape returned in NamedShape.
0107   //! If Geometry is true, NamedShape contains the
0108   //! first appearance of Selection.
0109   Standard_EXPORT bool Select(const TopoDS_Shape& Selection,
0110                               const bool          Geometry          = false,
0111                               const bool          KeepOrientatation = false) const;
0112 
0113   //! Updates the topological naming on the label
0114   //! aLabel given as an argument at construction time.
0115   //! The underlying shape returned in the method
0116   //! NamedShape is updated.
0117   //! To read this shape, use the method TNaming_Tool::GetShape
0118   Standard_EXPORT bool Solve(NCollection_Map<TDF_Label>& Valid) const;
0119 
0120   //! Returns the attribute list args.
0121   //! This list contains the named shape on which the topological naming was built.
0122   Standard_EXPORT void Arguments(NCollection_Map<occ::handle<TDF_Attribute>>& args) const;
0123 
0124   //! Returns the NamedShape build or under construction,
0125   //! which contains the topological naming..
0126   Standard_EXPORT occ::handle<TNaming_NamedShape> NamedShape() const;
0127 
0128 private:
0129   TDF_Label myLabel;
0130 };
0131 
0132 #endif // _TNaming_Selector_HeaderFile