• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Tr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Tr的典型用法代码示例。如果您正苦于以下问题:C++ Tr类的具体用法?C++ Tr怎么用?C++ Tr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Tr类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: maybeFlipInTreeBits

 void maybeFlipInTreeBits() {
   Tr* t;
   for(std::size_t i = 0; i < inTrees.size(); i++) {
     t = inTrees[i];
     t->maybeFlipInTreeBits();
   }
 }
开发者ID:Anaphory,项目名称:p4-phylogeny,代码行数:7,代码来源:p4stm.cpp


示例2: _test_surface_neighbors_3_sphere

void
_test_surface_neighbors_3_sphere( const Tr & )
{
  Tr T;

  int n=200, m=20;
  double r = 3;

  typedef typename Tr::Geom_traits                 Gt;
  typedef typename Gt::Point_3                     Point;

  std::vector<Point> points;
  points.reserve(n+m);

  // Create n+m-4 points on a sphere of radius 2
  CGAL::Random_points_on_sphere_3<Point> g(r);
  CGAL::cpp11::copy_n( g, n+m, std::back_inserter(points));

  for(int i=0; i<n ; i++)
    T.insert(points[i]);

  //test with different calls:
  int k=0;
  for(int i=n;i<n+m;i++)
  {
    test_coords_and_neighbors(T, points[i],
                              typename Gt::Vector_3(points[i]-CGAL::ORIGIN),
                              typename Gt::FT(0.5),++k % 8);
  }
}
开发者ID:lrineau,项目名称:cgal,代码行数:30,代码来源:_test_surface_neighbors_3.cpp


示例3: ShereMesh

void ShereMesh() {
  Tr tr;            // 3D-Delaunay triangulation
  C2t3 c2t3 (tr);   // 2D-complex in 3D-Delaunay triangulation

  // defining the surface
  Surface_3 surface(sphere_function,             // pointer to function
                    Sphere_3(CGAL::ORIGIN, 2.)); // bounding sphere
  // Note that "2." above is the *squared* radius of the bounding sphere!

  // defining meshing criteria
  CGAL::Surface_mesh_default_criteria_3<Tr> criteria(30.,  // angular bound
                                                     0.1,  // radius bound
                                                     0.1); // distance bound
  // meshing surface
  CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Non_manifold_tag());

  std::cout << "Final number of points: " << tr.number_of_vertices() << "\n";

  //Output mesh
  //Polyhedron polymesh;
  //bool result = CGAL::output_surface_facets_to_polyhedron(c2t3, polymesh);
  //std::cout << "output_surface_facets_to_polyhedron: " << result << "\n";

  //Scommentare per salvare mesh su file
  std::ofstream out("mesh_sphere_test_low.off");
  CGAL::output_surface_facets_to_off (out, c2t3);
  std::cout << "SAVED MESH\n";

  //std::list<TriangleGT> triangleMesh;
  //std::back_insert_iterator<std::list<TriangleGT> > bii(triangleMesh);
  //output_surface_facets_to_triangle_soup(c2t3, bii);
}
开发者ID:Sunwinds,项目名称:larmor-physx,代码行数:32,代码来源:SphereMesher.cpp


示例4: main

int main() {
  Tr tr;            // 3D-Delaunay triangulation
  C2t3 c2t3 (tr);   // 2D-complex in 3D-Delaunay triangulation

  // defining the surface
  Surface_3 surface(moebius_function,             // pointer to function
                    Sphere_3(Point_3(0.0001, -0.0003, 0.), 2.)); // bounding sphere

  // defining meshing criteria
  CGAL::Surface_mesh_default_criteria_3<Tr> criteria(30.,  // angular bound
                                                     0.05,  // radius bound
                                                     0.05); // distance bound
  // meshing surface
  CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Non_manifold_tag());

  std::ofstream out("out.off");

#ifndef NDEBUG
  const bool result = 
#endif
    CGAL::output_surface_facets_to_off(out, c2t3,
				       CGAL::Surface_mesher::IO_VERBOSE | 
				       CGAL::Surface_mesher::IO_ORIENT_SURFACE);

  assert(result == false);

  std::cout << "Final number of points: " << tr.number_of_vertices() << "\n";
}
开发者ID:Asuzer,项目名称:cgal,代码行数:28,代码来源:mesh_moebius_strip.cpp


示例5: setInTreeInternalBits

 void setInTreeInternalBits() {
   Tr* t;
   for(std::size_t i = 0; i < inTrees.size(); i++) {
     t = inTrees[i];
     //std::cout << "Stm->setInTreeInternalBits()  setting internal bits for inTree " << i << std::endl;
     t->setInternalBits();
   }
 }
开发者ID:Anaphory,项目名称:p4-phylogeny,代码行数:8,代码来源:p4stm.cpp


示例6: setInTreeTaxBits

 void setInTreeTaxBits() {
   Tr* t;
   for(std::size_t i = 0; i < inTrees.size(); i++) {
     t = inTrees[i];
     t->setInTreeTaxBits();
     //std::cout << "Stm.setInTreeTaxBits() setting taxBits for inTree " << i << " to " << t->taxBits;
     //std::cout << " firstOnePos " << t->firstOnePos << std::endl;
   }
 }
开发者ID:Anaphory,项目名称:p4-phylogeny,代码行数:9,代码来源:p4stm.cpp


示例7: main

int main(int , char** argv)
{
  Tr tr;
  C2T3 c2t3(tr);

  std::ifstream ifs(argv[1]);
  if( !ifs )
  {
    std::cerr << "Usage:\n"
              << "  " << argv[0] << " FILE\n"
              << "\n"
	      << "  FILE must be " << format_cgal_description
              << "\n";
    return EXIT_FAILURE;
  }

  std::cout << "  Reading " << argv[1] << std::endl;

  if( CGAL::Mesh_3::input_mesh(ifs, c2t3,
                               true,
                               &std::cerr) )
//   if( CGAL::input_pslg_from_medit(ifs,
//                                   c2t3,
//                                   true,         // debug
//                                   &std::cout) ) // debug to cout
  {
    display_faces_counts(tr, "    ", &std::cout);

    std::cout << "\n  Statistics:\n";

    std::cout << "(vertices)\n";
    display_vertices_by_surface_indices_statistics(tr, "    ", &std::cout);

    std::cout << "(facets)\n";
    display_facets_by_surface_indices_statistics(c2t3, "    ", &std::cout);

    Compute_min_angle<Tr> min_angle(tr);

    double min = 180;
    for(Tr::Finite_cells_iterator cit = tr.finite_cells_begin();
	cit != tr.finite_cells_end();
	++cit)
      if(cit->is_in_domain())
      {
	const double angle = min_angle(cit);
	if( angle < min ) min = angle;
      }
	
    std::cout << "\nmin angle: " << min << "\n";

    return EXIT_SUCCESS;
  }
  else
    return EXIT_FAILURE;
}
开发者ID:ArcEarth,项目名称:cgal,代码行数:55,代码来源:stat_mesh.cpp


示例8: test_coords_and_neighbors

void
test_coords_and_neighbors(const Tr& T, const  typename
                          Tr::Geom_traits::Point_3& p,
                          const typename Tr::Geom_traits::Vector_3& n,
                          const typename  Tr::Geom_traits::FT& tolerance, const int& version)
{
  CGAL::Set_ieee_double_precision pfr;

  typedef std::pair<typename Tr::Geom_traits::Point_3,
      typename Tr::Geom_traits::FT >    Point_coord_pair;

  std::vector<Point_coord_pair>  coords;
  typename Tr::Geom_traits::FT   norm;
  norm = test_coords(T, p, n,version, std::back_inserter(coords)).second;
  assert(test_norm( coords.begin(), coords.end(), norm));
  assert(test_barycenter(coords.begin(), coords.end(), norm, p, tolerance));
  //All function testing surface neighbors are
  // grouped together:
  std::vector< typename Tr::Geom_traits::Point_3 >  neighbors;
  test_neighbors(T, p, n,version, std::back_inserter(neighbors));
  assert(compare_neighbors(coords.begin(),
                           coords.end(),neighbors.begin(),
                           neighbors.end(), T.geom_traits()));
  //done
}
开发者ID:lrineau,项目名称:cgal,代码行数:25,代码来源:_test_surface_neighbors_3.cpp


示例9: dump

 void dump() {
   std::cout << "Stm dump(), nTax=" << this->nTax << std::endl;
   if(this->bigT == NULL) {
     std::cout << "  bigT is not set" << std::endl;
   } else {
     std::cout << "---- bigT dump ---------" << std::endl;
     this->bigT->dump();
     std::cout << "---- end of bigT dump --" << std::endl;
   }
   Tr* t;
   for(std::size_t i = 0; i < inTrees.size(); i++) {
     t = this->inTrees[i];
     std::cout << "---- inTree " << i << " dump ---------" << std::endl;
     t->dump();
     std::cout << "--------" << std::endl;
   }
 }
开发者ID:Anaphory,项目名称:p4-phylogeny,代码行数:17,代码来源:p4stm.cpp


示例10: main

int main() {
  Tr tr;            // 3D-Delaunay triangulation
  C2t3 c2t3 (tr);   // 2D-complex in 3D-Delaunay triangulation

  // defining the surface
  Surface_3 surface(sphere_function,             // pointer to function
                    Sphere_3(CGAL::ORIGIN, 2.)); // bounding sphere
  // Note that "2." above is the *squared* radius of the bounding sphere!

  // defining meshing criteria
  CGAL::Surface_mesh_default_criteria_3<Tr> criteria(30.,  // angular bound
                                                     0.1,  // radius bound
                                                     0.1); // distance bound
  // meshing surface
  CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Non_manifold_tag());

  std::cout << "Final number of points: " << tr.number_of_vertices() << "\n";
}
开发者ID:Asuzer,项目名称:cgal,代码行数:18,代码来源:mesh_an_implicit_function.cpp


示例11: main

int main() {
  Tr tr;            // 3D-Delaunay triangulation
  C2t3 c2t3 (tr);   // 2D-complex in 3D-Delaunay triangulation

  // defining the surface
  std::ifstream file_input("data/triceratops.off");
  Polyhedral_surface surface(file_input);

  // defining meshing criteria
  CGAL::Surface_mesh_default_criteria_3<Tr> 
    facets_criteria(30.,  // angular bound
		    0.5,  // radius bound
		    0.5); // distance bound
  CGAL::Surface_mesh_default_edges_criteria_3<Tr>
    edges_criteria(0.5,  // radius bound
		   0.5); // distance bound

  // meshing surface
  CGAL::make_piecewise_smooth_surface_mesh(c2t3, surface,
					   facets_criteria, edges_criteria,
					   CGAL::Manifold_tag());

  std::cout << "Final number of points: " << tr.number_of_vertices() << "\n";
}
开发者ID:Asuzer,项目名称:cgal,代码行数:24,代码来源:polyhedron_remesher.cpp


示例12: main

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;
}
开发者ID:alex-tifrea,项目名称:GSoC2013_CGAL_code_sample,代码行数:94,代码来源:generate_mesh_3_torus.cpp


示例13: sqr_it

void sqr_it(Tr &ob){
    ob.set_i(ob.get_i()*ob.get_i());
    cout<<"经过sqr_it()函数后数据成员为:"<<ob.get_i()<<endl;
}
开发者ID:xiayu0321,项目名称:cppExer,代码行数:4,代码来源:funcPara.cpp


示例14: test_neighbors

OutputIterator
test_neighbors(const Tr& T, const typename Tr::Geom_traits::Point_3& p,
               const typename Tr::Geom_traits::Vector_3& n,
               const int& version,
               OutputIterator out)
{
  typedef CGAL::Voronoi_intersection_2_traits_3<typename Tr::Geom_traits>   I_traits;

  //the result type of the certified version:
  typedef std::pair<  OutputIterator, bool >  NeighborIt_bool_pair;

  typename Tr::Cell_handle start;
  //test different function calls
  switch(version)
  {
    case 0:{
      //certified call with Kernel:
      NeighborIt_bool_pair
          result_pair = CGAL::surface_neighbors_certified_3(T.points_begin(),
                                                            T.points_end(), p, n,
                                                            out,
                                                            T.geom_traits());
      assert(result_pair.second);
      out = result_pair.first; break;}
    case 1: {
      //certified call with instantiated traits::
      NeighborIt_bool_pair
          result_pair = CGAL::surface_neighbors_certified_3(T.points_begin(),
                                                            T.points_end(), p,
                                                            out, I_traits(p,n));
      assert(result_pair.second);
      out =result_pair.first; break;}
      //both versions with locate:
    case 2:{
      start = T.locate(p);
      //certified call with Kernel and locate:
      out =CGAL::surface_neighbors_3(T, p,n,out, start);
      break;}
    case 3: {
      start = T.locate(p);
      //with instantiated traits and locate:
      out =CGAL::surface_neighbors_3(T,p,out, I_traits(p,n),start);
      break;}
      //taking all points:
    case 4: {
      //with instantiated traits and locate:
      out =
          CGAL::surface_neighbors_3(T,p,out,I_traits(p,n));
      break;}
    case 5: {
      //certified call with Kernel and locate:
      out =
          CGAL::surface_neighbors_3(T, p,n,out);
      break;}
      //the last two with certification:
    case 6: {
      out =
          CGAL::surface_neighbors_3(T.points_begin(),
                                    T.points_end(),
                                    p, out,I_traits(p,n));
      break;
    }
    case 7: {
      out =
          CGAL::surface_neighbors_3(T.points_begin(),
                                    T.points_end(),
                                    p,n,out,T.geom_traits());
      break;
    }
    default:
      std::cout << "Switch function calls: Nothing is tested. " <<
                   std::endl;
  }
  return out;
}
开发者ID:lrineau,项目名称:cgal,代码行数:75,代码来源:_test_surface_neighbors_3.cpp


示例15: test_coords

std::pair< OutputIterator,  typename Tr::Geom_traits::FT>
test_coords(const Tr& T,
            const typename Tr::Geom_traits::Point_3& p,
            const typename Tr::Geom_traits::Vector_3& n,
            const int& version, OutputIterator out)
{
  typedef CGAL::Voronoi_intersection_2_traits_3<typename Tr::Geom_traits>     I_traits;

  //coordinate computation result types
  typedef CGAL::Triple< OutputIterator, typename Tr::Geom_traits::FT, bool >  Result_triple;
  //the result type of the certified version:
  typedef CGAL::Quadruple< OutputIterator, typename Tr::Geom_traits::FT, bool, bool > Result_quadruple;

  typename Tr::Cell_handle start;
  typename Tr::Geom_traits::FT  norm = 1; // 1 for that default doesn't trigger an assert
  //test different function calls
  switch(version){
    case 0:{
      Result_triple result
          = CGAL::surface_neighbor_coordinates_3(T, p,n,out);
      assert(result.third);
      norm =  result.second;
      break;}
    case 1: {
      Result_triple result  =
          CGAL::surface_neighbor_coordinates_3(T, p,out,I_traits(p,n));
      assert(result.third);
      norm =  result.second; break;}
      //both versions with locate:
    case 2:{
      start = T.locate(p);
      Result_triple result  = CGAL::surface_neighbor_coordinates_3(T, p, n, out, start);
      assert(result.third);
      norm =  result.second; break;}
    case 3: {
      start = T.locate(p);
      Result_triple result  =
          CGAL::surface_neighbor_coordinates_3(T, p, out, I_traits(p,n), start);
      assert(result.third);
      norm =  result.second; break;}
      //taking all points:
    case 4: {
      Result_triple result
          = CGAL::surface_neighbor_coordinates_3(T.points_begin(),
                                                 T.points_end(), p, n,
                                                 out,
                                                 T.geom_traits());
      assert(result.third);
      norm =  result.second; break;}
    case 5: {
      Result_triple result
          = CGAL::surface_neighbor_coordinates_3(T.points_begin(),
                                                 T.points_end(), p,
                                                 out ,I_traits(p,n));
      assert(result.third);
      norm =  result.second; break;}
      //the last two with certification:
    case 6: {
      Result_quadruple
          result = CGAL::surface_neighbor_coordinates_certified_3
                   (T.points_begin(), T.points_end(),p,n,
                    out, T.geom_traits());
      assert(result.third && result.fourth);
      norm =  result.second; break;
    }
    case 7: {
      Result_quadruple
          result = CGAL::surface_neighbor_coordinates_certified_3
                   (T.points_begin(), T.points_end(),p, out ,I_traits(p,n));
      assert(result.third && result.fourth);
      norm =  result.second;
      break;
    }
    default:
      std::cout << "Switch function calls: Nothing is tested. " <<
                   std::endl;
  }
  assert(norm > 0);

  return std::make_pair(out, norm);
}
开发者ID:lrineau,项目名称:cgal,代码行数:81,代码来源:_test_surface_neighbors_3.cpp


示例16: main

int main(int argc, char** argv)
{
    int arg_count = 1;
    bool terminal_output = true;
    bool delaunay = false;
    bool verbose = false;

    if(argc < 2)
    {
        usage(argv);
        return 1;
    }

    while(argv[arg_count][0] == '-' && std::string(argv[arg_count]) != "--")
    {
        if(std::string(argv[arg_count]) == "-Q")
            terminal_output = false;
        else if(std::string(argv[arg_count]) == "-D")
            delaunay = true;
        else if(std::string(argv[arg_count]) == "-v")
            verbose = true;
        else
        {
            std::cerr << "Unknown option " << argv[arg_count] << std::endl;
            usage(argv);
            return 1;
        }
        ++arg_count;
    }
    if(std::string(argv[arg_count]) == "--")
        ++arg_count;

    if(argc < arg_count+1 || argc > arg_count+2)
    {
        usage(argv);
        return 1;
    }
    std::ifstream input(argv[arg_count]);
    if(input)
    {
        Tr t;
        CGAL::read_triangle_poly_file(t, input);
        if(delaunay)
        {
            if(verbose)
                std::cerr << "Make conforming Delaunay..." << std::endl;
            CGAL::make_conforming_Delaunay_2(t);
        }
        else
        {
            if(verbose)
                std::cerr << "Make conforming Gabriel..." << std::endl;
            CGAL::make_conforming_Gabriel_2(t);
        }

        if(argc==arg_count+1)
        {
            if(terminal_output)
                CGAL::write_triangle_poly_file(t, std::cout);
        }
        else
        {
            std::ofstream output(argv[arg_count+1]);
            CGAL::write_triangle_poly_file(t, output);
        }

        if(terminal_output)
            std::cerr
                    << "Number of points: " << t.number_of_vertices() << std::endl
                    << "Number of triangles: " << t.number_of_faces () << std::endl;

    }
    else
    {
        std::cerr << "Bad file: " << argv[arg_count] << std::endl;
        usage(argv);
        return 1;
    }
    return 0;
}
开发者ID:swarbhanu,项目名称:CGAL-Mesh,代码行数:80,代码来源:conform.cpp


示例17: main

int main()
{
  Tr::Point p1(0,0,0);
  Tr::Point p2(1,0,0);
  Tr::Point p3(0,1,0);
  Tr::Point p4(0,0,1);
  
  Tr tr;
  tr.insert(p1);
  tr.insert(p2);
  tr.insert(p3);
  tr.insert(p4);
  
  Tr::Cell_handle ch = tr.finite_cells_begin();
  int k = 0;
  Tr::Facet f = std::make_pair(ch,k);
  Tr::Cell::Subdomain_index sub_index = 1;
  Tr::Cell::Surface_patch_index surf_index = 2;
  Tr::Cell::Surface_patch_index surf_index_bis = 21;
  Tr::Vertex::Index index (surf_index);
  Tr::Vertex::Index index_bis(surf_index_bis);
  
  // Init cell
  tr.dual(ch);
  ch->set_subdomain_index(sub_index);
  
  // Init facet
  Tr::Bare_point facet_circum =
    tr.geom_traits().construct_weighted_circumcenter_3_object()(
      tr.point(ch, k+1), tr.point(ch, k+2), tr.point(ch, k+3));

  ch->set_surface_patch_index(k,surf_index);
  ch->set_facet_surface_center(k,facet_circum);
  ch->set_facet_surface_center_index(k,index);
  
  // Init vertices
  ch->vertex(0)->set_dimension(2);
  ch->vertex(1)->set_dimension(2);
  ch->vertex(2)->set_dimension(2);
  ch->vertex(3)->set_dimension(2);
  
  ch->vertex(0)->set_index(index);
  ch->vertex(1)->set_index(index);
  ch->vertex(2)->set_index(index_bis);
  ch->vertex(3)->set_index(index_bis);
  
  // -----------------------------------
  // Test edge criteria
  // -----------------------------------
  Tr::Bare_point bp1 = tr.geom_traits().construct_point_3_object()(p1);

  Mc ec1(edge_size = 1);
  assert( ec1.edge_criteria_object().sizing_field(bp1,1,index) == 1 );
  
  Mc ec2(edge_sizing_field = Esf(2));
  assert( ec2.edge_criteria_object().sizing_field(bp1,1,index) == 2 );

  Mc ec3(edge_sizing_field = 3.);
  assert( ec3.edge_criteria_object().sizing_field(bp1,1,index) == 3 );
  
  Mc ec4(edge_size = 4.1,
         edge_sizing_field = Esf(4.2));
  assert( ec4.edge_criteria_object().sizing_field(bp1,1,index) == 4.1 );
  
  Mc ec5(sizing_field = 5.);
  assert( ec5.edge_criteria_object().sizing_field(bp1,1,index) == 5 );
  
  Mc ec6(sizing_field = 6.1,
         edge_sizing_field = 6.2);
  assert( ec6.edge_criteria_object().sizing_field(bp1,1,index) == 6.2 );
  
  Mc ec7(sizing_field = 7.1,
         edge_size = 7.2);
  assert( ec7.edge_criteria_object().sizing_field(bp1,1,index) == 7.2 );
  
  
  // -----------------------------------
  // Test facet criteria
  // -----------------------------------
  typedef Tr::Geom_traits::FT FT;
  Tr::Geom_traits::Compute_squared_radius_3 squared_radius = tr.geom_traits().compute_squared_radius_3_object();
  Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object();

  FT radius_facet = CGAL::sqrt(squared_radius(cp(tr.point(ch, k+1)),
                                              cp(tr.point(ch, k+2)),
                                              cp(tr.point(ch, k+3))));

  FT facet_size_ok = radius_facet*FT(10);
  FT facet_size_nok = radius_facet/FT(10);

  Mc fc1(facet_size = facet_size_ok);
  assert( ! fc1.facet_criteria_object()(tr, f) );

  Mc fc2(facet_sizing_field = facet_size_ok);
  assert( ! fc2.facet_criteria_object()(tr, f) );

  Mc fc3(facet_sizing_field = Fsf(facet_size_ok));
  assert( ! fc3.facet_criteria_object()(tr, f) );

  Mc fc4(facet_sizing_field = facet_size_nok,
//.........这里部分代码省略.........
开发者ID:lrineau,项目名称:cgal,代码行数:101,代码来源:test_mesh_criteria_creation.cpp


示例18: write_c3t3_to_vtk_xml_file

    bool write_c3t3_to_vtk_xml_file(const C3t3 &c3t3, const std::string &file_name)
    {
        typedef typename C3t3::Triangulation Tr;
        typedef typename C3t3::Cells_in_complex_iterator Cell_iterator;
        typedef typename Tr::Finite_vertices_iterator Vertex_iterator;
        
        // Domain
        typedef Exact_predicates_inexact_constructions_kernel K;
        typedef K::FT FT;
        typedef K::Point_3 Point;
        
        // check that file extension is "vtu"
        CGAL_assertion(file_name.substr(file_name.length()-4,4) == ".vtu");
        
        // open file
        std::ofstream vtk_file(file_name.c_str());
        
        // header
        vtk_file << "<VTKFile type=\"UnstructuredGrid\" ";
        vtk_file << "version=\"0.1\" ";
        vtk_file << "byte_order=\"BigEndian\">" << std::endl;
        
        int indent_size = 2;
        std::string indent_unit(indent_size, ' ');
        std::string indent = indent_unit;
        vtk_file << indent + "<UnstructuredGrid>" << std::endl;
        
        // write mesh
        Tr t = c3t3.triangulation();
        int num_vertices = t.number_of_vertices();
        int num_cells = c3t3.number_of_cells_in_complex();
        
        indent += indent_unit;
        vtk_file << indent + "<Piece NumberOfPoints=\"" << num_vertices << "\" ";
        vtk_file << "NumberOfCells=\"" << num_cells << "\">" << std::endl;
        
        // Write vertices
        indent += indent_unit;
        vtk_file << indent + "<Points>" << std::endl;
        
        indent += indent_unit;
        vtk_file << indent;
        vtk_file << "<DataArray type=\"Float32\" NumberOfComponents=\"3\" Format=\"ascii\">" << std::endl;
        
        std::map<Point, int> V;
        int i=0;
        indent += indent_unit;
        
        for (Vertex_iterator it=t.finite_vertices_begin(); it != t.finite_vertices_end(); ++it)
        {
            vtk_file << indent;
            vtk_file << it->point().x() << " " << it->point().y() << " " << it->point().z() << std::endl;
            V[it->point()] = i;
            ++i;
        }
        
        indent.erase(indent.length()-indent_size, indent_size);
        vtk_file << indent + "</DataArray>" << std::endl;

        indent.erase(indent.length()-indent_size, indent_size);
        vtk_file << indent + "</Points>" << std::endl;

        // Write tetrahedra
        vtk_file << indent << "<Cells>" << std::endl;
        
        indent += indent_unit;
        vtk_file << indent;
        vtk_file << "<DataArray type=\"Int32\" Name=\"connectivity\" Format=\"ascii\">";
        vtk_file << std::endl;
        
        indent += indent_unit;
        Cell_iterator it;
        for (it = c3t3.cells_in_complex_begin(); it != c3t3.cells_in_complex_end(); ++it)
        {
            const typename Tr::Cell c(*it);
            const typename Tr::Vertex_handle v0 = c.vertex(0);
            const typename Tr::Vertex_handle v1 = c.vertex(1);
            const typename Tr::Vertex_handle v2 = c.vertex(2);
            const typename Tr::Vertex_handle v3 = c.vertex(3);
            
            vtk_file << indent;
            vtk_file << V[v0->point()] << " ";
            vtk_file << V[v1->point()] << " ";
            vtk_file << V[v2->point()] << " ";
            vtk_file << V[v3->point()] << std::endl;
        }
        
        indent.erase(indent.length()-indent_size, indent_size);
        vtk_file << indent + "</DataArray>" << std::endl;
        
        // offsets
        // every element is a four node tetrahedron so all offsets are multiples of 4
        vtk_file << indent;
        vtk_file << "<DataArray type=\"Int32\" Name=\"offsets\" Format=\"ascii\">";
        vtk_file << std::endl;
        i = 4;
        indent += indent_unit;
        for (it = c3t3.cells_in_complex_begin(); it != c3t3.cells_in_complex_end(); ++it)
        {
            vtk_file << indent << i << std::endl;
//.........这里部分代码省略.........
开发者ID:cbutakoff,项目名称:tools,代码行数:101,代码来源:poly2mesh.cpp


示例19: _test_surface_neighbors_3_cube

void
_test_surface_neighbors_3_cube(const Tr &, const Transformation&
                               transform, const int n = 75,
                               typename Tr::Geom_traits::FT tolerance = typename Tr::Geom_traits::FT(1e-29),
                               bool grid=true)
{
  Tr T;

  int m=10;
  double r = 3;

  typedef typename Tr::Geom_traits                Gt;
  typedef typename Gt::FT                         Coord_type;
  typedef typename Gt::Point_3                    Point;
  typedef typename Gt::Point_2                    Point_2;
  typedef typename Gt::Vector_3                   Vector;

  //data points: generate random points in a square of length r
  std::vector<Point_2> points_2_data;
  points_2_data.reserve(n);

  if(grid)
  {
    CGAL::points_on_square_grid_2(r, n, std::back_inserter(points_2_data),
                                  CGAL::Creator_uniform_2<Coord_type,Point_2>());
  }
  else
  {
    CGAL::Random_points_in_square_2<Point_2> g(r);
    CGAL::cpp11::copy_n(g, n, std::back_inserter(points_2_data));
  }
  for(int i=0; i < n; i++)
  {
    T.insert(transform(Point(points_2_data[i].x(),points_2_data[i].y(), -r)));
    T.insert(transform(Point(points_2_data[i].x(),points_2_data[i].y(), r)));
    T.insert(transform(Point(-r, points_2_data[i].x(),points_2_data[i].y())));
    T.insert(transform(Point(r, points_2_data[i].x(), points_2_data[i].y())));
    T.insert(transform(Point(points_2_data[i].x(), -r, points_2_data[i].y())));
    T.insert(transform(Point(points_2_data[i].x(), r, points_2_data[i].y())));
  }

  //test_points: generate random points in a square of length r
  std::vector<Point_2> points_2_test;
  points_2_test.reserve(m);
  CGAL::Random_points_in_square_2<Point_2> g2(r-1.0);
  CGAL::cpp11::copy_n(g2, m, std::back_inserter(points_2_test));

  int k=0;
  for(int i=0;i<m;i++)
  {
    //test point on z=r plane:
    test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
                                                points_2_test[i].y(), r)),
                              transform(Vector(0,0,1)),tolerance, ++k % 8);
    //test point on x=-r plane:
    test_coords_and_neighbors(T,transform(Point(-r, points_2_test[i].x(),
                                                points_2_test[i].y())),
                              transform(Vector(-1,0,0)),tolerance, ++k % 8 );
    //test point on x=r plane:
    test_coords_and_neighbors(T,transform(Point(r, points_2_test[i].x(),
                                                points_2_test[i].y())),
                              transform(Vector(1,0,0)),tolerance,++k % 8 );
    //test point on y=-r plane:
    test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
                                                -r,points_2_test[i].y())),
                              transform(Vector(0,-1,0)),tolerance,++k % 8 );
    //test point on y=r plane:
    test_coords_and_neighbors(T,transform(Point(points_2_test[i].x(),
                                                r,points_2_test[i].y())),
                              transform(Vector(0,1,0)),tolerance,++k % 8);
  }

  //test a sample point:
  //with Delaunay triangulation filering:
  test_coords_and_neighbors(T,transform(Point(points_2_data[n/2].x(),
                                        points_2_data[n/2].y(), r)),
                            transform(Vector(0,0,1)),Coord_type(0),0);

  //considering all points:
  test_coords_and_neighbors(T,transform(Point(points_2_data[n/2].x(),
                                        points_2_data[n/2].y(), r)),
                            transform(Vector(0,0,1)),Coord_type(0),4);
}
开发者ID:lrineau,项目名称:cgal,代码行数:83,代码来源:_test_surface_neighbors_3.cpp



注:本文中的Tr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TraCIServer类代码示例发布时间:2022-05-31
下一篇:
C++ Tpetra_Vector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap