//------------------------------------------------------------
// $Id: ddaInfo.cc,v 1.1.1.1 1999/11/25 06:26:09 yamauchi Exp $
//------------------------------------------------------------
//	DDA information implementation
//	1998年1月29日(木)
//	(C) 1995-1998 Copyright YAMAUCHI Hitoshi 山内 斉
//	3DDDA のための情報
//------------------------------------------------------------
#include <assert.h>
#include "ddaInfo.h"

//------------------------------
// DDA の初期設定が済んだことを記す
//------------------------------
void DDAInfoClass::
setDDAset(void)
{
#ifndef REDUCE_VERBOSE_INFO
    if(this->mIsInit == YES)
    {
	cout << "Warning: 3DDDAA Info is already initialized." << endl;
    }
#endif
    this->mIsInit = YES;	
}

// void DDAInfoClass::
// setDDAsetWithVolID(int volID)
// {
// #ifndef REDUCE_VERBOSE_INFO
//     if(this->mIsInit == YES)
//     {
// 	cout << "Warning: 3DDDAA Info for volume is already inited." << endl; 
//     }
// #endif
//     assert(volID >= 0);
//     // なんでも良いがこの値ならば volume ID と間違わないだろう。
//     this->mDDAsetVolID = volID;	
// }


//------------------------------
// 相対位置の変更(進行方向に直交するセル平面との交わり位置)
// 方向 dir1 に d1 の相対位置,  dir2 の方向に d2 の位置
//------------------------------
void DDAInfoClass::
changeRelativePos(const double d1, const int dir1,
		  const double d2, const int dir2)
{
    static const char *pMsg = "Error!: illegal Vector3 direction dir at "
	"DDAInfoClass::changeRelativePos";
    double p[3];
    
    p[Vector3::X] = this->mRelativePos.get(Vector3::X);
    p[Vector3::Y] = this->mRelativePos.get(Vector3::Y);
    p[Vector3::Z] = this->mRelativePos.get(Vector3::Z);
    
    switch(dir1)
    {
    case Vector3::X: 
	p[Vector3::X] = d1;	break;
	
    case Vector3::Y:
	p[Vector3::Y] = d1;	break;
	
    case Vector3::Z:
	p[Vector3::Z] = d1;	break;
	
    default:
	cerr << pMsg << "1" << endl;	
	break;
    }
    
    switch(dir2)
    {
    case Vector3::X:
	p[Vector3::X] = d2;	break;
	
    case Vector3::Y:
	p[Vector3::Y] = d2;	break;
	
    case Vector3::Z:
	p[Vector3::Z] = d2;	break;
	
    default:
	cerr << pMsg << "2" << endl;
	break;
    }
    
    this->mRelativePos.set(p[Vector3::X], p[Vector3::Y], p[Vector3::Z]);
}

//------------------------------
// 進行方向の軸の設定
//------------------------------
void DDAInfoClass::
setGoingDir(DIR_3D goingdir)
{
    assert(goingdir <=  DIR_ILLEGAL);
    
    this->mGoingdir = goingdir;
}

//------------------------------
// print out
//------------------------------
void DDAInfoClass::
print(const char *pHead) const 
{
    cout << pHead << "----- 3DDDA Info. ----- calc is already do:" 
	<< ((this->mIsInit == YES) ? "YES " : "NO ");
    cout << pHead << "relPos(" << this->mRelativePos << ")\n";
    cout << pHead << "DDAVec(" << this->mDDAVec      << ")\n";    
    cout << pHead << "travAxis:" << this->mTraverseAxis 
	<< " goingDir:" << this->mGoingdir << endl;
}
