// File generated by CPPExt (Value)
//
//                     Copyright (C) 1991 - 2000 by  
//                      Matra Datavision SA.  All rights reserved.
//  
//                     Copyright (C) 2001 - 2004 by
//                     Open CASCADE SA.  All rights reserved.
// 
// This file is part of the Open CASCADE Technology software.
//
// This software may be distributed and/or modified under the terms and
// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
// and appearing in the file LICENSE included in the packaging of this file.
//  
// This software is distributed on an "AS IS" basis, without warranty of any
// kind, and Open CASCADE SA hereby disclaims all such warranties,
// including without limitation, any warranties of merchantability, fitness
// for a particular purpose or non-infringement. Please see the License for
// the specific terms and conditions governing rights and limitations under the
// License.

#ifndef _IFGraph_SubPartsIterator_HeaderFile
#define _IFGraph_SubPartsIterator_HeaderFile

#ifndef _Interface_Graph_HeaderFile
#include <Interface_Graph.hxx>
#endif
#ifndef _Handle_TColStd_HSequenceOfInteger_HeaderFile
#include <Handle_TColStd_HSequenceOfInteger.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Handle_Interface_InterfaceModel_HeaderFile
#include <Handle_Interface_InterfaceModel.hxx>
#endif
#ifndef _Handle_Standard_Transient_HeaderFile
#include <Handle_Standard_Transient.hxx>
#endif
class TColStd_HSequenceOfInteger;
class Standard_OutOfRange;
class Standard_NoSuchObject;
class Interface_InterfaceError;
class Interface_Graph;
class Interface_InterfaceModel;
class Standard_Transient;
class Interface_EntityIterator;
class Interface_GraphContent;


#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif

//! defines general form for graph classes of which result is <br>
//!           not a single iteration on Entities, but a nested one : <br>
//!           External iteration works on sub-parts, identified by each <br>
//!           class (according to its algorithm) <br>
//!           Internal Iteration concerns Entities of a sub-part <br>
//!           Sub-Parts are assumed to be disjoined; if they are not, <br>
//!           the first one has priority <br>
//! <br>
//!           A SubPartsIterator can work in two steps : first, load <br>
//!           entities which have to be processed <br>
//!           then, analyse to set those entities into sub-parts <br>
class IFGraph_SubPartsIterator  {

public:

    void* operator new(size_t,void* anAddress) 
      {
        return anAddress;
      }
    void* operator new(size_t size) 
      { 
        return Standard::Allocate(size); 
      }
    void  operator delete(void *anAddress) 
      { 
        if (anAddress) Standard::Free((Standard_Address&)anAddress); 
      }
 // Methods PUBLIC
 // 

//! Creates with a Graph, whole or parts of it <br>
//!           whole True  : works on the entire Model <br>
//!           whole False : empty, ready to be filled <br>
//!           SubPartIterator is set to load entities <br>
Standard_EXPORT IFGraph_SubPartsIterator(const Interface_Graph& agraph,const Standard_Boolean whole);

//! Creates a SubPartIterator from another one and gets its Data <br>
//!           Note that only non-empty sub-parts are taken into account <br>
//!           PartNum is set to the last one <br>
Standard_EXPORT IFGraph_SubPartsIterator(IFGraph_SubPartsIterator& other);

//! Gets Parts from another SubPartsIterator (in addition to the <br>
//!           ones already recorded) <br>
//!           Error if both SubPartsIterators are not based on the same Model <br>
Standard_EXPORT   void GetParts(IFGraph_SubPartsIterator& other) ;

//! Returns the Model with which this Iterator was created <br>
Standard_EXPORT   Handle_Interface_InterfaceModel Model() const;

//! Adds an empty part and sets it to receive entities <br>
Standard_EXPORT   void AddPart() ;

//! Returns count of registered parts <br>
Standard_EXPORT   Standard_Integer NbParts() const;

//! Returns numero of part which currently receives entities <br>
//!           (0 at load time) <br>
Standard_EXPORT   Standard_Integer PartNum() const;

//! Sets SubPartIterator to get Entities (by GetFromEntity & <br>
//!           GetFromIter) into load status, to be analysed later <br>
Standard_EXPORT   void SetLoad() ;

//! Sets numero of receiving part to a new value <br>
//!           Error if not in range (1-NbParts) <br>
Standard_EXPORT   void SetPartNum(const Standard_Integer num) ;

//! Adds an Entity : into load status if in Load mode, to the <br>
//!           current part if there is one. If shared is True, adds <br>
//!           also its shared ones (shared at all levels) <br>
Standard_EXPORT   void GetFromEntity(const Handle(Standard_Transient)& ent,const Standard_Boolean shared) ;

//! Adds a list of Entities (into Load mode or to a Part), <br>
//!           given as an Iterator <br>
Standard_EXPORT   void GetFromIter(const Interface_EntityIterator& iter) ;

//! Erases data (parts, entities) : "me" becomes empty and in <br>
//!           load status <br>
Standard_EXPORT   void Reset() ;

//! Called by Clear, this method allows evaluation just before <br>
//!           iteration; its default is doing nothing, it is designed to <br>
//!           be redefined <br>
Standard_EXPORT virtual  void Evaluate() ;

//! Returns entities which where loaded (not set into a sub-part) <br>
Standard_EXPORT   Interface_GraphContent Loaded() const;

//! Same as above, but under the form of a Graph <br>
Standard_EXPORT   Interface_Graph LoadedGraph() const;

//! Returns True if an Entity is loaded (either set into a <br>
//!           sub-part or not) <br>
Standard_EXPORT   Standard_Boolean IsLoaded(const Handle(Standard_Transient)& ent) const;

//! Returns True if an Entity is Present in a sub-part <br>
Standard_EXPORT   Standard_Boolean IsInPart(const Handle(Standard_Transient)& ent) const;

//! Returns number of the sub-part in which an Entity has been set <br>
//!           if it is not in a sub-part (or not loaded at all), Returns 0 <br>
Standard_EXPORT   Standard_Integer EntityPartNum(const Handle(Standard_Transient)& ent) const;

//! Sets iteration to its beginning; calls Evaluate <br>
Standard_EXPORT   void Start() ;

//! Returns True if there are more sub-parts to iterate on <br>
//!           Note : an empty sub-part is not taken in account by Iteration <br>
Standard_EXPORT   Standard_Boolean More() ;

//! Sets iteration to the next sub-part <br>
//!           if there is not, IsSingle-Entities will raises an exception <br>
Standard_EXPORT   void Next() ;

//! Returns True if current sub-part is single (has only one Entity) <br>
//!           Error if there is no sub-part to iterate now <br>
Standard_EXPORT   Standard_Boolean IsSingle() const;

//! Returns the first entity of current sub-part, that is for a <br>
//!           Single one, the only one it contains <br>
//!           Error : same as above (end of iteration) <br>
Standard_EXPORT   Handle_Standard_Transient FirstEntity() const;

//! Returns current sub-part, not as a "Value", but as an Iterator <br>
//!           on Entities it contains <br>
//!           Error : same as above (end of iteration) <br>
Standard_EXPORT   Interface_EntityIterator Entities() const;


Standard_EXPORT virtual  void Delete() ;
Standard_EXPORT virtual ~IFGraph_SubPartsIterator() { Delete(); }





protected:

 // Methods PROTECTED
 // 


 // Fields PROTECTED
 //
Interface_Graph thegraph;


private: 

 // Methods PRIVATE
 // 

//! Returns the Graph used by <me>. Used to create another <br>
//!           SubPartsIterator from <me> <br>
Standard_EXPORT  const Interface_Graph& Graph() const;


 // Fields PRIVATE
 //
Handle_TColStd_HSequenceOfInteger theparts;
Handle_TColStd_HSequenceOfInteger thefirsts;
Standard_Integer thepart;
Standard_Integer thecurr;


};





// other Inline functions and methods (like "C++: function call" methods)
//


#endif
