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
Hurstel
CGoGN
Commits
94f9a08e
Commit
94f9a08e
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
c0dbd7e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
27 deletions
+27
-27
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+2
-2
include/Algo/Export/export.h
include/Algo/Export/export.h
+1
-1
include/Algo/Export/export.hpp
include/Algo/Export/export.hpp
+24
-24
No files found.
Apps/Examples/viewer.cpp
View file @
94f9a08e
...
...
@@ -235,8 +235,8 @@ void Viewer::exportMesh(std::string& filename)
Algo
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
(),
allDarts
)
;
else
if
(
extension
.
compare
(
0
,
4
,
std
::
string
(
".ply"
))
==
0
)
{
std
::
vector
<
typename
PFP
::
TVEC3
>
attributes
;
attributes
.
push_back
(
position
)
;
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"
))
...
...
include/Algo/Export/export.h
View file @
94f9a08e
...
...
@@ -56,7 +56,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
* @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
)
;
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
...
...
include/Algo/Export/export.hpp
View file @
94f9a08e
...
...
@@ -165,7 +165,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
}
template <typename PFP>
bool
exportPLYnew
(
typename
PFP
::
MAP
&
map
,
const
std
::
vector
<
typename
PFP
::
TVEC3
>&
attributeHandlers
,
const
char
*
filename
,
bool
binary
,
const
FunctorSelect
&
good
)
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;
...
...
@@ -241,33 +241,33 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector<typename PFP::TVEC3>
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
)
for (typename std::vector<typename PFP::TVEC3
*
>::const_iterator attrHandler = attributeHandlers.begin() ; attrHandler != attributeHandlers.end() ; ++attrHandler)
{
if
(
attrHandler
->
isValid
()
&&
(
attrHandler
->
getOrbit
()
==
VERTEX
)
)
if (
(*
attrHandler
)
->isValid() && (
(*
attrHandler
)
->getOrbit() == VERTEX) )
{
if
(
attrHandler
->
name
().
compare
(
"position"
)
==
0
)
// Vertex position property
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
;
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
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
;
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
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
;
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
;
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 ;
}
}
}
...
...
@@ -281,9 +281,9 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector<typename PFP::TVEC3>
{
// 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
;
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)
...
...
@@ -298,10 +298,10 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector<typename PFP::TVEC3>
{
// 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
)
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
]]
;
const typename PFP::VEC3& v =
(*
(*attrHandler)
)
[vertices[i]] ;
out.write((char*)(&(v[0])), sizeof(v)) ;
}
...
...
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