#pragma once #include "akLinker.h" //#include "akSTLVector.h" //namespace akSTL //{ #include template class CakTrajectory { public: CakTrajectory(); ~CakTrajectory(); void clear(); //¸Þ¸ð¸® »èÁ¦´Â ¾ÈµÊ void setMemSize(unsigned int memsize); //memsize°¡ 0À϶§ ¸Þ¸ð¸® »èÁ¦ void pointAdd(T point); void pointSet( unsigned int nindex , T point ); void getPoints(T* pPointBuffer, unsigned int nBufferLength); int size(){return m_nPointNum;}; T& operator [](unsigned int nindex); CakTrajectory& operator= (CakTrajectory& traj); static unsigned int s_TrajectorySize; //°¡´ÉÇÏ¸é ¾Æ·¡ÀÇ ¸â¹ö º¯¼ö¿¡ Á÷Á¢ ¼öÁ¤Àº ÇÏÁö ¸»°Í!! public: int m_nMemSize; //È®º¸ ¸Þ¸ð¸® »çÀÌÁî int m_nPointIndex; //ÇöÀç À妽º int m_nPointNum; //ÇöÀç ÀÔ·ÂµÈ Point °¹¼ö T* m_pPoints; //µ¥ÀÌÅÍ º¯¼ö }; //} template unsigned int CakTrajectory::s_TrajectorySize = 100; template CakTrajectory::CakTrajectory(void) { m_pPoints = NULL; m_nMemSize = 0; clear(); setMemSize(s_TrajectorySize); }; template CakTrajectory::~CakTrajectory(void) { setMemSize(0); }; template void CakTrajectory::clear() //¸Þ¸ð¸® »èÁ¦´Â ¾ÈµÊ { m_nMemSize; //È®º¸ ¸Þ¸ð¸® »çÀÌÁî m_nPointIndex = -1; //ÇöÀç À妽º m_nPointNum = 0; //ÇöÀç ÀÔ·ÂµÈ Point °¹¼ö //m_pPoints; //µ¥ÀÌÅÍ º¯¼ö } template void CakTrajectory::setMemSize(unsigned int memsize) //memsize°¡ 0À϶§ ¸Þ¸ð¸® »èÁ¦ { //clear if(m_pPoints != NULL) { clear(); m_nMemSize = 0; delete [] m_pPoints; m_pPoints = NULL; } if(memsize > 0) { m_nMemSize = memsize; m_pPoints = new T [m_nMemSize]; } } template void CakTrajectory::pointAdd(T point) { m_nPointIndex++; if(m_nPointIndex >= m_nMemSize) { m_nPointIndex = 0; } m_nPointNum++; if(m_nPointNum >= m_nMemSize) { m_nPointNum = m_nMemSize; } m_pPoints[m_nPointIndex] = point; } template void CakTrajectory::pointSet( unsigned int nindex , T point ) { int pointindex = m_nPointIndex-nindex; if(pointindex<0) pointindex = m_nPointNum + pointindex; m_pPoints[pointindex] = point; } template T& CakTrajectory::operator[]( unsigned int nindex ) { int pointindex = m_nPointIndex-nindex; if(pointindex<0) pointindex = m_nPointNum + pointindex; return m_pPoints[pointindex]; } template CakTrajectory& CakTrajectory::operator=( CakTrajectory& traj ) { if(m_nMemSize != traj.m_nMemSize) { if(m_pPoints) { delete [] m_pPoints; } m_pPoints = new T[traj.m_nMemSize]; } m_nMemSize = traj.m_nMemSize; m_nPointIndex = traj.m_nPointIndex; m_nPointNum = traj.m_nPointNum; memcpy(m_pPoints, traj.m_pPoints, sizeof(khVector3d)*traj.m_nMemSize); return *this; }