mirror of https://github.com/CGAL/cgal
cleanup
This commit is contained in:
parent
9ea2ccedb4
commit
ee808b748c
|
|
@ -10,25 +10,25 @@ typedef CGAL::Cartesian<Number_Type> Rep;
|
||||||
typedef CGAL::Snap_rounding_traits_2<Rep> Sr_traits;
|
typedef CGAL::Snap_rounding_traits_2<Rep> Sr_traits;
|
||||||
typedef Rep::Segment_2 Segment_2;
|
typedef Rep::Segment_2 Segment_2;
|
||||||
typedef Rep::Point_2 Point_2;
|
typedef Rep::Point_2 Point_2;
|
||||||
|
typedef std::list<Segment_2> Seg_list;
|
||||||
|
typedef std::list<Point_2> Point_list;
|
||||||
|
typedef std::list<Point_list> Point_list_list;
|
||||||
|
|
||||||
void read_data(int argc,char *argv[],Number_Type &prec,std::list<Segment_2> &seg_list)
|
bool read_data(int argc, char *argv[], Number_Type &prec, Seg_list &seg_list)
|
||||||
{
|
{
|
||||||
int number_of_segments,i;
|
|
||||||
CGAL::Segment_data<Rep> seg;
|
|
||||||
Number_Type x1,y1,x2,y2;
|
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
std::cerr << "syntex: test <input file name>\n";
|
std::cerr << "syntex: test <input file name>\n";
|
||||||
std::exit(1);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream is(argv[1]);
|
std::ifstream is(argv[1]);
|
||||||
|
|
||||||
if (is.bad()) {
|
if (is.bad()) {
|
||||||
std::cerr << "Bad input file : " << argv[1] << std::endl;
|
std::cerr << "Bad input file : " << argv[1] << std::endl;
|
||||||
std::exit(1);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int number_of_segments;
|
||||||
is >> number_of_segments;
|
is >> number_of_segments;
|
||||||
|
|
||||||
is >> prec;
|
is >> prec;
|
||||||
|
|
@ -38,26 +38,27 @@ void read_data(int argc,char *argv[],Number_Type &prec,std::list<Segment_2> &seg
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int i;
|
||||||
for (i = 0; i < number_of_segments; ++i) {
|
for (i = 0; i < number_of_segments; ++i) {
|
||||||
|
Number_Type x1, y1, x2, y2;
|
||||||
is >> x1;
|
is >> x1;
|
||||||
is >> y1;
|
is >> y1;
|
||||||
is >> x2;
|
is >> x2;
|
||||||
is >> y2;
|
is >> y2;
|
||||||
seg_list.push_back(Segment_2(Point_2(x1,y1),Point_2(x2,y2)));
|
seg_list.push_back(Segment_2(Point_2(x1,y1),Point_2(x2,y2)));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_out(std::list<std::list<Point_2> >::iterator begin_iter,
|
void print_out(Point_list_list::iterator begin_iter,
|
||||||
std::list<std::list<Point_2> >::iterator end_iter)
|
Point_list_list::iterator end_iter)
|
||||||
{
|
{
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for(std::list<std::list<Point_2> >::iterator i = begin_iter;
|
std::list<std::list<Point_2> >::iterator i;
|
||||||
i != end_iter;
|
for(i = begin_iter; i != end_iter; ++i) {
|
||||||
++i) {
|
|
||||||
std::cout << "Polyline number " << ++counter << ":\n";
|
std::cout << "Polyline number " << ++counter << ":\n";
|
||||||
for(std::list<Point_2>::iterator i2 = i->begin();
|
std::list<Point_2>::iterator i2;
|
||||||
i2 != i->end();
|
for (i2 = i->begin(); i2 != i->end(); ++i2)
|
||||||
++i2)
|
|
||||||
std::cout << " (" << CGAL::to_double(i2->x()) << ":"
|
std::cout << " (" << CGAL::to_double(i2->x()) << ":"
|
||||||
<< CGAL::to_double(i2->y()) << ")\n";
|
<< CGAL::to_double(i2->y()) << ")\n";
|
||||||
|
|
||||||
|
|
@ -67,32 +68,34 @@ void print_out(std::list<std::list<Point_2> >::iterator begin_iter,
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
std::list<Segment_2> seg_list;
|
Seg_list seg_list;
|
||||||
std::list<std::list<Point_2> > output_list;
|
Point_list_list output_list;
|
||||||
|
|
||||||
Number_Type prec;
|
Number_Type prec;
|
||||||
|
|
||||||
read_data(argc,argv,prec,seg_list);
|
if (!read_data(argc,argv,prec,seg_list))
|
||||||
|
return -1;
|
||||||
|
|
||||||
CGAL::snap_rounding_2<Sr_traits,std::list<Segment_2>::const_iterator,
|
CGAL::snap_rounding_2<Sr_traits, Seg_list::const_iterator,
|
||||||
std::list<std::list<Point_2> > >(
|
Point_list_list>(seg_list.begin(),
|
||||||
seg_list.begin(),seg_list.end(),output_list,
|
seg_list.end(),
|
||||||
|
output_list,
|
||||||
prec, true, false, 3);
|
prec, true, false, 3);
|
||||||
|
|
||||||
std::cout << "input segments\n";
|
std::cout << "input segments" << std::endl;
|
||||||
for(std::list<Segment_2>::iterator i1 = seg_list.begin();
|
std::list<Segment_2>::iterator i1;
|
||||||
i1 != seg_list.end();
|
for (i1 = seg_list.begin(); i1 != seg_list.end(); ++i1)
|
||||||
++i1)
|
|
||||||
std::cout << *i1 << std::endl;
|
std::cout << *i1 << std::endl;
|
||||||
|
|
||||||
std::cout << "\nthe output\n";
|
std::cout << std::endl << "the output" << std::endl;
|
||||||
print_out(output_list.begin(),output_list.end());
|
print_out(output_list.begin(),output_list.end());
|
||||||
|
|
||||||
std::cout << "\ntesting sr\n";
|
std::cout << std::endl << "testing sr" << std::endl;
|
||||||
output_list.clear();
|
output_list.clear();
|
||||||
CGAL::snap_rounding_2<Sr_traits,std::list<Segment_2>::const_iterator,
|
CGAL::snap_rounding_2<Sr_traits, Seg_list::const_iterator,
|
||||||
std::list<std::list<Point_2> > >(
|
Point_list_list>(seg_list.begin(),
|
||||||
seg_list.begin(),seg_list.end(),output_list,
|
seg_list.end(),
|
||||||
|
output_list,
|
||||||
prec, false, false, 3);
|
prec, false, false, 3);
|
||||||
print_out(output_list.begin(),output_list.end());
|
print_out(output_list.begin(),output_list.end());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue