Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pries, Jason
Oersted
Commits
3b82b01e
Commit
3b82b01e
authored
Oct 19, 2016
by
JasonPries
Browse files
Update Sketch.save_as to create directory if it does not exist using Boost::Filesystem
parent
1029a0f0
Changes
6
Hide whitespace changes
Inline
Side-by-side
.travis.yml
View file @
3b82b01e
...
...
@@ -10,12 +10,13 @@ matrix:
apt
:
sources
:
-
ubuntu-toolchain-r-test
-
boost-latest
-
george-edison55-precise-backports
packages
:
-
cmake
-
cmake-data
-
g++-6
#
- l
co
v
-
l
ibboost1.55-all-de
v
before_install
:
-
mkdir -p $HOME/bin
...
...
CMakeLists.txt
View file @
3b82b01e
...
...
@@ -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/
)
...
...
src/Sketch/CMakeLists.txt
View file @
3b82b01e
...
...
@@ -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
src/Sketch/src/Sketch.cpp
View file @
3b82b01e
...
...
@@ -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
)
{
...
...
src/Sketch/src/Sketch.h
View file @
3b82b01e
...
...
@@ -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
...
...
test/Sketch/test_Star.cpp
View file @
3b82b01e
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment