def save(self, **kwargs): self.ctm.addAttrib(self.aux, "auxdat") self.ctm.addAttrib(self.mni, "mnicoords") self.ctm.save(**kwargs) ctm = CTMfile(self.tf.name) return ctm.getMesh(), self.tf.read()
def read_pack(ctmfile): fname = os.path.splitext(ctmfile)[0] jsfile = json.load(open(fname + ".json")) offset = jsfile["offsets"] meshes = [] with open(ctmfile, "r") as ctmfp: ctmfp.seek(0, 2) offset.append(ctmfp.tell()) for start, end in zip(offset[:-1], offset[1:]): ctmfp.seek(start) tf = tempfile.NamedTemporaryFile() tf.write(ctmfp.read(end - start)) tf.seek(0) ctm = CTMfile(tf.name, "r") pts, polys, norms = ctm.getMesh() meshes.append((pts, polys)) return meshes
def read_pack(ctmfile): fname = os.path.splitext(ctmfile)[0] jsfile = json.load(open(fname + ".json")) offset = jsfile['offsets'] meshes = [] with open(ctmfile, 'r') as ctmfp: ctmfp.seek(0, 2) offset.append(ctmfp.tell()) for start, end in zip(offset[:-1], offset[1:]): ctmfp.seek(start) tf = tempfile.NamedTemporaryFile() tf.write(ctmfp.read(end - start)) tf.seek(0) ctm = CTMfile(tf.name, "r") pts, polys, norms = ctm.getMesh() meshes.append((pts, polys)) return meshes
def save(self, **kwargs): self.ctm.addAttrib(self.aux, 'auxdat') self.ctm.save(**kwargs) ctm = CTMfile(self.tf.name) return ctm.getMesh(), self.tf.read()