Example #1
0
 Progress_to_std_cerr_callback (const char* name)
   : name (name)
 {
   timer.start();
   t_start = timer.time();
   t_latest = t_start;
 }
Example #2
0
int main()
{
    const int N = 10000000; // 10M
    CGAL::Real_timer timer;
    timer.start();
    std::vector<Point_3> points;
    points.reserve(N);
    CGAL::Random_points_in_sphere_3<Point_3> g( 100.0);
    CGAL::cpp11::copy_n( g, N, std::back_inserter(points));
    timer.stop();
    std::cout << "Fill vector: " << timer.time() << " sec" << std::endl;
    timer.reset();
    timer.start();
    int res=0;
    Predicate predicate;
    for(int j = 0; j < 10; ++j) {
        for(int i = 0; i < N-4; i++) {
            res += predicate(points[i], points[i+1], points[i+2], points[i+3]);
        }
    }
    timer.stop();
    std::cout << "result = " << res << std::endl;
#ifndef ONLY_TEST_COMPARISONS
    std::cout << "Orientation: ";
#else
    std::cout << "Comparisons: ";
#endif
    std::cout << timer.time() << " sec" << std::endl;
}
Example #3
0
void check_timeout()
{
  if ( sTimeout > 0.0 && sTimeoutWatchdog.time() > sTimeout  )
  {
    sHadTimedOut = true ;
    
    throw Timed_out() ;
  }  
}
Example #4
0
int main(int, char** argv)
{
  Mesh m1,m2;
  std::ifstream input(argv[1]);
  input >> m1;
  input.close();

  input.open(argv[2]);
  input >> m2;

  std::cout << "First mesh has " << num_faces(m1) << " faces\n";
  std::cout << "Second mesh has " << num_faces(m2) << " faces\n";

  CGAL::Real_timer time;
  #if defined(CGAL_LINKED_WITH_TBB)
  time.start();
   std::cout << "Distance between meshes (parallel) "
             << PMP::approximate_Hausdorff_distance<CGAL::Parallel_tag>(
                  m1,m2,PMP::parameters::number_of_points_per_area_unit(4000))
             << "\n";
  time.stop();
  std::cout << "done in " << time.time() << "s.\n";
  #endif

  time.reset();
  time.start();
  std::cout << "Distance between meshes (sequential) "
            << PMP::approximate_Hausdorff_distance<CGAL::Sequential_tag>(
                 m1,m2,PMP::parameters::number_of_points_per_area_unit(4000))
            << "\n";
  time.stop();
  std::cout << "done in " << time.time() << "s.\n";

  general_tests<K>(m1,m2);

  test_concept();

  return 0;
}
Example #5
0
  bool operator()(double advancement) const
  {
    // Avoid calling time() at every single iteration, which could
    // impact performances very badly
    ++ nb;
    if (advancement != 1 && nb % 100 != 0)
      return true;

    double t = timer.time();
    if (advancement == 1 || (t - t_latest) > 0.1) // Update every 1/10th of second
    {
      std::cerr << "\r" // Return at the beginning of same line and overwrite
                << name << ": " << int(advancement * 100) << "%";
      
      if (advancement == 1)
        std::cerr << std::endl;
      t_latest = t;
    }

    return true;
  }
Example #6
0
void end_timeout_watchdog()
{
  sTimeoutWatchdog.stop();  
}
Example #7
0
void start_timeout_watchdog()
{
  sTimeoutWatchdog.reset();
  sTimeoutWatchdog.start();  
  sHadTimedOut = false ;
}
Meshing_thread* cgal_code_mesh_3_templated(const Mesh* pMesh,
                                 const Polylines_container& polylines,
                                 const Mesh* pBoundingMesh,
                                 QString filename,
                                 const double facet_angle,
                                 const double facet_sizing,
                                 const double facet_approx,
                                 const double tet_sizing,
                                 const double edge_size,
                                 const double tet_shape,
                                 bool protect_features,
                                 bool protect_borders,
                                 const double sharp_edges_angle,
                                 const int manifold,
                                 const bool surface_only,
                                 CGAL::Three::Scene_interface* scene)
{
  if(!pMesh) return 0;

  std::cerr << "Meshing file \"" << qPrintable(filename) << "\"\n";
  std::cerr << "  angle: " << facet_angle << std::endl
            << "  edge size bound: " << edge_size << std::endl
            << "  facets size bound: " << facet_sizing << std::endl
            << "  approximation bound: " << facet_approx << std::endl;
  if (is_closed(*pMesh))
    std::cerr << "  tetrahedra size bound: " << tet_sizing << std::endl;

  std::cerr << "Build AABB tree...";
  CGAL::Real_timer timer;
  timer.start();

  typedef typename Polyhedral_mesh_domain_selector<Mesh>::type Polyhedral_mesh_domain;
  // Create domain
  Polyhedral_mesh_domain* p_domain = NULL;
  if (!surface_only && is_closed(*pMesh))
    p_domain = new Polyhedral_mesh_domain(*pMesh);
  else if (!surface_only && pBoundingMesh != NULL && is_closed(*pBoundingMesh))
    p_domain = new Polyhedral_mesh_domain(*pMesh, *pBoundingMesh);
  else
  {
    std::vector<const Mesh*> poly_ptrs_vector(1, pMesh);
    p_domain = new Polyhedral_mesh_domain(poly_ptrs_vector.begin(), poly_ptrs_vector.end());
  }

  // Features
  if(polylines.empty() && protect_features) {
      //includes detection of borders in the surface case
      p_domain->detect_features(sharp_edges_angle);
  }
  else if (polylines.empty() && protect_borders)
  {
    p_domain->detect_borders();
  }
  if(! polylines.empty()){
    p_domain->add_features(polylines.begin(), polylines.end());
    protect_features = true; // so that it will be passed in make_mesh_3
  }

  std::cerr << " done (" << timer.time() * 1000 << " ms)" << std::endl;

  Scene_c3t3_item* p_new_item = new Scene_c3t3_item(surface_only);
  p_new_item->setScene(scene);

  QString tooltip = QString("<div>From \"") + filename +
    QString("\" with the following mesh parameters"
            "<ul>"
            "<li>Angle: %1</li>"
            "<li>Edge size bound: %2</li>"
            "<li>Facets size bound: %3</li>"
            "<li>Approximation bound: %4</li>")
    .arg(facet_angle)
    .arg(edge_size)
    .arg(facet_sizing)
    .arg(facet_approx);
  if (is_closed(*pMesh))
    tooltip += QString("<li>Tetrahedra size bound: %1</li>" )
        .arg(tet_sizing);
  tooltip += "</ul></div>";

  p_new_item->setProperty("toolTip",tooltip);
  Mesh_parameters param;
  param.facet_angle = facet_angle;
  param.facet_sizing = facet_sizing;
  param.facet_approx = facet_approx;
  param.tet_sizing = tet_sizing;
  param.tet_shape = tet_shape;
  param.edge_sizing =  edge_size;
  param.manifold = manifold;
  param.protect_features = protect_features || protect_borders;
  param.use_sizing_field_with_aabb_tree = polylines.empty() && protect_features;

  typedef ::Mesh_function<Polyhedral_mesh_domain,
                          Mesh_fnt::Polyhedral_domain_tag> Mesh_function;
  Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(),
                                                     p_domain, param);
  return new Meshing_thread(p_mesh_function, p_new_item);
}