Ejemplo n.º 1
0
int main()
{
  // Define functions
  Function f1(&torus_function);
  Function f2(&sphere_function<5>);
  Function f3(&sphere_function<2>);

  Function_vector v;
  v.push_back(&f1);
  v.push_back(&f2);
  //v.push_back(&f3);

  // Domain (Warning: Sphere_3 constructor uses square radius !)
  Mesh_domain domain(v, K::Sphere_3(CGAL::ORIGIN, 5.*5.), 1e-6);

  // Set mesh criteria
  Facet_criteria facet_criteria(30, 0.2, 0.02); // angle, size, approximation
  Cell_criteria cell_criteria(2., 0.4); // radius-edge ratio, size
  Mesh_criteria criteria(facet_criteria, cell_criteria);

  // Mesh generation
  C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_exude(), no_perturb());

  // Perturbation (maximum cpu time: 10s, targeted dihedral angle: default)
  CGAL::perturb_mesh_3(c3t3, domain, time_limit = 10);
  
  // Exudation
  CGAL::exude_mesh_3(c3t3,12);
  
  // Output
  std::ofstream medit_file("out.mesh");
  CGAL::output_to_medit(medit_file, c3t3);

  return 0;
}
void test_constructor_vfunc ()
{
  Function_vector vfunc;
  vfunc.push_back(cube_function_1);
  vfunc.push_back(cube_function_2);

  Labeling_function lfunc(vfunc);

  Point_3 p1(0.5, 0.5, 0.5);
  Point_3 p2(2.5, 2.5, 2.5);
  Point_3 p3(1.5, 1.5, 1.5);
  Point_3 p_out(4., 4., 4.);

  Labeling_function::return_type rp1 = lfunc(p1);
  Labeling_function::return_type rp2 = lfunc(p2);
  Labeling_function::return_type rp3 = lfunc(p3);
  Labeling_function::return_type rp_out = lfunc(p_out);

  assert(rp1 != 0);
  assert(rp2 != 0);
  assert(rp3 != 0);
  assert(rp_out == 0);

  assert(rp1 != rp2);
  assert(rp1 != rp3);
  assert(rp2 != rp3);
}
int main()
{
  // Define functions
  Function f1 = cube_function_1;
  Function f2 = cube_function_2;

  Function_vector v;
  v.push_back(f1);
  v.push_back(f2);

  std::vector<std::string> vps;
  vps.push_back("--");

  // Domain (Warning: Sphere_3 constructor uses square radius !)
  Mesh_domain_with_features domain(Function_wrapper(v, vps), K::Sphere_3(CGAL::ORIGIN, 5.*5.));
  Polylines polylines;
  create_polylines(polylines);
  domain.add_features(polylines.begin(),polylines.end());

  // Set mesh criteria
  Mesh_criteria criteria(edge_size = 0.15,
      facet_angle = 30, facet_size = 0.2,
      cell_radius_edge_ratio = 2, cell_size = 0.4);

  // Mesh generation
  C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_exude(), no_perturb());

  // Perturbation (maximum cpu time: 10s, targeted dihedral angle: default)
  CGAL::perturb_mesh_3(c3t3, domain, time_limit = 10);
  
  // Exudation
  CGAL::exude_mesh_3(c3t3,12);
  
  // Output
  std::ofstream medit_file("out_cubes_intersection_with_features.mesh");
  CGAL::output_to_medit(medit_file, c3t3);

  return 0;
}
int main()
{
  // Define functions
  Function f1(&torus_function);
  Function f2(&sphere_function<3>);

  Function_vector v;
  v.push_back(f1);
  v.push_back(f2);
  // Domain (Warning: Sphere_3 constructor uses square radius !)
  Mesh_domain domain(v, K::Sphere_3(CGAL::ORIGIN, 5.*5.), 1e-6);

  // Set mesh criteria
  Facet_criteria facet_criteria(30, 0.2, 0.02); // angle, size, approximation
  Cell_criteria cell_criteria(2., 0.4); // radius-edge ratio, size
  Mesh_criteria criteria(facet_criteria, cell_criteria);

  // Mesh generation
  C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_exude(), no_perturb());

  // Output
  std::stringstream off_file;
  c3t3.output_boundary_to_off(off_file);
  assert( off_file.str().size() > 20 );

  off_file.str("");
  c3t3.output_facets_in_complex_to_off(off_file);
  assert( off_file.str().size() > 20 );

  for (int i=0;i<4; ++i){
    off_file.str("");
    c3t3.output_boundary_to_off(off_file,i);
    assert( off_file.str().size() > 20 );
  }

  return 0;
}
int main()
{
	CGAL::Timer t;
	t.start();
	// Define functions
	Function f1(&torus_function);
	Function f2(&sphere_function<5>);
	Function f3(&tanglecube_function);
	Function f4(&heart_function);
	Function f5(&klein_function);
	Function f6(&false_knot_function);
	Function f7(&knot1_function);
	Function f8(&octic_function);

	Function_vector v;
	v.push_back(&f1);
	//v.push_back(&f2);
	//v.push_back(&f3);
	//v.push_back(&f4);
	//v.push_back(&f5);
	//v.push_back(&f6);
	//v.push_back(&f7);
	//v.push_back(&f8);

	// Domain (Warning: Sphere_3 constructor uses square radius !)
	Mesh_domain domain(v, K::Sphere_3(CGAL::ORIGIN, 5.*5.), 1e-6);

	// Set mesh criteria
	Facet_criteria facet_criteria(30, 0.2, 0.02); // angle, size, approximation
	Cell_criteria cell_criteria(2., 0.4); // radius-edge ratio, size
	Mesh_criteria criteria(facet_criteria, cell_criteria);

	// Mesh generation
	C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_exude(), no_perturb());

	// Perturbation (maximum cpu time: 10s, targeted dihedral angle: default)
	CGAL::perturb_mesh_3(c3t3, domain, time_limit = 10);
	
	// Exudation
	CGAL::exude_mesh_3(c3t3,12);

	CGAL::Random rand;

	t.stop();
	std::cout << "Time elapsed for building the mesh: " << t.time() << std::endl;
	t.reset();
	
	t.start();
	int nr = 1500;
	std::vector<Point> points;
	points.reserve(nr);
	CGAL::Random_points_in_mesh_3<Point, C3t3, FastPolicy> g(c3t3);
	t.stop();
	std::cout << "Time elapsed for init Random_points_in_mesh_3: " <<
		t.time() << std::endl;
	t.reset();

	t.start();
	CGAL::cpp11::copy_n( g, nr, std::back_inserter(points));
	t.stop();
	std::cout << "Time elapsed for generating the points: " << t.time() << std::endl;
	t.reset();

	Tr tr = c3t3.triangulation();
	Tetrahedron3 tet;
	Tr::Finite_cells_iterator it = tr.finite_cells_begin();
	for (; it != tr.finite_cells_end(); it++) {
		if (c3t3.is_in_complex(it)) {
			tet = tr.tetrahedron(it);
			break;
		}
	}

	t.start();
	std::vector<Point> points_tet;
	points_tet.reserve(nr);
	CGAL::Random_points_in_tetrahedron_3<Point> g1(tet);
	CGAL::cpp11::copy_n(g1, nr, std::back_inserter(points_tet));
	t.stop();
	std::cout << "Time elapsed for " << nr << " points in one tetrahedron: " <<
		t.time() << std::endl;
	t.reset();

	std::cout << "The generated points are: " << std::endl;
	for (int i = 0; i < nr; i++) {
		std::cout << points[i].x() << " " << points[i].y() << " " <<
			points[i].z() << std::endl;
	}

	points_tet.clear();
	points.clear();
	v.clear();
	return 0;
}