0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / Interface / Interface_Graph.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-09-22
2// Created by: Christian CAILLET
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _Interface_Graph_HeaderFile
18#define _Interface_Graph_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <TCollection_AsciiString.hxx>
25#include <TColStd_HArray1OfInteger.hxx>
26#include <Interface_BitMap.hxx>
27#include <TColStd_HArray1OfListOfInteger.hxx>
28#include <Standard_Boolean.hxx>
29#include <Standard_Integer.hxx>
30#include <TColStd_HSequenceOfTransient.hxx>
31#include <Standard_Type.hxx>
32class Interface_InterfaceModel;
33class Standard_DomainError;
34class Interface_GeneralLib;
35class Interface_Protocol;
36class Interface_GTool;
37class Standard_Transient;
38class Interface_BitMap;
39class Interface_EntityIterator;
40class TCollection_HAsciiString;
41
42
43//! Gives basic data structure for operating and storing
44//! graph results (usage is normally internal)
45//! Entities are Mapped according their Number in the Model
46//!
47//! Each Entity from the Model can be known as "Present" or
48//! not; if it is, it is Mapped with a Status : an Integer
49//! which can be used according to needs of each algorithm
50//! In addition, the Graph brings a BitMap which can be used
51//! by any caller
52//!
53//! Also, it is bound with two lists : a list of Shared
54//! Entities (in fact, their Numbers in the Model) which is
55//! filled by a ShareTool, and a list of Sharing Entities,
56//! computed by deduction from the Shared Lists
57//!
58//! Moreover, it is possible to redefine the list of Entities
59//! Shared by an Entity (instead of standard answer by general
60//! service Shareds) : this new list can be empty; it can
61//! be changed or reset (i.e. to come back to standard answer)
62class Interface_Graph
63{
64public:
65
66 DEFINE_STANDARD_ALLOC
67
68
69 //! Creates an empty graph, ready to receive Entities from amodel
70 //! Note that this way of Creation allows <me> to verify that
71 //! Entities to work with are contained in <amodel>
72 //! Basic Shared and Sharing lists are obtained from a General
73 //! Services Library, given directly as an argument
74 Standard_EXPORT Interface_Graph(const Handle(Interface_InterfaceModel)& amodel, const Interface_GeneralLib& lib, const Standard_Boolean theModeStats = Standard_True);
75
76 //! Same as above, but the Library is defined through a Protocol
77 Standard_EXPORT Interface_Graph(const Handle(Interface_InterfaceModel)& amodel, const Handle(Interface_Protocol)& protocol, const Standard_Boolean theModeStats = Standard_True);
78
79 //! Same as above, but the Library is defined through a Protocol
80 Standard_EXPORT Interface_Graph(const Handle(Interface_InterfaceModel)& amodel, const Handle(Interface_GTool)& gtool, const Standard_Boolean theModeStats = Standard_True);
81
82 //! Same a above but works with the Protocol recorded in the Model
83 Standard_EXPORT Interface_Graph(const Handle(Interface_InterfaceModel)& amodel, const Standard_Boolean theModeStats = Standard_True);
84
85 //! Creates a Graph from another one, getting all its data
86 //! Remark that status are copied from <agraph>, but the other
87 //! lists (sharing/shared) are copied only if <copied> = True
88 Standard_EXPORT Interface_Graph(const Interface_Graph& agraph, const Standard_Boolean copied = Standard_False);
89
90 //! Erases data, making graph ready to rebegin from void
91 //! (also resets Shared lists redefinitions)
92 Standard_EXPORT void Reset();
93
94 //! Erases Status (Values and Flags of Presence), making graph
95 //! ready to rebegin from void. Does not concerns Shared lists
96 Standard_EXPORT void ResetStatus();
97
98 //! Returns size (max nb of entities, i.e. Model's nb of entities)
99 Standard_EXPORT Standard_Integer Size() const;
100
101 //! Returns size of array of statuses
102 Standard_EXPORT Standard_Integer NbStatuses() const;
103
104 //! Returns the Number of the entity in the Map, computed at
105 //! creation time (Entities loaded from the Model)
106 //! Returns 0 if <ent> not contained by Model used to create <me>
107 //! (that is, <ent> is unknown from <me>)
108 Standard_EXPORT Standard_Integer EntityNumber (const Handle(Standard_Transient)& ent) const;
109
110 //! Returns True if an Entity is noted as present in the graph
111 //! (See methods Get... which determine this status)
112 //! Returns False if <num> is out of range too
113 Standard_EXPORT Standard_Boolean IsPresent (const Standard_Integer num) const;
114
115 //! Same as above but directly on an Entity <ent> : if it is not
116 //! contained in the Model, returns False. Else calls
117 //! IsPresent(num) with <num> given by EntityNumber
118 Standard_EXPORT Standard_Boolean IsPresent (const Handle(Standard_Transient)& ent) const;
119
120 //! Returns mapped Entity given its no (if it is present)
121 Standard_EXPORT const Handle(Standard_Transient)& Entity (const Standard_Integer num) const;
122
123 //! Returns Status associated to a numero (only to read it)
124 Standard_EXPORT Standard_Integer Status (const Standard_Integer num) const;
125
126 //! Modifies Status associated to a numero
127 Standard_EXPORT void SetStatus (const Standard_Integer num, const Standard_Integer stat);
128
129 //! Clears Entity and sets Status to 0, for a numero
130 Standard_EXPORT void RemoveItem (const Standard_Integer num);
131
132 //! Changes all status which value is oldstat to new value newstat
133 Standard_EXPORT void ChangeStatus (const Standard_Integer oldstat, const Standard_Integer newstat);
134
135 //! Removes all items of which status has a given value stat
136 Standard_EXPORT void RemoveStatus (const Standard_Integer stat);
137
138 //! Returns the Bit Map in order to read or edit flag values
139 Standard_EXPORT const Interface_BitMap& BitMap() const;
140
141 //! Returns the Bit Map in order to edit it (add new flags)
142 Standard_EXPORT Interface_BitMap& CBitMap();
143
144 //! Returns the Model with which this Graph was created
145 Standard_EXPORT const Handle(Interface_InterfaceModel)& Model() const;
146
147 //! Loads Graph with all Entities contained in the Model
148 Standard_EXPORT void GetFromModel();
149
150 //! Gets an Entity, plus its shared ones (at every level) if
151 //! "shared" is True. New items are set to status "newstat"
152 //! Items already present in graph remain unchanged
153 //! Of course, redefinitions of Shared lists are taken into
154 //! account if there are some
155 Standard_EXPORT void GetFromEntity (const Handle(Standard_Transient)& ent, const Standard_Boolean shared, const Standard_Integer newstat = 0);
156
157 //! Gets an Entity, plus its shared ones (at every level) if
158 //! "shared" is True. New items are set to status "newstat".
159 //! Items already present in graph are processed as follows :
160 //! - if they already have status "newstat", they remain unchanged
161 //! - if they have another status, this one is modified :
162 //! if cumul is True, to former status + overlapstat (cumul)
163 //! if cumul is False, to overlapstat (enforce)
164 Standard_EXPORT void GetFromEntity (const Handle(Standard_Transient)& ent, const Standard_Boolean shared, const Standard_Integer newstat, const Standard_Integer overlapstat, const Standard_Boolean cumul);
165
166 //! Gets Entities given by an EntityIterator. Entities which were
167 //! not yet present in the graph are mapped with status "newstat"
168 //! Entities already present remain unchanged
169 Standard_EXPORT void GetFromIter (const Interface_EntityIterator& iter, const Standard_Integer newstat);
170
171 //! Gets Entities given by an EntityIterator and distinguishes
172 //! those already present in the Graph :
173 //! - new entities added to the Graph with status "newstst"
174 //! - entities already present with status = "newstat" remain
175 //! unchanged
176 //! - entities already present with status different form
177 //! "newstat" have their status modified :
178 //! if cumul is True, to former status + overlapstat (cumul)
179 //! if cumul is False, to overlapstat (enforce)
180 //! (Note : works as GetEntity, shared = False, for each entity)
181 Standard_EXPORT void GetFromIter (const Interface_EntityIterator& iter, const Standard_Integer newstat, const Standard_Integer overlapstat, const Standard_Boolean cumul);
182
183 //! Gets all present items from another graph
184 Standard_EXPORT void GetFromGraph (const Interface_Graph& agraph);
185
186 //! Gets items from another graph which have a specific Status
187 Standard_EXPORT void GetFromGraph (const Interface_Graph& agraph, const Standard_Integer stat);
188
189 //! Returns True if <ent> or the list of entities shared by <ent>
190 //! (not redefined) contains items unknown from this Graph
191 //! Remark : apart from the status HasShareError, these items
192 //! are ignored
193 Standard_EXPORT Standard_Boolean HasShareErrors (const Handle(Standard_Transient)& ent) const;
194
195 //! Returns the sequence of Entities Shared by an Entity
196 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShareds (const Handle(Standard_Transient)& ent) const;
197
198 //! Returns the list of Entities Shared by an Entity, as recorded
199 //! by the Graph. That is, by default Basic Shared List, else it
200 //! can be redefined by methods SetShare, SetNoShare ... see below
201 Standard_EXPORT Interface_EntityIterator Shareds (const Handle(Standard_Transient)& ent) const;
202
203 //! Returns the list of Entities which Share an Entity, computed
204 //! from the Basic or Redefined Shared Lists
205 Standard_EXPORT Interface_EntityIterator Sharings (const Handle(Standard_Transient)& ent) const;
206
207 //! Returns the sequence of Entities Sharings by an Entity
208 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharings (const Handle(Standard_Transient)& ent) const;
209
210 //! Returns the list of sharings entities, AT ANY LEVEL, which are
211 //! kind of a given type. A sharing entity kind of this type
212 //! ends the exploration of its branch
213 Standard_EXPORT Interface_EntityIterator TypedSharings (const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& type) const;
214
215 //! Returns the Entities which are not Shared (their Sharing List
216 //! is empty) in the Model
217 Standard_EXPORT Interface_EntityIterator RootEntities() const;
218
219 //! Determines the name attached to an entity, by using the
220 //! general service Name in GeneralModule
221 //! Returns a null handle if no name could be computed or if
222 //! the entity is not in the model
223 Standard_EXPORT Handle(TCollection_HAsciiString) Name (const Handle(Standard_Transient)& ent) const;
224
225 //! Returns the Table of Sharing lists. Used to Create
226 //! another Graph from <me>
227 Standard_EXPORT const Handle(TColStd_HArray1OfListOfInteger)& SharingTable() const;
228
229 //! Returns mode resposible for computation of statuses;
230 Standard_EXPORT Standard_Boolean ModeStat() const;
231
232
233
234
235protected:
236
237
238 //! Initialize statuses and flags
239 Standard_EXPORT void InitStats();
240
241
242 Handle(Interface_InterfaceModel) themodel;
243 TCollection_AsciiString thepresents;
244 Handle(TColStd_HArray1OfInteger) thestats;
245 Handle(TColStd_HArray1OfListOfInteger) thesharings;
246
247
248private:
249
250
251 //! Performs the Evaluation of the Graph, from an initial Library,
252 //! either defined through a Protocol, or given dierctly
253 //! Called by the non-empty Constructors
254 //!
255 //! Normally, gtool suffices. But if a Graph is created from a
256 //! GeneralLib directly, it cannot be used
257 //! If <gtool> is defined, it has priority
258 Standard_EXPORT void Evaluate();
259
260
261 Interface_BitMap theflags;
262
263
264};
265
266
267
268
269
270
271
272#endif // _Interface_Graph_HeaderFile