Ctr2SufManager::~Ctr2SufManager()
{
	//mesh
	delete mesh;
	
	//Contour
	clearOldContour();
	clearContour();

	//clear processed data
	clearPData();

	//clear partition data
	clearPartition();

	//clear face contour data
	clearFaceContour();
}
void KW_CS2Surf::partitionStl()
{
	clearFaceContour();
	//clear the old result, a new generation start from here!
	//because other data may be dependent on the value of partition result, 
	//so before clearpartition, other data must be cleared too!
	clearPartition();

	clearStlSubspaceInfo();

	//temporary data
	floatvector tssver;
	intvector tssedge;
	vector<intvector> tssface;
	intvector tssface_planeindex;
	vector<intvector> tssspace;
	vector<intvector> tssspace_planeside;

	//partition!
	SpacePartitioner partitioner;

	partitioner.partition( planenum, pparam, pbbox, enlargeratio,
		tssver, tssedge, tssface, tssface_planeindex, tssspace, tssspace_planeside);

	//copy them out
	this->vecSSver=tssver;
	this->vecSSedge=tssedge;
	this->iSSfacenum=tssface.size();
	this->vecSSface_planeindex=tssface_planeindex;
	this->vecvecSSface=tssface;
	for (int i=0;i<this->iSSfacenum;i++)
	{
		this->vecSSfaceedgenum.push_back(vecvecSSface.at(i).size());
	}
	this->iSSspacenum=tssspace.size();
	this->vecvecSSspace=tssspace;
	for (int i=0;i<this->iSSspacenum;i++)
	{
		this->vecSSspacefacenum.push_back(this->vecvecSSspace.at(i).size());
	}

	//clear the temporary data   
	tssver.clear();
	tssedge.clear();

	int size = tssface.size();
	for( int i = 0; i < size; i ++ )
		tssface[ i ].clear();
	tssface.clear();
	tssface_planeindex.clear();

	size = tssspace.size();
	for( int i = 0; i < size; i ++)
	{
		tssspace[ i ].clear();
		tssspace_planeside[ i ].clear();
	}
	tssspace.clear();
	tssspace_planeside.clear();	

	SortFaceInfo();
}