Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:19:26

0001 // Created on: 1992-11-02
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1992-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_EntityCluster_HeaderFile
0018 #define _Interface_EntityCluster_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Transient.hxx>
0024 #include <Standard_Integer.hxx>
0025 class Interface_EntityIterator;
0026 
0027 //! Auxiliary class for EntityList. An EntityList designates an
0028 //! EntityCluster, which brings itself an fixed maximum count of
0029 //! Entities. If it is full, it gives access to another cluster
0030 //! ("Next"). This class is intended to give a good compromise
0031 //! between access time (faster than a Sequence, good for little
0032 //! count) and memory use (better than a Sequence in any case,
0033 //! overall for little count, better than an Array for a very
0034 //! little count. It is designed for a light management.
0035 //! Remark that a new Item may not be Null, because this is the
0036 //! criterium used for "End of List"
0037 class Interface_EntityCluster : public Standard_Transient
0038 {
0039 
0040 public:
0041   //! Creates an empty, non-chained, EntityCluster
0042   Standard_EXPORT Interface_EntityCluster();
0043 
0044   //! Creates a non-chained EntityCluster, filled with one Entity
0045   Standard_EXPORT Interface_EntityCluster(const occ::handle<Standard_Transient>& ent);
0046 
0047   //! Creates an empty EntityCluster, chained with another one
0048   //! (that is, put BEFORE this other one in the list)
0049   Standard_EXPORT Interface_EntityCluster(const occ::handle<Interface_EntityCluster>& ec);
0050 
0051   //! Creates an EntityCluster, filled with a first Entity, and
0052   //! chained to another EntityCluster (BEFORE it, as above)
0053   Standard_EXPORT Interface_EntityCluster(const occ::handle<Standard_Transient>&      ant,
0054                                           const occ::handle<Interface_EntityCluster>& ec);
0055 
0056   //! Appends an Entity to the Cluster. If it is not full, adds the
0057   //! entity directly inside itself. Else, transmits to its Next
0058   //! and Creates it if it does not yet exist
0059   Standard_EXPORT void Append(const occ::handle<Standard_Transient>& ent);
0060 
0061   //! Removes an Entity from the Cluster. If it is not found, calls
0062   //! its Next one to do so.
0063   //! Returns True if it becomes itself empty, False else
0064   //! (thus, a Cluster which becomes empty is deleted from the list)
0065   Standard_EXPORT bool Remove(const occ::handle<Standard_Transient>& ent);
0066 
0067   //! Removes an Entity from the Cluster, given its rank. If <num>
0068   //! is greater than NbLocal, calls its Next with (num - NbLocal),
0069   //! Returns True if it becomes itself empty, False else
0070   Standard_EXPORT bool Remove(const int num);
0071 
0072   //! Returns total count of Entities (including Next)
0073   Standard_EXPORT int NbEntities() const;
0074 
0075   //! Returns the Entity identified by its rank in the list
0076   //! (including Next)
0077   Standard_EXPORT const occ::handle<Standard_Transient>& Value(const int num) const;
0078 
0079   //! Changes an Entity given its rank.
0080   Standard_EXPORT void SetValue(const int num, const occ::handle<Standard_Transient>& ent);
0081 
0082   //! Fills an Iterator with designated Entities (includes Next)
0083   Standard_EXPORT void FillIterator(Interface_EntityIterator& iter) const;
0084 
0085   //! Destructor
0086   //! If Next exists, destroy from the last entity in reverse order.
0087   Standard_EXPORT ~Interface_EntityCluster() override;
0088 
0089   friend class Interface_EntityList;
0090 
0091   DEFINE_STANDARD_RTTIEXT(Interface_EntityCluster, Standard_Transient)
0092 
0093 private:
0094   //! Returns True if all the set of entities local to a Cluster is
0095   //! full. Used by EntityList.
0096   Standard_EXPORT bool IsLocalFull() const;
0097 
0098   //! Returns count of entities in the local set (without Next)
0099   //! Entities can then be read normally by method Value
0100   Standard_EXPORT int NbLocal() const;
0101 
0102   //! Returns True if a Cluster has a Next
0103   Standard_EXPORT bool HasNext() const;
0104 
0105   //! Returns Next Cluster in the chain
0106   Standard_EXPORT occ::handle<Interface_EntityCluster> Next() const;
0107 
0108   occ::handle<Standard_Transient>      theents[4];
0109   occ::handle<Interface_EntityCluster> thenext;
0110 };
0111 
0112 #endif // _Interface_EntityCluster_HeaderFile