text:
CDigitalMatter::CDigitalMatter(void)
{
	Path = ""; //initialize path to nothing
	ClearPalette();
}

CDigitalMatter::~CDigitalMatter(void)
{
	ClearMatter();
}

CDigitalMatter& CDigitalMatter::operator=(const CDigitalMatter& RefObj)
{
	Lattice = RefObj.Lattice;
	Voxel = RefObj.Voxel;
	Structure = RefObj.Structure;
	Palette = RefObj.Palette;
	Path = RefObj.Path;

	return *this;
}

void CDigitalMatter::ClearMatter(void) //clears out everything...
{
	Lattice.ClearLattice();
	Voxel.ClearVoxel();
	Structure.ClearStructure();
	ClearPalette();
}

void CDigitalMatter::InitializeMatter(CDMF_Lattice* pLattice, int xV, int yV, int zV)
{
	ClearMatter();

	LoadDefaultPalette();
	Lattice = *pLattice;
	Voxel.SetVoxName(BOX);
	Structure.CreateStructure(xV, yV, zV);

}

void CDigitalMatter::InitializeMatter(void) //loads default
{
	if(!LoadFile("Default.dmf")){ //try loading default file (must be in working directory)... if not default to 10x 1mm cubes

		ClearMatter();
		AddMat("Flexible");
		AddMat("Stiff");
		AddMat("Light");
		Palette[1].SetColor(1, 0, 0);
		Palette[1].SetElasticMod(1.0f);
		Palette[1].SetDensity(10.0f);

		Palette[2].SetColor(0, 0, 1);
		Palette[2].SetElasticMod(100.0f);
		Palette[2].SetDensity(10.0f);

		Palette[3].SetColor(1, 1, 0);
		Palette[3].SetElasticMod(10.0f);
		Palette[3].SetDensity(1.0f);

		Lattice.SetLattice(0.001f);

		Voxel.SetVoxName(BOX);
		Structure.CreateStructure(10, 10, 10);
	}
}

void CDigitalMatter::InitializeMatter(float iLattice_Dim, int xV, int yV, int zV) //intializes object with some default params, including dynamic arrays
{
	ClearMatter();

	LoadDefaultPalette();
	Lattice.SetLattice(iLattice_Dim);
	Voxel.SetVoxName(BOX); ///XXX Temporary!!
	Structure.CreateStructure(xV, yV, zV);
}

void CDigitalMatter::LoadDefaultPalette(void)
{
	if (!LoadFile("Default.dmf", true)){ //try to load the default palette from default dmf object
		AddMat("Default"); //otherwise, add a single, default material
	}
}

void CDigitalMatter::ClearPalette() //clears the material palette, leaving only empty (vacant) material
{
	int VecSize = (int)Palette.size();
	if (VecSize != 0)
		Palette.erase(Palette.begin(), Palette.begin()+VecSize); //erase the materials array

	//add back the default (empty) first material
	CDMF_Material Empty = CDMF_Material(NULL, NULL, NULL, NULL, "Erase");

	Palette.push_back(Empty);
}

void CDigitalMatter::DeleteMat(int Index) //deletes a material (in palette and object) and moves the rest of the material indexes down
{
	//checks
	if (Index >= (int)Palette.size()){
		std::cout << "invalid material to delete\n";
		return;
	}

	if (Index == 0){
		std::cout << "Cannot delete Null material\n";
		return;
	}

	Structure.EraseMaterial(Index, true); //erase and shift down....
	Palette.erase(Palette.begin()+Index);

}

int CDigitalMatter::AddMat(std::string Name, float ElasticMod, float PoissonsRatio, float R, float G, float B, float Alpha) //adds a material to the end of the palette with specified properties
{
	//checks
	if (Name == "" || Name == " "){
		std::cout << "Invalid material Name\n";
		return -1;
	}

	for (int i=0; i<(int)Palette.size(); i++)
	{
		if (Name == Palette[i].GetName()){
			std::cout << "Name already in use\n";
			return -1;
		}
	}

	int NextIndex = (int)Palette.size(); //not plus one!
	if (NextIndex<=256){ //if we have a material slot left...
		CDMF_Material tmp;
		Palette.push_back(tmp);
		Palette[NextIndex].SetName(Name);
		Palette[NextIndex].SetColor(R, G, B, Alpha);
		Palette[NextIndex].SetElasticMod(ElasticMod);
		Palette[NextIndex].SetPoissonsRatio(PoissonsRatio);
		Palette[NextIndex].SetDensity(1.0f);
		return NextIndex;
	}
	else {
		std::cout << "Maximum number of materials reached!\n";
		return -1;
	}
}

void CDigitalMatter::New(void) //new dmf
{
	Close();
}

void CDigitalMatter::Save(void) //saves the file, or prompts if not yet been saved
{
	if (Path == ""){ //if file path is empty string (IE not been saved yet)
		std::cout <<"Enter Name to save DMF as:\n";
		std::cin >> Path;
	}

	if (Path.size() != 0) SaveFile(Path);
	else Path = "";
}

bool CDigitalMatter::Open(void) //Brings up file dialog to open dmf file
{
	Close();

	std::string tmpPath;
	std::cout << "Enter File name to open:\n";
	std::cin >> tmpPath;
	if (Path.size()!= 0){
		Path = tmpPath;
		LoadFile(Path);
		return true;
	}
	return false;

}

void CDigitalMatter::Close(void) //closes (and clears) the dmf object
{
	ClearMatter();
	Path = "";

}

bool CDigitalMatter::OpenPal(void) //Open a palette
{
	std::string TmpPath;
	std::cout << "Enter name of Palette to open:\n";
	std::cin >> TmpPath;

	if(TmpPath.size() != 0){
		ClearPalette(); //clear all materials
		LoadFile(TmpPath, true);
		return true;
	}
	return false;
}

void CDigitalMatter::SavePal(void) //save a palette
{
	std::string TmpPath;
	std::cout << "Enter name of file to save Palette to:\n";
	std::cin >> TmpPath;

	if(TmpPath.size() != 0){
		SaveFile(TmpPath);
	}
}

void CDigitalMatter::SaveFile(std::string filename, bool OnlyPal)
{
	std::cout << "jmc: here:\n";
	Path = filename;
	CXML_Rip XML;
	WriteXML(&XML);
	XML.SaveFile(filename);
}

bool CDigitalMatter::LoadFile(std::string filename, bool OnlyPal)
{
	std::string tmpS;
	ClearMatter(); //clears everything!

	CXML_Rip XML;
	if (XML.LoadFile(filename)){
		Path = filename;
		ReadXML(&XML);
	}

	return true;
}

void CDigitalMatter::WriteXML(CXML_Rip* pXML)
{
	pXML->DownLevel("DMF");
	pXML->SetAttribute("Version", "0.93");
		Lattice.WriteXML(pXML);
		Voxel.WriteXML(pXML);
		pXML->DownLevel("Palette");
		for (int i=1; i<(int)Palette.size(); i++){ //Can skip the "empty" material (0)
			pXML->DownLevel("Material");
			pXML->SetAttribute("ID", i);
			Palette[i].WriteXML(pXML);
			pXML->UpLevel();
		}
		pXML->UpLevel();
		Structure.WriteXML(pXML);

	pXML->UpLevel();
}

void CDigitalMatter::ReadXML(CXML_Rip* pXML)
{
	std::string ThisVersion = "0.93"; //version of the reading code... (JON WILL CHANGE THIS WHEN UPDATING SOURCE!)
	std::string Version;
	pXML->GetAttribute("Version", &Version);
	if (atof(Version.c_str()) > atof(ThisVersion.c_str())) std::cout << "Attempting to open newer version of DMF file!\n";

	if (pXML->FindElement("Lattice")){
		Lattice.ReadXML(pXML);
		pXML->UpLevel();
	}
	if (pXML->FindElement("Voxel")){
		Voxel.ReadXML(pXML);
		pXML->UpLevel();
	}
	if (pXML->FindElement("Palette")){
		while (pXML->FindElement("Material")){
			CDMF_Material tmpMat;
			tmpMat.ReadXML(pXML, Version);
			Palette.push_back(tmpMat);
		}
		pXML->UpLevel(); //Material
	//	pXML->UpLevel(); //Palette
	}
	if (pXML->FindElement("Structure")){
		Structure.ReadXML(pXML, Version);
		pXML->UpLevel();
	}
}

void CDigitalMatter::GetWorkSpace(Vec3D* Dim) //calculate actual workspace dimensions
{
	float LatDim = Lattice.GetLatticeDim();
	//calculate the dims
	Dim->x = LatDim*((Structure.GetVXDim()-1)*Lattice.GetXDimAdj()+1 + Lattice.GetMaxOffsetX());
	Dim->y = LatDim*((Structure.GetVYDim()-1)*Lattice.GetYDimAdj()+1 + Lattice.GetMaxOffsetY());
	if (Voxel.GetVoxName() == SPHERE)
		Dim->z = LatDim*((Structure.GetVZDim()-1)*Lattice.GetZDimAdj()+1);
	else
		Dim->z = LatDim*Structure.GetVZDim()*Lattice.GetZDimAdj();

}

Vec3D CDigitalMatter::GetWorkSpace() //calculate actual workspace dimensions (acounting for dif offsets!)
{
	Vec3D ToReturn;
	GetWorkSpace(&ToReturn);
	return ToReturn;
}

bool CDigitalMatter::GetXYZ(Vec3D* Point, int index) //gets the XYZ coordinates of an index in the master array, returns true if a valid location
{
	float Eps = 0.000001f; //hack, offset to make sure its all on the right side of zero
	float TotalXOffP = 0.0f; //running variables to add the offsets to. (in percentage of width
	float TotalYOffP = 0.0f;

	int iz = 0;
	int iy = 0;
	int ix = 0;
	GetXYZNom(&ix, &iy, &iz, index); //get nominal x, y, z indicies

	TotalXOffP = Lattice.GetXLiO()*iy + Lattice.GetXLaO()*iz + Eps; //total offset
	TotalYOffP = Lattice.GetYLiO()*ix + Lattice.GetYLaO()*iz + Eps;

	//THESE ARE PSEUDO-HACKED!!! (don't work with arbitrary...)
	if (Lattice.GetXLaO() > Lattice.GetYLaO())
		if (((int)(TotalYOffP/Lattice.GetYDimAdj()))%2 == 1)
			TotalXOffP += 0.5;
	else if (Lattice.GetYLaO() > Lattice.GetXLaO())
		if (((int)(TotalXOffP/Lattice.GetXDimAdj()))%2 == 1)
			TotalYOffP += 0.5;

	TotalXOffP = TotalXOffP - ((int)(TotalXOffP/Lattice.GetXDimAdj()))*Lattice.GetXDimAdj();
	TotalYOffP = TotalYOffP - ((int)(TotalYOffP/Lattice.GetYDimAdj()))*Lattice.GetYDimAdj();

	Point->x = Lattice.GetLatticeDim()*(0.5 + TotalXOffP + ix*Lattice.GetXDimAdj());
	Point->y =Lattice.GetLatticeDim()*(0.5 + TotalYOffP + iy*Lattice.GetYDimAdj());
	if (Voxel.GetVoxName() != SPHERE)
		Point->z = Lattice.GetLatticeDim()*((0.5 + iz)*Lattice.GetZDimAdj());
	else
		Point->z = Lattice.GetLatticeDim()*(0.5 + iz*Lattice.GetZDimAdj());

	return true;
}

bool CDigitalMatter::IsAdjacent(int Index1, int Index2, Vec3D* RelativeLoc) //true if these voxels are touching!
{
	int tmp = (int)Structure[Index2];
	(void) tmp; //to get rid of unused variable warning
	if (Index1 < 0 || Index2 >= Structure.GetArraySize() || Structure[Index2] == 0)
		return false;

	//optomize later! XXX
	Vec3D P1;
	Vec3D P2;
	Vec3D Rel;

	GetXYZ(&P1, Index1);
	GetXYZ(&P2, Index2);

	Rel = P2-P1;
	if (RelativeLoc != NULL) //set the relativeness if wanted
		*RelativeLoc = Rel;

	if (Rel.Length()<1.4*Lattice.GetLatticeDim())
		return true;
	else
		return false;
}

void CDigitalMatter::Resize(CDMF_Structure* pStructure) //resizes a structure, preserving voxels in correct locations
{
	CDMF_Structure LStruct;
	LStruct.CreateStructure(pStructure->GetVXDim(), pStructure->GetVYDim(), pStructure->GetVZDim());

	int tX=0;
	int tY=0;
	int tZ=0;
	int NewIndex = 0;
	Vec3D UselessPoint;

	//Populate the Temporary new array
	for (int i=0; i<Structure.GetArraySize(); i++){ //go through the existing array
		if (Structure[i] != 0){ //If there is a voxel present
			GetXYZNom(&tX, &tY, &tZ, i); //sets the current XYZ indices
			if (tX < LStruct.GetVXDim() && tY < LStruct.GetVYDim() && tZ < LStruct.GetVZDim()){ //if its within the new area... (X, Y, Z are totals- based from 1)
				if (GetXYZ(&UselessPoint, i)){
					NewIndex = tX + LStruct.GetVXDim()*tY + LStruct.GetVXDim()*LStruct.GetVYDim()*tZ;
					if (NewIndex <= LStruct.GetArraySize()) {
						LStruct[NewIndex] = Structure[i];
					}
					else {
						std::cout << "Index Out-of-range\n";
					}
				}
			}
		}
	}
	Structure = LStruct;
}

void CDigitalMatter::Transform(Vec3D Trans) //shift the strucutre within the workspace (Caution! Trucates!)
{
	//create a copy of current object...
	char* pTmpVoxArray = NULL;
	pTmpVoxArray = new char[Structure.GetArraySize()];
	for (int i=0; i<Structure.GetArraySize(); i++){
		*(pTmpVoxArray+i) = Structure[i];
	}

	int tX = 0, tY = 0, tZ = 0;
	//overwrite with transformed values:
	for (int i=0; i<Structure.GetArraySize(); i++){
		GetXYZNom(&tX, &tY, &tZ, i);
		int NewIndex = GetIndex(tX-(int)Trans.x, tY-(int)Trans.y, tZ-(int)Trans.z);
		if(NewIndex != -1){ //if it was within bounds
			Structure[i] = *(pTmpVoxArray+NewIndex);
		}
		else {
			Structure[i] = 0;
		}
	}

	delete [] pTmpVoxArray;
	pTmpVoxArray = NULL;
}

int CDigitalMatter::GetNumVox(void)
{
	int NumVox = 0;
	for (int i=0; i<Structure.GetArraySize(); i++){ //for each voxel in the array
		if(Structure[i]!=0){ //if this is stuff we want to replace
			NumVox++;
		}
	}
	return NumVox;
}

int CDigitalMatter::GetNumVox(int MatIndex)
{
	int NumVox = 0;
	for (int i=0; i<Structure.GetArraySize(); i++){ //for each voxel in the array
		if(Structure[i] == MatIndex){ //if this is instantiated
			NumVox++;
		}
	}
	return NumVox;
}

float CDigitalMatter::GetWeight(void) //returns weight based on densities stored in material.
{
	float SumWeight = 0;

	//crude volume (works for cubes...)
	float VoxVol = Lattice.GetLatticeDim()*Lattice.GetLatticeDim()*Lattice.GetLatticeDim();

	for (int i=0; i<Structure.GetArraySize(); i++){ //for each voxel in the array
		if (Structure[i]!= 0)
			SumWeight += Palette[(int)Structure[i]].GetDens()*VoxVol;
	}
	return SumWeight;
}

CDMF_Material* CDigitalMatter::GetLeafMat(int Index) //gets the lowest level of material
{
	return GetLeafMat(Index, &Structure); //need this seperate to recurse properly
}

CDMF_Material* CDigitalMatter::GetLeafMat(int Index, CDMF_Structure* pStructure) //returns the material for a given substrucutre
{
	int MatIndex = abs((int)(*pStructure)[Index]);

	if (MatIndex <= 0 || MatIndex > (int)Palette.size()){
		return NULL;
	}

	switch (Palette[MatIndex].GetMatType()){
		case SINGLE:
			return &Palette[MatIndex];
			break;
		case INTERNAL:
			if (Palette[MatIndex].HasLocalStructure()){
				int x, y, z;
				GetXYZNom(&x, &y, &z, Index);
				x = (x - Palette[MatIndex].GetSubXOffset()) % Palette[MatIndex].GetSubXSize();
				while (x<0) x += Palette[MatIndex].GetSubXSize();
				y = (y - Palette[MatIndex].GetSubYOffset()) % Palette[MatIndex].GetSubYSize();
				while (y<0) y += Palette[MatIndex].GetSubYSize();
				z = (z - Palette[MatIndex].GetSubZOffset()) % Palette[MatIndex].GetSubZSize();
				while (z<0) z += Palette[MatIndex].GetSubZSize();

				int NewIndex = Palette[MatIndex].pStructure->GetIndex(x, y, z);
				return GetLeafMat(NewIndex, Palette[MatIndex].pStructure);
			}
			else
				return &Palette[MatIndex]; //default to default material values...

			break;

		case EXTERNAL:
			if (Palette[MatIndex].pDMF){
				int x, y, z;
				GetXYZNom(&x, &y, &z, Index);
				x = (x - Palette[MatIndex].GetSubXOffset()) % Palette[MatIndex].GetSubXSize();
				while (x<0) x += Palette[MatIndex].GetSubXSize();
				y = (y - Palette[MatIndex].GetSubYOffset()) % Palette[MatIndex].GetSubYSize();
				while (y<0) y += Palette[MatIndex].GetSubYSize();
				z = (z - Palette[MatIndex].GetSubZOffset()) % Palette[MatIndex].GetSubZSize();
				while (z<0) z += Palette[MatIndex].GetSubZSize();

				return Palette[MatIndex].pDMF->GetLeafMat(Palette[MatIndex].pDMF->Structure.GetIndex(x, y, z));
			}
			else
				return &Palette[MatIndex]; //defualt to default material values...
			break;
	}
	return NULL;
}

bool CDigitalMatter::SetVoxel(int x, int y, int z, int MatIndex) //sets the material index at a lattice location
{
	if (MatIndex >=0 && MatIndex < (int)Palette.size()){
		int Index = GetIndex(x, y, z);
		if (Index != -1){ //if it was a valid index!
			SetVoxel(Index, MatIndex);
			return true; //successful
		}
	}
	return false; //error out
}

int CDigitalMatter::GetVoxel(int x, int y, int z) //returns the material index (at a lattice location)
{
	int index = GetIndex(x, y, z);

	if (index == -1) return -1;
	else return GetVoxel(index);
}

////////////////////////////LATTICE///////////////////////////////////////
CDMF_Lattice::CDMF_Lattice(void)
{
	ClearLattice();
}

CDMF_Lattice::~CDMF_Lattice(void)
{
}

CDMF_Lattice& CDMF_Lattice::operator=(const CDMF_Lattice& RefLat)
{
	Lattice_Dim = RefLat.Lattice_Dim;
	X_Dim_Adj = RefLat.X_Dim_Adj;
	Y_Dim_Adj = RefLat.Y_Dim_Adj;
	Z_Dim_Adj = RefLat.Z_Dim_Adj;
	X_Line_Offset = RefLat.X_Line_Offset;
	Y_Line_Offset = RefLat.Y_Line_Offset;
	X_Layer_Offset = RefLat.X_Layer_Offset;
	Y_Layer_Offset = RefLat.Y_Layer_Offset;

	return *this;
}

void CDMF_Lattice::ClearLattice()
{
	Lattice_Dim = 0.0f;
	X_Dim_Adj = 1.0f;
	Y_Dim_Adj = 1.0f;
	Z_Dim_Adj = 1.0f;
	X_Line_Offset = 0.0f;
	Y_Line_Offset = 0.0f;
	X_Layer_Offset = 0.0f;
	Y_Layer_Offset = 0.0f;
}

void CDMF_Lattice::ReadXML(CXML_Rip* pXML)
{
	if (!pXML->FindLoadElement("Lattice_Dim", &Lattice_Dim)) Lattice_Dim = 0.001f;
	if (!pXML->FindLoadElement("X_Dim_Adj", &X_Dim_Adj)) X_Dim_Adj = 1.0f;
	if (!pXML->FindLoadElement("Y_Dim_Adj", &Y_Dim_Adj)) Y_Dim_Adj = 1.0f;
	if (!pXML->FindLoadElement("Z_Dim_Adj", &Z_Dim_Adj)) Z_Dim_Adj = 1.0f;
	if (!pXML->FindLoadElement("X_Line_Offset", &X_Line_Offset)) X_Line_Offset = 0.0f;
	if (!pXML->FindLoadElement("Y_Line_Offset", &Y_Line_Offset)) Y_Line_Offset = 0.0f;
	if (!pXML->FindLoadElement("X_Layer_Offset", &X_Layer_Offset)) X_Layer_Offset = 0.0f;
	if (!pXML->FindLoadElement("Y_Layer_Offset", &Y_Layer_Offset)) Y_Layer_Offset = 0.0f;
}

void CDMF_Lattice::WriteXML(CXML_Rip* pXML)
{
	pXML->DownLevel("Lattice");
		pXML->Element("Lattice_Dim", Lattice_Dim);
		pXML->Element("X_Dim_Adj", X_Dim_Adj);
		pXML->Element("Y_Dim_Adj", Y_Dim_Adj);
		pXML->Element("Z_Dim_Adj", Z_Dim_Adj);
		pXML->Element("X_Line_Offset", X_Line_Offset);
		pXML->Element("Y_Line_Offset", Y_Line_Offset);
		pXML->Element("X_Layer_Offset", X_Layer_Offset);
		pXML->Element("Y_Layer_Offset", Y_Layer_Offset);
	pXML->UpLevel();
}

float CDMF_Lattice::GetMaxOffsetX(void)
{
	float XMaxOffset = 0;
	if (X_Line_Offset > XMaxOffset)
		XMaxOffset = X_Line_Offset;
	if (X_Layer_Offset > XMaxOffset)
		XMaxOffset = X_Layer_Offset;
	if (2*X_Layer_Offset > XMaxOffset && 2*X_Layer_Offset < X_Dim_Adj)
		XMaxOffset = 2*X_Layer_Offset;

	return XMaxOffset;
}

float CDMF_Lattice::GetMaxOffsetY(void)
{
	float YMaxOffset = 0;
	if (Y_Line_Offset > YMaxOffset)
		YMaxOffset = Y_Line_Offset;
	if (Y_Layer_Offset > YMaxOffset)
		YMaxOffset = Y_Layer_Offset;
	if (2*Y_Layer_Offset > YMaxOffset && 2*Y_Layer_Offset < Y_Dim_Adj)
		YMaxOffset = 2*Y_Layer_Offset;

	return YMaxOffset;
}

//////////////////////////MATERIAL/////////////////////////////

CDMF_Material::CDMF_Material(void)
{
	pStructure = NULL;
	pDMF = NULL;
	ClearMaterial();
}

CDMF_Material::CDMF_Material(float r, float g, float b, float a, std::string newName) //allow us to create easily
{
	pStructure = NULL;
	pDMF = NULL;
	ClearMaterial();

	MatType = SINGLE; //inferred from list of params!

	Name = newName;
	SetColor(r, g, b, a);
}

CDMF_Material::CDMF_Material(const CDMF_Material& RefMat) //copy constructor
{
	Name = RefMat.Name;
	MatType = RefMat.MatType;

	Red = RefMat.Red;
	Green = RefMat.Green;
	Blue = RefMat.Blue;
	Alpha = RefMat.Alpha;

	Elastic_Mod = RefMat.Elastic_Mod;
	Density = RefMat.Density;
	Poissons_Ratio = RefMat.Poissons_Ratio;
	CTE = RefMat.CTE;

	X_Offset = RefMat.X_Offset;
	Y_Offset = RefMat.Y_Offset;
	Z_Offset = RefMat.Z_Offset;

	if (RefMat.pStructure != NULL){
		pStructure = new CDMF_Structure;
		*pStructure = *RefMat.pStructure;
	}
	else
		pStructure = NULL;

	File = RefMat.File;

	if (RefMat.pDMF != NULL){ //delete the old if it exist
		pDMF = new CDigitalMatter;
		*pDMF = *RefMat.pDMF;
	}
	else
		pDMF = NULL;

}

CDMF_Material::~CDMF_Material(void)
{
	if (pStructure != NULL){
		delete pStructure;
		pStructure = NULL;
	}
	if (pDMF != NULL){
		delete pDMF;
		pDMF = NULL;
	}
}

CDMF_Material& CDMF_Material::operator=(const CDMF_Material& RefMat)
{

	Name = RefMat.Name;
	MatType = RefMat.MatType;

	Red = RefMat.Red;
	Green = RefMat.Green;
	Blue = RefMat.Blue;
	Alpha = RefMat.Alpha;

	Elastic_Mod = RefMat.Elastic_Mod;
	Density = RefMat.Density;
	Poissons_Ratio = RefMat.Poissons_Ratio;
	CTE = RefMat.CTE;

	X_Offset = RefMat.X_Offset;
	Y_Offset = RefMat.Y_Offset;
	Z_Offset = RefMat.Z_Offset;

	if (pStructure != NULL){ //delete the old if it exist
		delete pStructure;
		pStructure = NULL;
	}

	if (RefMat.pStructure){ //null materi
		pStructure = new CDMF_Structure();
		*pStructure = *RefMat.pStructure;
	}

	File = RefMat.File;

	if (pDMF != NULL){ //delete the old if it exist
		delete pDMF;
		pDMF = NULL;
	}

	if (RefMat.pDMF){ //null
		pDMF = new CDigitalMatter;
		*pDMF = *RefMat.pDMF;
	}

	return *this;

}

void CDMF_Material::ClearMaterial(void)
{
	Name = "";
	MatType = SINGLE;

	Red = 0.5f;
	Green = 0.5f;
	Blue = 0.5f;
	Alpha = 1.0f;

	Elastic_Mod = 0.0f;
	Density = 0.0f;
	Poissons_Ratio = 0.0f;
	CTE = 0.0f;

	if (pStructure != NULL){
		delete [] pStructure;
		pStructure = NULL;
	}

	X_Offset = 0;
	Y_Offset = 0;
	Z_Offset = 0;

	//for external material definition
	File = "";

	if (pDMF != NULL){
		delete [] pDMF;
		pDMF = NULL;
	}

}

void CDMF_Material::SetColor(float r, float g, float b, float a)
{
	Red = r;
	Green = g;
	Blue = b;
	Alpha = a;
}

void CDMF_Material::SetColor(float r, float g, float b)
{
	SetColor(r, g, b, 1.0f);
}

void CDMF_Material::WriteXML(CXML_Rip* pXML)
{
//	pXML->DownLevel("Material");
	pXML->Element("MatType", MatType);

	switch (MatType){
		case SINGLE:
			pXML->Element("Name", Name);
			pXML->DownLevel("Display");
				pXML->Element("Red", Red);
				pXML->Element("Green", Green);
				pXML->Element("Blue", Blue);
				pXML->Element("Alpha", Alpha);
			pXML->UpLevel();
			pXML->DownLevel("Mechanical");
				pXML->Element("Elastic_Mod", Elastic_Mod);
				pXML->Element("Density", Density);
				pXML->Element("Poissons_Ratio", Poissons_Ratio);
				pXML->Element("CTE", CTE);
			pXML->UpLevel();
			break;
		case INTERNAL:
			pXML->Element("Name", Name);
			pStructure->WriteXML(pXML);
			pXML->Element("X_Offset", X_Offset);
			pXML->Element("Y_Offset", Y_Offset);
			pXML->Element("Z_Offset", Z_Offset);
			break;
		case EXTERNAL:
			pXML->Element("File", File);
			break;
	}
//	pXML->UpLevel();
}

void CDMF_Material::ReadXML(CXML_Rip* pXML, std::string Version)
{
	if (!pXML->FindLoadElement("MatType", &MatType)){ //if there's not a MatType tag, we need some detective work...
		if (pXML->FindElement("Structure")) {pXML->UpLevel(); MatType = INTERNAL;}
		else if (pXML->FindElement("DMF")) {pXML->UpLevel(); MatType = EXTERNAL;}
		else MatType = SINGLE;
	}
	if (!pXML->FindLoadElement("Name", &Name)) Name = "Default";

	switch (MatType){
		case SINGLE:
			if (pXML->FindElement("Display")){
				if (!pXML->FindLoadElement("Red", &Red)) Red = 0.5;
				if (!pXML->FindLoadElement("Green", &Green)) Green = 0.5;
				if (!pXML->FindLoadElement("Blue", &Blue)) Blue = 0.5;
				if (!pXML->FindLoadElement("Alpha", &Alpha)) Alpha = 1.0;
				pXML->UpLevel();
			}
			if (pXML->FindElement("Mechanical")){
				if (!pXML->FindLoadElement("Elastic_Mod", &Elastic_Mod)) Elastic_Mod = 0;
				if (!pXML->FindLoadElement("Density", &Density)) Density = 0;
				if (!pXML->FindLoadElement("Poissons_Ratio", &Poissons_Ratio)) Poissons_Ratio = 0;
				if (!pXML->FindLoadElement("CTE", &CTE)) CTE = 0;
				pXML->UpLevel();
			}
			break;
		case INTERNAL:
			if (!pXML->FindLoadElement("Name", &Name)) Name = "";
			if (!pXML->FindLoadElement("X_Offset", &X_Offset)) X_Offset = 0;
			if (!pXML->FindLoadElement("Y_Offset", &Y_Offset)) Y_Offset = 0;
			if (!pXML->FindLoadElement("Z_Offset", &Z_Offset)) Z_Offset = 0;

			if (pXML->FindElement("Structure")){
				if (pStructure == NULL)
					pStructure = new CDMF_Structure;
				pStructure->ReadXML(pXML, Version);
				pXML->UpLevel();
			}
			break;
		case EXTERNAL:
			if (!pXML->FindLoadElement("File", &File)) File = "";
			if (pDMF == NULL) pDMF = new CDigitalMatter;
			if (File != "") pDMF->LoadFile(File);
			break;
	}
}

////////////////////////////////STRUCTURE////////////////////////////////

CDMF_Structure::CDMF_Structure()
{
	pData = NULL; //initialize to void
	ClearStructure(); //clear all model parameters
}

CDMF_Structure::~CDMF_Structure()
{
	if (pData != NULL){
		delete [] pData;
		pData = NULL;
	}
}

CDMF_Structure::CDMF_Structure(const CDMF_Structure& RefStruct) //copy constructor
{
	Compression = RefStruct.Compression;
	X_Voxels = RefStruct.X_Voxels;
	Y_Voxels = RefStruct.Y_Voxels;
	Z_Voxels = RefStruct.Z_Voxels;

	m_SizeOfArray = RefStruct.m_SizeOfArray;

	if (pData != NULL){ //clear current array
		delete [] pData;
		pData = NULL;
	}

	if (RefStruct.pData != NULL){
		pData = new char[RefStruct.m_SizeOfArray];
		for (int i=0; i<RefStruct.m_SizeOfArray; i++)
			*(pData+i) = *(RefStruct.pData+i);
	}
}

CDMF_Structure& CDMF_Structure::operator=(const CDMF_Structure& RefStruct)
{

	Compression = RefStruct.Compression;
	X_Voxels = RefStruct.X_Voxels;
	Y_Voxels = RefStruct.Y_Voxels;
	Z_Voxels = RefStruct.Z_Voxels;

	m_SizeOfArray = RefStruct.m_SizeOfArray;

	if (pData != NULL) //delete the old if it exist
		delete [] pData;
	pData = new char[RefStruct.m_SizeOfArray];
	for (int i=0; i<RefStruct.m_SizeOfArray; i++)
		*(pData+i) = *(RefStruct.pData+i);

	return *this;
}

void CDMF_Structure::WriteXML(CXML_Rip* pXML)
{
	pXML->DownLevel("Structure");
	pXML->SetAttribute("Compression", "ASCII_READABLE");

	pXML->Element("X_Voxels", X_Voxels);
	pXML->Element("Y_Voxels", Y_Voxels);
	pXML->Element("Z_Voxels", Z_Voxels);

	pXML->DownLevel("Data");

	for (int i=0; i<Z_Voxels; i++){
		std::string Data;
		for (int j=0; j<X_Voxels*Y_Voxels; j++){Data += pData[i*X_Voxels*Y_Voxels + j]+48;} //store in ascii numbers
		int size = Data.size();
		(void) size; //to get rid of unused variable warning
		pXML->Element("Layer", Data, true);
	}
	pXML->UpLevel();
	pXML->UpLevel();
}

void CDMF_Structure::ReadXML(CXML_Rip* pXML, std::string Version)
{
	std::string Compression;
	pXML->GetAttribute("Compression", &Compression);

	if (!pXML->FindLoadElement("X_Voxels", &X_Voxels)) X_Voxels = 1;
	if (!pXML->FindLoadElement("Y_Voxels", &Y_Voxels)) Y_Voxels = 1;
	if (!pXML->FindLoadElement("Z_Voxels", &Z_Voxels)) Z_Voxels = 1;

	CreateStructure(X_Voxels, Y_Voxels, Z_Voxels); //create the space for the structure

	if (Version == "" || Version == "0.93"){ //newest version
		pXML->FindElement("Data");
		for (int i=0; i<Z_Voxels; i++){
			std::string DataInString;
			pXML->FindLoadElement("Layer", &DataInString, true);
			for(int k=0; k<X_Voxels*Y_Voxels; k++){
				pData[X_Voxels*Y_Voxels*i + k] = *(DataInString.data() + k);
			}
		}
	}
	else if (Version == "0.92") { //legacy version
		std::string Data;
		pXML->FindLoadElement("Data", &Data);

		//QByteArray RawData = Data.toAscii();

		//char *pDataIn = RawData.data(); //get pointer to characters

		//int IteratorIn = 0; //iterator for input file
		//int Iterator = 0; //iterator for output file

		//for (int k=0; k<X_Voxels*Y_Voxels*Z_Voxels + 2*Z_Voxels; k++){ //specific to old system where each ascii line was a layer...
		//	if (pDataIn[IteratorIn] != 0x0A && pDataIn[IteratorIn] != 0x0D){ //ignore carraige returns and line feeds
		//		char tmp = pDataIn[IteratorIn];
		//		pData[Iterator++] = pDataIn[IteratorIn];
		//	}
		//	IteratorIn++;
		//}
	}
}

#ifdef MFC
void CDMF_Structure::WriteStructure(ofstream* pFile, std::string Padding)
{
	*pFile << Padding << "<Structure Compression=\"" << Compression << "\">\n";

	*pFile << Padding << "  <X_Voxels>" << X_Voxels << "</X_Voxels>\n";
	*pFile << Padding << "  <Y_Voxels>" << Y_Voxels << "</Y_Voxels>\n";
	*pFile << Padding << "  <Z_Voxels>" << Z_Voxels << "</Z_Voxels>\n";

	*pFile << Padding << "  <Data>\n";

	*pFile << "<![CDATA[\n";
	for (int k=0; k<Z_Voxels; k++){ //store each layers' data on a seperate line
		for (int ij=0; ij<X_Voxels*Y_Voxels; ij++){
			BYTE PutValue = (BYTE)abs(pData[k*X_Voxels*Y_Voxels + ij]);
			(*pFile).put(PutValue);
		}
		*pFile << "\n";
	}
	*pFile << "]]>\n";

	*pFile << Padding << "  </Data>\n";
	*pFile << Padding << "</Structure>\n";
}

void CDMF_Structure::ReadStructure(CStdioFile* pFile)
{
	std::string line = "";
	int count = 0;

	while(line.Left(12).CompareNoCase("</Structure>") != 0){ //Go until the </Structure> tag
		pFile->ReadString(line);
		line.Trim(' ');
		if (count++ > 1000){ //watch for infinite loops...
			AfxMessageBox("Could not find closing Lattice tag");
			return;
		}

		if(line.Left(10).CompareNoCase("<X_Voxels>") == 0 && sscanf_s(line, "<X_Voxels>%d</X_Voxels>", &X_Voxels)!=1)
			AfxMessageBox("Error Reading Structure Parameters: X_Voxels");
		if(line.Left(10).CompareNoCase("<Y_Voxels>") == 0 && sscanf_s(line, "<Y_Voxels>%d</Y_Voxels>", &Y_Voxels)!=1)
			AfxMessageBox("Error Reading Structure Parameters: Y_Voxels");
		if(line.Left(10).CompareNoCase("<Z_Voxels>") == 0 && sscanf_s(line, "<Z_Voxels>%d</Z_Voxels>", &Z_Voxels)!=1)
			AfxMessageBox("Error Reading Structure Parameters: Z_Voxels");

		if(line.Left(6).CompareNoCase("<Data>") == 0){
			pFile->ReadString(line);
			line.Trim(' ');
			if (line.Left(10).CompareNoCase("<![CDATA[") != 0){
				AfxMessageBox("did not find CDATA tag in expected place!");
				return;
			}

			if (X_Voxels == 0 || Y_Voxels == 0 || Z_Voxels == 0){ //check to make sure we have decent parameters!
				AfxMessageBox("Invalid Structure dimensions when data loading. (reorder file?)");
				return;
			}
			CreateStructure(X_Voxels, Y_Voxels, Z_Voxels);

			for (int k=0; k<Z_Voxels; k++){
				int numTrans = pFile->Read(pData+k*X_Voxels*Y_Voxels, X_Voxels*Y_Voxels);
				pFile->Seek(2, CFile::current); //move past the endline character!
			}

			pFile->ReadString(line);
			line.Trim(' ');
			if (line.Left(10).CompareNoCase("]]>") != 0){
				AfxMessageBox("did not find ending CDATA tag in expected place!");
				//return; //(can probably recover from this...)
			}
		}
	}
}
#endif

void CDMF_Structure::ClearStructure() //completey erases, frees, and destroys the voxel array
{
	m_SizeOfArray = 0;
	if (pData != NULL){
		delete [] pData;
		pData = NULL;
	}

	Compression = "";

	X_Voxels = 0;
	Y_Voxels = 0;
	Z_Voxels = 0;
}

void CDMF_Structure::CreateStructure(int xV, int yV, int zV) //creates empty structure with these dimensions
{
	m_SizeOfArray = xV*yV*zV;

	X_Voxels = xV;
	Y_Voxels = yV;
	Z_Voxels = zV;

	if (pData != NULL) //delete the old if it exist
		delete [] pData;
	pData = new char[m_SizeOfArray];

	ResetStructure(); //sets to zeros!
}

void CDMF_Structure::ResetStructure() //erases all voxel imformation within voxel array
{
	for (int i=0; i<m_SizeOfArray; i++)
		pData[i] = 0;
}

void CDMF_Structure::EraseMaterial(int Matindex, bool ShiftDown)
{
	//Delete all voxels in the matrix made of this material and (optionally) shift down the rest...
	for (int i=0; i<m_SizeOfArray; i++){
		if (*(pData+i) == Matindex)
			*(pData+i) = 0;

		if (ShiftDown && (int)*(pData+i) > Matindex)
			*(pData+i) = abs(*(pData+i))-1;

	}
}

int CDMF_Structure::GetIndex(int x, int y, int z) { //returns the index of the array from xyz indices
	if (x<0 || x >= X_Voxels || y<0 || y >= Y_Voxels || z<0 || z >= Z_Voxels) { //if this XYZ is out of the area
		return -1;
	}
	else {
		return x + X_Voxels*y + X_Voxels*Y_Voxels*z;
	}
}

bool CDMF_Structure::GetXYZNom(int* x, int* y, int* z, int index) //gets the physical position of the voxels from index
{
	if (index<0 || index > X_Voxels*Y_Voxels*Z_Voxels){
		*x = -1;
		*y = -1;
		*z = -1;
		return false;
	}
	else {
		*z = (int)((float)index / (X_Voxels*Y_Voxels)); //calculate the indices in x, y, z directions
		*y = (int)(((float)index - *z*X_Voxels*Y_Voxels)/X_Voxels);
		*x = index - *z*X_Voxels*Y_Voxels - *y*X_Voxels;
		return true;
	}
}

////////////////////////////////VOXEL////////////////////////////

CDMF_Voxel::CDMF_Voxel(void)
{
	ClearVoxel();
}

CDMF_Voxel::~CDMF_Voxel(void)
{
}

CDMF_Voxel& CDMF_Voxel::operator=(const CDMF_Voxel& RefVox)
{

	Vox_Name = RefVox.Vox_Name;
	File = RefVox.File;
	X_Squeeze = RefVox.X_Squeeze;
	Y_Squeeze = RefVox.Y_Squeeze;
	Z_Squeeze = RefVox.Z_Squeeze;

	return *this;

}

void CDMF_Voxel::ReadXML(CXML_Rip* pXML)
{
	std::string Name;
	if (pXML->FindLoadElement("File", &File)) {Vox_Name = VOXFILE; }
	else if (pXML->FindLoadElement("Vox_Name", &Name)){
		if (Name == "SPHERE") Vox_Name = SPHERE;
		else if (Name == "BOX") Vox_Name = BOX;
		else if (Name == "CYLINDER") Vox_Name = CYLINDER;
		else Vox_Name = BOX; //if not these three...
		File = "";
	}
	else { //default
		Vox_Name = BOX; //default
		File = "";
	}

	if (!pXML->FindLoadElement("X_Squeeze", &X_Squeeze)) X_Squeeze = 1.0;
	if (!pXML->FindLoadElement("Y_Squeeze", &Y_Squeeze)) Y_Squeeze = 1.0;
	if (!pXML->FindLoadElement("Z_Squeeze", &Z_Squeeze)) Z_Squeeze = 1.0;
}

void CDMF_Voxel::WriteXML(CXML_Rip* pXML)
{
	pXML->DownLevel("Voxel");
		switch (Vox_Name){
			case VOXFILE: pXML->Element("File", File); break;
			case SPHERE: pXML->Element("Vox_Name", "SPHERE"); break;
			case BOX: pXML->Element("Vox_Name", "BOX"); break;
			case CYLINDER: pXML->Element("Vox_Name", "CYLINDER"); break;
		}
		pXML->Element("X_Squeeze", X_Squeeze);
		pXML->Element("Y_Squeeze", Y_Squeeze);
		pXML->Element("Z_Squeeze", Z_Squeeze);
	pXML->UpLevel();
}

#ifdef MFC
void CDMF_Voxel::WriteVoxel(ofstream* pFile)
{
	*pFile << "<Voxel>\n";

	switch (Vox_Name){
		case VOXFILE:
			*pFile << "  <File>" << File << "</File>\n";
			break;
		case SPHERE:
			*pFile << "  <Vox_Name>SPHERE</Vox_Name>\n";
			break;
		case BOX:
			*pFile << "  <Vox_Name>BOX</Vox_Name>\n";
			break;
		case CYLINDER:
			*pFile << "  <Vox_Name>CYLINDER</Vox_Name>\n";
			break;
	}
		*pFile << "  <X_Squeeze>" << X_Squeeze << "</X_Squeeze>\n";
		*pFile << "  <Y_Squeeze>" << Y_Squeeze << "</Y_Squeeze>\n";
		*pFile << "  <Z_Squeeze>" << Z_Squeeze << "</Z_Squeeze>\n";

	*pFile << "</Voxel>\n";

}

void CDMF_Voxel::ReadVoxel(CStdioFile* pFile)
{
	std::string line = "";
	int count = 0;

	while(line.Left(8).CompareNoCase("</Voxel>") != 0){ //Go until the </Lattice> tag
		(*pFile).ReadString(line);
		line.Trim(' ');
		if (count++ > 1000){ //watch for infinite loops...
			AfxMessageBox("Could not find closing Voxel tag");
			return;
		}

		if(line.Left(6).CompareNoCase("<File>") == 0){ //if we find this tag, its an external file!
			File = line.Mid(6, line.GetLength()-13);
			Vox_Name = VOXFILE;
			//LOAD THE FILE HERE!!!
		}

		if(line.Left(10).CompareNoCase("<Vox_Name>") == 0){
			std::string Name = line.Mid(10, line.GetLength()-21);
			if (Name.CompareNoCase("SPHERE") == 0) Vox_Name = SPHERE;
			else if (Name.CompareNoCase("BOX") == 0) Vox_Name = BOX;
			else if (Name.CompareNoCase("CYLINDER") == 0) Vox_Name = CYLINDER;
		}

		if(line.Left(11).CompareNoCase("<X_Squeeze>") == 0 && sscanf_s(line, "<X_Squeeze>%f</X_Squeeze>", &X_Squeeze)!=1)
			AfxMessageBox("Error Reading Material Parameters: X_Squeeze");
		if(line.Left(11).CompareNoCase("<Y_Squeeze>") == 0 && sscanf_s(line, "<Y_Squeeze>%f</Y_Squeeze>", &Y_Squeeze)!=1)
			AfxMessageBox("Error Reading Material Parameters: Y_Squeeze");
		if(line.Left(11).CompareNoCase("<Z_Squeeze>") == 0 && sscanf_s(line, "<Z_Squeeze>%f</Z_Squeeze>", &Z_Squeeze)!=1)
			AfxMessageBox("Error Reading Material Parameters: Z_Squeeze");
	}
}
#endif

void CDMF_Voxel::ClearVoxel(void)
{
	Vox_Name = SPHERE; //default to sphere!
	File = "";
	X_Squeeze = 1.0f;
	Y_Squeeze = 1.0f;
	Z_Squeeze = 1.0f;
}

redpajama_set_name: RedPajamaGithub


Below is a list of club activities members of NOS enjoy. With the exception of the Book Club, these activities require a paid NOS membership to participate. Many require advance reservations. NOS recommends early reservations as space can be limited. Some clubs take a hiatus during the summer months.
2nd Thursday at 2:00 p.m.
This club meets monthly at the Suntree/Viera Public Library for group discussion. Please call Sue Kaplan for more information. Bookmarks listing the reading assignments are also available at the library any time. Contact Sue for more information.
NOS invites you to join us for breakfast. The Breakfast Club meets a different restaurants each month. This club is for both men and ladies. Restaurant locations will be published each month and advance reservations are strictly required! Contact Laurie for information and reservations.
NOS offers daytime bridge for individuals. Each group of eight players meets once a month. Members each take a turn hosting. For more information about these groups call Judith or Janet.
Bunco luncheons are open to all NOS members, but reservations are a must. Join us at the Suntree Country Club for lunch and an afternoon of Bunco. This is a no-brainer activity and lots of fun. Bunco luncheons are scheduled on the 2nd Friday of the month. For reservations or information, please call Merilee Riopelle.
The Neighbors of Suntree Cocktail Mixer meets at various locations on the 2nd Wednesday evening of each month. Drink Specials galore! Couples and singles welcome! Reservations are required! Members must contact Teresa to reserve a spot.
Members of this group meet in various homes each month to enjoy refreshments and listen to interesting speakers arranged by Patti Coggins. Reservations are required! Early reservations are recommended, as space can sometimes be limited. Please call Patti to reserve your spot at the next meeting.
NOS has four groups playing Hand & Foot. This card game is similar to Canasta. These groups play on either the 1st Friday, 2nd Wednesday, 3rd Friday, or 4th Wednesday of each month. Nancy, Laura, and Norma are looking for players who can sub in these groups. Contact Nancy if you would like to learn how to play and or wish to start a new group.
This group enjoys having lunch at a different restaurant each month. Restaurant locations will be published each month. Advance reservations are strictly required. Call Claire for information and reservations.
Mah-jongg is an anchient Chinese game played with special tiles. NOS Mah-jongg groups meet regularly (weekly, bi-weekly, or monthly) as decided by its members. Mary Ann Caputo will act as a match-maker of Mah-jongg players. Call Mary Ann if you would like to find a group or be added to the substitute list. A class taught by experienced players can also be arranged for those interested in learning the game.
Pampered Palates is a social dining group which meets monthly in the homes of its members. For information and sign-up, call Linda.
NOS offers an evening Bridge group for partners/couples. This group meets on the 2nd Monday each month. Members take turns hosting the group in their homes. For more information contact Laurie.


Fantastic Beasts and Where to Find Them is the first of an upcoming trilogy of films based on Fantastic Beasts and Where to Find Them, one of the companion books to J.K. Rowling's Harry Potter series. Rowling will make her screen writing debut with this film. David Heyman, who produced the Harry Potter films, will be returning as producer for Fantastic Beasts.
It is set in New York in 1926, seventy years before the Harry Potter series, and will feature Newton Scamander as a main character. Fantastic Beasts and Where to Find Them tells us that Scamander had been travelling the world in research of magical creatures since 1918, culminating with the publication of his masterpiece in 1927.
Warner Bros approached Rowling about using the book for a film, from which she pitched idea that couldn't dislodge". Upon returning to Harry Potter for the first time since 2007, Rowling commented: "I always said that I would only revisit the wizarding world if I had an idea that I was really excited about and this is it. She stated that the idea of seeing Scamander "realised by another author was difficult hence her decision to be the film's screenwriter.
James Newton Howard is one of the most prominent film score composers, known for orchestrally oriented scores, with a selection ranging from relationship dramas to romantic comedies to large-scale action pictures. He is also an arranger, orchestrator and record producer. He has written or arranged songs for Barbra Streisand, Bob Seger, Rod Stewart, Rickie Lee Jones, Cher and many more. His song The Hanging Tree - performed by Jennifer Lawrence for The Hunger Games: Mocking Jay OST - has been all over the charts worldwide.
He has written over 70 movie scores, including The Fugitive (Academy Award nomination), Space Jam (an ASCAP Award winner), Pretty Woman, My Best Friend's Wedding, Guilty by Suspicion, Major League, King Ralph, Prince of Tides (Academy Award nomination), Primal Fear (ASCAP Award), Runaway Bride, The Sixth Sense, A Perfect Murder, One Fine Day (Grammy nomination), Batman Begins, The Hunger Games, and The Bourne Legacy. He has been twice nominated for the Academy Award for Best Song ("For the First Time" from One Fine Day and for "Look what Love has Done" from Junior). In addition, he wrote the themes for the television series The Sentinel and E.R. (winning an Emmy award and an ASCAP Award). His music is particularly admired for its seamless blending of popular and classical music elements.


text:
REVIEW: Mechanism of Primary and Secondary Ion-Radical Pair Formation in Photosystem I Complexes
G. E. Milanovsky1, V. V. Ptushenko1, D. A. Cherepanov2, and A. Yu. Semenov1*
1Belozersky Institute of Physico-Chemical Biology, Lomonosov Moscow State University, 119992 Moscow, Russia; fax: +7 (495) 939-3181; E-mail: semenov@genebee.msu.ru
2Frumkin Institute of Physical Chemistry and Electrochemistry, Russian Academy of Sciences, 119071 Moscow, Russia; fax: +7 (495) 952-5308
Received November 24, 2013
The mechanisms of the ultrafast charge separation in reaction centers of photosystem I (PS I) complexes are discussed. A kinetic model of the primary reactions in PS I complexes is presented. The model takes into account previously calculated values of redox potentials of cofactors, reorganization energies of the primary P700+A0- and secondary P700+A1- ion-radical pairs formation, and the possibility of electron transfer via both symmetric branches A and B of redox-cofactors. The model assumes that the primary electron acceptor A0 in PS I is represented by a dimer of chlorophyll molecules Chl2A/Chl3A and Chl2B/Chl3B in branches A and B of the cofactors. The characteristic times of formation of P700+A0- and P700+A1- calculated on the basis of the model are close to the experimental values obtained by pump–probe femtosecond absorption spectroscopy. It is demonstrated that a small difference in the values of redox potentials between the primary electron acceptors A0A and A0B in branches A and B leads to asymmetry of the electron transfer in a ratio of 70 : 30 in favor of branch A. The secondary charge separation is thermodynamically irreversible in the submicrosecond range and is accompanied by additional increase in asymmetry between the branches of cofactors of PS I.
KEY WORDS: photosystem I, reaction center, electron transfer, primary reactions, kinetic modeling
Abbreviations: A0A and A0B, chlorophyll primary electron acceptor in branches A and B; A1A and A1B, phylloquinone molecules (secondary electron acceptors in branches A and B); Chl, chlorophyll; Chl1A/Chl1B, Chl2A/Chl2B, and Chl3A/Chl3B, first, second, and third pairs of chlorophyll molecules in symmetric branches of redox cofactors A and B of PS I; P700, chlorophyll dimer (the primary electron donor); PS I, photosystem I; RC, reaction center.
Photosynthetic reaction centers (RC) are usually grouped into two types depending on the nature of the terminal acceptor. Type II RCs include those of purple bacteria and photosystem II and contain loosely bound quinone as terminal acceptor. Type I RCs include homodimeric RCs of green photosynthetic bacteria Chlorobium and Chloracidobacterium and heliobacteria Heliobacteriaceae, and heterodimeric RC of photosystem I (PS I) from plants and cyanobacteria that have protein-bound iron–sulfur cluster as the acceptor [1]. PS I of cyanobacteria contains 12 protein subunits, 96 chlorophyll molecules (Chl), 22 carotenoids, three [4Fe-4S] clusters, two phylloquinones, and four lipid molecules. Two transmembrane subunits PsaA and PsaB form a C2-symmetric heterodimeric core complex containing most of the cofactors [2] (Fig. 1).
Fig. 1. Localization of the redox cofactors of electron transfer in reaction center of PS I. Chl1A(B), Chl2A(B), Chl3A(B) – first, second, and third pairs of chlorophyll molecules in the symmetric branches of redox cofactors A and B; A1A, A1B – phylloquinone molecules in branches A and B; FX, FA, and FB – [4Fe-4S] clusters.
Out of 96 Chl molecules, six are electron transfer cofactors and are localized near the contact surfaces of the PsaA and PsaB subunits. The chlorophyll dimer P700 consists of two Chl a molecules (Chl1A/Chl1B), the porphyrin planes of which are parallel to each other (with distance of 3.6 Å) and perpendicular to the plane of the membrane. The spatial localization of the other two molecules of Chl a (Chl2A/Chl2B) roughly corresponds to the localization of two molecules of monomeric bacteriochlorophyll in the RC of purple bacteria, and two more molecules of Chl a (Chl3A and Chl3B) are arranged similarly to two molecules of bacteriopheophytin in RC of purple bacteria [3, 4]. The planes of the porphyrin rings of Chl2A (Chl2B) and Chl3A (Chl3B) molecules are parallel (with distance of 3.9 Å), but they are slightly more shifted relative to each other than Chl1A and Chl1B (Fig. 2). PS I also includes two molecules of phylloquinone (A1A and A1B). The pairs of Chl and phylloquinone molecules are arranged in two symmetric branches A and B and bound with PsaA and PsaB subunits, respectively. Branch A includes molecules Chl1A, Chl2A, Chl3A, and phylloquinone A1A, while branch B includes Chl1B, Chl2B, Chl3B, and phylloquinone A1B. The two cofactor branches of the electron transfer chain merge on inter-polypeptide iron–sulfur cluster FX. Terminal electron acceptors – [4Fe-4S] clusters FA and FB – are localized on the stromal subunit PsaC. The electron transfer chain PS I consists of P700, A0 (one or both pairs of Chl molecules designated as Chl2A/Chl3A and Chl2B/Chl3B), A1 (one or both phylloquinone molecules A1A/A1B), and iron–sulfur clusters FX, FA, and FB. It is now known that the electron transfer in PS I occurs through both branches of the redox cofactors from P700 to FX, but the degree of asymmetry of this transfer and the factors that cause it are not clear [5, 6]. In addition, to date the kinetics of the primary charge separation and even the nature of the primary electron donor and acceptor in PS I remain controversial [6, 7]. This review discusses and analyzes the energetic and kinetic data that clarify the mechanism of the primary stages of electron transfer in PS I.
Fig. 2. Relative arrangement in the dimers of chlorophyll molecules constituting the primary donor P700 (Chl1A and Chl1B) and the primary electron acceptor A0A (Chl2A/Chl3A) in PS I in branch A of redox cofactors. The axial ligands to the central Mg atom of chlorophyll molecules and the distance between the plane of the porphyrin rings and Mg atoms are noted.
EXPERIMENTAL STUDIES OF THE PRIMARY STAGES OF ELECTRON TRANSFER IN PS I
We have recently shown that after the preferential excitation of P700 the formation of the primary radical pair P700+A0- occurs within 100 fs, and the subsequent electron transfer forming P700+A1- has a characteristic time of ~25 ps [7]. Subsequent electron transfer reactions from A1A- and A1B- to FX occur with characteristic times of ~200 and ~20 ns, respectively [5, 6, 8, 9]. Then sequential electron transfer occurs from FX to the terminal iron–sulfur clusters FA and FB and further still to the soluble proteins ferredoxin or flavodoxin. Photooxidized P700+ is reduced by plastocyanin or cytochrome c6, returning all cofactors of PS I back to their original state, where the primary electron donor P700 is reduced and all subsequent acceptors are oxidized. In the absence of exogenous electron donors and acceptors, the charge-separated state P700+[FA/FB]- recombines to the ground state with a characteristic time of ~50 ms [10, 11].
Chl2A/Chl2B and Chl3A/Chl3B molecules, constituting the primary acceptor A0, are characterized by unusual axial ligands, namely, water in the case of Chl2A/Chl2B and methionine residues in the case of Chl3A/Chl3B. The methionine residues (Met688PsaA and Met668PsaB) are conserved in all known species of plants and cyanobacteria. These methionine residues have been replaced in cyanobacteria mutants by leucine, histidine, and asparagine residues [12-14]. Ultrafast optical measurements demonstrated that the electron transfer kinetics from A0- to A1 is slowed in PS I from the mutants in branch A (M688LPsaA, M688NPsaA, and M688HPsaA), while the kinetics of the mutants in branch B (M668LPsaB, M668NPsaB, and M668HPsaB) do not differ from the kinetics of PS I observed in the wild-type cyanobacteria [13, 14]. These data indicate the asymmetric contribution of cofactor branches A and B in the formation of secondary ion-radical pair P700+A1-. Time-resolved study of the EPR spectra of PS I mutants M688NPsaA and M668NPsaB at the frequency of 95 GHz (W-band) at 100 K demonstrated that the kinetics of charge recombination were similar in PS I from the wild-type and the branch B mutant and was significantly different in PS I from the branch A mutant [15]. Analysis of the electron spin echo envelope modulation (ESEEM) showed that the distances between the centers of ion-radical pair P700+A1- in PS I from the wild-type and from the branch B mutant correspond to electron transfer only through the A branch.
CALCULATIONS OF ENERGETIC CHARACTERISTICS OF PRIMARY CHARGE SEPARATION IN PS I
Estimation of the energetic characteristics of the electron transfer in PS I is crucial for theoretical description of the primary charge separation and interpretation of the experimental data described in the previous section. In this section we will briefly describe the results of our calculations of redox potentials of PS I cofactors, obtained by estimation of the electrostatic interactions between cofactors and protein and with each other, based on its atomic structure ([2], PDB code 1JB0).
Functioning of the system of molecules with the same chemical nature (Chl molecules) in the sequence of redox reactions as both donors and acceptors of electron is possible due to the modification of their redox properties through the interaction with the protein environment. The greatest influence on the redox potentials of P700 and A0 is caused by the interaction between Chl molecules of RC with their axial ligands and by the electric dipole moments of the peptide groups.
The ligands of Chl1A and Chl1B molecules are histidines, the ligands of Chl2A and Chl2B are water molecules, and the ligands of Chl3A and Chl3B are methionines (Fig. 2). The imidazole ring of histidine has a significantly greater electric dipole moment than a water molecule or a methionine residue. The Nε-atom of the imidazole ring of histidine carries a negative charge of ~0.56-0.57 elementary charge [16, 17]. As the histidine ring, which is the ligand of Chl1A (Chl1B), is directed to the central Mg atom with this atom, it creates a significant negative electrical potential in the tetrapyrrole rings of P700 (–0.23 V according to our calculations within the macroscopic model described in [18]), stabilizing the oxidized state of the molecule. For other ligands – water molecules and methionine – this electrostatic effect is ~(–0.1 V) [18]. Influence of the local electric field distribution in the protein on the redox potentials of cofactors – Chl molecules – leads to the fact that electron transfer from P700* to the primary electron acceptor, which consists of Chl3A (Chl3B) or Chl2A/Chl3A dimer (Chl2B/Chl3B dimer), is energetically favorable.
In addition to these effects, which can be described in terms of classical electrostatics, an important role in determining the redox properties of P700 and A0, which is necessary for the primary charge separation, is played by the electronic conjugation arising from the interaction of π-orbital systems of parallel porphyrin rings. As the result of such interaction of π-orbital systems, the charge is delocalized over both porphyrin rings, and two chlorophyll molecules can function as a single redox center, A0. In this case the negative charge, appearing on Chl2 and Chl3 molecules as the result of photo-induced charge separation in PS I, is stabilized as compared with the case of non-interacting Chl2 and Chl3 molecules. This effect is manifested in some increase in the redox potential of the A0/A0- couple. According to our calculations using the methods of quantum chemistry, this increase is ~0.045 V; a similar coupling effect exists for P700, lowering the value of Em(P700/P700+), as compared with the redox potentials of monomeric chlorophyll molecules forming the P700, by 0.095 V [18].
We calculated the redox potential (Em) of the primary electron donor (P700/P700+) by the semi-continuum approach (taking into account the heterogeneity of the dielectric constant of PS I) in combination with quantum chemistry methods (taking into account the effect of electron pairing in the P700 dimer); this value was found to be +0.45 V [18]. When PS I is excited by light with a wavelength of 700 nm (quantum energy of 1.77 eV), electronic excitation is localized on the dimer P700, turning it into a strong reducer P700* with Em value of P700*/P700+ pair equal to –1.32 V, which is 50-90 mV less than Em of the primary acceptor A0 (Em of the A0A/A0A- pair is –1.23 V; Em of the A0B/A0B- pair is –1.27 V [18]).
An alternative model of the primary stages of charge separation in PS I was recently proposed [19], in which the role of the primary electron donor is played by monomeric Chl2A (Chl2B), and the role of the primary acceptor is assumed by Chl3A monomer (Chl3B). Analysis of the electrostatic interactions between the molecules of chlorophyll Chl2A (Chl2B) and Chl3A (Chl3B) with their protein environment apparently evidences against this hypothesis. Calculation of the redox potential of the Chl2A/Chl2A+ and Chl2B/Chl2B+ pairs gives the value of +0.82 V, and the potential of Chl3B/Chl3B- and Chl3A/Chl3A- pairs, which correspond to A0 in this model, is ~(–1.01 V) [18]. As a result, the redox potential of the hypothetical acceptor (redox couple Chl3/Chl3-) becomes about 60 mV lower than the potential of the hypothetical donor (redox couple Chl2*/Chl2+). Thus in this model the primary charge separation between Chl2A (Chl2B) and Chl3A (Chl3B) is thermodynamically unfavorable, and the functioning of Chl2A (Chl2B) as the primary electron donor seems unlikely.
MODELING THE KINETICS OF FORMATION OF THE PRIMARY AND SECONDARY ION-RADICAL PAIRS
Electron transfer in biological systems can be described in terms of Marcus theory [20], which links the transfer rate constant to the free energy of the reaction, the reorganization energy of the system, and the electronic conjugation between the donor and acceptor. Several empirical approximations were proposed to describe the dependence of the electronic coupling on the distance between donor and acceptor in proteins [21, 22].
Previously Santabarbara et al. [23] proposed a kinetic model of PS I, constructed on the basis of Marcus equation in Moser–Dutton approximation [21], that takes into consideration the possibility of an independent electron transfer through either branch of cofactors (A or B). The distances between the redox cofactors in the model were taken from the crystallographic structure of PS I, and the values of the redox potentials of cofactors and estimates of the reorganization energies of the corresponding reactions were obtained from indirect data published previously [19, 24]. The kinetics of formation of the primary and secondary ion-radical pairs in this model were distinct for the two branches of cofactors with characteristic times τ of 8.9 and 6.5 ps for the primary charge separation and 35.5 and 25 ps for the secondary separation along branches A and B, respectively. These kinetics, calculated within the framework of this model, contradict the experimental data with femtosecond resolution on the primary ion-radical pair formation [7].
Recently in our laboratory molecular dynamics studies of PS I were performed [25], which made it possible to estimate the reorganization energy λ of the primary and secondary charge separation reactions in both branches of cofactors. Within the framework of the molecular dynamics model, we considered the primary electron acceptor to consist either of the third chlorophyll Chl3A/Chl3B [25], or the dimer of second and third chlorophylls Chl2A/Chl3A and Chl2B/Chl3B with uniform charge distribution between two chlorophyll molecules (our unpublished data). According to the latter model, the value of the outer-sphere reorganization energy λout of the primary charge separation on characteristic time of ~100 fs is ~70 mV, and λout of the secondary charge separation over the time of 100 ps is 550 mV in both branches of cofactors. Inner-sphere reorganization energy value λin was taken as 100 mV [26, 27].
Due to significant discrepancy in estimates based on the model of Santabarbara et al. with experimental data, we attempted to clarify the characteristics of the primary and secondary charge separation reactions in PS I. To describe the kinetics of formation of the primary and secondary ion-radical pairs in both branches of the redox cofactors, we used a system of differential equations described in [23], except for the step of electron excitation transfer from the antenna to P700, which was not simulated. To estimate the values of the PS I cofactor redox potentials and the free energy of charge separation reactions ΔG, we used the data obtained by the semi-continuum approach, which takes into account the heterogeneous distribution of the dielectric constant in PS I and the influence of preexisting protein electrostatic field [18]. The values of reorganization energy λ were taken from the results of molecular dynamics simulation described above [25], as well as from our preliminary calculations. Rates of forward and reverse electron transfer were calculated by the semi-empirical Moser–Dutton equation [21] using these estimates of λ, ΔG, and the distances between cofactors measured during the molecular modeling. The results are presented in the table.
Calculation of the characteristic times of formation of the primary (P700+A0-) and secondary (P700+A1-) ion-radical pairs and the relative contributions of cofactor branches A and B in electron transfer
Note: The table shows the reorganization energy (λ1, λ2), free energy change (ΔG1, ΔG2), as well as the characteristic times of the forward electron transfer (τ1, τ2) and the relative contributions of redox cofactors branches A and B (A1, A2) to the primary and secondary electron transfer.
a, b Data obtained from references [23] and [16], respectively.
According to this model, the characteristic time τ1 of the primary charge separation (formation of P700+A0- pair) was 0.1-0.3 ps, and the characteristic time of the secondary charge separation (P700+A1- pair) τ2 was 16-20 ps, which is in good agreement with the experimental results obtained with the direct excitation of Chl molecules of RC with femtosecond time resolution [7]. It is notable that the slight difference in redox potentials between the primary electron acceptors A0A and A0B in branches A and B led to the emergence of the asymmetry in the electron transfer in the ratio of 70 : 30 in favor of branch A. The model also predicts a very fast (<7 ps) equilibration between states P700+A0A- and P700+A0B-, which is faster than the characteristic time τ2 of the secondary ion-radical pair P700+A1- formation. The secondary charge separation process is kinetically irreversible on the submicrosecond time scale since recombination of charges in the P700+A1- pair occurs on a time scale that is several orders of magnitude greater than the characteristic time of the forward transfer from A1 to FX and is accompanied by increased asymmetry between the cofactor branches of PS I in favor of branch A.
It should be noted that the use of the Marcus equation derived in non-adiabatic approximation for the description of ultrafast reactions of the primary charge separation with a characteristic time of 100 fs is not indisputable. It is very likely that the kinetics of the primary ion-radical pair formation is affected by vibrational modes of the protein, which are ignored by the Marcus model. Such oscillations were observed experimentally by us earlier [28]. In addition, the empirical Moser–Dutton equation was obtained for transfer reactions at the distance of ≥10 Å, whereas the distance between the primary electron donor P700 and the second pair of chlorophyll molecules Chl2A/Chl2B does not exceed 4 Å.
This paper is dedicated to the memory of the remarkable Russian scientist – founder of national photobiochemistry and pioneer in the study of light-dependent electron transfer in photosynthesis – Alexander Abramovich Krasnovsky. One of the authors (A.Yu.S.) had the good fortune and honor to discuss the mechanism of photosynthetic electron transfer with Prof. A. A. Krasnovsky many times. On the initiative of A. A. Krasnovsky, collaboration was started in 1986 with the laboratory of his disciple, V. A. Shuvalov, on the kinetics of electron transfer in the reaction centers of the photosynthetic bacterium Rhodopseudomonas (Blastochloris) viridis, for which the X-ray crystal structure with atomic resolution was first obtained [3]. At the present time, this cooperation continues in the study of the primary reactions of charge transfer in PS I and PS II complexes [7, 14, 29].
This study was supported by the Russian Foundation for Basic Research (grants 11-04-91330, 12-04-00821, and 13-04-40299-H) and CRDF grant RUB1-7029-MO-11.
1.Sadekar, S., Raymond, J., and Blankenship, R. E. (2006) Mol. Biol. Evol., 23, 2001-2007.
2.Jordan, P., Fromme, P., Witt, H. T., Klukas, O., Saenger, W., and Krauß, N. (2001) Nature, 411, 909-917.
3.Deisenhofer, J., Epp, O., Miki, K., Huber, R., and Michel, H. (1985) Nature, 318, 618-624.
4.Komiya, H., Yeates, T. O., Rees, D. C., Allen, J. P., and Feher, G. (1988) Proc. Natl. Acad. Sci. USA, 85, 9012-9016.
5.Guergova-Kuras, M., Boudreaux, B., Joliot, A., Joliot, P., and Redding, K. (2001) Proc. Natl. Acad. Sci. USA, 98, 4437-4442.
6.Srinivasan, N., and Golbeck, J. H. (2009) Biochim. Biophys. Acta Bioenerg., 1787, 1057-1088.
7.Shelaev, I. V., Gostev, F. E., Mamedov, M. D., Sarkisov, O. M., Nadtochenko, V. A., Shuvalov, V. A., and Semenov, A. Y. (2010) Biochim. Biophys. Acta Bioenerg., 1797, 1410-1420.
8.Brettel, K. (1988) FEBS Lett., 239, 93-98.
9.Setif, P., and Bottin, H. (1989) Biochemistry, 28, 2689-2697.
10.Sauer, K., Mathis, P., Acker, S., and Van Best, J. A. (1978) Biochim. Biophys. Acta, 503, 120-134.
11.Vassiliev, I. R., Jung, Y. S., Mamedov, M. D., Semenov, A., and Golbeck, J. H. (1997) Biophys. J., 72, 301-315.
12.Cohen, R. O., Shen, G., Golbeck, J. H., Xu, W., Chitnis, P. R., Valieva, A. I., van der Est, A., Pushkar, Y., and Stehlik, D. (2004) Biochemistry, 43, 4741-4754.
13.Dashdorj, N., Xu, W., Cohen, R. O., Golbeck, J. H., and Savikhin, S. (2005) Biophys. J., 88, 1238-1249.
14.Semenov, A. Y., Mamedov, M. D., Golbeck, J. H., Shuvalov, V. A., and Nadtochenko, V. A. (2013) in Abst. Int. Conf. "Photosynthesis Research for Sustainability" (Feyziyev, Y. M., Huseinova, I. M., and Allakhverdiev, S. I., eds.) Nurlar, Baku, p. 79.
15.Savitsky, A., Gopta, O., Mamedov, M., Golbeck, J. H., Tikhonov, A., Moebius, K., and Semenov, A. (2010) Appl. Magnet. Resonance, 37, 85-102.
16.Cornell, W. D., Cieplak, P., Bayly, C. I., Gould, I. R., Merz, K. M., Ferguson, D. M., Spellmeyer, D. C., Fox, T., Caldwell, J. W., and Kollman, P. A. (1995) J. Am. Chem. Soc., 117, 5179-5197.
17.Sitkoff, D., Sharp, K. A., and Honig, B. (1994) J. Phys. Chem., 98, 1978-1988.
18.Ptushenko, V. V., Cherepanov, D. A., Krishtalik, L. I., and Semenov, A. Y. (2008) Photosynth. Res., 97, 55-74.
19.Muller, M. G., Niklas, J., Lubitz, W., and Holzwarth, A. R. (2003) Biophys. J., 85, 3899-3922.
20.Marcus, R. A., and Sutin, N. (1985) Biochim. Biophys. Acta, 811, 265-322.
21.Moser, C. C., and Dutton, P. L. (1992) Biochim. Biophys. Acta, 1101, 171-176.
22.Onuchic, J. N., Beratan, D. N., Winkler, J. R., and Gray, H. B. (1992) Annu. Rev. Biophys. Biomol. Struct., 21, 349-377.
23.Santabarbara, S., Heathcote, P., and Evans, M. C. W. (2005) Biochim. Biophys. Acta, 1708, 283-310.
24.Ishikita, H., and Knapp, E.-W. (2003) J. Biol. Chem., 26, 52002-52011.
25.Milanovsky, G. E., Ptushenko, V. V., Golbeck, G. H., Semenov, A. Yu., and Cherepanov, D. A. (2014) Biochim. Biophys. Acta, in press.
26.Sigfridsson, E., Olsson, M. H. M., and Ryde, U. (2001) J. Phys. Chem. B, 105, 5546-5552.
27.Amashukeli, X., Gruhn, N. E., Lichtenberger, D. L., Winkler, J. R., and Gray, H. B. (2004) J. Am. Chem. Soc., 126, 15566-15571.
28.Sarkisov, O. M., Gostev, F. E., Shelaev, I. V., Novoderezhkin, V. I., Gopta, O. A., Mamedov, M. D., Semenov, A. Y., and Nadtochenko, V. A. (2006) Phys. Chem. Chem. Phys., 8, 5671-5678.
29.Shelaev, I. V., Gostev, F. E., Vishnev, M. I., Shkuropatov, A. Ya., Ptushenko, V. V., Mamedov, M. D., Sarkisov, O. M., Nadtochenko, V. A., Semenov, A. Yu., and Shuvalov, V. A. (2011) J. Photochem. Photobiol. B: Biol., 104, 44-50.

redpajama_set_name: RedPajamaCommonCrawl


text:
Discover the Trail
Trail Stats & History
Thru-Paddle Basics
Section Paddles
— Maps & GPS
— Navigation Confusion
— Permits & Fees
— Resupply
— Water
— Fuel Resupply
— Physical Preparation
— Finances
— Skills Checklist
— Rest & Zero Days
— To & From the Termini
— Choosing a Kayak
— Packing the Kayak
— Marine Gear
— Camping Gear
— On Your PFD
— Electronics
— Photography
— Gear Checklist
— The Anti-Checklist
— Grocery Shopping
— Food Prep & Storage
On-Trail Challenges
— Health Issues
— Sanitation
— Weather
— Wildlife
— Insects
— Dangerous Plants
— Corrosion
— Emergencies
The Thru-Paddle Experience
— Mental Challenges
— Ethical Paddling
— Trail Lingo
— After Your Adventure
— Thru-Paddle Alumni
Foreign Travelers
Protect Florida's Environment
Blog Archive from 2008-09
The Open Boat
Thru-Paddle Florida
Mental Challenges
The Biggest Obstacles are in Your Head
Most guidebooks and websites like this one focus on obvious, external challenges one might face, like inclement weather. Everyone faces these objective problems, which have objective solutions that can be tested empirically. While these physical and material preparations are important, equally important is mental and emotional preparation.
So Why Are You Doing This?
While hiking the AT, a fellow thru-hiker invited me to a party at his parent's house. Me and three other hikers caught a ride from the trail to a nearby town. We stood out in a party thrown by wealthy New Englanders who wore pressed white pants and polos and drank wine under rented canopies. I defended my appearance to a scowling woman, telling her I had been hiking the AT for five months.
"Well, that must be nice," she said. "To be able to just pick up and go. Some of us have to work."
I didn't care enough about her opinion to counter the implication that I was a child of privilege. It was not the things I had in my life that made the journey possible — it was the things I didn't have, like health insurance, a job, a house, an apartment, a wife, a girlfriend, kids, et cetera. Over two years, I had sacrificed a career and two relationships to make the trip possible.
I don't know why I made those sacrifices — the trail was an indescribable, inexplicable force that took hold of me. During the first anxious nights on the trail in Georgia, hopeful thru-hikers tried to ask other hikers why they wanted to thru-hike. The nervous uncertainty on their faces was obvious. They doubted their own motivations and hoped to reinforce their weakening resolve with the words of others, but no one had an answer. No one knew precisely why they were there.
Months later in Virginia, a middle school class came to a hiker hostel and me and a few other hikers did a Q&A with them. A boy asked why we were thru-hiking and the room fell into stony silence.
"I'm in it for the money and the women," I said. Big laughs.
Feel free to use that line when someone asks you why you are doing what you are doing.
Do It To Do It, Not To Get It Done
Jokes aside, here is the real reason you need to get up every morning, break camp, and paddle for seven hours: to do it. Don't try to do the CT because you want to finish it, because you want to reach the end. To make what I mean clear, let me tell you about when I was thru-hiking the Appalachian Trail. In the first weeks of the hike, I met a lot of guys whose imaginations had already reached Maine when their bodies were still in Georgia. They flew out of camp every morning and would push themselves to do high-mileage days. They seemed anxious to reach the end of the Trail, but one-by-one I watched them quit. Their great anxiety and energy to make progress, to feel some sense of completion was thwarted by the reality that 2000 miles could not be hiked quickly, that there wouldn't be any feeling of completion for months. They grew frustrated and discouraged; their mental stamina deteriorated.
Each of these guys was physically capable of reaching Maine, but their motives for hiking were all wrong. They were hiking the AT in order to finish it, rather than simply to do it, and as a result, their minds were always in the future, and they were never able to enjoy the present. My favorite explication of this idea is Vietnamese Zen Buddhist Nhat Hanh's dishwashing story from his book The Miracle of Mindfulness (1975, page 4). The philosophical parts are in bold:
In the United States, I have a close friend named Jim Forest. When I first met him eight years ago, he was working with the Catholic Peace Fellowship. Last winter, Jim came to visit. I usually wash the dishes after we've finished the evening meal, before sitting down and drinking tea with everyone else. One night, Jim asked if he might do the dishes.
I said, "Go ahead, but if you wash the dishes you must know the way to wash them."
Jim replied, "Come on, you think I don't know how to wash the dishes?"
I answered, "There are two ways to wash the dishes. The first is to wash the dishes in order to have clean dishes and the second is to wash the dishes in order to wash the dishes."
Jim was delighted and said, "I choose the second way — to wash the dishes to wash the dishes."
From then on, Jim knew how to wash the dishes. I transferred the "responsibility" to him for an entire week. If while washing dishes, we think only of the cup of tea that awaits us, thus hurrying to get the dishes out of the way as if they were a nuisance, then we are not "washing the dishes to wash the dishes." What's more, we are not alive during the time we are washing the dishes. In fact, we are completely incapable of realizing the miracle of life while standing at the sink. If we can't wash the dishes, the chances are we won't be able to drink our tea either. While drinking the cup of tea, we will only be thinking of other things, barely aware of the cup in our hands. Thus we are sucked away into the future—and we are incapable of actually living one minute of life.
This is perhaps a lesson that to be truly understood, has to be experienced.
Coping with Adversity
I give this advice to everyone: If you can paddle the first 100 miles, then physically you can make it to Fort Clinch. However, if your head and your heart aren't in the right place, you'll quit and go home.
The biggest challenges on a long-term, long-distance trek are mental. Knowing, accepting, and understanding of this is the best preparation.
I experience four consistent and predictable stages of anger and despair when things get hard on the trail. When the rain won't stop, my gear is muddy, I'm cold, and it's been too long since my last zero-day, certain things begins to happen:
First, I become upset with the trail itself. I have thoughts like these: "I can't believe I have to… why the hell does it go here… it's so fucking stupid for it to go this way… I hate this weather…" et cetera.
Second, I become upset with my gear: "The maps are shit… whoever wrote the guidebook doesn't know what they're talking about… this tent's a piece of shit… fuck this stove…" et cetera
Third, I become upset with the people in my group: "It's so typical he would do this… what the hell is wrong with him… why doesn't he… I wish he would shut up…" et cetera
Fourth, everything that has ever gone wrong in my life swells up from my memory: every failed relationship, every resentment I ever had toward my parents, every frustration or setback in college, et cetera.
How long the miserable conditions persist is directly related to which stage I reach. If the misery only lasts for a few hours one day, I'll only hit stage one. If the conditions last longer, stage two is reached, and so on. Be aware that this will happen to you — and that you can push past it. Reaching stage four can feel like hitting a wall, and I think this is when people quit. But if you just keep going, you'll make it.
I have had a number of epiphanies due to these moments of utter despair. Once I had reached stage four, and then realized that I wasn't fighting the trail, or even the sea. I was fighting myself. The biggest obstacles in my way were my own fatigue, discomfort, thirst, and hunger. I was getting in my own way, and after this epiphany, everything became easier. This lesson stayed with me after I finished the trail and is not something that can be taught. You may understand it intellectually, but to feel it, to be changed by it — it needs to be experienced firsthand.
Personal Qualities Needed
Guidebooks and websites (including this one) always have checklists. But in addition to the usual gear checklists and preparation checklists I am including a checklist of character traits and personal skills that make one likely to succeed during a thru-hike.
This is not a list of must haves. After all, no one is perfect and no individual has every quality listed below. But keep in mind that in the same way everyone believes they have a great sense of humor (which of course is not true), we often believe the best about ourselves. Self-evaluation is hard and this list is meant as an aid for one's self-inventory. Where we come up lacking, the trail itself will help us grow, if we let it.
Qualities of a Great Traveler:
1) An Easygoing Disposition
a temper as serene at the end of the day as at the beginning*
a willingness and eagerness to try new foods
an active mind not easily bored
delight toward the unexpected
an easy laugh
2) A Love of Human Nature
a love to meet new people
quick judge of character
ability to make new friends easily
inexhaustible patience for other people
empathetic, selfless, & considerate
interest in local history, customs, & culture
3) A Love of Nature
a sense of belonging in the natural world
comfortable when dirty
the ability to sleep anywhere
derives a sense of wonder from the natural world
does not fear wildlife
4) Determination & Self-Control
a calm composure during a crisis
the ability to take decisive action quickly
a good organizer
embraces lengthy & tedious planning
ability to set long-term goals and stick to a plan
good with money
* This list was inspired by Freya Stark's "Ten Qualities Needed by a Traveler" from which I took "a temper as serene at the end of the day as at the beginning." That line struck me as extremely insightful.
Freya Stark, an British adventurer and author of twenty books, also wrote these words of wisdom: "One can only really travel if one lets oneself go and takes what every place brings without trying to turn it into a healthy private pattern of one's own and I suppose that is the difference between travel and tourism."
Those who venture onto a trail in order to "find themselves" never do so and usually quit before the finish line. Inner peace, enlightenment, and happiness are not found at the end of the trail. I realized this fact when I met a man on the AT whose son had died tragically. His marriage had fallen apart under the stress and he was on the trail in order to escape his pain and find solace. Instead, he was trapped alone with that pain and was suffering even more.
That said, it is impossible to spend months away from one's normal life, alone in the wilderness, and not be changed by the ordeal. The nature of the change differs from person to person due to our personalities, idiosyncrasies, and unique experiences. Just keep in mind that you should never undertake a thru-hike expressly to seek that change. You're in it for the money and the women, remember?
Alafia River Press - alafiariverpress@gmail.com


This pretty pair of old vases (nineteenth time) is gray cast iron (lack of paint and wear time). Medici style, each vase is based on a carved stone base (pillar top pose sealed). It presents gadroons and two large handles very expressive and worked. 30 cm without the base, 43 cm with the base. 32 cm without handles, 47 cm with handles base: 35 cm x 35 cm x h 13 cm.
A handle is unsoldered, so to restore. The item "pair of Medici cast iron vacations nineteenth century" is on sale since Saturday, January 5, 2019. It is in the category "art, antiquities \ architecture, materials \ garden, exterior, ironwork ". The seller is "olivier-georges-antiques" and is located in castelnaudary. This item can be shipped to the following country: France.


text:
Home GREY HATS Team JUSTIN WEAVER
JUSTIN WEAVER
A.K.A: Magnum
RECORD: 8-5-0
TEAM: Team Viper
OUT OF: Lincoln, NE
HOMETOWN: Franklin, NE
Last Fight L/ Mike Messer
Next Fight Angel Ortega
WordPress Video Gallery Plugin
Justin "Magnum" Weaver, born (August 3rd, 1989) in York, Nebraska, moved with his family and grew up in Riverton, Nebraska a small town 200 miles Southwest of Omaha.
Justin Weaver got his start in MMA through his friend and fellow Grey Hat Team Member Cody Land. "I wrestled in college at Hastings College in Nebraska and met Cody and he introduced me to the Hard Knocks Gym there. After that I was hooked on Mixed Martial Arts," says Weaver. Justin trains in kickboxing, Jiu Jitsu and wrestling 6 days a week at Lincoln MMA with Team Viper and considers Robert Rojas to be his mentor at this point in his career. Justin held the MCF Lightweight Title belt and will be fighting Angel Ortega for another Lightweight Title in October of 2014.
Weaver considers his most impressive victory to be against Jordan Vigil (175 lbs) at MCF 8. "I fought Vigil kind of last minute at 175. It was a big move for me and I came out with a win. It was challenging, fighting at that weight. That fight gave me a lot of confidence to move on in my career," says Weaver. Justin considers himself to be a little above average as a fighter right now. "I am training hard everyday to improve and I just got to keep winning. I'd like to fight on an RFA card at some point soon. I think that will help put me on the map nationally," says Weaver.
When he is not training Justin works full time in underground pipeline construction. Justin was one of the inaugural members of the Grey Hat Team and has been an active part of promoting MMA Futures. "I love what you guys have done for me, Cody and the other guys. I've met a lot of people especially for out-of-town training. It has been a great asset for me to be a part of the team," says Weaver. One thing that most people don't know about Justin Weaver is that he scored a 29 on his ACT to get into college. "I was kind of a nerdy smart kid in high school. I had never been in a fight until I did it in the cage," says Weaver.
Justin's family is very supportive of his choice to compete in MMA. "My dad was all for it from the git-go but my mom said to me, 'Justin, you have got to grow up sometime.' But she got over it and now she comes to all of my fights," says Weaver. When asked to describe his life right now in one word, Weaver says, "Extreme." Justin works hard to be the best he can be an we are very proud to have him as part of the MMA Futures Grey Hat Team. We look forward to great things from this young man in the near future.
MAGNUM'S MAJOR SPONSORS BELOW
MMA Future "Pioneer" Hat
MMA Futures "Building" T-Shirt
MMA Futures – DBN T-Shirt
Legal Beatdown 2015 – Pinnacle Combat
Nathan Rogers - January 24, 2015
MMA Futures is live at the 5 Flags Event Center in Dubuque Iowa to Bring you live play-by-play from Pinnacle Combat's Legal Beatdown 2015
Trey Smith – Meet a Fighter
MMA 101: Overtraining Is A Myth
UFC Fight Night 133 Results: "Cigano" Returns In Triumphant Fashion
Dynasty Combat Sports 47: Ryan Leininger Claims Title


What went wrong with Trump's family-separation effort at the border?
In Texas at a hub for border crossings, families spread throughout U.S.
Two parents hoped to raise $1,500 for separated families. Then their Facebook fundraiser went viral.
Trump says, 'Our country is full.' The truth is we need more immigrants.


text:
Q: Advantages of using Hibernate over Open JPA I want to use Hibernate in my application(In combination with Spring).
so I would like to know what are the general advantages of using Spring Hibernate over Spring Open JPA?
I have seen many links but did not get the clear idea.
Please let me know.

A: *

*Here is a performance comparison statistics for a test and the results of the tests per JPA implementation library.
For this test the time was fixed to 30 minutes of running.

*

*The following chart presents results of a specific test(persisting simple entity objects in batches of 5000 per transactions)

Information sources : Soruce 1 , Source 2
Hope this helps.

redpajama_set_name: RedPajamaStackExchange


I started with 1 coat of OPI Nail Envy, followed by 2 coats of Essence - Black is Back (my favourite black) and finally 2 coats of Miracle Max.
Miracle Max is a glitter filled flakie that turns the most amazing blues and green depending on which way the light hits it. I couldn't stop staring at this!
Wow, what a gorgeous polish!


Why devote the extra time to working with first-time buyers?
For some, the niche generates good feelings akin to first love.
Andi Grant's passion for her sales niche is pretty well summed up in her website's URL, firsttimehome buyerrealestate.com, which is bursting with tips to help buyers in South Los Angeles and Long Beach, Calif., turn their dreams of home ownership into a reality.
24 Hour Real Estate Co., in Downey, Calif., got into the real estate business in 2006 when, as luck would have it, real estate prices began to plummet. But she leaned in during the downturn and, for the past three years, Grant has focused her marketing efforts on the particularly challenging first-time buyer segment, which now comprises 70 percent of her business.
So what's the appeal of a niche that typically requires extra hand-holding, particularly when it comes to obtaining a loan? "I love helping them to achieve the American dream," she says.
At first, Grant didn't pursue first-time home buyers. They came to her—at open houses. "I had to equip myself with information specifically geared to answering their many questions on the spot," she says. Creating a branding campaign aimed at them was the next step.
Making sure first-timers are prepared for the responsibility is Saxena's priority. When they aren't, "I keep in touch to see if their decision factors have changed or if they need more help." Nothing beats the feeling, however, when the pieces come together. "Everyone remembers their first love, and everyone remembers their first home purchase," she says.
making first-timers your exclusive focus.
In five to seven years, they'll be back in the market, says David Kent, ABR, CRS, broker-owner of The Real Buyers Agent HBC in Charleston, S.C., and you want that business coming back to you.


By Robyn WischA federal judge has dismissed a lawsuit against some of the largest beer manufacturers in the world. The suit claimed the beer makers were contributing to chronic alcoholism on the Pine Ridge Indian Reservation in South Dakota.
The suit was filed in district court in Lancaster County on behalf of the Oglala Sioux Tribe. It named major beer makers, including Anheuser Busch and Miller Coors among others, along with four liquor stores that operate in the border town of Whiteclay, Neb. Whiteclay sits a few hundred yards from the border of Pine Ridge and is home to about 11 people. But the stores sell what amounts to four million cans of beer in Whiteclay each year. So most of that alcohol is presumed to be transported over the border into Pine Ridge, which is a dry reservation.And:U.S. District Judge John Gerrard dismissed the suit Monday but in his ruling, he said there is "little question that alcohol sold in Whiteclay contributes significantly to tragic conditions on the reservation." He suggested the defendants "could, or should" do more to improve those conditions before saying the matter does not belong in federal court.
White said the judge has left the door open for the tribe to pursue the case in state court, which he is advising his clients to do. Lawyers for the stores and the beer makers have declined to comment after repeated requests.Comment: As everyone but the Indians, perhaps, expected, the lawsuit went nowhere. But if it focused more attention on the problem, it served that purpose, at least.
For more on Whiteclay, see Pix of My South Dakota Trip and Fiasco Raps About Pine Ridge.


text:
<?php
/**
 * Process.php
 *
 * The Process class is meant to simplify the task of processing
 * user submitted forms, redirecting the user to the correct
 * pages if errors are found, or if form is successful, either
 * way. Also handles the logout procedure.
 *
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 19, 2004
 */
include("../include/session.php");

class Process
{
   /* Class constructor */
   function Process(){
      global $session;
      /* User submitted login form */
      if(isset($_POST['sublogin'])){
         $this->procLogin();
      }
      /* User submitted registration form */
      else if(isset($_POST['subjoin'])){
         $this->procRegister();
      }
      /* User submitted forgot password form */
      else if(isset($_POST['subforgot'])){
         $this->procForgotPass();
      }
      /* User submitted edit account form */
      else if(isset($_POST['subedit'])){
         $this->procEditAccount();
      }
      /**
       * The only other reason user should be directed here
       * is if he wants to logout, which means user is
       * logged in currently.
       */
      else if($session->logged_in){
         $this->procLogout();
      }
      /**
       * Should not get here, which means user is viewing this page
       * by mistake and therefore is redirected.
       */
       else{
          header('Location: ../index.php');
       }
   }

   /**
    * procLogin - Processes the user submitted login form, if errors
    * are found, the user is redirected to correct the information,
    * if not, the user is effectively logged in to the system.
    */
   function procLogin(){
      global $session, $form;
      /* Login attempt */
      $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));

      /* Login successful */
      if($retval){

/*		 if ($session->referrer=="http://www.my.isa-geek.com/index.php") {
*/		 header('Location: main.php');
/*		 }

		 else {
		 header('Location: '.$session->referrer);
		 }
*/      }
      /* Login failed */
      else{
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
         header('Location: '.$session->referrer);
      }
   }

   /**
    * procLogout - Simply attempts to log the user out of the system
    * given that there is no logout form to process.
    */
   function procLogout(){
      global $session;
      $retval = $session->logout();
      header('Location: ../index.php');
   }

   /**
    * procRegister - Processes the user submitted registration form,
    * if errors are found, the user is redirected to correct the
    * information, if not, the user is effectively registered with
    * the system and an email is (optionally) sent to the newly
    * created user.
    */
   function procRegister(){
      global $session, $form;
      /* Convert username to all lowercase (by option) */
      if(ALL_LOWERCASE){
         $_POST['user'] = strtolower($_POST['user']);
      }
      /* Registration attempt */
      $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email']);

      /* Registration Successful */
      if($retval == 0){
         $_SESSION['reguname'] = $_POST['user'];
         $_SESSION['regsuccess'] = true;
		 header('Location: ../welcome.php?user=' . $_POST['user']);

      }
      /* Error found with form */
      else if($retval == 1){
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
         header('Location: ../index.php?show=regform');
      }
      /* Registration attempt failed */
      else if($retval == 2){
         $_SESSION['reguname'] = $_POST['user'];
         $_SESSION['regsuccess'] = false;
         header('Location: ../index.php?show=regform&reg=FAILED&error=' . mysql_error());
      }
   }

   /**
    * procForgotPass - Validates the given username then if
    * everything is fine, a new password is generated and
    * emailed to the address the user gave on sign up.
    */
   function procForgotPass(){
      global $database, $session, $mailer, $form;
      /* Username error checking */
      $subuser = $_POST['user'];
      $field = "user";  //Use field name for username
      if(!$subuser || strlen($subuser = trim($subuser)) == 0){
         $form->setError($field, "* Username not entered
");
      }
      else{
         /* Make sure username is in database */
         $subuser = stripslashes($subuser);
         if(strlen($subuser) < 5 || strlen($subuser) > 30 ||
            !eregi("^([0-9a-z])+$", $subuser) ||
            (!$database->usernameTaken($subuser))){
            $form->setError($field, "* Username does not exist
");
         }
      }

      /* Errors exist, have user correct them */
      if($form->num_errors > 0){
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
      }
      /* Generate new password and email it to user */
      else{
         /* Generate new password */
         $newpass = $session->generateRandStr(8);

         /* Get email of user */
         $usrinf = $database->getUserInfo($subuser);
         $email  = $usrinf['email'];

         /* Attempt to send the email with new password */
         if($mailer->sendNewPass($subuser,$email,$newpass)){
            /* Email sent, update database */
            $database->updateUserField($subuser, "password", md5($newpass));
            $_SESSION['forgotpass'] = true;
         }
         /* Email failure, do not change password */
         else{
            $_SESSION['forgotpass'] = false;
         }
      }

      header('Location: '.$session->referrer);
   }

   /**
    * procEditAccount - Attempts to edit the user's account
    * information, including the password, which must be verified
    * before a change is made.
    */
   function procEditAccount(){
      global $session, $form;
      /* Account edit attempt */
      $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']);

      /* Account edit successful */
      if($retval){
         $_SESSION['useredit'] = true;
         header('Location: settings.php?user=' . $session->username);
      }
      /* Error found with form */
      else{
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
         header('Location: settings.php?user=' . $session->username);
      }
   }
};

/* Initialize process */
$process = new Process;

?>


Welcome to another challenge and this time we have a theme challenge with a fill in the blank introduction! We've just had the March equinox this past week, which signals the first day of spring in the Northern Hemisphere and the first day of fall in the Southern Hemisphere, but our challenge is focusing on the season of spring and your favourite thing about it!
Simply fill in the blank and make your card with that thing as your theme!
Please include the challenge graphic and link back to the challenge in your blog post. Turn off word verification so we can send you lots of feedback. Make sure you link the post not the whole blog to the Linky. Use #AYSI146 when uploading to a public gallery.
meant to load this two days ago and forgot...here is my card if you wanna stop by!


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mongo="http://www.springframework.org/schema/data/mongo"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context.xsd
           http://www.springframework.org/schema/data/mongo
           http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd"
       default-lazy-init="true" default-autowire="byName">

    <context:annotation-config/>
    <mongo:repositories base-package="com.sfl.coolmonkey.coolfs.persistence.repositories.*"/>
    <context:component-scan base-package="com.sfl.coolmonkey.coolfs.persistence.repositories.*"/>

    <mongo:mongo id="mongo"
                 host="#{appProperties['database.mongo.host']}"
                 port="#{appProperties['database.mongo.port']}">
        <mongo:options connections-per-host="#{appProperties['database.mongo.connectionsperhost']}"
                       threads-allowed-to-block-for-connection-multiplier="#{appProperties['database.mongo.threadallowedtoblockforconnectionmultiplier']}"
                       connect-timeout="#{appProperties['database.mongo.connecttimeout']}"
                       max-wait-time="#{appProperties['database.mongo.maxwaittime']}"
                       auto-connect-retry="#{appProperties['database.mongo.autoconnectretry']}"
                       socket-keep-alive="#{appProperties['database.mongo.socket.keepalive']}"
                       socket-timeout="#{appProperties['database.mongo.socket.timeout']}"
                       slave-ok="#{appProperties['database.mongo.slaveok']}"
                       write-number="#{appProperties['database.mongo.write.number']}"
                       write-timeout="#{appProperties['database.mongo.write.timeout']}"
                       write-fsync="#{appProperties['database.mongo.write.fsync']}"/>
    </mongo:mongo>

    <mongo:db-factory id="mongoDbFactory"
                      dbname="#{appProperties['database.mongo.dbname']}"
                      mongo-ref="mongo"
                      username="#{appProperties['database.mongo.username']}"
                      password="#{appProperties['database.mongo.password']}"/>

    <bean id="mongoMappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext"/>

    <bean id="mappingMongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
        <constructor-arg name="dbRefResolver">
            <bean class="org.springframework.data.mongodb.core.convert.DefaultDbRefResolver">
                <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
            </bean>
        </constructor-arg>
        <constructor-arg name="mappingContext" ref="mongoMappingContext"/>
    </bean>

    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
        <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
        <constructor-arg name="mongoConverter" ref="mappingMongoConverter"/>
    </bean>

    <bean id="mongoGridFsVenueFilesTemplate" class="org.springframework.data.mongodb.gridfs.GridFsTemplate">
        <constructor-arg name="dbFactory" ref="mongoDbFactory"/>
        <constructor-arg name="converter" ref="mappingMongoConverter"/>
        <constructor-arg name="bucket" value="${database.mongo.gridfs.venue.bucket}"/>
    </bean>

    <bean id="indexResolver" class="org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver">
        <constructor-arg name="mappingContext" ref="mongoMappingContext"/>
    </bean>

    <bean id="gridFsTemplate" class="org.springframework.data.mongodb.gridfs.GridFsTemplate">
        <constructor-arg ref="mongoDbFactory"/>
        <constructor-arg ref="mappingMongoConverter"/>
    </bean>

</beans>


We offer a full menu all day, we have a full salad bar with over 30 items and have vegetable soup daily as well as a house soup each day, family friendly with seating for small or large groups. Saturdays we have our special All you can eat bbq pork ribs starting at 5pm and of course as with all our dinners it includes soup and salad bar, potato, veggie of the day and the dessert of the day:) And oh Sundays at CC's. Turkey, dressing and all the fixins. We are located right off I94 in Glendive Mt Exit 215.
Great service and the soups were fabby. We had vegetable soup and Wisconsin cheese soup. We also ate the Denver sandwich and a pounded pork sandwich. Half of the sandwiches will be our road trip afternoon snack! Yummy lunch!!
Just what we needed at the end of a long day; simple and yummy diner fare, great service.
Be the first to add a review to the Cc's Family Cafe.