当前位置: 首页>>代码示例>>C++>>正文


C++ Timer::start方法代码示例

本文整理汇总了C++中cgal::Timer::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::start方法的具体用法?C++ Timer::start怎么用?C++ Timer::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cgal::Timer的用法示例。


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

示例1: main

int main(int argc, char* argv[])
{
  CGAL::Timer timer;
  // first param is dimension
  // second param is number of points
  int dimension = 4;
  int n = 100;
  int m = 100;

  if (argc > 1 && std::string(argv[1])== std::string("-h")) {
    std::cout<<"usage: "<<argv[0]<<" [dim] [#points] [max coords]\n";
    return 1;
  }
  if (argc > 1)  dimension = atoi(argv[1]);
  if (argc > 2)  n = atoi(argv[2]);
  if (argc > 3)  m = atoi(argv[2]);

  Delaunay_d T(dimension);
  std::list<Point_d> L;

  random_points_in_range(n,dimension,-m,m,L);

  timer.start();
  int i=0;
  std::list<Point_d>::iterator it;
  for(it = L.begin(); it!=L.end(); ++it) {
    T.insert(*it); i++;
    if (i%10==0)
      std::cout << i << " points inserted" << std::endl;
  }
  timer.stop();
  std::cout << "used time for inserts  " << timer.time() << std::endl;

  std::cout << "entering check" << std::endl;

  timer.reset();
  timer.start();
  T.is_valid();
  timer.stop();
  std::cout << "used time for sanity check  " << timer.time() << std::endl;
  

  std::cout << "entering nearest neighbor location" << std::endl;
  L.clear();
  random_points_in_range(n/10,dimension,-m,m,L);

  timer.reset();
  timer.start();
  i = 0;
  for(it = L.begin(); it!=L.end(); ++it) {
    T.nearest_neighbor(*it); i++;
    if (i%10==0) std::cout << i << " points located" << std::endl;
  }
  timer.stop();
  std::cout << "used time for location  " << timer.time() << std::endl;

  T.print_statistics();
  std::cout << "done" << std::endl;
  return 0;
}
开发者ID:mvdan,项目名称:geoc-viewer,代码行数:60,代码来源:delaunay_dd-runtime.cpp

示例2: time_insertion_and_check

void time_insertion_and_check(pp_int V, int n, int d,
  CGAL::Convex_hull_d<R>& C, std::string s, bool check=true)
{
  typedef typename CGAL::Convex_hull_d<R>::chull_has_local_non_convexity
    chull_has_local_non_convexity;
  typedef typename CGAL::Convex_hull_d<R>::chull_has_double_coverage
    chull_has_double_coverage;
  typedef typename CGAL::Convex_hull_d<R>::
    chull_has_center_on_wrong_side_of_hull_facet
    chull_has_center_on_wrong_side_of_hull_facet;

  std::cout << " timing of " << s << std::endl;
  std::vector< CGAL::Point_d<R> > P(n); int i;
  for(i=0; i<n; ++i)
    P[i] = CGAL::Point_d<R>(d,V[i],V[i]+d,1);

  timer.reset(); timer.start(); // float ti = used_time();
  for(i=0; i<n; ++i) {
    C.insert(P[i]);
    if (i%10==0) std::cout << i << " points inserted" << std::endl;
  }
  timer.stop();
  double t = timer.time(); timer.reset(); // float t = used_time(ti);
  (*p_table_file) << s << "\t" << d << " " << n << " "
                  << C.number_of_vertices() << " " << C.number_of_facets()
                  << "\t" << t;
  C.print_statistics();
  std::cout << "used time for inserts  " << t << std::endl;

  C.clear(d);
  timer.start(); // ti = used_time();
  C.initialize(P.begin(),P.end());
  timer.stop(); t = timer.time(); timer.reset();
  // t = used_time(ti);
  C.print_statistics();
  std::cout << "used time for inserts  " << t << std::endl;

  if (check) {
    timer.start();
    std::cout << "entering check" << std::endl;
    try { C.is_valid(true); }
    catch ( chull_has_local_non_convexity )
    { std::cerr << "local non-convexity determined\n"; }
    catch ( chull_has_double_coverage )
    { std::cerr << "double coverage determined\n"; }
    catch ( chull_has_center_on_wrong_side_of_hull_facet )
    { std::cerr << "facet center problem determined\n"; }

    // t = used_time(ti);
    timer.stop(); t = timer.time();
    (*p_table_file) << "\t" << t <<std::endl;
    std::cout<<"used time for sanity check  "<< t <<std::endl<<std::endl;
  } else {
    (*p_table_file) << "\t" << "no"<<std::endl;
    std::cout<<"no check"<<std::endl;
  }
  p_table_file->flush();
}
开发者ID:mvdan,项目名称:geoc-viewer,代码行数:58,代码来源:chull_dd-runtime.cpp

示例3: main

int main() {
  const unsigned int N = 50;
  CGAL::Timer timer;
  timer.start();

  std::vector<Point_3> points, queries;
  Point_3 p;

  std::ifstream point_stream("points.xyz");
  while(point_stream >> p){
    points.push_back(p);

  }

  My_point_property_map ppmap(points);
  Distance tr_dist(ppmap);

  std::ifstream query_stream("queries.xyz");
  while(query_stream >> p ){
    queries.push_back(p);

  }
  timer.stop();
  std::cerr << "reading points took " << timer.time() << " sec." << std::endl;


  timer.reset();
  timer.start();
  Tree tree( boost::counting_iterator<std::size_t>(0),
             boost::counting_iterator<std::size_t>(points.size()),
             Splitter(),
             Traits(ppmap));
  tree.build();
  timer.stop();
  std::cerr << "tree construction took " << timer.time() << " sec." << std::endl;


  // Initialize the search structure, and search all N points
  
  double d = 0;
  timer.reset();
  timer.start();
  for(int i = 0; i < queries.size(); i++){
    K_neighbor_search search(tree, queries[i], 50, 0, true, tr_dist);

    // report the N nearest neighbors and their distance
    // This should sort all N points by increasing distance from origin
    for(K_neighbor_search::iterator it = search.begin(); it != search.end(); ++it){
      //std::cout << it->first << std::endl;
      d += get(ppmap,it->first).x();
    }
  }
  timer.stop();
  std::cerr << d << std::endl;
  std::cerr << queries.size() << " queries in " << timer.time() << " sec." << std::endl;

  return 0;
}
开发者ID:Asuzer,项目名称:cgal,代码行数:58,代码来源:nearest_neighbor_searching_inplace_50.cpp

示例4: done

void
insert_constraints_using_spatial_sort(SDG& sdg)
{
  typedef typename Points_container::const_iterator Points_iterator;
  typedef std::vector<Points_iterator> Indices;
  typedef std::vector<typename SDG::Vertex_handle> Vertices;

  Sort_traits_2<K, Points_iterator> sort_traits;

  Indices indices;
  indices.reserve(points.size());
  for(Points_iterator it = points.begin(); it != points.end(); ++it) {
    indices.push_back(it);
  }
  std::random_shuffle(indices.begin(), indices.end());
  CGAL::spatial_sort(indices.begin(), indices.end(),
                     sort_traits);

  std::cerr << "Inserting " << points.size() << " points...";
  CGAL::Timer timer;
  timer.start();
  Vertices vertices;
  vertices.resize(points.size());
  typename SDG::Vertex_handle hint;
  for(typename Indices::const_iterator
        pt_it_it = indices.begin(), end = indices.end();
      pt_it_it != end; ++pt_it_it) {
    typename SDG::Vertex_handle vh = sdg.insert(**pt_it_it, hint);
    hint = vh;
    vertices[*pt_it_it - points.begin()] = vh;
  }
  timer.stop();
  std::cerr << " done (" << timer.time() << "s)\n";

  std::cerr << "Inserting " << constraints.size() << " constraints...";

  timer.reset();
  timer.start();
  for(typename Constraints_container::const_iterator
        cit = constraints.begin(), end = constraints.end();
      cit != end; ++cit) {
    const typename SDG::Vertex_handle& v1 = vertices[cit->first];
    const typename SDG::Vertex_handle& v2 = vertices[cit->second];
    if(v1 != v2)
      sdg.insert(v1, v2);
  }

  timer.stop();
  std::cerr << " done (" << timer.time() << "s)\n";
}
开发者ID:Asuzer,项目名称:cgal,代码行数:50,代码来源:benchmark-gen.cpp

示例5: main

int main( int argc, char **argv) {
    if ( argc != 3) {
        cerr << "Usage: " << argv[0] << " <infile1> <infile2>" << endl;
        cerr << "       Minkowsky sum of two 3d polyhedra in OFF format." 
             << endl;
        cerr << "       Output in OFF to stdout." << endl;
        exit(1);
    }
    Polyhedron P1;
    Polyhedron P2;
    read( argv[1], P1);
    read( argv[2], P2);

    CGAL::Timer t;
    t.start();

    vector<Point> points;
    Add_points add;
    fold( P1.vertices_begin(), P1.vertices_end(),
          P2.vertices_begin(), P2.vertices_end(),
          back_inserter( points),
          add);
    Polyhedron P3;
    convex_hull_3( points.begin(), points.end(), P3);

    t.stop();
    std::cout << "Runtime Minkowski Sum: " << t.time() << std::endl;

    //    cout << P3;
    return 0;
}
开发者ID:ArcEarth,项目名称:cgal,代码行数:31,代码来源:convex.cpp

示例6: bench_distance

void Scene::bench_distance(Facet_tree& tree,
                           const int function,
                           const double duration)
{

    // generates 100K random point queries
    srand(0);
    unsigned int nb_queries = 100000;
    std::vector<Point> queries;
    for(unsigned int i=0;i<nb_queries;i++)
        queries.push_back(random_point(tree.bbox()));

    CGAL::Timer timer;
    timer.start();
    unsigned int nb = 0;
    while(timer.time() < duration)
    {
        const Point& query = queries[nb%nb_queries];
        switch(function)
        {
        case SQ_DISTANCE:
            tree.squared_distance(query);
            break;
        case CLOSEST_POINT:
            tree.closest_point(query);
            break;
        case CLOSEST_POINT_AND_PRIMITIVE_ID:
            tree.closest_point_and_primitive(query);
        }
        nb++;
    }

    double speed = (double)nb / (double)timer.time();
    std::cout << speed << " queries/s" << std::endl;
}
开发者ID:FMX,项目名称:CGAL,代码行数:35,代码来源:benchmarks.cpp

示例7: createPlane

//create a plane passing the center, with the average of some normals as normal
//the plane created is stored in m_basePlane
//用:CGAL::Plane_3<Kernel>我们这里默认了所得到的边界点是有顺序的!!!
void SgpProp::createPlane(Vertex_handle &center, Polyhedron* mesh)
{
	std::cout << "  SgpProp::createPlane() begin!" <<std::endl;
	CGAL::Timer timer;
	timer.start();	

	std::list<Vertex_handle>& main_border = mesh->main_border();
	if (main_border.empty())
	{
		main_border = mesh->extract_longest_border();
	}

	std::list<Vector_3 > spokes;//a circular linked list
	for (std::list<Vertex_handle>::iterator it=main_border.begin(); it!=main_border.end(); ++it)
	{
		Vertex_handle vh = *it;
		spokes.push_back(vh->point() - center->point());
	}
	spokes.push_back(*(spokes.begin()) );

	std::list<Vector_3 >::iterator bVector = spokes.begin();
	std::list<Vector_3 >::iterator nVector = bVector;
	Vector_3 sum_norm(0,0,0);
	for(++nVector; nVector != spokes.end(); ++nVector,++bVector)
	{
		sum_norm = sum_norm + CGAL::cross_product(*bVector,*nVector);
	} 

	m_basePlaneNormal = sum_norm/(spokes.size()+1);
	
	std::cout << "....Time: " << timer.time() << " seconds." << std::endl<<std::endl;
}
开发者ID:aldongqing,项目名称:jjcao_code,代码行数:35,代码来源:SgpProp.cpp

示例8: tr

template < class Traits > double test_sort(unsigned int degree, unsigned int n)
{
    typedef CGAL::Kinetic::Sort < Traits > Sort;
    Traits tr(0, 10000);
    Sort sort(tr);
    CGAL::Random r;
    for (unsigned int i = 0; i < n; ++i) {
        std::vector < double >cf;
        for (unsigned int j = 0; j < degree + 1; ++j) {
            cf.push_back(r.get_double());
        }
        typename Traits::Kinetic_kernel::Motion_function fn(cf.begin(),
            cf.end());
        typename Traits::Kinetic_kernel::Point_1 pt(fn);
        tr.active_points_1_table_handle()->insert(pt);
    }
    CGAL::Timer timer;
    timer.start();
    int ne = 0;
    while (tr.simulator_handle()->next_event_time() !=
    tr.simulator_handle()->end_time()) {
        tr.simulator_handle()->set_current_event_number(tr.
            simulator_handle()->
            current_event_number()
            + 1);
        ++ne;
        if (ne == 1000)
            break;
    }
    timer.stop();
    return timer.time() / static_cast < double >(ne);
}
开发者ID:Fox-Heracles,项目名称:cgal,代码行数:32,代码来源:timings.cpp

示例9: main

// just reusing the tests from the T3 package to check whether the
// periodic vertices and cells fulfill the requirements.
int main(int, char**)
{
  CGAL::Timer timer;
  timer.start();
  _test_cls_periodic_3_tds_3(Tds());
  std::cerr << timer.time() << " sec." << std::endl;
  return 0;
}
开发者ID:lrineau,项目名称:cgal,代码行数:10,代码来源:test_periodic_3_triangulation_tds.cpp

示例10: main

int main()
{
  int i, loops=10000000;
  CGAL::Timer t;
  double dt;

#if 0

// Those timings were made on my laptop, which is now not mine anymore,
// so I need to make them again to be able to make useful comparisons...
// Maybe automazing the process would be useful to test on different
// platforms...

  //                   mp   / mp1  / mp2  / mp3

  // Cartesian       : 3.44 / 2.71 / 2.67 / 3.5
  // PointC2         : 2.27 / 2.26 / 2.17 / 2.78
  // Advanced kernel : 2.25 / 2.26 / 2.17 / 2.78
  // SimpleCartesian : 1.23 (1.21) (= without the wrapper classes)
  // Homogeneous     : 4.46 (3.47)

  dt = t.time(); t.start();
  for (i=0; i<loops; i++)
    Point2 C = CGAL::midpoint(A,B);

#else

  // Cartesian       : 4.13 / 3.68 / 3.63 / 4.65
  // PointC2         : 3.29 / 3.29 / 3.16 / 3.5
  // Advanced kernel : 3.29 / 3.29 / 3.16 / 3.51
  // SimpleCartesian : 1.32 (1.21)
  // Homogeneous     : 5.23 (4.22)

  Point2 C;
  dt = t.time(); t.start();
  for (i=0; i<loops; i++)
    C = CGAL::midpoint(A,B);

#endif

  t.stop();
  std::cout << "time = " << t.time()-dt << std::endl;

  return 0;
}
开发者ID:ArcEarth,项目名称:cgal,代码行数:45,代码来源:tst10.cpp

示例11: main

int main (int argc, char *argv[]) {
    // Cube
    std::list<Plane> planes;
    planes.push_back(Plane(1, 0, 0, -1));
    planes.push_back(Plane(-1, 0, 0, -1));
    planes.push_back(Plane(0, 1, 0, -1));
    planes.push_back(Plane(0, -1, 0, -1));
    planes.push_back(Plane(0, 0, 1, -1));
    planes.push_back(Plane(0, 0, -1, -1));

    std::vector<Point> points;
    int N, steps;
    // Number of points
    if (argc > 1) {
        N = atoi(argv[1]);
    } else {
        N = 50;
    }

    // Number of steps
    if (argc > 2) {
        steps = atoi(argv[2]);
    } else {
        steps = 10;
    }

    CGAL::Random_points_in_sphere_3<Point> g;
    for (int i = 0; i < N; i++) {
        Point p = *g++;
        points.push_back(p);
    }

    std::ofstream bos("before_lloyd.xyz");
    std::copy(points.begin(), points.end(),
              std::ostream_iterator<Point>(bos, "\n"));

    // Apply Lloyd algorithm: will generate points
    // uniformly sampled inside a cube.
    for (int i = 0; i < steps; i++) {
        std::cout << "iteration " << i + 1 << std::endl;

        CGAL::Timer timer;
        timer.start();
        lloyd_algorithm(planes.begin(),
                        planes.end(),
                        points);
        timer.stop();

        std::cout << "Execution time : " << timer.time() << "s\n";
    }

    std::ofstream aos("after_lloyd.xyz");
    std::copy(points.begin(), points.end(),
              std::ostream_iterator<Point>(aos, "\n"));

    return 0;
}
开发者ID:freehawkzk,项目名称:cgal,代码行数:57,代码来源:lloyd_algorithm.cpp

示例12: main

int main (int argc, char *argv[])
{
  // Get the name of the input file from the command line, or use the default
  // fan_grids.dat file if no command-line parameters are given.
  const char * filename = (argc > 1) ? argv[1] : "fan_grids.dat";

  // Open the input file.
  std::ifstream     in_file (filename);

  if (! in_file.is_open()) {
    std::cerr << "Failed to open " << filename << " ..." << std::endl;
    return (1);
  }

  // Read the segments from the file.
  // The input file format should be (all coordinate values are integers):
  // <n>                                 // number of segments.
  // <sx_1> <sy_1>  <tx_1> <ty_1>        // source and target of segment #1.
  // <sx_2> <sy_2>  <tx_2> <ty_2>        // source and target of segment #2.
  //   :      :       :      :
  // <sx_n> <sy_n>  <tx_n> <ty_n>        // source and target of segment #n.
  
  std::list<Segment_2>  segments;

  unsigned int n;
  in_file >> n;
  unsigned int i;
  for (i = 0; i < n; ++i) {
    int sx, sy, tx, ty;
    in_file >> sx >> sy >> tx >> ty;
    segments.push_back (Segment_2 (Point_2 (Number_type(sx), Number_type(sy)),
                                   Point_2 (Number_type(tx), Number_type(ty))));
  }
  in_file.close();

  // Construct the arrangement by aggregately inserting all segments.
  Arrangement_2                  arr;
  CGAL::Timer                    timer;

  std::cout << "Performing aggregated insertion of " 
            << n << " segments." << std::endl;

  timer.start();
  insert (arr, segments.begin(), segments.end());
  timer.stop();

  // Print the arrangement dimensions.
  std::cout << "V = " << arr.number_of_vertices()
	    << ",  E = " << arr.number_of_edges() 
	    << ",  F = " << arr.number_of_faces() << std::endl;

  std::cout << "Construction took " << timer.time() 
	    << " seconds." << std::endl;
  
  return 0;
}
开发者ID:2php,项目名称:cgal,代码行数:56,代码来源:predefined_kernel.cpp

示例13: main

int main()
{
  CGAL::Timer timer;
  timer.start();
  _test_cls_alpha_shape_3<Alpha_shape_3>();
  _test_cls_alpha_shape_3_exact<EAlpha_shape_3>();

  std::cerr << timer.time() << " sec." << std::endl;
  return 0;
}
开发者ID:ArcEarth,项目名称:cgal,代码行数:10,代码来源:test_periodic_3_alpha_shape_3.cpp

示例14: benchmark_intersections

void Scene::benchmark_intersections(const double duration)
{
    if(m_pPolyhedron == NULL)
    {
        std::cout << "Load polyhedron first." << std::endl;
        return;
    }

    // constructs tree
    std::cout << "Construct AABB tree...";
    CGAL::Timer timer;
    timer.start();
    Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
    std::cout << "done (" << timer.time() << " s)" << std::endl;

    // generates random queries
    const int nb_queries = 1000000;
    std::cout << "Generates random queries...";
    std::vector<Ray> rays;
    std::vector<Line> lines;
    std::vector<Plane> planes;
    std::vector<Segment> segments;
    timer.start();
    srand(0);
    int i = 0;
    for(i=0; i<nb_queries; i++)
    {
        rays.push_back(random_ray(tree.bbox()));
        lines.push_back(random_line(tree.bbox()));
        planes.push_back(random_plane(tree.bbox()));
        segments.push_back(random_segment(tree.bbox()));
    }
    std::cout << "done (" << timer.time() << " s)" << std::endl;

    // bench for all functions and query types
    bench_intersections(tree,duration,DO_INTERSECT,"do_intersect()",rays,lines,planes,segments,nb_queries);
    bench_intersections(tree,duration,ANY_INTERSECTED_PRIMITIVE,"any_intersected_primitive()",rays,lines,planes,segments,nb_queries);
    bench_intersections(tree,duration,ANY_INTERSECTION,"any_intersection()",rays,lines,planes,segments,nb_queries);
    bench_intersections(tree,duration,NB_INTERSECTIONS,"number_of_intersected_primitives()",rays,lines,planes,segments,nb_queries);
    bench_intersections(tree,duration,ALL_INTERSECTED_PRIMITIVES,"all_intersected_primitives()",rays,lines,planes,segments,nb_queries);
    bench_intersections(tree,duration,ALL_INTERSECTIONS,"all_intersections()",rays,lines,planes,segments,nb_queries);
}
开发者ID:FMX,项目名称:CGAL,代码行数:42,代码来源:benchmarks.cpp

示例15: generate_points_in

void Scene::generate_points_in(const unsigned int nb_points,
                               const double min,
                               const double max)
{
    if(m_pPolyhedron == NULL)
    {
        std::cout << "Load polyhedron first." << std::endl;
        return;
    }

    typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
    typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
    typedef CGAL::AABB_tree<Traits> Tree;

    std::cout << "Construct AABB tree...";
    Tree tree(faces(*m_pPolyhedron).first, faces(*m_pPolyhedron).second, *m_pPolyhedron);
    std::cout << "done." << std::endl;

    CGAL::Timer timer;
    timer.start();
    std::cout << "Generate " << nb_points << " points in interval ["
              << min << ";" << max << "]";

    unsigned int nb_trials = 0;
    Vector vec = random_vector();
    while(m_points.size() < nb_points)
    {
        Point p = random_point(tree.bbox());

        // measure distance
        FT signed_distance = std::sqrt(tree.squared_distance(p));

        // measure sign
        Ray ray(p,vec);
        int nb_intersections = (int)tree.number_of_intersected_primitives(ray);
        if(nb_intersections % 2 != 0)
            signed_distance *= -1.0;

        if(signed_distance >= min &&
                signed_distance <= max)
        {
            m_points.push_back(p);
            if(m_points.size()%(nb_points/10) == 0)
                std::cout << "."; // ASCII progress bar
        }
        nb_trials++;
    }
    double speed = (double)nb_trials / timer.time();
    std::cout << "done (" << nb_trials << " trials, "
              << timer.time() << " s, "
              << speed << " queries/s)" << std::endl;
    changed();
}
开发者ID:weaselp,项目名称:cgal,代码行数:53,代码来源:Scene.cpp


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