/****************************************************************************
** GMAF - The Geometry Modeling Algorithms Framework
**
** Created : 07132000
**
** Copyright (C) 2000 by Le-Jeng Shiue.  All rights reserved.
**
****************************************************************************/
#ifdef _MAM_VERSION
#include <vrs/vrs.h>
#include <mam/mam.h>

#include "vrsSubQuadVertexIterator.h"
#endif _MAM_VERSION

#include "gmafCCSubVisualObject.h"
#include "gmafQuadMap.h"
#include "gmafQuad.h"

gmafCCSubVisualObject::gmafCCSubVisualObject(gmafQuadMap* qm) 
  : mpQuadMap(qm) {
  mQuadList = mpQuadMap->getQuadList();
}

gmafCCSubVisualObject::~gmafCCSubVisualObject() {
}


#ifdef _MAM_VERSION

MThing* gmafCCSubVisualObject::createMAMObject() {
  return (MThing*) visualizeQuadMap();
}

RSharedObj* gmafCCSubVisualObject::visualizeQuadMap() {
  MThing* obj = new MThing();
  
  obj->append(new RFaceStyle(mStyle, mStyle));

  for (int i = 0; i < mQuadList.size(); i++)
    obj->append(visualizeQuad(mQuadList[i]));
  
  return obj;
}

inline RSharedObj* gmafCCSubVisualObject::visualizeQuad(gmafQuad* quad) {
  RPolygonSet* p = new RPolygonSet(RPolygonSet::Quads, 
				   new vrsSubQuadVertexIterator(quad));
  return p;
}

RSharedObj* gmafCCSubVisualObject::visualizeQuad(gmafQuad* quad, int style) {
  MThing* obj = new MThing();
  obj->append(new RFaceStyle(style, style));
  RPolygonSet* q = new RPolygonSet(RPolygonSet::Quads, 
				   new vrsSubQuadVertexIterator(quad));
  obj->append(q);
  return obj;
}

#endif _MAM_VERSION


#ifdef _OGL_VERSION
void gmafCCSubVisualObject::display() {
}
#endif _OGL_VERSION
