std::vector<int> collectInnerPointsIDs(std::vector<Point_3> points)
{
	DEBUG_START;
	Delaunay::Lock_data_structure locking_ds(
			CGAL::Bbox_3(-1000., -1000., -1000., 1000.,
				1000., 1000.), 50);
	Delaunay triangulation(points.begin(), points.end(),
			&locking_ds);
	auto infinity = triangulation.infinite_vertex();

	std::vector<int> outerPlanesIDs;
	int numPlanes = points.size();
	for (int i = 0; i < numPlanes; ++i)
	{
		Point_3 point = points[i];
		Delaunay::Locate_type lt;
		int li, lj;
		Delaunay::Cell_handle c = triangulation.locate(point,
				lt, li, lj);

		auto vertex = c->vertex(li);
		ASSERT(lt == Delaunay::VERTEX
					&& vertex->point() == point);
		if (!triangulation.is_edge(vertex, infinity, c, li, lj))
		{
			outerPlanesIDs.push_back(i);
		}
	}
	DEBUG_END;
	return outerPlanesIDs;
}
int main()
{
#ifdef CGAL_LINKED_WITH_TBB
  typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

  // Regular T3
  typedef CGAL::Triangulation_data_structure_3< 
    CGAL::Regular_triangulation_vertex_base_3<K>, 
    CGAL::Regular_triangulation_cell_base_3<K>, 
    CGAL::Parallel_tag>                                       Tds;

  typedef CGAL::Regular_triangulation_3<K, Tds>               Rt;

  typedef Rt::Bare_point                                      Bare_point;
  typedef Rt::Weighted_point                                  Weighted_point;
  typedef Rt::Vertex_handle                                   Vertex_handle;

  const int NUM_INSERTED_POINTS = 5000;

  CGAL::Random_points_in_cube_3<Bare_point> rnd(1.);

  // Construction from a vector of 1,000,000 points
  std::vector<Weighted_point> V;
  V.reserve(NUM_INSERTED_POINTS);
  for (int i = 0; i != NUM_INSERTED_POINTS; ++i)
    V.push_back(Weighted_point(*rnd++));
  
  // Construct the locking data-structure, using the bounding-box of the points
  Rt::Lock_data_structure locking_ds(
    CGAL::Bbox_3(-1., -1., -1., 1., 1., 1.), 50);
  // Contruct the triangulation in parallel
  std::cerr << "Construction and insertion" << std::endl;
  Rt rtr(V.begin(), V.end(), &locking_ds);

  assert(rtr.is_valid());

  std::cerr << "Remove" << std::endl;
  // Remove the first 1/10 vertices
  std::vector<Vertex_handle> vertices_to_remove;
  Rt::Finite_vertices_iterator vit = rtr.finite_vertices_begin();
  for (int i = 0 ; i < NUM_INSERTED_POINTS/10 ; ++i)
    vertices_to_remove.push_back(vit++);
  // Parallel remove
  rtr.remove(vertices_to_remove.begin(), vertices_to_remove.end());
  
  assert(rtr.is_valid());

#endif //CGAL_LINKED_WITH_TBB

  return 0;
}
示例#3
0
int main()
{
  CGAL::Random_points_in_cube_3<Point> rnd(1.);

  std::cerr << "Construction of a 3D Delaunay triangulation from a vector of " 
            << NUM_INSERTED_POINTS << " random points in a cube" << std::endl;
  std::vector<Point> V;
  V.reserve(NUM_INSERTED_POINTS);
  for (int i = 0; i != NUM_INSERTED_POINTS; ++i)
    V.push_back(*rnd++);
  
  // Sequential Delaunay T3
  typedef CGAL::Delaunay_triangulation_3<K> SequentialTriangulation;

  Timer t;
  t.start();
  SequentialTriangulation S(V.begin(), V.end());
  t.stop();
  std::cerr << "Sequential construction takes " << t.time() << " sec." << std::endl;
  
// Parallel Delaunay T3
#ifdef CGAL_LINKED_WITH_TBB
  typedef CGAL::Triangulation_data_structure_3< 
    CGAL::Triangulation_vertex_base_3<K>, 
    CGAL::Triangulation_cell_base_3<K>, 
    CGAL::Parallel_tag>                          ParallelTds;
  typedef CGAL::Delaunay_triangulation_3<K, ParallelTds> ParallelTriangulation;

  t.reset();
  t.start();
  // Construct the locking data-structure, using the bounding-box of the points
  ParallelTriangulation::Lock_data_structure locking_ds(
    CGAL::Bbox_3(-1., -1., -1., 1., 1., 1.), 50);
  // Construct the triangulation in parallel
  ParallelTriangulation T(V.begin(), V.end(), &locking_ds);
  t.stop();
  std::cerr << "Parallel construction takes " << t.time() << " sec. with "
            << tbb::task_scheduler_init::default_num_threads() << " threads" << std::endl;
#endif

  return 0;
}
示例#4
0
Delaunay_triangulation_3 triangulationfromdatacube(FoMo::DataCube goftcube)
{
	typedef K::Point_3                                    Point;
	int commrank;
#ifdef HAVEMPI
	MPI_Comm_rank(MPI_COMM_WORLD,&commrank);
#else
	commrank = 0;
#endif
	FoMo::tgrid grid = goftcube.readgrid();
	int ng=goftcube.readngrid();
	std::vector<Point> delaunaygrid;
	delaunaygrid.resize(ng);

	for (int i=0; i<ng; i++)
	{
		delaunaygrid[i]=Point(grid[0][i],grid[1][i],grid[2][i]);
	}

	// compute the Delaunay triangulation
	if (commrank==0) std::cout << "Doing Delaunay triangulation for interpolation onto rays... " << std::flush;
	Delaunay_triangulation_3 DT;
	// The triangulation should go quicker if it is sorted
	// CGAL::spatial_sort(delaunaygrid.begin(),delaunaygrid.end());
	// but I don't know how this affects the values in the maps.
	// Apparently, this is already done internally.
#if defined(CGAL_LINKED_WITH_TBB) && CGAL_VERSION_NR >= CGAL_VERSION_NUMBER(4,4,0) 
	double minz=*(min_element(grid[2].begin(),grid[2].end()));
	double maxz=*(max_element(grid[2].begin(),grid[2].end()));
	double minx=*(min_element(grid[0].begin(),grid[0].end()));
	double maxx=*(max_element(grid[0].begin(),grid[0].end()));
	double miny=*(min_element(grid[1].begin(),grid[1].end()));
	double maxy=*(max_element(grid[1].begin(),grid[1].end()));
	Delaunay_triangulation_3::Lock_data_structure locking_ds(CGAL::Bbox_3(minx, miny, minz, maxx, maxy, maxz), 50);
	DT.insert(delaunaygrid.begin(),delaunaygrid.end());
#else	
	DT.insert(delaunaygrid.begin(),delaunaygrid.end());
#endif
	if (commrank==0) std::cout << "Done!" << std::endl << std::flush;
	return DT;
}