fix a bug in reading coordinates and setting material IDs