Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:07

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