Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
b7e0ef8b
Commit
b7e0ef8b
authored
Dec 02, 2009
by
Mathias Goldau
Browse files
[FIX
#114
] temp file issue fixed
parent
87dbd038
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
src/dataHandler/io/WIOTools.hpp
src/dataHandler/io/WIOTools.hpp
+11
-0
src/modules/marchingCubes/test/WMMarchingCubes_test.h
src/modules/marchingCubes/test/WMMarchingCubes_test.h
+9
-4
No files found.
src/dataHandler/io/WIOTools.hpp
View file @
b7e0ef8b
...
...
@@ -27,6 +27,7 @@
#include <stdint.h>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <string>
...
...
@@ -100,5 +101,15 @@ namespace wiotools
{
return
boost
::
filesystem
::
exists
(
boost
::
filesystem
::
path
(
path
)
);
}
inline
std
::
string
tempFileName
()
{
// REGARDING THE COMPILER WARNING
// 1. mkstemp is only available for POSIX systems
// 2. the warning generated here is due to a race condition
// while tmpnam invents the fileName it may be created by another process
// 3. file names like "/tmp/pansen" or "C:\pansen" are platform dependent
return
std
::
string
(
std
::
tmpnam
(
NULL
)
);
}
}
// end of namespace
#endif // WIOTOOLS_HPP
src/modules/marchingCubes/test/WMMarchingCubes_test.h
View file @
b7e0ef8b
...
...
@@ -25,14 +25,15 @@
#ifndef WMMARCHINGCUBES_TEST_H
#define WMMARCHINGCUBES_TEST_H
#include <vector>
#include <string>
#include <vector>
#include <cxxtest/TestSuite.h>
#include "../WMMarchingCubes.h"
#include "../../../common/WLogger.h"
#include "../../../math/WPosition.h"
#include "../../../dataHandler/io/WIOTools.hpp"
static
WLogger
logger
;
static
bool
loggerInitialized
=
false
;
...
...
@@ -262,10 +263,11 @@ public:
{
WMMarchingCubes
mc
;
WTriangleMesh
triMesh
;
std
::
string
fileName
=
"/tmp/dummerNameDenSichKeinerMerkenBraucht2.vtk"
;
std
::
string
fileName
=
wiotools
::
tempFileName
()
;
bool
result
=
mc
.
save
(
fileName
,
triMesh
);
TS_ASSERT_EQUALS
(
result
,
false
);
// should return false as we did not have any vertices or triangles.
TS_ASSERT
(
!
wiotools
::
fileExists
(
fileName
)
);
}
/**
...
...
@@ -295,12 +297,13 @@ public:
}
triMesh
.
setVertices
(
vertices
);
std
::
string
fileName
=
"/tmp/dummerNameDenSichKeinerMerkenBraucht.vtk"
;
std
::
string
fileName
=
wiotools
::
tempFileName
()
;
mc
.
save
(
fileName
,
triMesh
);
bool
result
=
mc
.
save
(
fileName
,
triMesh
);
TS_ASSERT_EQUALS
(
result
,
false
);
// should return false as we did not have all coordinates values finite.
TS_ASSERT
(
!
wiotools
::
fileExists
(
fileName
)
);
}
/**
...
...
@@ -367,7 +370,7 @@ public:
}
triMesh
.
setVertices
(
vertices
);
std
::
string
fileName
=
"/tmp/dummerNameDenSichKeinerMerkenBraucht.vtk"
;
std
::
string
fileName
=
wiotools
::
tempFileName
()
;
mc
.
save
(
fileName
,
triMesh
);
WTriangleMesh
result
=
mc
.
load
(
fileName
);
...
...
@@ -386,6 +389,8 @@ public:
TS_ASSERT_DELTA
(
triMesh
.
getVertex
(
i
)[
j
],
result
.
getVertex
(
i
)[
j
],
delta
);
}
}
TS_ASSERT
(
wiotools
::
fileExists
(
fileName
)
);
std
::
remove
(
fileName
.
c_str
()
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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