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
f5edacbc
Commit
f5edacbc
authored
Jul 25, 2018
by
Christian Mattes
Browse files
Handling types being unregistered during saving more gracefully
parent
0869c4fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/polymesh/formats/pm.cc
View file @
f5edacbc
...
...
@@ -60,20 +60,24 @@ 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'
);
}
static
const
std
::
string
unregistered_type_name
=
"UNREGISTERED_TYPE"
;
template
<
class
tag
>
static
std
::
ostream
&
storeAttributes
(
std
::
ostream
&
out
,
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
primitive_attribute_base
<
tag
>>>
const
&
attrs
)
{
for
(
auto
const
&
attr
:
attrs
)
{
write_string
(
out
,
attr
.
first
);
// Attribute Name
auto
const
&
ser
=
find_serializer_for
(
*
attr
.
second
);
if
(
ser
.
second
)
{
write_string
(
out
,
attr
.
first
);
// Attribute Name
write_string
(
out
,
ser
.
first
);
// Attribute Type
ser
.
second
->
serialize
(
out
,
*
attr
.
second
);
// Attribute Data
}
else
{
write_string
(
out
,
unregistered_type_name
);
std
::
cout
<<
"polymesh::write_pm: "
<<
attr
.
first
<<
" has unregistered type and is not going to be written."
<<
std
::
endl
;
}
}
...
...
@@ -91,6 +95,9 @@ static bool restoreAttributes(std::istream &in, Mesh const &mesh, attribute_coll
read_string
(
in
,
attrName
);
read_string
(
in
,
attrType
);
if
(
attrType
==
unregistered_type_name
)
continue
;
auto
it
=
sSerializers
.
find
(
attrType
);
if
(
it
!=
sSerializers
.
end
())
{
...
...
src/polymesh/formats/pm.hh
View file @
f5edacbc
#pragma once
#include
<glm/glm.hpp>
#include
<iostream>
#include
<string>
...
...
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