From b0dae464af10bf263c97aca1847a15aa7c52de0a Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Wed, 13 Sep 2023 18:50:41 -0400 Subject: [PATCH] By default do not wrap atomic coordinates to the unit cell In most inorganic cases, the atomic coordinates are already fractional and this shouldn't matter. But this can break atom-atom bonds (e.g., in Avogadro) https://github.com/OpenChemistry/avogadrolibs/issues/1318 Signed-off-by: Geoff Hutchison --- src/formats/cifformat.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/formats/cifformat.cpp b/src/formats/cifformat.cpp index 75f5cd17ae..fe1bf3d0ea 100644 --- a/src/formats/cifformat.cpp +++ b/src/formats/cifformat.cpp @@ -83,6 +83,7 @@ namespace OpenBabel " B Use bonds listed in CIF file from _geom_bond_etc records (overrides option b)\n\n" "Write Options e.g. -xg:\n" + " w Wrap atomic coordinates to unit cell (default = off)\n" " g Write bonds using _geom_bond_etc fields \n\n"; } @@ -1565,6 +1566,9 @@ namespace OpenBabel return false; ostream &ofs = *pConv->GetOutStream(); + // default is false - leave coordinates as they are + bool wrapFractional = pConv->IsOption("w", OBConversion::OUTOPTIONS); + char buffer[BUFF_SIZE]; ofs <<"# CIF file generated by openbabel "<GetVector(); if (pUC != nullptr) { v = pUC->CartesianToFractional(v); - v = pUC->WrapFractionalCoordinate(v); + if (wrapFractional) + v = pUC->WrapFractionalCoordinate(v); } X = v.x(); Y = v.y();