1 // Created on: 1992-09-23
2 // Created by: Christian CAILLET
3 // Copyright (c) 1992-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 _IFGraph_SubPartsIterator_HeaderFile
18 #define _IFGraph_SubPartsIterator_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Interface_Graph.hxx>
25 #include <TColStd_HSequenceOfInteger.hxx>
26 #include <Standard_Integer.hxx>
27 #include <Standard_Boolean.hxx>
28 class Standard_OutOfRange;
29 class Standard_NoSuchObject;
30 class Interface_InterfaceError;
31 class Interface_Graph;
32 class Interface_InterfaceModel;
33 class Standard_Transient;
34 class Interface_EntityIterator;
35 class Interface_GraphContent;
38 //! defines general form for graph classes of which result is
39 //! not a single iteration on Entities, but a nested one :
40 //! External iteration works on sub-parts, identified by each
41 //! class (according to its algorithm)
42 //! Internal Iteration concerns Entities of a sub-part
43 //! Sub-Parts are assumed to be disjoined; if they are not,
44 //! the first one has priority
46 //! A SubPartsIterator can work in two steps : first, load
47 //! entities which have to be processed
48 //! then, analyse to set those entities into sub-parts
49 class IFGraph_SubPartsIterator
56 //! Creates with a Graph, whole or parts of it
57 //! whole True : works on the entire Model
58 //! whole False : empty, ready to be filled
59 //! SubPartIterator is set to load entities
60 Standard_EXPORT IFGraph_SubPartsIterator(const Interface_Graph& agraph, const Standard_Boolean whole);
62 //! Creates a SubPartIterator from another one and gets its Data
63 //! Note that only non-empty sub-parts are taken into account
64 //! PartNum is set to the last one
65 Standard_EXPORT IFGraph_SubPartsIterator(IFGraph_SubPartsIterator& other);
67 //! Gets Parts from another SubPartsIterator (in addition to the
68 //! ones already recorded)
69 //! Error if both SubPartsIterators are not based on the same Model
70 Standard_EXPORT void GetParts (IFGraph_SubPartsIterator& other);
72 //! Returns the Model with which this Iterator was created
73 Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
75 //! Adds an empty part and sets it to receive entities
76 Standard_EXPORT void AddPart();
78 //! Returns count of registered parts
79 Standard_EXPORT Standard_Integer NbParts() const;
81 //! Returns numero of part which currently receives entities
83 Standard_EXPORT Standard_Integer PartNum() const;
85 //! Sets SubPartIterator to get Entities (by GetFromEntity &
86 //! GetFromIter) into load status, to be analysed later
87 Standard_EXPORT void SetLoad();
89 //! Sets numero of receiving part to a new value
90 //! Error if not in range (1-NbParts)
91 Standard_EXPORT void SetPartNum (const Standard_Integer num);
93 //! Adds an Entity : into load status if in Load mode, to the
94 //! current part if there is one. If shared is True, adds
95 //! also its shared ones (shared at all levels)
96 Standard_EXPORT void GetFromEntity (const Handle(Standard_Transient)& ent, const Standard_Boolean shared);
98 //! Adds a list of Entities (into Load mode or to a Part),
99 //! given as an Iterator
100 Standard_EXPORT void GetFromIter (const Interface_EntityIterator& iter);
102 //! Erases data (parts, entities) : "me" becomes empty and in
104 Standard_EXPORT void Reset();
106 //! Called by Clear, this method allows evaluation just before
107 //! iteration; its default is doing nothing, it is designed to
109 Standard_EXPORT virtual void Evaluate();
111 //! Returns entities which where loaded (not set into a sub-part)
112 Standard_EXPORT Interface_GraphContent Loaded() const;
114 //! Same as above, but under the form of a Graph
115 Standard_EXPORT Interface_Graph LoadedGraph() const;
117 //! Returns True if an Entity is loaded (either set into a
119 Standard_EXPORT Standard_Boolean IsLoaded (const Handle(Standard_Transient)& ent) const;
121 //! Returns True if an Entity is Present in a sub-part
122 Standard_EXPORT Standard_Boolean IsInPart (const Handle(Standard_Transient)& ent) const;
124 //! Returns number of the sub-part in which an Entity has been set
125 //! if it is not in a sub-part (or not loaded at all), Returns 0
126 Standard_EXPORT Standard_Integer EntityPartNum (const Handle(Standard_Transient)& ent) const;
128 //! Sets iteration to its beginning; calls Evaluate
129 Standard_EXPORT void Start();
131 //! Returns True if there are more sub-parts to iterate on
132 //! Note : an empty sub-part is not taken in account by Iteration
133 Standard_EXPORT Standard_Boolean More();
135 //! Sets iteration to the next sub-part
136 //! if there is not, IsSingle-Entities will raises an exception
137 Standard_EXPORT void Next();
139 //! Returns True if current sub-part is single (has only one Entity)
140 //! Error if there is no sub-part to iterate now
141 Standard_EXPORT Standard_Boolean IsSingle() const;
143 //! Returns the first entity of current sub-part, that is for a
144 //! Single one, the only one it contains
145 //! Error : same as above (end of iteration)
146 Standard_EXPORT Handle(Standard_Transient) FirstEntity() const;
148 //! Returns current sub-part, not as a "Value", but as an Iterator
149 //! on Entities it contains
150 //! Error : same as above (end of iteration)
151 Standard_EXPORT Interface_EntityIterator Entities() const;
153 Standard_EXPORT virtual ~IFGraph_SubPartsIterator();
159 Interface_Graph thegraph;
165 //! Returns the Graph used by <me>. Used to create another
166 //! SubPartsIterator from <me>
167 Standard_EXPORT const Interface_Graph& Graph() const;
170 Handle(TColStd_HSequenceOfInteger) theparts;
171 Handle(TColStd_HSequenceOfInteger) thefirsts;
172 Standard_Integer thepart;
173 Standard_Integer thecurr;
184 #endif // _IFGraph_SubPartsIterator_HeaderFile