/****************************************************************************
** GMAF - The Geometry Modeling Algorithms Framework
**
** Created : 04032000
**
** Copyright (C) 2000 by Le-Jeng Shiue.  All rights reserved.
**
****************************************************************************/
#ifndef gmafPCCMQuad_H
#define gmafPCCMQuad_H

#include "assert.h"

#include "BlitzExtension/blitzConfig.h"
#include "CgalExtension/cgalConfig.h"
#include "DataStructure/gmafDataStructure.h"

class gmafQuad;

/**
   gmafPCCMQuad: See appendix of PCCM
*/
class gmafPCCMQuad : public gmafDataStructure {
// ENUMS
public:
  enum { UPPER_LEFT = 0,
	 LOWER_LEFT = 1,
	 LOWER_RIGHT = 2,
	 UPPER_RIGHT = 3};

// VARIABLES
/**@name Class Variables */
//@{
protected:
  /** 
      The input quad for this pccmquad
  */
  gmafQuad* mpQuad;
  /** 
      This array is the pccmquad matrix 
  */
  VertexMatrix2D mPCCMControlNet;

private:

//@}

// METHODS
/**@name Class Methods */
//@{
public:
  /**
     Constructor of gmafPCCMQuad
  */
  gmafPCCMQuad(gmafQuad* q);

  /**
     Destructor of gmafPCCMQuad
  */    
  virtual ~gmafPCCMQuad();
  
  inline int getWidth();
  inline int getHeight();

  inline Vertex3D& getAlphaCorner(int c);
  /**
     Get the control net of this pccmquad
   */
  inline VertexMatrix2D& getPCCMControlNet();

  /**
     Dump the quad matrix
   */
  void dump();
protected:
  
private:

};

inline int gmafPCCMQuad::getWidth() { return mPCCMControlNet.cols(); }

inline int gmafPCCMQuad::getHeight() { return mPCCMControlNet.rows(); }

inline VertexMatrix2D& gmafPCCMQuad::getPCCMControlNet() { 
  return mPCCMControlNet; 
}

inline Vertex3D& gmafPCCMQuad::getAlphaCorner(int c) {
  int h = mPCCMControlNet.rows();
  int w = mPCCMControlNet.cols();
  if (c == UPPER_LEFT) return mPCCMControlNet(0, 0);
  else if (c == LOWER_LEFT) return mPCCMControlNet(h-1, 0);
  else if (c == LOWER_RIGHT) return mPCCMControlNet(h-1, w-1);
  else if (c == UPPER_RIGHT) return mPCCMControlNet(0, w-1);
  else assert(false);
}

#endif gmafPCCMQuad_H
