 		__syncthreads();
 		//----------------Time Consuming 1 ms----------------
 		//has_visited[facetidx_in_block][has_visited_nb[facetidx_in_block]++] = to_visit[0];
-		index_t counter = 0;
+		//index_t counter = 0;
+		index_t current_seed;
+		int ns;
 		while (to_visit_pos){
-			index_t current_seed = to_visit[to_visit_pos - 1];
+			current_seed = to_visit[to_visit_pos - 1];
 			to_visit_pos--;
 			
 			intersection_clip_facet_SR(

					has_visited_flag = false;
				}
			}
			current_polygon = current_store;
			/*current_polygon.vertex_nb = 3;

			current_polygon.vertex[0].x = v1.x; current_polygon.vertex[0].y = v1.y; current_polygon.vertex[0].z = v1.z; current_polygon.vertex[0].w = 1.0;
			current_polygon.vertex[1].x = v2.x; current_polygon.vertex[1].y = v2.y; current_polygon.vertex[1].z = v2.z; current_polygon.vertex[1].w = 1.0;
			current_polygon.vertex[2].x = v3.x; current_polygon.vertex[2].y = v3.y; current_polygon.vertex[2].z = v3.z; current_polygon.vertex[2].w = 1.0;*/
			counter++;
			
		}
		//__syncthreads();

		//if (tid >= facets_nb) return;

		//load \memory[facet] 3 times.
		const int3 facet_index = {
			facets[tid * dim + 0],
			facets[tid * dim + 1],
			facets[tid * dim + 2]
		};

		//load \memory[vertex] 9 times.
		const double3 v1 = {
			vertex[facet_index.x * dim + 0],
			vertex[facet_index.x * dim + 1],
			vertex[facet_index.x * dim + 2]
		};
		const double3 v2 = {
			vertex[facet_index.y * dim + 0],
			vertex[facet_index.y * dim + 1],
			vertex[facet_index.y * dim + 2]
		};
		const double3 v3 = {
			vertex[facet_index.z * dim + 0],
			vertex[facet_index.z * dim + 1],
			vertex[facet_index.z * dim + 2]
