Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-05 09:22:34

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 <Standard_Integer.hxx>
0026 #include <NCollection_Sequence.hxx>
0027 #include <NCollection_HSequence.hxx>
0028 #include <Standard_Boolean.hxx>
0029 class Interface_InterfaceModel;
0030 class Standard_Transient;
0031 class Interface_EntityIterator;
0032 class Interface_GraphContent;
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   DEFINE_STANDARD_ALLOC
0049 
0050   //! Creates with a Graph, whole or parts of it
0051   //! whole True  : works on the entire Model
0052   //! whole False : empty, ready to be filled
0053   //! SubPartIterator is set to load entities
0054   Standard_EXPORT IFGraph_SubPartsIterator(const Interface_Graph& agraph, const bool whole);
0055 
0056   //! Creates a SubPartIterator from another one and gets its Data
0057   //! Note that only non-empty sub-parts are taken into account
0058   //! PartNum is set to the last one
0059   Standard_EXPORT IFGraph_SubPartsIterator(IFGraph_SubPartsIterator& other);
0060 
0061   //! Gets Parts from another SubPartsIterator (in addition to the
0062   //! ones already recorded)
0063   //! Error if both SubPartsIterators are not based on the same Model
0064   Standard_EXPORT void GetParts(IFGraph_SubPartsIterator& other);
0065 
0066   //! Returns the Model with which this Iterator was created
0067   Standard_EXPORT occ::handle<Interface_InterfaceModel> Model() const;
0068 
0069   //! Adds an empty part and sets it to receive entities
0070   Standard_EXPORT void AddPart();
0071 
0072   //! Returns count of registered parts
0073   Standard_EXPORT int NbParts() const;
0074 
0075   //! Returns numero of part which currently receives entities
0076   //! (0 at load time)
0077   Standard_EXPORT int PartNum() const;
0078 
0079   //! Sets SubPartIterator to get Entities (by GetFromEntity &
0080   //! GetFromIter) into load status, to be analysed later
0081   Standard_EXPORT void SetLoad();
0082 
0083   //! Sets numero of receiving part to a new value
0084   //! Error if not in range (1-NbParts)
0085   Standard_EXPORT void SetPartNum(const int num);
0086 
0087   //! Adds an Entity : into load status if in Load mode, to the
0088   //! current part if there is one. If shared is True, adds
0089   //! also its shared ones (shared at all levels)
0090   Standard_EXPORT void GetFromEntity(const occ::handle<Standard_Transient>& ent, const bool shared);
0091 
0092   //! Adds a list of Entities (into Load mode or to a Part),
0093   //! given as an Iterator
0094   Standard_EXPORT void GetFromIter(const Interface_EntityIterator& iter);
0095 
0096   //! Erases data (parts, entities) : "me" becomes empty and in
0097   //! load status
0098   Standard_EXPORT void Reset();
0099 
0100   //! Called by Clear, this method allows evaluation just before
0101   //! iteration; its default is doing nothing, it is designed to
0102   //! be redefined
0103   Standard_EXPORT virtual void Evaluate();
0104 
0105   //! Returns entities which where loaded (not set into a sub-part)
0106   Standard_EXPORT Interface_GraphContent Loaded() const;
0107 
0108   //! Same as above, but under the form of a Graph
0109   Standard_EXPORT Interface_Graph LoadedGraph() const;
0110 
0111   //! Returns True if an Entity is loaded (either set into a
0112   //! sub-part or not)
0113   Standard_EXPORT bool IsLoaded(const occ::handle<Standard_Transient>& ent) const;
0114 
0115   //! Returns True if an Entity is Present in a sub-part
0116   Standard_EXPORT bool IsInPart(const occ::handle<Standard_Transient>& ent) const;
0117 
0118   //! Returns number of the sub-part in which an Entity has been set
0119   //! if it is not in a sub-part (or not loaded at all), Returns 0
0120   Standard_EXPORT int EntityPartNum(const occ::handle<Standard_Transient>& ent) const;
0121 
0122   //! Sets iteration to its beginning; calls Evaluate
0123   Standard_EXPORT void Start();
0124 
0125   //! Returns True if there are more sub-parts to iterate on
0126   //! Note : an empty sub-part is not taken in account by Iteration
0127   Standard_EXPORT bool More();
0128 
0129   //! Sets iteration to the next sub-part
0130   //! if there is not, IsSingle-Entities will raises an exception
0131   Standard_EXPORT void Next();
0132 
0133   //! Returns True if current sub-part is single (has only one Entity)
0134   //! Error if there is no sub-part to iterate now
0135   Standard_EXPORT bool IsSingle() const;
0136 
0137   //! Returns the first entity of current sub-part, that is for a
0138   //! Single one, the only one it contains
0139   //! Error : same as above (end of iteration)
0140   Standard_EXPORT occ::handle<Standard_Transient> FirstEntity() const;
0141 
0142   //! Returns current sub-part, not as a "Value", but as an Iterator
0143   //! on Entities it contains
0144   //! Error : same as above (end of iteration)
0145   Standard_EXPORT Interface_EntityIterator Entities() const;
0146 
0147   Standard_EXPORT virtual ~IFGraph_SubPartsIterator();
0148 
0149 protected:
0150   Interface_Graph thegraph;
0151 
0152 private:
0153   //! Returns the Graph used by <me>. Used to create another
0154   //! SubPartsIterator from <me>
0155   Standard_EXPORT const Interface_Graph& Graph() const;
0156 
0157   occ::handle<NCollection_HSequence<int>> theparts;
0158   occ::handle<NCollection_HSequence<int>> thefirsts;
0159   int                                     thepart;
0160   int                                     thecurr;
0161 };
0162 
0163 #endif // _IFGraph_SubPartsIterator_HeaderFile