Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:21:04

0001 // Created on: 1995-11-08
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1995-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 _Interface_Category_HeaderFile
0018 #define _Interface_Category_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 
0028 #include <Interface_GTool.hxx>
0029 class Interface_Protocol;
0030 class Standard_Transient;
0031 class Interface_ShareTool;
0032 class Interface_InterfaceModel;
0033 
0034 //! This class manages categories
0035 //! A category is defined by a name and a number, and can be
0036 //! seen as a way of rough classification, i.e. less precise than
0037 //! a cdl type.
0038 //! Hence, it is possible to dispatch every entity in about
0039 //! a dozen of categories, twenty is a reasonable maximum.
0040 //!
0041 //! Basically, the system provides the following categories :
0042 //! Shape (Geometry, BRep, CSG, Features, etc...)
0043 //! Drawing (Drawing, Views, Annotations, Pictures, Sketches ...)
0044 //! Structure (Component & Part, Groups & Patterns ...)
0045 //! Description (Meta-Data : Relations, Properties, Product ...)
0046 //! Auxiliary (those which do not enter in the above list)
0047 //! and some dedicated categories
0048 //! FEA, Kinematics, Piping, etc...
0049 //! plus Professional for other dedicated non-classed categories
0050 //!
0051 //! In addition, this class provides a way to compute then quickly
0052 //! query category numbers for an entire model.
0053 //! Values are just recorded as a list of numbers, control must
0054 //! then be done in a wider context (which must provide a Graph)
0055 class Interface_Category
0056 {
0057 public:
0058   DEFINE_STANDARD_ALLOC
0059 
0060   //! Creates a Category, with no protocol yet
0061   Interface_Category()
0062       : myGTool(new Interface_GTool)
0063   {
0064     Init();
0065   }
0066 
0067   //! Creates a Category with a given protocol
0068   Interface_Category(const occ::handle<Interface_Protocol>& theProtocol)
0069       : myGTool(new Interface_GTool(theProtocol))
0070   {
0071     Init();
0072   }
0073 
0074   //! Creates a Category with a given GTool
0075   Interface_Category(const occ::handle<Interface_GTool>& theGTool)
0076       : myGTool(theGTool)
0077   {
0078     Init();
0079   }
0080 
0081   //! Sets/Changes Protocol
0082   void SetProtocol(const occ::handle<Interface_Protocol>& theProtocol)
0083   {
0084     myGTool->SetProtocol(theProtocol);
0085   }
0086 
0087   //! Determines the Category Number for an entity in its context,
0088   //! by using general service CategoryNumber
0089   Standard_EXPORT int CatNum(const occ::handle<Standard_Transient>& theEnt,
0090                              const Interface_ShareTool&             theShares);
0091 
0092   //! Clears the recorded list of category numbers for a Model
0093   void ClearNums() { myNum.Nullify(); }
0094 
0095   //! Computes the Category Number for each entity and records it,
0096   //! in an array (ent.number -> category number)
0097   //! Hence, it can be queried by the method Num.
0098   //! The Model itself is not recorded, this method is intended to
0099   //! be used in a wider context (which detains also a Graph, etc)
0100   Standard_EXPORT void Compute(const occ::handle<Interface_InterfaceModel>& theModel,
0101                                const Interface_ShareTool&                   theShares);
0102 
0103   //! Returns the category number recorded for an entity number
0104   //! Returns 0 if out of range
0105   Standard_EXPORT int Num(const int theNumEnt) const;
0106 
0107   //! Records a new Category defined by its names, produces a number
0108   //! New if not yet recorded
0109   Standard_EXPORT static int AddCategory(const char* const theName);
0110 
0111   //! Returns the count of recorded categories
0112   Standard_EXPORT static int NbCategories();
0113 
0114   //! Returns the name of a category, according to its number
0115   Standard_EXPORT static const char* Name(const int theNum);
0116 
0117   //! Returns the number of a category, according to its name
0118   Standard_EXPORT static int Number(const char* const theName);
0119 
0120   //! Default initialisation
0121   //! (protected against several calls : passes only once)
0122   Standard_EXPORT static void Init();
0123 
0124 private:
0125   occ::handle<Interface_GTool>          myGTool;
0126   occ::handle<NCollection_HArray1<int>> myNum;
0127 };
0128 
0129 #endif // _Interface_Category_HeaderFile