Skip to content

Commit

Permalink
Update binary datastream version and add support for v1 and v2.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Nov 28, 2023
1 parent a3ff67b commit 5f320de
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions corelib/src/libs/SireVol/triclinicbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static const RegisterMetaType<TriclinicBox> r_box;
/** Serialise to a binary datastream */
QDataStream &operator<<(QDataStream &ds, const TriclinicBox &box)
{
writeHeader(ds, r_box, 1) << box.v0 << box.v1 << box.v2
writeHeader(ds, r_box, 2) << box.v0 << box.v1 << box.v2
<< box.rotation_matrix << box.cell_matrix << box.cell_matrix_inverse
<< box.dist_max << box._alpha << box._beta << box._gamma << box.vol
<< box.is_rotated << box.is_reduced << box.invlength;
Expand All @@ -64,13 +64,21 @@ QDataStream &operator>>(QDataStream &ds, TriclinicBox &box)
VersionID v = readHeader(ds, r_box);

if (v == 1)
{
Vector v0, v1, v2;
ds >> v0 >> v1 >> v2;

// Reconstruct the box.
box = TriclinicBox(v0, v1, v2, true, true);
}
else if (v == 2)
{
ds >> box.v0 >> box.v1 >> box.v2 >> box.rotation_matrix >> box.cell_matrix >> box.cell_matrix_inverse
>> box.dist_max >> box._alpha >> box._beta >> box._gamma >> box.vol >> box.is_rotated >> box.is_reduced
>> box.invlength;
>> box.dist_max >> box._alpha >> box._beta >> box._gamma >> box.vol >> box.is_rotated >> box.is_reduced
>> box.invlength;
}
else
throw version_error(v, "1", r_box, CODELOC);
throw version_error(v, "1,2", r_box, CODELOC);

return ds;
}
Expand Down

0 comments on commit 5f320de

Please sign in to comment.