# Filename: tri_segment_intersections_pt.py
# Purpose: Gets the intersections of a line segment as points.
# Returns: Points.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
dgd_file = "pydemo.dgd.isis" # database to access
layer_name = "CONTOUR_150" # layer to access

with vulcan.dgd(dgd_file, "r") as dgd: # open up the database in read mode
    layer = dgd.get_layer(layer_name) # choose the correct layer
    line = layer.get_object(0) # get object in layer
    coordinates = line.get_coordinates() # Get coordinates of polyline
    line_start = coordinates[0] # get first element in list
    line_end = coordinates[-1] # get last element in list

with vulcan.triangulation(input_tri, 'r') as tri: # Open triangulation
    intersection_points = tri.segment_intersections_pt(line_start,line_end)

    # do something with points...
    print(intersection_points)