import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import open3d as o3d densifyN = 50000 output_path = 'F:/Surface reconstruction pre' shape_file = 'F:/Surface reconstruction pre/cylinder.obj' V,E,F_ = util.parseObj(shape_file) F = util.removeWeirdDuplicate(F_) Vorig,Eorig,Forig = V.copy(),E.copy(),F.copy() # sort by length (maintain a priority queue) Elist = list(range(len(E))) Elist.sort(key=lambda i:util.edgeLength(V,E,i),reverse=True) # create edge-to-triangle and triangle-to-edge lists EtoF = [[] for j in range(len(E))] FtoE = [[] for j in range(len(F))] for f in range(len(F)): v = F[f] util.pushEtoFandFtoE(EtoF,FtoE,E,f,v[0],v[1]) util.pushEtoFandFtoE(EtoF,FtoE,E,f,v[0],v[2]) util.pushEtoFandFtoE(EtoF,FtoE,E,f,v[1],v[2]) V,E,F = list(V),list(E),list(F) # repeat densification for z in range(densifyN): util.densify(V,E,F,EtoF,FtoE,Elist)
output_path = "output/{0}".format(CATEGORY) if not os.path.isdir(output_path): os.makedirs(output_path) for m in models: timeStart = time.time() shape_file = "{2}/{0}/{1}/models/model_normalized.obj".format(CATEGORY,m,SHAPENETPATH) V,E,F = util.parseObj(shape_file) F = util.removeWeirdDuplicate(F) Vorig,Eorig,Forig = V.copy(),E.copy(),F.copy() # sort by length (maintain a priority queue) Elist = list(range(len(E))) Elist.sort(key=lambda i:util.edgeLength(V,E,i),reverse=True) # create edge-to-triangle and triangle-to-edge lists EtoF = [[] for j in range(len(E))] FtoE = [[] for j in range(len(F))] for f in range(len(F)): v = F[f] util.pushEtoFandFtoE(EtoF,FtoE,E,f,v[0],v[1]) util.pushEtoFandFtoE(EtoF,FtoE,E,f,v[0],v[2]) util.pushEtoFandFtoE(EtoF,FtoE,E,f,v[1],v[2]) V,E,F = list(V),list(E),list(F) # repeat densification for z in range(densifyN): util.densify(V,E,F,EtoF,FtoE,Elist)