Commit 3b82b01e authored by JasonPries's avatar JasonPries
Browse files

Update Sketch.save_as to create directory if it does not exist using Boost::Filesystem

parent 1029a0f0
......@@ -10,12 +10,13 @@ matrix:
apt:
sources:
- ubuntu-toolchain-r-test
- boost-latest
- george-edison55-precise-backports
packages:
- cmake
- cmake-data
- g++-6
#- lcov
- libboost1.55-all-dev
before_install:
- mkdir -p $HOME/bin
......
......@@ -5,6 +5,9 @@ project(Oersted)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
find_package(Boost REQUIRED COMPONENTS system filesystem)
include_directories(${Boost_INCLUDE_DIR})
include_directories(./lib/ ./lib/Eigen/ ./lib/GoogleTest/googletest/include/gtest)
add_subdirectory(./lib/)
......
......@@ -18,4 +18,6 @@ set(SOURCE_FILES
./src/Contour.h ./src/Contour.cpp)
add_library(sketch STATIC ${SOURCE_FILES})
\ No newline at end of file
add_library(sketch STATIC ${SOURCE_FILES})
target_link_libraries(sketch ${Boost_LIBRARIES})
\ No newline at end of file
......@@ -76,12 +76,18 @@ void Sketch::add_element(Pattern &p) {
}
template<>
void Sketch::save_as<SaveMethod::Rasterize>(std::string file_name) const {
void Sketch::save_as<SaveMethod::Rasterize>(std::string path, std::string file_name) const {
/*
This is a stub for visualization
*/
boost::filesystem::path dir(path);
if(!boost::filesystem::exists(path)) {
boost::filesystem::create_directories(path);
}
std::fstream fs;
fs.open(file_name, std::fstream::out);
fs.open(path + file_name, std::fstream::out);
for (size_t i = 0; i < Curves.size(); ++i) {
if (!Curves[i]->ForConstruction) {
for (size_t j = 0; j <= 10; ++j) {
......
......@@ -10,9 +10,10 @@
#include <algorithm>
#include <numeric>
#include <cfloat>
#include "Eigen"
#include <boost/filesystem.hpp>
class Sketch;
// Sketch Parameter
......@@ -174,7 +175,7 @@ public:
// Save Functions
template<SaveMethod S>
void save_as(std::string file_name) const;
void save_as(std::string path, std::string file_name) const;
private:
// SketchParameter
......
......@@ -399,7 +399,7 @@ TEST(STAR, CONSTRUCTION_LINES) {
s.solve();
s.build();
s.save_as<SaveMethod::Rasterize>("./output/Star/construction_lines_0.csv");
s.save_as<SaveMethod::Rasterize>("./test/output/Star/", "construction_lines_0.csv");
EXPECT_TRUE(s.size_contours() == 1);
EXPECT_TRUE(s.contour(0)->size() == 4);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment