Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
polymesh
Commits
0869c4fc
Commit
0869c4fc
authored
Jul 25, 2018
by
Christian Mattes
Browse files
Naming convention fixes
parent
ec2bde01
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/polymesh/formats/pm.cc
View file @
0869c4fc
...
...
@@ -26,7 +26,7 @@ std::pair<std::string, detail::GenericAttributeSerializer *> find_serializer_for
return
{{},
nullptr
};
}
struct
PMH
eader
struct
pm_h
eader
{
char
pm
[
4
]
=
{
'P'
,
'M'
,
0
,
0
};
int32_t
num_vertices
;
...
...
@@ -41,8 +41,8 @@ struct PMHeader
bool
valid
()
const
{
return
pm
[
0
]
==
'P'
&&
pm
[
1
]
==
'M'
&&
pm
[
2
]
==
0
&&
pm
[
3
]
==
0
;
}
};
template
<
class
T
ag
>
static
std
::
istream
&
read_index
(
std
::
istream
&
in
,
primitive_index
<
T
ag
>
&
idx
)
template
<
class
t
ag
>
static
std
::
istream
&
read_index
(
std
::
istream
&
in
,
primitive_index
<
t
ag
>
&
idx
)
{
int32_t
val
;
in
.
read
(
reinterpret_cast
<
char
*>
(
&
val
),
sizeof
(
int32_t
));
...
...
@@ -50,8 +50,8 @@ static std::istream &read_index(std::istream &in, primitive_index<Tag> &idx)
return
in
;
}
template
<
class
T
ag
>
static
std
::
ostream
&
write_index
(
std
::
ostream
&
out
,
primitive_index
<
T
ag
>
const
&
idx
)
template
<
class
t
ag
>
static
std
::
ostream
&
write_index
(
std
::
ostream
&
out
,
primitive_index
<
t
ag
>
const
&
idx
)
{
const
int32_t
val
=
idx
.
value
;
return
out
.
write
(
reinterpret_cast
<
char
const
*>
(
&
val
),
sizeof
(
int32_t
));
...
...
@@ -60,8 +60,8 @@ static std::ostream &write_index(std::ostream &out, primitive_index<Tag> const &
static
std
::
ostream
&
write_string
(
std
::
ostream
&
out
,
std
::
string
const
&
text
)
{
return
out
.
write
(
text
.
c_str
(),
text
.
size
()
+
1
);
}
static
std
::
istream
&
read_string
(
std
::
istream
&
in
,
std
::
string
&
text
)
{
return
std
::
getline
(
in
,
text
,
'\0'
);
}
template
<
class
T
ag
>
static
std
::
ostream
&
storeAttributes
(
std
::
ostream
&
out
,
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
primitive_attribute_base
<
T
ag
>>>
const
&
attrs
)
template
<
class
t
ag
>
static
std
::
ostream
&
storeAttributes
(
std
::
ostream
&
out
,
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
primitive_attribute_base
<
t
ag
>>>
const
&
attrs
)
{
for
(
auto
const
&
attr
:
attrs
)
{
...
...
@@ -80,10 +80,10 @@ static std::ostream &storeAttributes(std::ostream &out, std::map<std::string, st
return
out
;
}
template
<
class
T
ag
>
template
<
class
t
ag
>
static
bool
restoreAttributes
(
std
::
istream
&
in
,
Mesh
const
&
mesh
,
attribute_collection
&
attrs
,
uint32_t
count
)
{
using
T
ag
P
tr
=
T
ag
*
;
using
t
ag
_p
tr
=
t
ag
*
;
for
(
uint32_t
i
=
0
;
i
<
count
;
i
++
)
{
...
...
@@ -94,7 +94,7 @@ static bool restoreAttributes(std::istream &in, Mesh const &mesh, attribute_coll
auto
it
=
sSerializers
.
find
(
attrType
);
if
(
it
!=
sSerializers
.
end
())
{
it
->
second
->
deserialize
(
in
,
mesh
,
attrs
,
attrName
,
T
ag
P
tr
{});
it
->
second
->
deserialize
(
in
,
mesh
,
attrs
,
attrName
,
t
ag
_p
tr
{});
}
else
{
...
...
@@ -113,7 +113,7 @@ void write_pm(std::ostream &out, const Mesh &mesh, const attribute_collection &a
if
(
!
mesh
.
is_compact
())
std
::
cout
<<
"polymesh::write_pm: saving a non-compact mesh."
<<
std
::
endl
;
PMH
eader
header
;
pm_h
eader
header
;
header
.
num_vertices
=
mesh
.
all_vertices
().
size
();
header
.
num_halfedges
=
mesh
.
all_halfedges
().
size
();
header
.
num_faces
=
mesh
.
all_faces
().
size
();
...
...
@@ -147,7 +147,7 @@ void write_pm(std::ostream &out, const Mesh &mesh, const attribute_collection &a
bool
read_pm
(
std
::
istream
&
input
,
Mesh
&
mesh
,
attribute_collection
&
attributes
)
{
PMH
eader
header
;
pm_h
eader
header
;
input
.
read
(
reinterpret_cast
<
char
*>
(
&
header
),
sizeof
(
header
));
assert
(
header
.
valid
()
&&
"PM-File contains the wrong magic number!"
);
...
...
@@ -169,13 +169,12 @@ bool read_pm(std::istream &input, Mesh &mesh, attribute_collection &attributes)
for
(
int
i
=
0
;
i
<
header
.
num_halfedges
;
++
i
)
read_index
(
input
,
ll
.
prev_halfedge_of
(
halfedge_index
(
i
)));
// Store attributes
restoreAttributes
<
vertex_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_vertex_attributes
)
&&
restoreAttributes
<
halfedge_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_halfedge_attributes
)
&&
restoreAttributes
<
edge_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_edge_attributes
)
&&
restoreAttributes
<
face_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_face_attributes
);
return
!
input
.
fail
();
// Restore attributes
return
restoreAttributes
<
vertex_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_vertex_attributes
)
&&
restoreAttributes
<
halfedge_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_halfedge_attributes
)
&&
restoreAttributes
<
edge_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_edge_attributes
)
&&
restoreAttributes
<
face_tag
>
(
input
,
mesh
,
attributes
,
header
.
num_face_attributes
)
//
&&
!
input
.
fail
();
}
void
write_pm
(
const
std
::
string
&
filename
,
const
Mesh
&
mesh
,
const
attribute_collection
&
attributes
)
...
...
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