Ejemplo n.º 1
0
int main(int argc, char*argv[])
{

    CGAL_SET_LOG_LEVEL(CGAL::Log::LOTS);

    typedef CGAL::Kinetic::Exact_simulation_traits Traits;

    typedef CGAL::Kinetic::Qt_widget_2<Traits::Simulator> Gui;
    typedef CGAL::Kinetic::Qt_moving_points_2<Traits, Gui> Qt_moving_points;
    typedef CGAL::Kinetic::Insert_event<Traits::Active_points_2_table> Insert_event;
    typedef Traits::Kinetic_kernel::Point_2 Moving_point;
    typedef CGAL::Kinetic::Enclosing_box_2<Traits> Box;
    Traits tr(0,100000.0);

    Gui::Handle qtsim=new Gui(argc, argv, tr.simulator_handle());
    Qt_moving_points::Handle qtmptp= new Qt_moving_points(qtsim, tr);
    Box::Handle box= new Box(tr);

    Traits::Kinetic_kernel::Function_kernel::Construct_function cf= tr.kinetic_kernel_object().function_kernel_object().construct_function_object();

    tr.simulator_handle()->new_event(Traits::Simulator::Time(0), Insert_event( Moving_point(cf(0,2,4),
                                     cf(2,-3,4)), tr.active_points_2_table_handle()));
    tr.simulator_handle()->new_event(Traits::Simulator::Time(.1),
                                     Insert_event( Moving_point(cf(3,2,4),
                                             cf(1,-3,4)),
                                             tr.active_points_2_table_handle()));

    return qtsim->begin_event_loop();
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
  unsigned int num_points=20;
  unsigned int degree =2;
  if (argc==3) {
    num_points= std::atoi(argv[1]);
    degree= std::atoi(argv[2]);
  }
  std::cout << "Using " << num_points  << " degree " << degree << " points.\n";
  CGAL_SET_LOG_LEVEL(CGAL::Log::NONE);
  bool error=false;
  {
    
    typedef CGAL::Kinetic::Exact_simulation_traits Tr;
    Tr tr(0,1000000);
    typedef Tr::Simulator::Time Time;
    
    typedef CGAL::Kinetic::Insert_event<Tr::Active_points_1_table> MOI;
    typedef Tr::Kinetic_kernel::Point_2 MP;
    typedef  Tr::Kinetic_kernel::Motion_function::NT NT;
    
    for (unsigned int i=0; i< num_points; ++i) {
      std::vector<double> coefs;
      for (unsigned int j=0; j<= degree; ++j) {
	coefs.push_back(static_cast<double>(std::rand())/static_cast<double>(RAND_MAX));
      }
      tr.simulator_handle()->new_event(Time(i/100.0), MOI(MP(Tr::Kinetic_kernel::Motion_function(coefs.begin(), coefs.end()),
							     Tr::Kinetic_kernel::Motion_function(NT(0.0))), 
							  tr.active_points_1_table_handle()));
    }
    error= error || sort_test<Tr>(tr);
  }
#ifdef CGAL_USE_CORE
  {
    
    typedef CGAL::Kinetic::CORE_Expr_exact_simulation_traits Tr;
    Tr tr(0,1000000);
    typedef Tr::Simulator::Time Time;
    
    typedef CGAL::Kinetic::Insert_event<Tr::Active_points_1_table> MOI;
    typedef Tr::Kinetic_kernel::Point_2 MP;
    typedef Tr::Kinetic_kernel::Motion_function::NT NT;
    
    for (unsigned int i=0; i< num_points; ++i) {
      std::vector<double> coefs;
      for (unsigned int j=0; j<= degree; ++j) {
	coefs.push_back(static_cast<double>(std::rand())/static_cast<double>(RAND_MAX));
      }
      tr.simulator_handle()->new_event(Time(i/100.0), MOI(MP(Tr::Kinetic_kernel::Motion_function(coefs.begin(), coefs.end()),
							     Tr::Kinetic_kernel::Motion_function(NT(0.0))), 
							  tr.active_points_1_table_handle()));
    }
    error= error || sort_test<Tr>(tr);
  }
#endif
  
 
  if (error || CGAL::Kinetic::internal::get_static_audit_failures() != 0) {
    return EXIT_FAILURE;
  }
  else {
    return EXIT_SUCCESS;
  }
}