# Create a new triangulation from point list.

from pathlib import Path
from maptek import vulcan

new_tri = 'newtopo.00t'
triPath = Path(new_tri)
		 
with open("points.csv", "r") as f1:
	with open("xyz.txt", "w") as f2:
		for line in f1:
			coord = line.split(",")
            

			if triPath.exists():
				print (f"Triangulation file {triPath} already exists.")
				exit()	 
			else:
				with vulcan.triangulation(new_tri, 'w') as tri:
					for i in range(len(line)): # range(start, stop, step)
						node1 = float(coord[i].strip())
						node2 = float(coord[i+1].strip())
						node3 = float(coord[i+2].strip())
						
						tri.add_node(node1, node2, node3)
						#tri.add_node(node2)
						#tri.add_node(node3)
						#tri.add_face(i,i+1,i+2)

#print(f"{new_tri} was created.")
