Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenVolumeMesh
OpenVolumeMesh
Commits
40e01383
Commit
40e01383
authored
Sep 17, 2021
by
Martin Heistermann
Browse files
Fix and clean up property default serialisation
parent
d41f8c2a
Changes
5
Hide whitespace changes
Inline
Side-by-side
extra/ovmb-kaitai/ovmb.ksy
View file @
40e01383
...
...
@@ -189,6 +189,8 @@ types:
type: array_span
- id: prop_idx
type: u4
- id: data
size-eos: true
propdir_chunk:
seq:
...
...
src/OpenVolumeMesh/IO/PropertyCodecs.cc
View file @
40e01383
...
...
@@ -19,12 +19,10 @@ namespace Codecs {
struct
BoolPropCodec
{
using
T
=
bool
;
static
void
encode_one
(
Encoder
&
enc
,
const
T
&
val
)
{
uint8_t
v
=
val
?
1
:
0
;
enc
.
write
(
v
);
enc
.
u8
(
val
);
}
static
void
decode_one
(
Decoder
&
reader
,
T
&
val
)
{
uint8_t
v
=
val
?
1
:
0
;
reader
.
read
(
v
);
uint8_t
v
=
reader
.
u8
();
if
(
v
!=
0
&&
v
!=
1
)
{
throw
parse_error
(
"invalid bool encoding"
);
}
...
...
@@ -37,15 +35,13 @@ struct BoolPropCodec {
for
(
size_t
bit
=
0
;
bit
<
n_bits
;
++
bit
)
{
bitset
.
set
(
bit
,
vec
[
i
+
bit
]);
}
uint8_t
tmp
=
static_cast
<
uint8_t
>
(
bitset
.
to_ulong
());
enc
.
write
(
tmp
);
enc
.
u8
(
static_cast
<
uint8_t
>
(
bitset
.
to_ulong
()));
}
}
static
void
decode_n
(
Decoder
&
decoder
,
std
::
vector
<
T
>
&
vec
,
size_t
idx_begin
,
size_t
idx_end
)
{
decoder
.
need
((
idx_end
-
idx_begin
+
7
)
/
8
);
for
(
size_t
i
=
idx_begin
;
i
<
idx_end
;
i
+=
8
)
{
uint8_t
tmp
=
0
;
decoder
.
read
(
tmp
);
uint8_t
tmp
=
decoder
.
u8
();
std
::
bitset
<
8
>
bitset
(
tmp
);
size_t
n_bits
=
std
::
min
(
size_t
(
8
),
idx_end
-
i
);
for
(
size_t
bit
=
0
;
bit
<
n_bits
;
++
bit
)
{
...
...
src/OpenVolumeMesh/IO/detail/WriteBuffer.cc
View file @
40e01383
...
...
@@ -23,6 +23,10 @@ void WriteBuffer::reset()
pos_
=
0
;
}
std
::
vector
<
uint8_t
>
WriteBuffer
::
vec
()
const
{
return
{
data_
.
begin
(),
data_
.
begin
()
+
pos_
};
}
void
WriteBuffer
::
write
(
const
uint8_t
*
s
,
size_t
n
)
{
need
(
n
);
...
...
src/OpenVolumeMesh/IO/detail/WriteBuffer.hh
View file @
40e01383
...
...
@@ -9,7 +9,7 @@ namespace OpenVolumeMesh::IO::detail {
class
OVM_EXPORT
WriteBuffer
{
public:
void
reset
();
std
::
vector
<
uint8_t
>
const
&
vec
()
const
{
return
data_
;}
;
std
::
vector
<
uint8_t
>
vec
()
const
;
;
void
write_to_stream
(
std
::
ostream
&
s
);
size_t
size
()
const
{
return
pos_
;}
...
...
src/Unittests/TestFiles/Cube_with_props.ovmb
View file @
40e01383
No preview for this file type
Write
Preview
Supports
Markdown
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