#include "stdAfx.h"
#include "vector3D.h"
#include "vector3DGroup.h"

Vector3DGroup::Vector3DGroup(int iInMaxElements)
{
	setLockMem( 0 );

	iNumElements = 0;
	iMaxElements = iInMaxElements;
	pElementList = new Vector3D[iInMaxElements];
}

Vector3DGroup::~Vector3DGroup()
{
	freeMem();
}

void Vector3DGroup::addElement(Vector3D& inVector)
{
	if(iNumElements < iMaxElements) {
		pElementList[iNumElements].assign(inVector);
		iNumElements++;
	}
	else {
		MessageBox( NULL, "face","face", MB_OK );//throw( "no more room element" );
	}
		
}

void Vector3DGroup::setNumElements( int iNewNumElements )
{
	iNumElements = iNewNumElements;
}

int Vector3DGroup::getNumElements()
{
	return iNumElements;
}

int Vector3DGroup::getMaxElements()
{
	return iMaxElements;
}

void Vector3DGroup::setElementAt(int index, float fInX, float fInY, float fInZ) {
	if(index < iNumElements) {
		pElementList[index].assign( Vector3D( fInX, fInY, fInZ ) );
	}
}

void Vector3DGroup::setElementAt(int index , Vector3D& inVector) {
	if(index < iNumElements) {
		pElementList[index].assign( inVector );
	}
}

Vector3D Vector3DGroup::getElementAt(int index)
{
	return pElementList[index];
}

void Vector3DGroup::freeMem()
{
//	if ( ! getLockMem() )
//	{
		delete pElementList;
//	}
}

void Vector3DGroup::setLockMem( int iInLockMem )
{
	iLockMem = iInLockMem;
}

int Vector3DGroup::getLockMem()
{
	return iLockMem;
}

// EOF