size_t DbWriter::readField(const PointBuffer& pb, char *pos, DimType dimType, PointId idx) { using namespace Dimension; size_t size = Dimension::size(dimType.m_type); pb.getField(pos, dimType.m_id, dimType.m_type, idx); auto iconvert = [pos](const XForm& xform) { double d; int32_t i; memcpy(&d, pos, sizeof(double)); d = (d - xform.m_offset) / xform.m_scale; i = boost::numeric_cast<int32_t>(lround(d)); memcpy(pos, &i, sizeof(int32_t)); }; if (m_locationScaling) { // For X, Y or Z. size = sizeof(int32_t); if (dimType.m_id == Id::X) { iconvert(m_xXform); size = sizeof(int32_t); } else if (dimType.m_id == Id::Y) { iconvert(m_yXform); size = sizeof(int32_t); } else if (dimType.m_id == Id::Z) { iconvert(m_zXform); size = sizeof(int32_t); } } return size; }