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
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
dedbad14
Commit
dedbad14
authored
Apr 18, 2012
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exportPly exports a list of vertex attributes
parent
66f26c13
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
176 additions
and
5 deletions
+176
-5
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+5
-1
include/Algo/Export/export.h
include/Algo/Export/export.h
+12
-0
include/Algo/Export/export.hpp
include/Algo/Export/export.hpp
+158
-3
include/Utils/nameTypes.h
include/Utils/nameTypes.h
+1
-1
No files found.
Apps/Examples/viewer.cpp
View file @
dedbad14
...
@@ -234,7 +234,11 @@ void Viewer::exportMesh(std::string& filename)
...
@@ -234,7 +234,11 @@ void Viewer::exportMesh(std::string& filename)
if
(
extension
==
std
::
string
(
".off"
))
if
(
extension
==
std
::
string
(
".off"
))
Algo
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
(),
allDarts
)
;
Algo
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
(),
allDarts
)
;
else
if
(
extension
.
compare
(
0
,
4
,
std
::
string
(
".ply"
))
==
0
)
else
if
(
extension
.
compare
(
0
,
4
,
std
::
string
(
".ply"
))
==
0
)
Algo
::
Export
::
exportPLY
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
(),
true
,
allDarts
)
;
{
std
::
vector
<
typename
PFP
::
TVEC3
>
attributes
;
attributes
.
push_back
(
position
)
;
Algo
::
Export
::
exportPLYnew
<
PFP
>
(
myMap
,
attributes
,
filename
.
c_str
(),
true
,
allDarts
)
;
}
else
if
(
extension
==
std
::
string
(
".map"
))
else
if
(
extension
==
std
::
string
(
".map"
))
myMap
.
saveMapBin
(
filename
)
;
myMap
.
saveMapBin
(
filename
)
;
else
else
...
...
include/Algo/Export/export.h
View file @
dedbad14
...
@@ -39,6 +39,7 @@ namespace Export
...
@@ -39,6 +39,7 @@ namespace Export
/**
/**
* export the map into a PLY file
* export the map into a PLY file
* @param the_map map to be exported
* @param the_map map to be exported
* @param position the position container
* @param filename filename of ply file
* @param filename filename of ply file
* @param binary write in binary mode
* @param binary write in binary mode
* @return true
* @return true
...
@@ -46,6 +47,17 @@ namespace Export
...
@@ -46,6 +47,17 @@ namespace Export
template
<
typename
PFP
>
template
<
typename
PFP
>
bool
exportPLY
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
char
*
filename
,
const
bool
binary
,
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 PLY file
* @param the_map map to be exported
* @param vertexAttrNames the vertex attribute names
* @param filename filename of ply file
* @param binary write in binary mode
* @return true
*/
template
<
typename
PFP
>
bool
exportPLYnew
(
typename
PFP
::
MAP
&
map
,
const
std
::
vector
<
typename
PFP
::
TVEC3
>&
attributeHandlers
,
const
char
*
filename
,
const
bool
binary
,
const
FunctorSelect
&
good
=
allDarts
)
;
/**
/**
* export the map into a OFF file
* export the map into a OFF file
* @param the_map map to be exported
* @param the_map map to be exported
...
...
include/Algo/Export/export.hpp
View file @
dedbad14
...
@@ -117,9 +117,9 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
...
@@ -117,9 +117,9 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
// Position property
// Position property
if
(
position
.
isValid
())
if
(
position
.
isValid
())
{
{
out
<<
"property "
<<
nameOfTypePly
(
position
[
0
][
0
])
<<
8
*
sizeof
(
position
[
0
][
0
])
<<
" x"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
(
position
[
0
][
0
])
<<
" x"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
(
position
[
0
][
1
])
<<
8
*
sizeof
(
position
[
0
][
1
])
<<
" y"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
(
position
[
0
][
1
])
<<
" y"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
(
position
[
0
][
2
])
<<
8
*
sizeof
(
position
[
0
][
2
])
<<
" z"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
(
position
[
0
][
2
])
<<
" z"
<<
std
::
endl
;
}
}
// Face element
// Face element
out
<<
"element face "
<<
facesSize
.
size
()
<<
std
::
endl
;
out
<<
"element face "
<<
facesSize
.
size
()
<<
std
::
endl
;
...
@@ -164,6 +164,161 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
...
@@ -164,6 +164,161 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
return
true
;
return
true
;
}
}
template
<
typename
PFP
>
bool
exportPLYnew
(
typename
PFP
::
MAP
&
map
,
const
std
::
vector
<
typename
PFP
::
TVEC3
>&
attributeHandlers
,
const
char
*
filename
,
bool
binary
,
const
FunctorSelect
&
good
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
// open file
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
;
return
false
;
}
unsigned
int
nbDarts
=
map
.
getNbDarts
()
;
std
::
vector
<
unsigned
int
>
facesSize
;
std
::
vector
<
std
::
vector
<
unsigned
int
>
>
facesIdx
;
facesSize
.
reserve
(
nbDarts
/
3
)
;
facesIdx
.
reserve
(
nbDarts
/
3
)
;
std
::
map
<
unsigned
int
,
unsigned
int
>
vIndex
;
unsigned
int
vCpt
=
0
;
std
::
vector
<
unsigned
int
>
vertices
;
vertices
.
reserve
(
nbDarts
/
6
)
;
// Go over all faces
CellMarker
markV
(
map
,
VERTEX
)
;
TraversorF
<
MAP
>
t
(
map
,
good
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
std
::
vector
<
unsigned
int
>
fidx
;
fidx
.
reserve
(
8
)
;
unsigned
int
degree
=
0
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
{
++
degree
;
unsigned
int
vNum
=
map
.
getEmbedding
(
VERTEX
,
it
)
;
if
(
!
markV
.
isMarked
(
it
))
{
markV
.
mark
(
it
)
;
vIndex
[
vNum
]
=
vCpt
++
;
vertices
.
push_back
(
vNum
)
;
}
fidx
.
push_back
(
vIndex
[
vNum
])
;
}
facesSize
.
push_back
(
degree
)
;
facesIdx
.
push_back
(
fidx
)
;
}
// Start writing the file
out
<<
"ply"
<<
std
::
endl
;
// ascii or binary
if
(
!
binary
)
out
<<
"format ascii 1.0"
<<
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
;
// Vertex elements
out
<<
"element vertex "
<<
vertices
.
size
()
<<
std
::
endl
;
for
(
typename
std
::
vector
<
typename
PFP
::
TVEC3
>::
const_iterator
attrHandler
=
attributeHandlers
.
begin
()
;
attrHandler
!=
attributeHandlers
.
end
()
;
++
attrHandler
)
{
if
(
attrHandler
->
isValid
()
&&
(
attrHandler
->
getOrbit
()
==
VERTEX
)
)
{
if
(
attrHandler
->
name
().
compare
(
"position"
)
==
0
)
// Vertex position property
{
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
0
])
<<
" x"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
1
])
<<
" y"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
2
])
<<
" z"
<<
std
::
endl
;
}
else
if
(
attrHandler
->
name
().
compare
(
"normal"
)
==
0
)
// normal property
{
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
0
])
<<
" nx"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
1
])
<<
" ny"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
2
])
<<
" nz"
<<
std
::
endl
;
}
else
if
(
attrHandler
->
name
().
compare
(
"color"
)
==
0
)
// vertex color property
{
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
0
])
<<
" red"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
1
])
<<
" green"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
2
])
<<
" blue"
<<
std
::
endl
;
}
else
// other vertex properties
{
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
0
])
<<
" "
<<
attrHandler
->
name
()
<<
"_0"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
1
])
<<
" "
<<
attrHandler
->
name
()
<<
"_1"
<<
std
::
endl
;
out
<<
"property "
<<
nameOfTypePly
((
*
attrHandler
)[
0
][
2
])
<<
" "
<<
attrHandler
->
name
()
<<
"_2"
<<
std
::
endl
;
}
}
}
// Face element
out
<<
"element face "
<<
facesSize
.
size
()
<<
std
::
endl
;
out
<<
"property list uint8 uint"
<<
8
*
sizeof
(
facesIdx
[
0
][
0
])
<<
" vertex_indices"
<<
std
::
endl
;
out
<<
"end_header"
<<
std
::
endl
;
if
(
!
binary
)
// ascii
{
// ascii vertices
for
(
unsigned
int
i
=
0
;
i
<
vertices
.
size
();
++
i
)
for
(
typename
std
::
vector
<
typename
PFP
::
TVEC3
>::
const_iterator
attrHandler
=
attributeHandlers
.
begin
()
;
attrHandler
!=
attributeHandlers
.
end
()
;
++
attrHandler
)
if
(
attrHandler
->
isValid
()
&&
attrHandler
->
getOrbit
()
==
VERTEX
)
out
<<
(
*
attrHandler
)[
vertices
[
i
]]
<<
std
::
endl
;
// ascii faces
for
(
unsigned
int
i
=
0
;
i
<
facesSize
.
size
();
++
i
)
{
out
<<
facesSize
[
i
]
;
for
(
unsigned
int
j
=
0
;
j
<
facesIdx
[
i
].
size
();
++
j
)
out
<<
" "
<<
facesIdx
[
i
][
j
]
;
out
<<
std
::
endl
;
}
}
else
// binary
{
// binary vertices
for
(
unsigned
int
i
=
0
;
i
<
vertices
.
size
();
++
i
)
for
(
typename
std
::
vector
<
typename
PFP
::
TVEC3
>::
const_iterator
attrHandler
=
attributeHandlers
.
begin
()
;
attrHandler
!=
attributeHandlers
.
end
()
;
++
attrHandler
)
if
(
attrHandler
->
isValid
()
&&
attrHandler
->
getOrbit
()
==
VERTEX
)
{
const
typename
PFP
::
VEC3
&
v
=
(
*
attrHandler
)[
vertices
[
i
]]
;
out
.
write
((
char
*
)(
&
(
v
[
0
])),
sizeof
(
v
))
;
}
// binary faces
for
(
unsigned
int
i
=
0
;
i
<
facesSize
.
size
();
++
i
)
{
unsigned
char
nbe
=
facesSize
[
i
]
;
out
.
write
((
char
*
)(
&
nbe
),
sizeof
(
unsigned
char
))
;
out
.
write
((
char
*
)(
&
(
facesIdx
[
i
][
0
])),
facesSize
[
i
]
*
sizeof
(
facesIdx
[
i
][
0
]))
;
}
}
out
.
close
()
;
return
true
;
}
template
<
typename
PFP
>
template
<
typename
PFP
>
bool
exportOFF
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
char
*
filename
,
const
FunctorSelect
&
good
)
bool
exportOFF
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
char
*
filename
,
const
FunctorSelect
&
good
)
{
{
...
...
include/Utils/nameTypes.h
View file @
dedbad14
...
@@ -77,7 +77,7 @@ template <> inline std::string nameOfTypePly(const long int& v) { return "invali
...
@@ -77,7 +77,7 @@ template <> inline std::string nameOfTypePly(const long int& v) { return "invali
template
<
>
inline
std
::
string
nameOfTypePly
(
const
unsigned
char
&
v
)
{
return
"uint8"
;
}
template
<
>
inline
std
::
string
nameOfTypePly
(
const
unsigned
char
&
v
)
{
return
"uint8"
;
}
template
<
>
inline
std
::
string
nameOfType
(
const
unsigned
short
int
&
v
)
{
return
"uint16"
;
}
template
<
>
inline
std
::
string
nameOfType
Ply
(
const
unsigned
short
int
&
v
)
{
return
"uint16"
;
}
template
<
>
inline
std
::
string
nameOfTypePly
(
const
unsigned
int
&
v
)
{
return
"uint32"
;
}
template
<
>
inline
std
::
string
nameOfTypePly
(
const
unsigned
int
&
v
)
{
return
"uint32"
;
}
...
...
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