Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:53

0001 // Created on: 1992-09-23
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 _IFGraph_SubPartsIterator_HeaderFile
0018 #define _IFGraph_SubPartsIterator_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Interface_Graph.hxx>
0025 #include <TColStd_HSequenceOfInteger.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <Standard_Boolean.hxx>
0028 class Interface_InterfaceModel;
0029 class Standard_Transient;
0030 class Interface_EntityIterator;
0031 class Interface_GraphContent;
0032 
0033 
0034 //! defines general form for graph classes of which result is
0035 //! not a single iteration on Entities, but a nested one :
0036 //! External iteration works on sub-parts, identified by each
0037 //! class (according to its algorithm)
0038 //! Internal Iteration concerns Entities of a sub-part
0039 //! Sub-Parts are assumed to be disjoined; if they are not,
0040 //! the first one has priority
0041 //!
0042 //! A SubPartsIterator can work in two steps : first, load
0043 //! entities which have to be processed
0044 //! then, analyse to set those entities into sub-parts
0045 class IFGraph_SubPartsIterator 
0046 {
0047 public:
0048 
0049   DEFINE_STANDARD_ALLOC
0050 
0051   
0052   //! Creates with a Graph, whole or parts of it
0053   //! whole True  : works on the entire Model
0054   //! whole False : empty, ready to be filled
0055   //! SubPartIterator is set to load entities
0056   Standard_EXPORT IFGraph_SubPartsIterator(const Interface_Graph& agraph, const Standard_Boolean whole);
0057   
0058   //! Creates a SubPartIterator from another one and gets its Data
0059   //! Note that only non-empty sub-parts are taken into account
0060   //! PartNum is set to the last one
0061   Standard_EXPORT IFGraph_SubPartsIterator(IFGraph_SubPartsIterator& other);
0062   
0063   //! Gets Parts from another SubPartsIterator (in addition to the
0064   //! ones already recorded)
0065   //! Error if both SubPartsIterators are not based on the same Model
0066   Standard_EXPORT void GetParts (IFGraph_SubPartsIterator& other);
0067   
0068   //! Returns the Model with which this Iterator was created
0069   Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
0070   
0071   //! Adds an empty part and sets it to receive entities
0072   Standard_EXPORT void AddPart();
0073   
0074   //! Returns count of registered parts
0075   Standard_EXPORT Standard_Integer NbParts() const;
0076   
0077   //! Returns numero of part which currently receives entities
0078   //! (0 at load time)
0079   Standard_EXPORT Standard_Integer PartNum() const;
0080   
0081   //! Sets SubPartIterator to get Entities (by GetFromEntity &
0082   //! GetFromIter) into load status, to be analysed later
0083   Standard_EXPORT void SetLoad();
0084   
0085   //! Sets numero of receiving part to a new value
0086   //! Error if not in range (1-NbParts)
0087   Standard_EXPORT void SetPartNum (const Standard_Integer num);
0088   
0089   //! Adds an Entity : into load status if in Load mode, to the
0090   //! current part if there is one. If shared is True, adds
0091   //! also its shared ones (shared at all levels)
0092   Standard_EXPORT void GetFromEntity (const Handle(Standard_Transient)& ent, const Standard_Boolean shared);
0093   
0094   //! Adds a list of Entities (into Load mode or to a Part),
0095   //! given as an Iterator
0096   Standard_EXPORT void GetFromIter (const Interface_EntityIterator& iter);
0097   
0098   //! Erases data (parts, entities) : "me" becomes empty and in
0099   //! load status
0100   Standard_EXPORT void Reset();
0101   
0102   //! Called by Clear, this method allows evaluation just before
0103   //! iteration; its default is doing nothing, it is designed to
0104   //! be redefined
0105   Standard_EXPORT virtual void Evaluate();
0106   
0107   //! Returns entities which where loaded (not set into a sub-part)
0108   Standard_EXPORT Interface_GraphContent Loaded() const;
0109   
0110   //! Same as above, but under the form of a Graph
0111   Standard_EXPORT Interface_Graph LoadedGraph() const;
0112   
0113   //! Returns True if an Entity is loaded (either set into a
0114   //! sub-part or not)
0115   Standard_EXPORT Standard_Boolean IsLoaded (const Handle(Standard_Transient)& ent) const;
0116   
0117   //! Returns True if an Entity is Present in a sub-part
0118   Standard_EXPORT Standard_Boolean IsInPart (const Handle(Standard_Transient)& ent) const;
0119   
0120   //! Returns number of the sub-part in which an Entity has been set
0121   //! if it is not in a sub-part (or not loaded at all), Returns 0
0122   Standard_EXPORT Standard_Integer EntityPartNum (const Handle(Standard_Transient)& ent) const;
0123   
0124   //! Sets iteration to its beginning; calls Evaluate
0125   Standard_EXPORT void Start();
0126   
0127   //! Returns True if there are more sub-parts to iterate on
0128   //! Note : an empty sub-part is not taken in account by Iteration
0129   Standard_EXPORT Standard_Boolean More();
0130   
0131   //! Sets iteration to the next sub-part
0132   //! if there is not, IsSingle-Entities will raises an exception
0133   Standard_EXPORT void Next();
0134   
0135   //! Returns True if current sub-part is single (has only one Entity)
0136   //! Error if there is no sub-part to iterate now
0137   Standard_EXPORT Standard_Boolean IsSingle() const;
0138   
0139   //! Returns the first entity of current sub-part, that is for a
0140   //! Single one, the only one it contains
0141   //! Error : same as above (end of iteration)
0142   Standard_EXPORT Handle(Standard_Transient) FirstEntity() const;
0143   
0144   //! Returns current sub-part, not as a "Value", but as an Iterator
0145   //! on Entities it contains
0146   //! Error : same as above (end of iteration)
0147   Standard_EXPORT Interface_EntityIterator Entities() const;
0148   
0149   Standard_EXPORT virtual ~IFGraph_SubPartsIterator();
0150 
0151 protected:
0152 
0153 
0154 
0155   Interface_Graph thegraph;
0156 
0157 
0158 private:
0159 
0160   
0161   //! Returns the Graph used by <me>. Used to create another
0162   //! SubPartsIterator from <me>
0163   Standard_EXPORT const Interface_Graph& Graph() const;
0164 
0165 
0166   Handle(TColStd_HSequenceOfInteger) theparts;
0167   Handle(TColStd_HSequenceOfInteger) thefirsts;
0168   Standard_Integer thepart;
0169   Standard_Integer thecurr;
0170 
0171 
0172 };
0173 
0174 
0175 
0176 
0177 
0178 
0179 
0180 #endif // _IFGraph_SubPartsIterator_HeaderFile