 							double* mesh_vertex,   int mesh_vertex_nb,
 							int* mesh_facet,    int mesh_facet_nb,
 							double* test_dis, double* test_centriod,
-							int* test_index)
+							int* test_index, double* test_seeds,
+							int* test_polygon_nb)
 {
 	int tid = blockIdx.x * blockDim.x + threadIdx.x;
 	

#include "device_atomic_functions.h"

#include "Math_basics.cuh"

#include "Polygon.h"
#include <iostream>

using namespace P_RVD;

//set global variable to store the seeds' position and weight
__device__ double* SeedsInformation;
/*
	process the cuda error
*/

	checkCudaErrors(cudaMemcpy(dev_mesh_facet_index, host_facet_index, sizeof(int) * points_nb * 3, cudaMemcpyHostToDevice));

	checkCudaErrors(cudaMemcpyToSymbol(SeedsInformation, &dev_seedsInformation, sizeof(double*), size_t(0), cudaMemcpyHostToDevice));
	checkCudaErrors(cudaMemcpyToSymbol(SeedsPolygon_nb, &dev_seedsPolyonNumber, sizeof(int*), size_t(0), cudaMemcpyHostToDevice));
	
	int x = (int)sqrt(mesh_facet_nb);
	int y = (int)(mesh_facet_nb / x + 1);
	//set the block
	compute_RVD << < x, y >> >(dev_seeds_pointer, points_nb, dev_mesh_vertex_pointer, mesh_vertex_nb, dev_mesh_facet_index, mesh_facet_nb,
		dev_test_dis, dev_test_center, dev_test_index, dev_test_seeds, dev_test_polygon);

	checkCudaErrors(cudaMemcpy(host_test_dis, dev_test_dis, sizeof(double) * points_nb, cudaMemcpyDeviceToHost));
	checkCudaErrors(cudaMemcpy(host_test_cen, dev_test_center, sizeof(double) * 3, cudaMemcpyDeviceToHost));
	checkCudaErrors(cudaMemcpy(host_test_index, dev_test_index, sizeof(int) * points_nb, cudaMemcpyDeviceToHost));
	checkCudaErrors(cudaMemcpy(host_test_seeds, dev_test_seeds, sizeof(double) * points_nb * 4, cudaMemcpyDeviceToHost));
	checkCudaErrors(cudaMemcpy(host_test_polygon, dev_test_polygon, sizeof(int) * points_nb, cudaMemcpyDeviceToHost));
	//printf("Thread 1:\n");
	//printf("center position : %.17lf, %.17lf, %.17lf \n", host_test_cen[0], host_test_cen[1], host_test_cen[2]);
	//printf("nearest 20 points' index:\n");
	//for (int i = 0; i < 20; ++i)
	//{
	//	printf("%d  : %d  \n",i, host_test_index[i]);
	//}
	//printf("current seed : %d\n", host_test_index[41]);
	//printf("current seed position : %.17lf, %.17lf, %.17lf \n", host_test_dis[3], host_test_dis[4], host_test_dis[5]);

	//printf("the 20 seeds near the current seed\n");
	//for (int i = 0; i < 20; ++i)
	//{
	//	printf("%d  : %d  \n",i, host_test_index[i + 21]);
	//}

	//printf(" %d  %d ȷƽ\n", host_test_index[41], host_test_index[42]);
	//printf("ԭpolygon:\n");
	//printf("vertex number : %d\n", host_test_index[43]);

	//for (int i = 0; i < host_test_index[43]; ++i)
	//{
	//	printf("x : %.17lf, y: %.17lf, z : %.17lf, w : %.6lf\n\n", host_test_dis[6 + i * 4 + 0], host_test_dis[6 + i * 4 + 1], host_test_dis[6 + i * 4 + 2], host_test_dis[6 + i * 4 + 3]);
	//}
	//printf("polygon:\n");
	//printf("vertex number : %d   buffer vertex number : %d\n", host_test_index[44], host_test_index[45]);
	//for (int i = 0; i < host_test_index[44]; ++i)
	//{
	//	printf("x : %.17lf, y: %.17lf, z : %.17lf, w : %.6lf\n\n", host_test_dis[101 + i * 4 + 0], host_test_dis[101 + i * 4 + 1], host_test_dis[101 + i * 4 + 2], host_test_dis[101 + i * 4 + 3]);
	//}

	//printf("ӵĵ\n");
	//for (int i = 0; i < 4; ++i)
	//{
	//	printf("x : %.17lf, y: %.17lf, z : %.17lf, w : %.6lf\n\n", host_test_dis[150 + i * 4 + 0], host_test_dis[150 + i * 4 + 1], host_test_dis[150 + i * 4 + 2], host_test_dis[150 + i * 4 + 3]);
	//}

	//printf("thread 1, facet 1, current seed : %d clipped polygon vertex number : %d\n",host_test_index[20], host_test_index[88]);
	//printf("successfully running!\n");

	ofstream fout("c.txt");
	printf("test : %d current seed :%d  vertex number : %d\n",host_test_index[1], host_test_index[2], host_test_index[3]);
	fout << "seed 185  nearest points" << endl;
	for (int i = 0; i < 20; ++i)
	{
		fout << host_test_index[i] << endl;
	}
	fout << "v1 : " << host_test_dis[0] << host_test_dis[1] << host_test_dis[2] << endl;
	fout << "v2 : " << host_test_dis[0] << host_test_dis[1] << host_test_dis[2] << endl;
	fout << "v2 : " << host_test_dis[0] << host_test_dis[1] << host_test_dis[2] << endl;

	for (int i = 0; i < points_nb; ++i)
	{
		if (host_test_seeds[i * 4 + 3] != 0){
			host_test_seeds[i * 4 + 0] /= host_test_seeds[i * 4 + 3];
			host_test_seeds[i * 4 + 1] /= host_test_seeds[i * 4 + 3];
			host_test_seeds[i * 4 + 2] /= host_test_seeds[i * 4 + 3];
		}
		//printf("seeds %d : %.16lf, %.16lf, %.16lf, , %.16lf \n", i, host_test_seeds[i * 4 + 0]
			//, host_test_seeds[i * 4 + 1], host_test_seeds[i * 4 + 2], host_test_seeds[i * 4 + 3]);
		//fout << i << ':' << host_test_seeds[i * 4 + 0] << ' ' << host_test_seeds[i * 4 + 1] << ' ' << host_test_seeds[i * 4 + 2] << ' ' << host_test_seeds[i * 4 + 3] << endl;
	}
	for (int i = 0; i < points_nb; ++i)
	{
		//fout << i << ':' << host_test_polygon[i] << endl;
	}
}