1 // Created on: 1995-05-12
2 // Created by: Christian CAILLET
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Interface_IntList_HeaderFile
18 #define _Interface_IntList_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Integer.hxx>
25 #include <TColStd_HArray1OfInteger.hxx>
26 #include <Standard_Boolean.hxx>
29 //! This class detains the data which describe a Graph. A Graph
30 //! has two lists, one for shared refs, one for sharing refs
31 //! (the reverses). Each list comprises, for each Entity of the
32 //! Model of the Graph, a list of Entities (shared or sharing).
33 //! In fact, entities are identified by their numbers in the Model
34 //! or Graph : this gives better performances.
36 //! A simple way to implement this is to instantiate a HArray1
37 //! with a HSequenceOfInteger : each Entity Number designates a
38 //! value, which is a Sequence (if it is null, it is considered as
39 //! empty : this is a little optimisation).
41 //! This class gives a more efficient way to implement this.
42 //! It has two lists (two arrays of integers), one to describe
43 //! list (empty, one value given immediately, or negated index in
44 //! the second list), one to store refs (pointed from the first
45 //! list). This is much more efficient than a list of sequences,
46 //! in terms of speed (especially for read) and of memory
48 //! An IntList can also be set to access data for a given entity
49 //! number, it then acts as a single sequence
51 //! Remark that if an IntList is created from another one, it can
52 //! be read, but if it is created without copying, it may not be
54 class Interface_IntList
61 //! Creates empty IntList.
62 Standard_EXPORT Interface_IntList();
64 //! Creates an IntList for <nbe> entities
65 Standard_EXPORT Interface_IntList(const Standard_Integer nbe);
67 //! Creates an IntList from another one.
68 //! if <copied> is True, copies data
69 //! else, data are not copied, only the header object is
70 Standard_EXPORT Interface_IntList(const Interface_IntList& other, const Standard_Boolean copied);
72 //! Initialize IntList by number of entities.
73 Standard_EXPORT void Initialize (const Standard_Integer nbe);
75 //! Returns internal values, used for copying
76 Standard_EXPORT void Internals (Standard_Integer& nbrefs, Handle(TColStd_HArray1OfInteger)& ents, Handle(TColStd_HArray1OfInteger)& refs) const;
78 //! Returns count of entities to be aknowledged
79 Standard_EXPORT Standard_Integer NbEntities() const;
81 //! Changes the count of entities (ignored if decreased)
82 Standard_EXPORT void SetNbEntities (const Standard_Integer nbe);
84 //! Sets an entity number as current (for read and fill)
85 Standard_EXPORT void SetNumber (const Standard_Integer number);
87 //! Returns the current entity number
88 Standard_EXPORT Standard_Integer Number() const;
90 //! Returns an IntList, identical to <me> but set to a specified
92 //! By default, not copied (in order to be read)
93 //! Specified <copied> to produce another list and edit it
94 Standard_EXPORT Interface_IntList List (const Standard_Integer number, const Standard_Boolean copied = Standard_False) const;
96 //! Sets current entity list to be redefined or not
97 //! This is used in a Graph for redefinition list : it can be
98 //! disable (no redefinition, i.e. list is cleared), or enabled
99 //! (starts as empty). The original list has not to be "redefined"
100 Standard_EXPORT void SetRedefined (const Standard_Boolean mode);
102 //! Makes a reservation for <count> references to be later
103 //! attached to the current entity. If required, it increases
104 //! the size of array used to store refs. Remark that if count is
105 //! less than two, it does nothing (because immediate storing)
106 Standard_EXPORT void Reservate (const Standard_Integer count);
108 //! Adds a reference (as an integer value, an entity number) to
109 //! the current entity number. Zero is ignored
110 Standard_EXPORT void Add (const Standard_Integer ref);
112 //! Returns the count of refs attached to current entity number
113 Standard_EXPORT Standard_Integer Length() const;
115 //! Returns True if the list for a number (default is taken as
116 //! current) is "redefined" (usefull for empty list)
117 Standard_EXPORT Standard_Boolean IsRedefined (const Standard_Integer num = 0) const;
119 //! Returns a reference number in the list for current number,
120 //! according to its rank
121 Standard_EXPORT Standard_Integer Value (const Standard_Integer num) const;
123 //! Removes an item in the list for current number, given its rank
124 //! Returns True if done, False else
125 Standard_EXPORT Standard_Boolean Remove (const Standard_Integer num);
127 //! Clears all data, hence each entity number has an empty list
128 Standard_EXPORT void Clear();
130 //! Resizes lists to exact sizes. For list of refs, a positive
131 //! margin can be added.
132 Standard_EXPORT void AdjustSize (const Standard_Integer margin = 0);
147 Standard_Integer thenbe;
148 Standard_Integer thenbr;
149 Standard_Integer thenum;
150 Standard_Integer thecount;
151 Standard_Integer therank;
152 Handle(TColStd_HArray1OfInteger) theents;
153 Handle(TColStd_HArray1OfInteger) therefs;
164 #endif // _Interface_IntList_HeaderFile