 	 */
 	__device__
 		void action(
-		const CudaPolygon polygon, index_t current_seed, double* retdata
+		const CudaPolygon& polygon, const index_t& current_seed, double* retdata
 	){
-		double weight;
-		double3 position;
-
 		index_t _v1 = 0;
 		index_t _v2, _v3;
 
 		double3 pos1, pos2, pos3;
-		double d1, d2, d3;
+		//double d1, d2, d3;
 		int triangle_nb = polygon.vertex_nb - 2;
 		if (triangle_nb <= 0) return;
-		
+
 		double total_weight = 0.0;
 		double3 centriodTimesWeight = { 0.0, 0.0, 0.0 };
 

	 */
	__device__
	void swap_polygon(CudaPolygon& ping, CudaPolygon& pong){
		
		ping = pong;
		pong.vertex_nb = 0;
	}


		// normal vector of the bisector [i, j]
		// and m the middle point of the bisector.
		double d = 0.0;
		double3 temp = sub(position_i, position_j);
		d = dot(add(position_i, position_j), temp);

		//The predecessor of the first vertex is the last vertex
		int prev_k = ping.vertex_nb - 1;

		//get the position data
		

		//then we compute prev_vertex_position "cross" n 
		//prev_l = prev_vertex_position . n
		double prev_l = ping.vertex[prev_k].x * temp.x + ping.vertex[prev_k].y * temp.y + ping.vertex[prev_k].z * temp.z;

		int prev_status = sgn(2.0 * prev_l - d);

		//traverse the Vertex in this Polygon
		for (int k = 0; k < ping.vertex_nb; ++k){

			

			double l = ping.vertex[k].x * temp.x + ping.vertex[k].y * temp.y + ping.vertex[k].z * temp.z;

			int status = sgn(2.0 * l - d);

			//If status of edge extremities differ,
