add function to read mesh directlly from memory