#ifndef INCLUDE_NASTCELLFIELD2D_H
#define INCLUDE_NASTCELLFIELD2D_H

//-----------------------------------------------------------------------------
//  NastCellField2d.h
//-----------------------------------------------------------------------------
//
//  Copyright (C) 1998 Technische Universitaet Muenchen, Germany
//  written by Bernhard Brueck
//
//  This file is part of Nast++
//
//-----------------------------------------------------------------------------
// CNastCellField2d entspricht dem ehemaligen Flagfeld. Es werden dort die 
// einzelnen Zellen gespeichert und erfragt werden. Beim setzen einer
// Zelle werden auch automatisch alle Nachbarzellen richtig gesetzt.
//-----------------------------------------------------------------------------
//  Aenderungen:
//

#include "NastConfig.h"
#include "NastArray2d.h"
#include "NastCell2d.h"
#include "NastBox2d.h"

class CNastCellField2d: public CNastObject
{
public:
    //-------------------------------------------------------------------------
    //                         Konstruktor + Destruktor
    //-------------------------------------------------------------------------
    // 
    //  Feld der Groesse 0..nSizeI-1, 0..nSizeJ-1 erzeugen
    CNastCellField2d( const CNastBox2d &box, int nSizeI, int nSizeJ );
    ~CNastCellField2d();

    //-------------------------------------------------------------------------
    //                             Memberfunktionen
    //-------------------------------------------------------------------------
    //  cell liefert eine einzelne Zelle
    //  setCellType  legt den Type einer Zelle fest
    //  countFluid   liefert die Anzahl der Fluidzellen zurueck
    
    const CNastCell2d& cell( int i, int j) const;
    void setCellType( int i, int j, CNastCell2d::Type type);
    int sizeI() const;
    int sizeJ() const;

    const CNastBox2d &box() const;
    int countFluid() const;

    //-------------------------------------------------------------------------
    //                                  Debug
    //-------------------------------------------------------------------------
    //  debugInfo    gibt Information ueber den Zustand des Objekts aus
    //  assertValid  testet das Objekt auf Integritaet
    //
    virtual void debugDump( CNastDumpContext &dumpContext ) const;
    virtual void assertValid() const;

private:
    // nicht impl.
    CNastCellField2d( const CNastCellField2d &other);	            
    const CNastCellField2d& operator=( const CNastCellField2d &other );

    //-------------------------------------------------------------------------
    //                            Membervariablen
    //-------------------------------------------------------------------------
    CNastArray2d<CNastCell2d> m_arrCells;    // Array mit den Zellen
    CNastBox2d m_box;
    int m_nCountFluid;		             // Anzahl der Fluidzellen
};


//-------------------------------------------------------------------------
//                            inline
//-------------------------------------------------------------------------
inline const CNastCell2d& 
CNastCellField2d::cell( int i, int j) const
{
    return m_arrCells(i ,j);
}

inline int 
CNastCellField2d::sizeI() const
{
    return m_arrCells.sizeI();
}

inline int 
CNastCellField2d::sizeJ() const
{
    return m_arrCells.sizeJ();
}

inline const CNastBox2d &
CNastCellField2d::box() const
{
    return m_box;
}

inline int
CNastCellField2d::countFluid() const
{
    return m_nCountFluid;
}

#endif // INCLUDE_NASTCELLFIELD2D_H

