diff --git a/build/CMakeFiles/HLlib.dir/src/HiddenLines.cpp.o b/build/CMakeFiles/HLlib.dir/src/HiddenLines.cpp.o index 138655a..20101bd 100644 Binary files a/build/CMakeFiles/HLlib.dir/src/HiddenLines.cpp.o and b/build/CMakeFiles/HLlib.dir/src/HiddenLines.cpp.o differ diff --git a/build/CMakeFiles/main.dir/src/main.cpp.o b/build/CMakeFiles/main.dir/src/main.cpp.o index a6a1a16..d127b84 100644 Binary files a/build/CMakeFiles/main.dir/src/main.cpp.o and b/build/CMakeFiles/main.dir/src/main.cpp.o differ diff --git a/build/libHLlib.a b/build/libHLlib.a index 76c599d..604d473 100644 Binary files a/build/libHLlib.a and b/build/libHLlib.a differ diff --git a/build/main b/build/main index 5a8af3c..6f00495 100755 Binary files a/build/main and b/build/main differ diff --git a/src/HiddenLines.cpp b/src/HiddenLines.cpp index 36b4677..3a08104 100644 --- a/src/HiddenLines.cpp +++ b/src/HiddenLines.cpp @@ -37,6 +37,8 @@ void HL::print_sol() if(stop_range == std::numeric_limits::max()) stop_print = "inf"; + if (start_range == stop_range) + continue; std::cout << "Line ID " << std::get<0>(*itr) << " visible from x=" << start_print << " to x=" << stop_print << std::endl; } @@ -196,42 +198,35 @@ std::vector HL::construct_HWprob(){ Line newline = Line(slope, ycept); newline.set_id(); sorted_lines.insert(newline); - lines.push_back(newline); auto line_holder = get_map(); //line_holder[newline.get_id()] = newline; line_holder.insert(std::pair (newline.get_id(), newline)); } - //Set most neg slope to start range of -inf, and most pos to stop of inf - Line lend = *lines.end(); - Line lbegin = *lines.begin(); - lend.set_vis_end(std::numeric_limits::max()); - lbegin.set_vis_start(std::numeric_limits::lowest()); - - std::string lend_stop = std::to_string(lend.get_vis_end()); - std::string lbegin_start = std::to_string(lbegin.get_vis_start()); - if(lend.get_vis_end() == std::numeric_limits::max()) - lend_stop = "inf"; - if(lbegin.get_vis_start() == std::numeric_limits::lowest()) - lbegin_start = "-inf"; + //Copy set to vector + std::copy(sorted_lines.begin(), sorted_lines.end(), std::back_inserter(lines)); + //Display Sorted Vector std::cout << "---------------Sorted Lines by slope:---------------" << std::endl; - for(Line line : sorted_lines) + for(std::vector::iterator it = lines.begin(); it != lines.end(); it++) { + Line line = *it; std::cout << "Line " << line.get_id() << " has slope " << line.get_slope() << " and a y-intercept of " << line.get_ycept() << std::endl; - std::cout << "Line " << line.get_id() << " visible from x=" << line.get_vis_start() << " to x=" <::lowest()); + std::cout << "Changed Line " << line.get_id() << " start vis to " << line.get_vis_start() << std::endl; + *it = line; + } + if (it == (std::prev(lines.end()))){ + line.set_vis_end(std::numeric_limits::max()); + std::cout << "Changed Line " << line.get_id() << " stop vis to " << line.get_vis_end() << std::endl; + *it = line; + } } std::cout << "-----------------------------------------------------" << std::endl; - std::cout << "From the sorted lines, we can derive that Line " << lend.get_id() << " is visible from x=" << lend.get_vis_start() << - " to x=" << lend_stop << std::endl; - - std::cout << "From the sorted lines, we can derive that Line " << lbegin.get_id() << " is visible from x=" << lbegin.get_vis_start() << - " to x=" << lbegin.get_vis_end() << std::endl; - return lines; } diff --git a/src/main.cpp b/src/main.cpp index 9216cc9..2f745b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,9 +13,6 @@ int main(int argc, char *argv[]) HL inst = HL(); std::cout << std::endl; - Line tmp = *inst.get_lines().end(); - std::cout << "Line "<< tmp.get_id() << " vis from x=" << tmp.get_vis_start() << " to x=" << tmp.get_vis_end() << std::endl; - std::cout << "Generating Solution.\n" << std::endl; auto lines = inst.get_lines(); inst.gen_sol(lines);