#ifndef GR_Entity_h
#define GR_Entity_h

// The following class is defined primarily so that ITAPS entities will
// work smoothly.  In particular, with a base Entity class that all
// GRUMMP mesh pieces derive from, in the ITAPS interface (a) many entity
// queries can be handled trivially by polymorphism (perhaps easier than
// in a class that has internal state, interestingly) and (b) more
// importantly, when a function requires the return of a collection of
// entity handles, I can return voided pointers to GRUMMP objects, and
// never have to address management of memory for newly-minted entities.

#include "GR_Classes.h"

#ifdef ITAPS
#include "GR_iMesh_Classes.h"
typedef iBase_EntityHandle_Private GRUMMP_Entity;
class Entity : public iBase_EntityHandle_Private {

#else

// If we're not building for ITAPS, then there's no iBase_EntityHandle_Private struct around to inherit from.
typedef Entity GRUMMP_Entity;
class Entity {

#endif

public:
  virtual ~Entity() {}
  virtual const Vert *pVVert(const int iV) const = 0;
  virtual const Face *pFFace(const int iF) const = 0;
  virtual const Cell *pCCell(const int iC) const = 0;
  Vert *pVVert(const int iV)
    {return const_cast<Vert*>(static_cast<const Entity*>(this)->pVVert(iV));}
  Face *pFFace(const int iF)
    {return const_cast<Face*>(static_cast<const Entity*>(this)->pFFace(iF));}
  Cell *pCCell(const int iC)
    {return const_cast<Cell*>(static_cast<const Entity*>(this)->pCCell(iC));}
  virtual void vAllVertHandles(GRUMMP_Entity* aHandle[]) const = 0;
  virtual void vAllFaceHandles(GRUMMP_Entity* aHandle[]) const = 0;
  virtual void vAllCellHandles(GRUMMP_Entity* aHandle[]) const = 0;
  virtual int iNumVerts() const = 0;
  virtual int iNumCells() const = 0;
  virtual int iNumFaces() const = 0;
  virtual void vMarkDeleted() = 0;
#ifdef ITAPS
  virtual int iTopologicalDimension() const = 0;
  virtual int eEntType() const = 0;
  virtual int eEntTopology() const = 0;
#endif
};

#endif // GR_Entity_h
