diff --git a/Snap_rounding_2/examples/Snap_rounding_2/data/snap_rounding_data b/Snap_rounding_2/examples/Snap_rounding_2/data/snap_rounding_data new file mode 100644 index 00000000000..246dc1873d4 --- /dev/null +++ b/Snap_rounding_2/examples/Snap_rounding_2/data/snap_rounding_data @@ -0,0 +1,5 @@ +4 +0 0 10 10 +0 10 10 0 +3 0 3 10 +7 0 7 10 \ No newline at end of file diff --git a/Snap_rounding_2/examples/Snap_rounding_2/snap_rounding_data.cpp b/Snap_rounding_2/examples/Snap_rounding_2/snap_rounding_data.cpp index 73354ee89b7..84f8fd3554f 100644 --- a/Snap_rounding_2/examples/Snap_rounding_2/snap_rounding_data.cpp +++ b/Snap_rounding_2/examples/Snap_rounding_2/snap_rounding_data.cpp @@ -20,17 +20,17 @@ /* Usage -* -* This example converts arbitrary-precision arrangment into fixed-precision using Snap Rounding and by using INPUT DATA FROM A USER SPECIFIED FILE. -* (Mandatory) path to the input file containing the arrangment information. -* (Optional) path to the output file where the results of snap rounding will be stored. -* Not providing this argument will print the result on standard output. -* -* Input file format -* Line # 1: Number of line-segments present in the file. -* Line # 2 to N+1: segment_start_point_x segment_start_point_y segment_end_point_x segment_end_point_y -* -* Each line should contain information about just one segment. + * + * This example converts arbitrary-precision arrangment into fixed-precision using Snap Rounding and by using INPUT DATA FROM A USER SPECIFIED FILE. + * (Mandatory) path to the input file containing the arrangment information. + * (Optional) path to the output file where the results of snap rounding will be stored. + * Not providing this argument will print the result on standard output. + * + * Input file format + * Line # 1: Number of line-segments present in the file. + * Line # 2 to N+1: segment_start_point_x segment_start_point_y segment_end_point_x segment_end_point_y + * + * Each line should contain information about just one segment. */ #include @@ -51,9 +51,10 @@ typedef std::list Polyline_list_2; int main(int argc, char* argv[]) { - if(argc > 3 || argc < 2) + //if(argc > 3 || argc < 2) + if(argc > 3) { - std::cout<< "Incorrect input. path to the INPUT file. (optional) path to the OUTPUT file" << std::endl; + std::cout<< "Incorrect input. path to the INPUT file. (optional) path to the OUTPUT file. No arguments to choose the default data file" << std::endl; return -1; } @@ -63,7 +64,10 @@ int main(int argc, char* argv[]) std::ifstream my_read_file; std::ofstream my_write_file; - my_read_file.open(argv[1]); + if(argc > 1) + my_read_file.open(argv[1]); + else + my_read_file.open("data/snap_rounding_data"); if(!my_read_file.is_open()) {