Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CGoGN
CGoGN
Commits
a6d0a247
Commit
a6d0a247
authored
Apr 17, 2012
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added ply binary export (boolean in function call)
parent
0edf4e04
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
18 deletions
+65
-18
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+1
-1
include/Algo/Export/export.h
include/Algo/Export/export.h
+1
-1
include/Algo/Export/export.hpp
include/Algo/Export/export.hpp
+63
-16
No files found.
Apps/Examples/viewer.cpp
View file @
a6d0a247
...
...
@@ -234,7 +234,7 @@ void Viewer::exportMesh(std::string& filename)
if
(
extension
==
std
::
string
(
".off"
))
Algo
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
(),
allDarts
)
;
else
if
(
extension
.
compare
(
0
,
4
,
std
::
string
(
".ply"
))
==
0
)
Algo
::
Export
::
exportPLY
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
(),
allDarts
)
;
Algo
::
Export
::
exportPLY
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
(),
true
,
allDarts
)
;
else
if
(
extension
==
std
::
string
(
".map"
))
myMap
.
saveMapBin
(
filename
)
;
else
...
...
include/Algo/Export/export.h
View file @
a6d0a247
...
...
@@ -43,7 +43,7 @@ namespace Export
* @return true
*/
template
<
typename
PFP
>
bool
exportPLY
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
char
*
filename
,
const
FunctorSelect
&
good
=
allDarts
)
;
bool
exportPLY
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
char
*
filename
,
const
bool
binary
,
const
FunctorSelect
&
good
=
allDarts
)
;
/**
* export the map into a OFF file
...
...
include/Algo/Export/export.hpp
View file @
a6d0a247
...
...
@@ -38,12 +38,16 @@ namespace Export
{
template
<
typename
PFP
>
bool
exportPLY
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
char
*
filename
,
const
FunctorSelect
&
good
)
bool
exportPLY
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
char
*
filename
,
bool
binary
,
const
FunctorSelect
&
good
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
std
::
ofstream
out
(
filename
,
std
::
ios
::
out
)
;
std
::
ofstream
out
;
//if (!binary)
out
.
open
(
filename
,
std
::
ios
::
out
)
;
//else
//out.open(filename, std::ios::out | std::ios::binary) ;
if
(
!
out
.
good
())
{
CGoGNerr
<<
"Unable to open file "
<<
CGoGNendl
;
...
...
@@ -85,21 +89,42 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
}
out
<<
"ply"
<<
std
::
endl
;
if
(
!
binary
)
out
<<
"format ascii 1.0"
<<
std
::
endl
;
out
<<
"comment no comment"
<<
std
::
endl
;
else
{
// test endianness
union
{
uint32_t
i
;
char
c
[
4
]
;
}
bint
=
{
0x01020304
}
;
if
(
bint
.
c
[
0
]
==
1
)
// big endian
out
<<
"format binary_big_endian 1.0"
<<
std
::
endl
;
else
out
<<
"format binary_little_endian 1.0"
<<
std
::
endl
;
}
out
<<
"comment File generated by the CGoGN library"
<<
std
::
endl
;
out
<<
"comment See : http://cgogn.unistra.fr/"
<<
std
::
endl
;
out
<<
"comment Or contact : cgogn@unistra.fr"
<<
std
::
endl
;
out
<<
"element vertex "
<<
vertices
.
size
()
<<
std
::
endl
;
out
<<
"property float x"
<<
std
::
endl
;
out
<<
"property float y"
<<
std
::
endl
;
out
<<
"property float z"
<<
std
::
endl
;
if
(
position
.
isValid
())
{
out
<<
"property float32 x"
<<
std
::
endl
;
out
<<
"property float32 y"
<<
std
::
endl
;
out
<<
"property float32 z"
<<
std
::
endl
;
}
out
<<
"element face "
<<
facesSize
.
size
()
<<
std
::
endl
;
out
<<
"property list u
char
int vertex_indices"
<<
std
::
endl
;
out
<<
"property list u
int8 u
int
32
vertex_indices"
<<
std
::
endl
;
out
<<
"end_header"
<<
std
::
endl
;
for
(
unsigned
int
i
=
0
;
i
<
vertices
.
size
();
++
i
)
if
(
!
binary
)
{
const
VEC3
&
v
=
position
[
vertices
[
i
]]
;
out
<<
v
[
0
]
<<
" "
<<
v
[
1
]
<<
" "
<<
v
[
2
]
<<
std
::
endl
;
}
for
(
unsigned
int
i
=
0
;
i
<
vertices
.
size
();
++
i
)
out
<<
position
[
vertices
[
i
]
]
<<
std
::
endl
;
for
(
unsigned
int
i
=
0
;
i
<
facesSize
.
size
();
++
i
)
{
out
<<
facesSize
[
i
]
;
...
...
@@ -107,8 +132,30 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
out
<<
" "
<<
facesIdx
[
i
][
j
]
;
out
<<
std
::
endl
;
}
}
else
{
for
(
unsigned
int
i
=
0
;
i
<
vertices
.
size
();
++
i
)
{
Geom
::
Vec3f
v
=
position
[
vertices
[
i
]]
;
for
(
unsigned
int
c
=
0
;
c
<
3
;
++
c
)
{
const
float
&
floatofdouble
=
v
[
c
]
;
out
.
write
((
char
*
)(
&
floatofdouble
),
sizeof
(
float
))
;
}
}
for
(
unsigned
int
i
=
0
;
i
<
facesSize
.
size
();
++
i
)
{
unsigned
char
nbe
=
facesSize
[
i
]
;
out
.
write
((
char
*
)(
&
nbe
),
sizeof
(
unsigned
char
))
;
for
(
unsigned
int
j
=
0
;
j
<
facesIdx
[
i
].
size
()
;
++
j
)
out
.
write
((
char
*
)(
&
(
facesIdx
[
i
][
j
])),
sizeof
(
unsigned
int
))
;
}
}
out
.
close
()
;
return
true
;
}
...
...
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