void Garment::setSpringAll(){
	int allClothLength = allCloth.size();
	int clothLength =0;
	float tmpx;
	float tmpy;
	float tmpz;

	for(int i = 0;i < allClothLength; i ++){
		clothLength = allCloth.at(i).getVectorMass()->size();
		for(int j = 0;j < clothLength;j ++){
			for(int k = 0;k < clothLength;k ++){

				if(j == k){
					continue;
				}

				tmpx = allCloth.at(i).getVectorMass()->at(j)->x  -  allCloth.at(i).getVectorMass()->at(k)->x;
				if(tmpx > STRUCTLENGTH * 2.0f  + STRUCTLENGTH * 2.0f / 10.0f){
					continue;
				}
				tmpy = allCloth.at(i).getVectorMass()->at(j)->y  -  allCloth.at(i).getVectorMass()->at(k)->y;
				if(tmpy > STRUCTLENGTH * 2.0f  + STRUCTLENGTH * 2.0f / 10.0f){
					continue;
				}
				tmpz = allCloth.at(i).getVectorMass()->at(j)->z  -  allCloth.at(i).getVectorMass()->at(k)->z;
				if(tmpz > STRUCTLENGTH * 2.0f  + STRUCTLENGTH * 2.0f / 10.0f){
					continue;
				}

				float tmplength = sqrt(
									tmpx * tmpx + tmpy * tmpy + tmpz * tmpz
								);

				if(tmplength < STRUCTLENGTH  + STRUCTLENGTH / 10.0f){
					Spring *tmpSring = new Spring(1,allCloth.at(i).getVectorMass()->at(j));

					tmpSring->setConnectedMass(allCloth.at(i).getVectorMass()->at(k));

					allCloth.at(i).getVectorMass()->at(j)->massSpring.push_back(tmpSring);

				}else if(tmplength < STRUCTLENGTH * 1.4142135623f  + STRUCTLENGTH * 1.4142135623f / 10.0f){
					Spring *tmpSring = new Spring(2,allCloth.at(i).getVectorMass()->at(j));

					tmpSring->setConnectedMass(allCloth.at(i).getVectorMass()->at(k));

					allCloth.at(i).getVectorMass()->at(j)->massSpring.push_back(tmpSring);

				}else if(tmplength < STRUCTLENGTH * 2.0f  + STRUCTLENGTH * 2.0f / 10.0f){
					Spring *tmpSring = new Spring(3,allCloth.at(i).getVectorMass()->at(j));

					tmpSring->setConnectedMass(allCloth.at(i).getVectorMass()->at(k));

					allCloth.at(i).getVectorMass()->at(j)->massSpring.push_back(tmpSring);

				}
				
			}

		}
	}
}
/**读入缝*/
bool Garment::readSeam(char * loc){
	int sizeCloth = allCloth.size()/2;


	for(int i = 0;i < sizeCloth/2; i ++){
		for(int j = 0; j < allCloth.at(i).massCloth.size();j ++){

			allCloth.at(i*2).getVectorMass()->at(j)->seamForce = Force(0,0,-SEAMFORCE);

			allCloth.at(i*2 + 1).getVectorMass()->at(j)->seamForce = Force(0,0,SEAMFORCE);
			//
		}
	}


	for(int i = 0;i < sizeCloth; i ++){
		for(int j = 0; j < allCloth.at(2*i).massSeam.size();j ++){
			allCloth.at(2*i).massSeam.at(j)->seamMassPoint=(allCloth.at(2*i+1).massSeam.at(j));
			allCloth.at(2*i).massSeam.at(j)->seamForce = Force(0,0,-SEAMFORCE);
			allCloth.at(2*i+1).massSeam.at(j)->seamMassPoint=(allCloth.at(2*i).massSeam.at(j));
			allCloth.at(2*i+1).massSeam.at(j)->seamForce = Force(0,0,SEAMFORCE);

			Spring *tmpSring = new Spring(1,allCloth.at(2*i).massSeam.at(j));
			tmpSring->setConnectedMass(allCloth.at(2*i+1).massSeam.at(j));
			allCloth.at(2*i).massSeam.at(j)->massSpring.push_back(tmpSring);
			allCloth.at(2*i).massSeam.at(j)->massSpring.push_back(tmpSring);

			tmpSring = new Spring(1,allCloth.at(2*i+1).massSeam.at(j));
			tmpSring->setConnectedMass(allCloth.at(2*i).massSeam.at(j));
			allCloth.at(2*i+1).massSeam.at(j)->massSpring.push_back(tmpSring);
			allCloth.at(2*i+1).massSeam.at(j)->massSpring.push_back(tmpSring);
			//
		}
	}
	

	//for(int i = 0;i < sizeCloth; i ++){
	//	for(int j = 0; j < allCloth.at(2*i).massSeam1.size();j ++){
	//		allCloth.at(2*i).massSeam1.at(j)->setSeamPoint(allCloth.at(2*i+1).massSeam1.at(j));
	//		allCloth.at(2*i+1).massSeam1.at(j)->setSeamPoint(allCloth.at(2*i).massSeam1.at(j));
	//	}
	//}

	int sizearmwidth = allCloth.at(2).massSeam1.size();
	
	int bodysize =allCloth.at(0).massSeam1.size()/2;

	for(int i = 0;i < sizearmwidth; i ++){
		/*allCloth.at(0).massSeam1.at(i)->setSeamPoint(allCloth.at(2).massSeam1.at(i));
		allCloth.at(0).massSeam1.at(i+bodysize)->setSeamPoint(allCloth.at(4).massSeam1.at(i));*/


		Spring *tmpSring = new Spring(1,allCloth.at(0).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(2).massSeam1.at(i));
		allCloth.at(0).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(0).massSeam1.at(i)->massSpring.push_back(tmpSring);

		tmpSring = new Spring(1,allCloth.at(0).massSeam1.at(i+bodysize));
		tmpSring->setConnectedMass(allCloth.at(4).massSeam1.at(i));
		allCloth.at(0).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);
		allCloth.at(0).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);

		/*allCloth.at(2).massSeam1.at(i)->setSeamPoint(allCloth.at(0).massSeam1.at(i));
		allCloth.at(4).massSeam1.at(i)->setSeamPoint(allCloth.at(0).massSeam1.at(i+bodysize));*/


		tmpSring = new Spring(1,allCloth.at(2).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(0).massSeam1.at(i));
		allCloth.at(2).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(2).massSeam1.at(i)->massSpring.push_back(tmpSring);

		tmpSring = new Spring(1,allCloth.at(4).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(0).massSeam1.at(i+bodysize));
		allCloth.at(4).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(4).massSeam1.at(i)->massSpring.push_back(tmpSring);

		/*allCloth.at(1).massSeam1.at(i)->setSeamPoint(allCloth.at(3).massSeam1.at(i));
		allCloth.at(1).massSeam1.at(i+bodysize)->setSeamPoint(allCloth.at(5).massSeam1.at(i));*/

		tmpSring = new Spring(1,allCloth.at(1).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(3).massSeam1.at(i));
		allCloth.at(1).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(1).massSeam1.at(i)->massSpring.push_back(tmpSring);

		tmpSring = new Spring(1,allCloth.at(1).massSeam1.at(i+bodysize));
		tmpSring->setConnectedMass(allCloth.at(5).massSeam1.at(i));
		allCloth.at(1).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);
		allCloth.at(1).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);

		/*allCloth.at(3).massSeam1.at(i)->setSeamPoint(allCloth.at(1).massSeam1.at(i));
		allCloth.at(5).massSeam1.at(i)->setSeamPoint(allCloth.at(1).massSeam1.at(i+bodysize));*/

		tmpSring = new Spring(1,allCloth.at(3).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(1).massSeam1.at(i));
		allCloth.at(3).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(3).massSeam1.at(i)->massSpring.push_back(tmpSring);

		tmpSring = new Spring(1,allCloth.at(5).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(1).massSeam1.at(i+bodysize));
		allCloth.at(5).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(5).massSeam1.at(i)->massSpring.push_back(tmpSring);
	}

	//sizearmwidth = bodysize -sizearmwidth;

	for(int i = sizearmwidth;i < bodysize; i ++){
		allCloth.at(0).massSeam1.at(i)->setSeamPoint(allCloth.at(1).massSeam1.at(i));
		allCloth.at(0).massSeam1.at(i+bodysize)->setSeamPoint(allCloth.at(1).massSeam1.at(i+bodysize));
		allCloth.at(0).massSeam1.at(i)->seamForce = Force(0,0,-SEAMFORCE);
		allCloth.at(0).massSeam1.at(i+bodysize)->seamForce = Force(0,0,-SEAMFORCE);

		allCloth.at(1).massSeam1.at(i)->setSeamPoint(allCloth.at(0).massSeam1.at(i));
		allCloth.at(1).massSeam1.at(i+bodysize)->setSeamPoint(allCloth.at(0).massSeam1.at(i+bodysize));
		allCloth.at(1).massSeam1.at(i)->seamForce = Force(0,0,SEAMFORCE);
		allCloth.at(1).massSeam1.at(i+bodysize)->seamForce = Force(0,0,SEAMFORCE);

		Spring *tmpSring = new Spring(1,allCloth.at(0).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(1).massSeam1.at(i));
		allCloth.at(0).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(0).massSeam1.at(i)->massSpring.push_back(tmpSring);

		tmpSring = new Spring(1,allCloth.at(0).massSeam1.at(i+bodysize));
		tmpSring->setConnectedMass(allCloth.at(1).massSeam1.at(i+bodysize));
		allCloth.at(0).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);
		allCloth.at(0).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);

		tmpSring = new Spring(1,allCloth.at(1).massSeam1.at(i));
		tmpSring->setConnectedMass(allCloth.at(0).massSeam1.at(i));
		allCloth.at(1).massSeam1.at(i)->massSpring.push_back(tmpSring);
		allCloth.at(1).massSeam1.at(i)->massSpring.push_back(tmpSring);

		tmpSring = new Spring(1,allCloth.at(1).massSeam1.at(i+bodysize));
		tmpSring->setConnectedMass(allCloth.at(0).massSeam1.at(i+bodysize));
		allCloth.at(1).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);
		allCloth.at(1).massSeam1.at(i+bodysize)->massSpring.push_back(tmpSring);
	}

	return true;
}