def read_from_off(self,infilename): from string import atoi, atof offfile=open(infilename,'r') lines = offfile.readlines() s = break_line_into_string(lines[1]) no_of_points=atoi(s[0]) no_of_polys=atoi(s[1]) for i in range(2,no_of_points+2): s = break_line_into_string(lines[i]) x = [atof (f) for f in s] self.coords.append (x) counter=0 for i in range(no_of_points+2,no_of_points+no_of_polys+2): label=None s = break_line_into_string(lines[i]) poly=[] poly.append(label) for j in range(1,len(s)): poly.append(atoi(s[j])) self.polys.append(poly) counter=counter+1 offfile.close()
def read_from_off(self, infilename): from string import atoi, atof offfile = open(infilename, 'r') lines = offfile.readlines() s = break_line_into_string(lines[1]) no_of_points = atoi(s[0]) no_of_polys = atoi(s[1]) for i in range(2, no_of_points + 2): s = break_line_into_string(lines[i]) x = [atof(f) for f in s] self.coords.append(x) counter = 0 for i in range(no_of_points + 2, no_of_points + no_of_polys + 2): label = None s = break_line_into_string(lines[i]) poly = [] poly.append(label) for j in range(1, len(s)): poly.append(atoi(s[j])) self.polys.append(poly) counter = counter + 1 offfile.close()
def read_xyz_with_comment(infilename): fp = open(infilename) #numpoints = fp.readline () size = float(fp.readline()) comment = fp.readline() label = 0 ret = [] for l in fp.readlines(): bl = break_line_into_string(l) x = float(bl[1]) y = float(bl[2]) R = 0. ret.append([label, x, y, R]) label += 1 fp.close() return (ret, comment)
def read_xyz_with_comment (infilename): fp = open (infilename) #numpoints = fp.readline () size = float(fp.readline () ) comment = fp.readline () label = 0 ret = [] for l in fp.readlines (): bl = break_line_into_string (l) x = float (bl[1]) y = float (bl[2]) R = 0. ret.append ([label, x, y, R]) label += 1 fp.close () return (ret, comment)