int main( int argc, char *argv[] ) { if ( argc >= 3 ) { std::cout << "usage: " << argv[0] << " [filename]" << std::endl; } ifstream ifs( (argc == 1) ? "data/sites2.cin" : argv[1] ); assert( ifs ); SDG2 sdg; SDG2::Site_2 site; // read the sites from the stream and insert them in the diagram while ( ifs >> site ) { sdg.insert( site ); } ifs.close(); //std::cout << "About to validate diagram ..." << std::endl; // validate the diagram //assert( sdg.is_valid(true, 1) ); //cout << endl << endl; //std::cout << "Diagram validated." << std::endl; std::cout << "About to print sdg for input file: " << ((argc == 1) ? "data/sites2.cin" : argv[1]) << std::endl ; sdg.file_output_verbose(std::cout); return 0; }
int main( int argc, char *argv[] ) { if ( ! (( argc == 1 ) || (argc == 2)) ) { std::cout <<"usage: "<< argv[0] <<" [filename]\n"; } ifstream ifs( (argc == 1) ? "data/sites2.cin" : argv[1] ); assert( ifs ); SDG2 sdg; SDG2::Site_2 site; // read the sites from the stream and insert them in the diagram while ( ifs >> site ) { sdg.insert( site ); CGAL_SDG_DEBUG( sdg.file_output_verbose(std::cout); ); CGAL_assertion( sdg.is_valid(false, 1) ); }
int main( int argc, char *argv[] ) { if ( ! (( argc == 1 ) || (argc == 2)) ) { std::cout <<"usage: "<< argv[0] <<" [filename]\n"; } ifstream ifs( (argc == 1) ? "data/sitesx.cin" : argv[1] ); assert( ifs ); SDG2 sdg; SDG2::Site_2 site; while ( ifs >> site ) { sdg.insert( site ); } ifs.close(); assert( sdg.is_valid(true, 1) ); cout << endl << endl; // print the number of input and output sites cout << "# of input sites : " << sdg.number_of_input_sites() << endl; cout << "# of output sites: " << sdg.number_of_output_sites() << endl; unsigned int n_ipt(0), n_iseg(0), n_opt(0), n_oseg(0), n_ptx(0); // count the number of input points and input segments SDG2::Input_sites_iterator iit; for (iit = sdg.input_sites_begin(); iit != sdg.input_sites_end(); ++iit) { if ( iit->is_point() ) { n_ipt++; } else { n_iseg++; } } // count the number of output points and output segments, as well // as the number of points that are points of intersection of pairs // of strongly intersecting sites SDG2::Output_sites_iterator oit; for (oit = sdg.output_sites_begin(); oit != sdg.output_sites_end(); ++oit) { if ( oit->is_segment() ) { n_oseg++; } else { n_opt++; if ( !oit->is_input() ) { n_ptx++; } } } cout << endl << "# of input segments: " << n_iseg << endl; cout << "# of input points: " << n_ipt << endl << endl; cout << "# of output segments: " << n_oseg << endl; cout << "# of output points: " << n_opt << endl << endl; cout << "# of intersection points: " << n_ptx << endl; return 0; }
int main() { std::ifstream ifs("data/sites.cin"); assert( ifs ); SDG2 sdg; SDG2::Site_2 site; // read the sites and insert them in the segment Delaunay graph while ( ifs >> site ) { sdg.insert(site); } // validate the segment Delaunay graph assert( sdg.is_valid(true, 1) ); return 0; }
int main() { std::ifstream ifs("data/sitesxx.rb.cin"); assert( ifs ); SDG2 sdg; Site_2 site; // read the sites and their info and insert them in the // segment Delaunay graph; print them as you read them std::cout << std::endl; std::cout << "Input sites:" << std::endl; std::cout << "------------" << std::endl; while ( ifs >> site ) { char c; ifs >> c; Red_blue info = (c == 'r') ? RED : BLUE; std::cout << site << std::flush; std::cout << "\r\t\t\t" << info << std::endl; sdg.insert(site, info); } std::cout << std::endl; // validate the segment Delaunay graph assert( sdg.is_valid(true, 1) ); // print the sites of the segment Delaunay graph and their info std::cout << std::endl << std::endl; std::cout << "Output sites:" << std::endl; std::cout << "-------------" << std::endl; for (FVIT it = sdg.finite_vertices_begin(); it != sdg.finite_vertices_end(); ++it) { std::cout << it->site() << std::flush; std::cout << "\r\t\t\t" << it->storage_site().info() << std::endl; } std::cout << std::endl; return 0; }
int main( int argc, char *argv[] ) { if ( ! (( argc == 1 ) || (argc == 2)) ) { std::cout <<"usage: "<< argv[0] <<" [filename]\n"; } std::ifstream ifs( (argc == 1) ? "data/sites.cin" : argv[1] ); assert( ifs ); SDG2 sdg; SDG2::Site_2 site; // read the sites and insert them in the segment Delaunay graph while ( ifs >> site ) { sdg.insert(site); } // validate the segment Delaunay graph assert( sdg.is_valid(true, 1) ); return 0; }
int main() { std::ifstream ifs("data/sites.cin"); assert( ifs ); SDG2 sdg; SDG2::Site_2 site; std::vector<SDG2::Site_2> sites; // read the sites while ( ifs >> site ) { sites.push_back(site); } //insert the sites all at once using spatial sorting to speed the insertion sdg.insert( sites.begin(), sites.end(),CGAL::Tag_true() ); // validate the segment Delaunay graph assert( sdg.is_valid(true, 1) ); return 0; }
int main( int argc, char *argv[] ) { if ( ! (( argc == 1 ) || (argc == 2)) ) { std::cout <<"usage: "<< argv[0] <<" [filename]\n"; } std::ifstream ifs( (argc == 1) ? "data/sitesxx.cin" : argv[1] ); assert( ifs ); SDG2 sdg; Site_2 site; Generate_info generate; // read the sites and their info and insert them in the // segment Delaunay graph; print them as you read them std::cout << std::endl; std::cout << "Input sites:" << std::endl; std::cout << "------------" << std::endl; while ( ifs >> site ) { Info info = generate(site); std::cout << site << std::flush; std::cout << "\r\t\t\t" << info << std::endl; sdg.insert(site, info); } std::cout << std::endl; // validate the segment Delaunay graph assert( sdg.is_valid(true) ); // print the sites of the segment Delaunay graph and their info std::cout << std::endl; std::cout << "Output sites:" << std::endl; std::cout << "-------------" << std::endl; for (FVIT it = sdg.finite_vertices_begin(); it != sdg.finite_vertices_end(); ++it) { if ( it->site().is_point() ) { std::cout << it->site() << std::flush; std::cout << "\r\t\t\t" << it->storage_site().info() << std::endl; } } for (FVIT it = sdg.finite_vertices_begin(); it != sdg.finite_vertices_end(); ++it) { if ( it->site().is_segment() ) { std::cout << it->site() << std::flush; std::cout << "\r\t\t\t" << it->storage_site().info() << std::endl; } } std::cout << std::endl; return 0; }
void diagrammeIpelet::protected_run(int fn) { SDG2 svd; //Voronoi for segments Delaunay dt; //Voronoi of points Regular rt; //power diagram Apollonius apo; //apollonius bool b=false; if (fn==4) { show_help(); return; } std::list<Point_2> pt_list; std::list<Segment_2> sg_list; std::list<Circle_2> cir_list; Iso_rectangle_2 bbox= read_active_objects( CGAL::dispatch_or_drop_output<Point_2,Polygon_2,Circle_2,Segment_2>( std::back_inserter(pt_list), segment_grabber(std::back_inserter(sg_list)), std::back_inserter(cir_list), std::back_inserter(sg_list) ) ); switch(fn){ case 1: case 0: //VORONOI if (pt_list.empty() && sg_list.empty()){ print_error_message(("No mark, no segment and no polygon selected")); return; } b=!( sg_list.empty() ); for (std::list<Segment_2>::iterator it=sg_list.begin();it!=sg_list.end();++it) svd.insert(it->point(0),it->point(1)); if (b) svd.insert(pt_list.begin(),pt_list.end()); else dt.insert(pt_list.begin(),pt_list.end()); break; case 2: //POWER DIAGRAM if (pt_list.empty() && cir_list.empty()){ print_error_message(("No mark nor circle selected")); return; } for (std::list<Circle_2>::iterator it=cir_list.begin();it!=cir_list.end();it++) rt.insert(Weighted_point_2(it->center(),it->squared_radius())); for (std::list<Point_2>::iterator it=pt_list.begin();it!=pt_list.end();it++) rt.insert(Weighted_point_2(*it,0)); break; case 3: //APOLLONIUS if (cir_list.empty()){ print_error_message(("No circle selected")); return; } for (std::list<Circle_2>::iterator it=cir_list.begin();it!=cir_list.end();it++) apo.insert(ASite(it->center(),sqrt(CGAL::to_double(it->squared_radius())))); for (std::list<Point_2>::iterator it=pt_list.begin();it!=pt_list.end();it++) apo.insert(ASite(*it,0)); break; } //end of switch Kernel::FT incr_len=(fn<2)?50:75; //slightly increase the size of the Bbox bbox=Iso_rectangle_2(bbox.min()+Kernel::Vector_2(-incr_len,-incr_len), bbox.max()+Kernel::Vector_2(incr_len,incr_len)); if(fn<2){ //recover dual objects if(b){ if (fn==0) draw_dual_in_ipe(svd,bbox); else draw_skeleton_in_ipe(svd,bbox); } else draw_dual_in_ipe(dt,bbox); } if(fn==2) draw_dual_in_ipe(rt,bbox); if(fn==3) draw_dual_in_ipe(apo,bbox); }