// EdIRIC.cpp : implementation file
//

#include "stdafx.h"

#include "Defines.hpp"

#ifdef D_ED_IR_ACTIVE

#include "EdIRIC.hpp"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////
// class CPA_EdIR_IntermediateCode
//////////////////////////////////////////////////////////////////

/****************************************************************************/
CPA_EdIR_IntermediateCode::CPA_EdIR_IntermediateCode()
{
	m_lOffset=0;
	m_eNodeType=eInvalidNode;
	m_ucDepth=0;
	m_eType=eInvalidType;
	m_lIndex=0;
	m_pclModel=NULL;
	m_dfValue=0.0;
	MTH3D_M_vNullVector(&(m_tdstVector));
	m_csString="";
}

/****************************************************************************/
CPA_EdIR_IntermediateCode::CPA_EdIR_IntermediateCode(CPA_EdIR_IntermediateCode *pclIntermediateCode)
{
	m_lOffset=pclIntermediateCode->m_lOffset;
	m_eNodeType=pclIntermediateCode->m_eNodeType;
	m_ucDepth=pclIntermediateCode->m_ucDepth;
	m_eType=pclIntermediateCode->m_eType;
	m_lIndex=pclIntermediateCode->m_lIndex;
	m_pclModel=pclIntermediateCode->m_pclModel;
	m_dfValue=pclIntermediateCode->m_dfValue;
	MTH3D_M_vCopyVector(&(m_tdstVector),&(pclIntermediateCode->m_tdstVector));
	m_csString=pclIntermediateCode->m_csString;
}

/****************************************************************************/
CPA_EdIR_IntermediateCode::CPA_EdIR_IntermediateCode(long lOffset,tdeNodeType eNodeType,long lIndex,CPA_Actor *pclModel)
{
	m_lOffset=lOffset;
	m_eNodeType=eNodeType;
	m_ucDepth=0;
	m_eType=eUseLong;
	m_lIndex=lIndex;
	m_pclModel=pclModel;
	m_dfValue=0.0;
	MTH3D_M_vNullVector(&(m_tdstVector));
	m_csString="";
}

/****************************************************************************/
CPA_EdIR_IntermediateCode::CPA_EdIR_IntermediateCode(long lOffset,tdeNodeType eNodeType,double dfValue)
{
	m_lOffset=lOffset;
	m_eNodeType=eNodeType;
	m_ucDepth=0;
	m_eType=eUseReal;
	m_lIndex=0;
	m_pclModel=NULL;
	m_dfValue=dfValue;
	MTH3D_M_vNullVector(&(m_tdstVector));
	m_csString="";
}

/****************************************************************************/
CPA_EdIR_IntermediateCode::CPA_EdIR_IntermediateCode(long lOffset,tdeNodeType eNodeType,
																										 double dfX,double dfY,double dfZ)
{
	m_lOffset=lOffset;
	m_eNodeType=eNodeType;
	m_ucDepth=0;
	m_eType=eUseVector;
	m_lIndex=0;
	m_pclModel=NULL;
	m_dfValue=0.0;
	MTH3D_M_vSetVectorElements(&(m_tdstVector),MTH_M_xDoubleToReal(dfX),MTH_M_xDoubleToReal(dfY),MTH_M_xDoubleToReal(dfZ));
	m_csString="";
}

/****************************************************************************/
CPA_EdIR_IntermediateCode::CPA_EdIR_IntermediateCode(long lOffset,tdeNodeType eNodeType,CString csString)
{
	m_lOffset=lOffset;
	m_eNodeType=eNodeType;
	m_ucDepth=0;
	m_eType=eUseString;
	m_lIndex=0;
	m_pclModel=NULL;
	m_dfValue=0.0;
	MTH3D_M_vNullVector(&(m_tdstVector));
	m_csString=csString;
}

/****************************************************************************/
CString	CPA_EdIR_IntermediateCode::m_fn_csGetValue()
{
	CString	csValue;

	switch(m_eType)
	{
		case eUseLong:
			csValue.Format("%ld",m_lIndex);
			break;

		case eUseReal:
			csValue.Format("%f",m_dfValue);
			break;

		case eUseVector:
			csValue.Format("%f,%f,%f",
										 MTH3D_M_xGetXofVector(&(m_tdstVector)),
										 MTH3D_M_xGetYofVector(&(m_tdstVector)),
										 MTH3D_M_xGetZofVector(&(m_tdstVector)));
			break;

		case eUseString:
			csValue=m_csString;
			break;

		default:
			AfxMessageBox("[DEV : CPA_EdIR_IntermediateCode::m_fn_csGetValue] Unknown type !!!"); 
	}

	return csValue;
}

/****************************************************************************/
long CPA_EdIR_IntermediateCode::m_fn_lGetIndex()
{
	ASSERT(m_eType==eUseLong);

	return m_lIndex;
}

/****************************************************************************/
CPA_Actor *CPA_EdIR_IntermediateCode::m_fn_pclGetModel()
{
	ASSERT(m_eType==eUseLong);

	return m_pclModel;
}

/****************************************************************************/
double CPA_EdIR_IntermediateCode::m_fn_dfGetValue()
{
	ASSERT(m_eType==eUseReal);

	return m_dfValue;
}

/****************************************************************************/
MTH3D_tdstVector CPA_EdIR_IntermediateCode::m_fn_tdstGetVector()
{
	ASSERT(m_eType==eUseVector);

	return m_tdstVector;
}

/****************************************************************************/
CString CPA_EdIR_IntermediateCode::m_fn_csGetString()
{
/////////////////////////////////////////////////////////////////////////////////
//TEMPORAIRE
//	ASSERT(m_eType==eUseString);
	ASSERT(m_eType!=eInvalidType);

	return m_csString;
}

/****************************************************************************/
long CPA_EdIR_IntermediateCode::m_fn_lGetOffset()
{
	return m_lOffset;
}

/****************************************************************************/
tdeNodeType CPA_EdIR_IntermediateCode::m_fn_tdeGetNodeType()
{
	return m_eNodeType;
}

/****************************************************************************/
unsigned char CPA_EdIR_IntermediateCode::m_fn_ucGetDepth()
{
	return m_ucDepth;
}

/****************************************************************************/
void CPA_EdIR_IntermediateCode::m_fn_vSetIndex(long lIndex)
{
	m_eType=eUseLong;
	m_lIndex=lIndex;
}

/****************************************************************************/
void CPA_EdIR_IntermediateCode::m_fn_vSetValue(double dfValue)
{
	m_eType=eUseReal;
	m_dfValue=dfValue;
}

/****************************************************************************/
void CPA_EdIR_IntermediateCode::m_fn_vSetNodeType(tdeNodeType eNodeType)
{
	m_eNodeType=eNodeType;
}

/****************************************************************************/
void CPA_EdIR_IntermediateCode::m_fn_vSetDepth(unsigned char ucDepth)
{
	m_ucDepth=ucDepth;
}

/****************************************************************************/
void CPA_EdIR_IntermediateCode::m_fn_vSetModel(CPA_Actor *pclModel)
{
	m_pclModel=pclModel;
}

/////////////////////////////////////////////////////////////////////////////////
//TEMPORAIRE
/****************************************************************************/
void CPA_EdIR_IntermediateCode::m_fn_vSetString(CString csString)
{
	m_csString=csString;
}
/////////////////////////////////////////////////////////////////////////////////

#endif //D_ED_IR_ACTIVE