Пример #1
0
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)
    
densifyV = np.array(V[-densifyN:])

x=densifyV[:,0]
y=densifyV[:,1]
z=densifyV[:,2]

fig = plt.figure()
	
	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)

	densifyV = np.array(V[-densifyN:])

	scipy.io.savemat("{0}/{1}.mat".format(output_path,m),{
		"V": Vorig,
		"E": Eorig,
		"F": Forig,
		"Vd": densifyV