maptek.vulcan.triangulation

The following functions can be used to edit Vulcan triangulations and manipulate properties.

To download all the example scripts, click here.


class faces(object):

Generator to move through each facet of a triangulation.

# Filename: tri_class_faces.py
# Purpose: A generator to move through each facet of a triangulation.
# Returns: A list of node indices for each facet.

from maptek import vulcan

input_tri = 'cube.00t'  # input tri

with vulcan.triangulation(input_tri) as tri:  # Open triangulation in read mode
    for face in tri.faces:
        print(face)
class nodes(object):

Generator to move through each node of a triangulation.

# Filename: tri_class_nodes.py
# Purpose: A generator to move through each node of a triangulation.
# Returns: A list of X, Y, Z coordinates for each node.

from maptek import vulcan

input_tri = 'cube.00t'  # input tri

with vulcan.triangulation(input_tri) as tri:  # Open triangulation in read mode
    for node in tri.nodes:
        print(node)
add_face(triangulation self, int n1, int n2, int n3) -> int
add_node(triangulation self, double x, double y, double z) -> int

Add a facet / node to the triangulation, and returns the index number of that facet or node.

Note:  In the example below, a facet was added to an existing triangulation. Two of the nodes already existed as part of the triangulation. The third node index was created when add_node() was called, then pass to the variable called n.

# Create a new triangulation.

from pathlib import Path
from maptek import vulcan

new_tri = 'new2.00t'

triPath = Path(new_tri)
if triPath.exists():
    print (f"Triangulation file {triPath} already exists.")
    exit()   
else:
    with vulcan.triangulation(new_tri, 'w') as tri:
        tri.add_node(78042.0, 5187.0, 78.0)
        tri.add_node(78033.0, 5164.0, 87.0)
        tri.add_node(78059.0, 5165.0, 70.0)
        tri.add_face(0,1,2)
        print(f"{new_tri} was created.")
append_faces(triangulation self, n0: int) -> void
append_vertices(triangulation self, n0: int) -> void

Appends a NumPy array of facets/nodes to a triangulation.

The append_faces method passes a 2D NumPy array with each element containing the three nodes used for each facet.

The append_vertices method passes a 2D NumPy array with each element containing the X,Y,Z coordinates of each vertex (node).

# Create a new triangulation, then append another facet.

from maptek import vulcan
import numpy as np

new_tri = 'new2.00t'
with vulcan.triangulation(new_tri, 'w') as tri:
    # create coordinate arrays for each node
    n0 = [77888.0, 4739.0, 100.0]
    n1 = [78160.0, 4208.0, 100.0]
    n2 = [78177.0, 4759.0, 50.0]
    n3 = [78353.0, 4399.0, 50.0]
    n4 = [78462.0, 5039.0, 100.0]
    
    f0 = [0,1,2]
    f1 = [1,2,3]
    f2 = [0,2,4]
    
    # create NumPy arrays
    nodes = np.array([n0, n1, n2, n3])
    faces = np.array([f0, f1])
    
    tri.put_vertices(nodes)
    tri.put_faces(faces)
    print(f"{new_tri} was created.")
    
    node = np.array([n4])
    face = np.array([f2])
    
    tri.append_vertices(node)
    tri.append_faces(face)
    print(f"A new facet was appended.")
centroid(triangulation self) -> point

Gets the centroid of a triangulation.

# Find the centroid of a triangulation and returns a point

from maptek import vulcan

input_tri = 'topo.00t'  # input triangulation

with vulcan.triangulation(input_tri) as tri:  # open triangulation in read mode
    centroid = tri.centroid()  # get the centroid of the given triangulation
    print(f"{centroid}")
clean(triangulation self) -> void

Cleans a triangulation, trying to remove consistency and crossing errors.

# Cleans a triangulation by attempting to remove any consistency and crossing errors

from maptek import vulcan

input_tri = 'topo.00t' # input tri

input_tri.clean()
    
clear(triangulation self) -> void

Clears all data from the triangulation, including all points, triangles, attributes, etc. This function is used to reset a triangulation by removing all the data.

Note:  This function clears triangles so a new triangulation surface can be created. Empty triangulations will not save.

# Clear all data from the triangulation

from maptek import vulcan

input_tri = 'p6535lh_pl400_01o.00t'
    

with vulcan.tri_attributes(input_tri) as tri:  # open triangulation in read mode
    values = tri.get_values()  # get the attribute values
    print(f"Before: {values}")
clear_triangles(triangulation self) -> void

Clears all triangle data, leaving attributes intact. This function could be used to copy an existing triangulation, clear out the points, make a new shape, then update the required attributes while leaving the rest intact. For example, building numerous stope solids, you could copy a base set of attributes such as level, mining area, etc., then input each stope's new points/vertices.

Note:  This function clears triangles and all attributes so a new triangulation surface can be created. Empty triangulations will not save.

# Clear all triangle data from the triangulation, leaving attributes intact.

from maptek import vulcan

input_tri = 'stockpile.00t'

with vulcan.tri_attributes(input_tri) as tri:  # open triangulation in read mode
    values = tri.get_values()  # get the attribute values
    print(f"Before: {values}")
			    
with vulcan.triangulation(input_tri, 'w') as tri:

    tri.clear_triangles() # removes all triangle data from triangulation
    
    # Do something to make it a valid triangulation so that it can be saved.
    # In this case, a simple facet is added.
    tri.add_node(0, 0, 0)
    tri.add_node(0, 1, 0)
    tri.add_node(1, 1, 0)
    tri.add_face(0, 1, 2)
			
with vulcan.tri_attributes(input_tri) as tri:  # open triangulation in read mode
    values = tri.get_values()  # get the attribute values
    print(f"After: {values}")
close(triangulation self) -> bool

Attempts to close a solid triangulation. This is the same operation as right-clicking on a triangulation and selecting Close Solid.

# Attempt to close solids

from maptek import vulcan

input_tris = ['cube_01.00t', 'cube_02.00t','cube_03.00t','cube_04.00t']

for solid in input_tris:
    with vulcan.triangulation(solid,'w') as tri:
        # check closure state    
        if tri.is_closed():
            print(f"{solid}: 'Closed'")
        else:
            print(f"{solid}: 'Not closed, attempting to close.'")
            tri.close()
            if tri.is_closed():
                print(f"    'Closed'")
            else:
                print(f"    'Could not close solid'")
contour(triangulation self, double z) -> obj_list

Gets the contours of a triangulation at a specified Z elevation.

# Create a layer displaying contour lines at a specified Z elevation.

from maptek import vulcan

input_tri = 'topo.00t'  # input triangular
dgd_file = "pydemo.dgd.isis"  # design database we want to access
layer_name = "CONTOUR_450"  # layer to access
elevation = 450.0 # z-value or elevation to use 

with vulcan.triangulation(input_tri) as tri:  # open triangulation in read mode
    contour_list = tri.contour(elevation)
    print(contour_list)

with vulcan.dgd(dgd_file, "w") as dgd:  # open up the database in write mode
    # Make layer since we're overwriting, it'll overwrite the old.
    layer = vulcan.layer('CONTOUR_450')
    
    for obj in contour_list:
        layer.append(obj)  # add line into the layer
    dgd.save_layer(layer)
delete_face(triangulation self, facet index number, bool purge_points=False) -> void

Deletes a facet from the triangulation. (Optional) Purges points no longer used.

# Delete facet of a triangulation and purge points no longer used

from maptek import vulcan

tri = 'topo.00t' # input triangulation

face_num = 0 # index of facet to delete

with vulcan.triangulation(tri, 'w') as tri: # Open triangulation in write mode
    tri.delete_face(face_num, True)   # Delete facet and the nodes no longer used
    # to keep the nodes, change True -> False
delete_node(triangulation self, node index number) -> void

Deletes a node from the triangulation.

# Delete node of a triangular

from maptek import vulcan

tri = 'Start.00t' # input tri

node_num = 0

with vulcan.triangulation(tri, 'w') as tri: # Open tri in write mode to change tri
    tri.delete_node(node_num) # delete node
    tri.save()
extent(triangulation self) -> 2D list

Get the triangulation extent as a list. This will return a list of the coordinates for the lower left and upper right corners of the extent perimeter.

Example:  [[x.y.z], [x,y,z]]

# Get the triangulation extent as a list

from maptek import vulcan

tri = 'topo_with_pit.00t' # input tri

with vulcan.triangulation(tri) as tri: # Open tri to get information
    extent_list = tri.extent()   # Get extent list
    print(f"{extent_list}")
extent_pts(triangulation self) -> point_list

Gets the triangulation extent as points. This will return a list of point information for the lower left and upper right corners of the extent perimeter.

Example:  (point(x,y,z,w,t,name), point(x,y,z,w,t,name))

# Get the triangulation extent as a list of points

from maptek import vulcan

tri = 'topo_with_pit.00t' # input tri

with vulcan.triangulation(tri) as tri: # Open tri to get information
    extent_list = tri.extent_pts()   # Get extent list
    print(f"{extent_list}")
face_direction(triangulation self, facet index number) -> point

Gets the facet direction and returns a point as a unit vector.

# Find the direction of a given face

from maptek import vulcan

input_tri = 'topo_with_pit.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    
    # get direction of single facet
    face_dir = tri.face_direction(0) # pass facet index 0
    print(f"{face_dir}")

    # iterate through to find the directions of all facets
    face_list = []     
    for i in range(tri.n_faces()):
        face_dir = tri.face_direction(i) # pass facet index 
        print(f"Facet index: {i}  {face_dir}")
        
face_neighborhood(triangulation self, facet index number) -> int_list

Get indices of neighbouring facets.

# Find the neighborhood of a given face

from maptek import vulcan

tri = 'slope_polys.00t' # input triangulation

with vulcan.triangulation(tri) as tri: # Open triangulation in read mode
    num_face = tri.n_faces() # Returns the number of facets in the triangulation.
    print(num_face)
    
    for i in range(num_face):
        neighbour_facets = tri.face_neighborhood(i)   # find indices of neighbouring facets
        print(f"{neighbour_facets}")
get_colour_index(triangulation self) -> int

Gets the triangulation colour (index).

# Get the colour index of a triangulation

from maptek import vulcan

tri = 'slope_polys.00t' # input triangulation

with vulcan.triangulation(tri) as tri: # open triangulation in read mode
    if tri.is_rgb(): # check if triangulation uses rgb or colour index
        print(f"error: triangulation uses RGB") # error if tri is rgb
    else:
        icolour = tri.get_colour_index() # get the colour index from the triangulation
        print(f"{icolour}")
get_elevation(triangulation self, double x, double y) -> double

Gets the elevation of an x,y location.

# Get the elevation of an x,y location

from maptek import vulcan

tri = 'ore_tq1.00t' # input tri

with vulcan.triangulation(tri) as tri: # Open tri in read mode
    elevation = tri.get_elevations(78154,4665) # Get elevation
    print(f"Elevation to 2 decimal places: {elevation:.2f}")
    print(f"Elevation to 4 decimal places: {elevation:.4f}")
    print(f"Elevation original format: {elevation}")
    
get_elevations(triangulation self, double x, double y) -> double_list

Gets any intersection elevations of an x,y location.

# Get list of elevations that intersect an x,y location

from maptek import vulcan

tri = 'ore_tq1.00t' # input tri

with vulcan.triangulation(tri) as tri: # Open tri in read mode
    elevation_list = tri.get_elevations(78154,4665) # Get elevation list
    print(f"{elevation_list}")
get_face(triangulation self, facet index number) -> int_list

Gets a facet and its point indices by index.

# Get the number of faces in a triangulation and return point indices of each face

from maptek import vulcan

input_tri = 'cube_01.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    num_face = tri.n_faces() # Returns the number of facets in the triangulation.
    
    for face in range(num_face):
        facet = tri.get_face(face) # Gets a facet and its point indices.
        print(f"face: {face}  Point indices: {facet}")
get_faces(triangulation self) -> 2D array

Gets the facets of a triangulation as a NumPy array.

# Get faces of a triangulation.

from maptek import vulcan

input_tri = 'topo.00t'

with vulcan.triangulation(input_tri, 'w') as tri:
    faces = tri.get_faces()
    print(f"{faces}")
get_node(triangulation self, node index number) -> double_list

Creates list of x,y,z coordinates for the node of a triangulation.

# Creates list of x,y,z coordinates for the node of a triangulation.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    num_face = tri.n_nodes() # Returns the number of nodes in the triangulation.
    
    for node in range(num_face):
        vertex = tri.get_node(node) # Gets a nodes and its coordinates.
        print(f"node: {node}: {vertex}")
get_properties(triangulation self) -> dictionary

Create a dictionary of triangulation properties.

# Get the properties of a triangulation

from maptek import vulcan
import glob, os, sys
from itertools import groupby

tri = 'topo.00t' # input tri

with vulcan.triangulation(tri) as tri: # Open tri to get information
    properties = tri.get_properties()   # Get properties
    #print(properties)
    for key, value in properties.items():
        print(str(key), ':', str(value))
get_rgb(triangulation self) -> int_list

Gets the triangulation colour (RGB).

# Get the rgb value list of a tri

from maptek import vulcan

tri = 'sphere.00t' # input tri

with vulcan.triangulation(tri) as tri: # open tri as read
    if tri.is_rgb() : # check if the tri is rgb
        rgb = tri.get_rgb() # get rgb colour
        print(f"{rgb}")
    else:
        print("error: triangulation is not rgb") # error if the tri is not rgb
get_translucency(triangulation self) -> double

Gets the triangulation translucency.

# Get the translucency value from a tri

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri: # open triangulation as read
    translucency = tri.get_translucency() # get translucency 
    print(f"{translucency}")
get_vertices(triangulation self) -> 2D array

Gets the node (vertex) coordinates of a triangulation as a NumPy array.

# Get the vertices of a triangulation.

from maptek import vulcan

input_tri = 'topo.00t'

with vulcan.triangulation(input_tri) as tri: open triangulation in read mode
    vertices = tri.get_vertices()
    print(f"{vertices}")
is_closed(triangulation self) -> bool

Reports the triangulation closure state of a solid triangulation.

# Attempt to close a list of solids.

from maptek import vulcan

input_tris = ['cube_01.00t', 'cube_02.00t','cube_03.00t','cube_04.00t']

for solid in input_tris:
    with vulcan.triangulation(solid,'w') as tri:
        # check closure state    
        if tri.is_closed():
            print(f"{solid}: 'Closed'")
        else:
            print(f"{solid}: 'Not closed, attempting to close.'")
            tri.close()
            if tri.is_closed():
                print(f"    'Closed'")
            else:
                print(f"    'Could not close solid'")
is_consistent(triangulation self) -> bool

Reports the existence of inconsistent triangles. Returns True if passed, False if it does not pass.

# Returns true if there are inconsistent triangles

from maptek import vulcan

tri = 'topo.00t' # input tri

with vulcan.triangulation(tri, 'r') as tri: # Open tri in read mode
    consistent = tri.is_consistent()    # Check if tri has inconsistent triangles
    print(f"{consistent}")
is_crossing(triangulation self) -> bool

Runs check for crossing triangles. Returns True if triangles are crossing, False if no crossing.

# Runs check for crossing triangles. Returns True if triangles are crossing, False if no crossing triangles.

from maptek import vulcan

tri = 'topo.00t' # input triangulation 

with vulcan.triangulation(tri) as tri: # Open triangulation in read mode
    crossing = tri.is_crossing()    # Check if the tri is crossing
    print(f"{crossing}")
is_ok(triangulation self) -> bool

Reports the triangulation load status (true if new). This can be placed at the beginning of an operation to check that a triangulation was properly loaded.

# Filename: tri_is_ok.py
# Purpose: Check the load status of a triangulation.
# Returns: Bool.

from maptek import vulcan

input_tri = 'cube.00t'

with vulcan.triangulation(input_tri, 'w') as tri:
    if not tri.is_ok():
        raise ValueError("Triangulation open failed.")
        
    # continue if no error raised...
is_rgb(triangulation self) -> bool

Returns True if the triangulation color is RGB.

# Return true if the tri colour is rgb

from maptek import vulcan

tri = 'sphere.00t' # input tri

with vulcan.triangulation(tri) as tri: # open tri as read
    rgb = tri.is_rgb() # check if the tri colour is rgb
    print(f"{rgb}")
load_grid(triangulation self, grid) -> void

Loads a grid into a triangulation.

Important:  If you use an existing triangulation it will be overwritten.

# Load a grid into a triangulation

from maptek import vulcan

input_tri = 'slope_polys.00t' # name for resulting triangulation
input_grid = 'thortopo.00g'

grid = vulcan.grid(input_grid)
assert(grid.ok)

with vulcan.triangulation(input_tri, 'w') as tri:
    tri.update_grid(grid)
    tri.save()
n_faces(triangulation self) -> int

Returns the number of facets in the triangulation.

# Get the number of faces in a triangulation and return point indices of each face

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    num_face = tri.n_faces() # Returns the number of facets in the triangulation.
    print(f"{num_face}")
n_nodes(triangulation self) -> int

Returns the number of nodes in the triangulation.

# Creates list of x,y,z coordinates for the node of a triangulation.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    num_face = tri.n_nodes() # Returns the number of nodes in the triangulation.
    
    for node in range(num_face):
        vertex = tri.get_node(node) # Gets a nodes and its coordinates.
        print(f"node: {node}: {vertex}")
neighbors(triangulation self, facet index number) -> int_list

Gets the triangle neighbours. Pass the index of the facet of interest and returns a list of neighbouring facet indices.

# Get neighbors of triangle facet and return as list

from maptek import vulcan

tri = 'slope_polys.00t' # input tri

with vulcan.triangulation(tri) as tri: # open tri as read
    neighbors_list = tri.neighbors(1) # get the list of neighbors for facet 1
    print(f"{neighbors_list}")
node_neighborhood(triangulation self, node index number) -> int_list

Gets the node neighbours. Pass the index of the node of interest and returns a list of neighbouring node indices.

# Find the facets surrounding a given a given node

from maptek import vulcan

tri = 'slope_polys.00t' # input triangulation

with vulcan.triangulation(tri) as tri: # Open triangulation in read mode
    num_nodes = tri.n_nodes() # Returns the number of nodes in the triangulation.
    print(f"total nodes: {num_nodes}")
    
    for i in range(num_nodes):
        neighbour_nodes = tri.node_neighborhood(i)   # find faces surrounding a node
        print(f"node: {i}    surrounding facets: {neighbour_nodes}")
normalise(triangulation self) -> void

Normalizes the triangulation faces so that they all face the same direction (out). Generally, there is no reason to call this method since any method that needs it will call it on its own.

# Normalizes the triangulation faces so that they all face the same direction (out).
# Generally, there is no reason to call this method since any method that needs it will
# call it on its own.

from maptek import vulcan

input_tri = 'new2.00t'  # input triangulation

with vulcan.triangulation(input_tri, "w") as tri:  # open triangulation in write mode to change the tri
    tri.normalise()  # fix facet directions
point_inside(triangulation self, double x, double y, double z) -> bool

Checks if a point is inside a closed triangulation.

# Check if an x/y/z coordinate is inside of a closed triangulation

from maptek import vulcan
import csv

input_tri = 'orebody.00t'

# using samples exported from composite database
samples_csv = '5ft_cmp_samples.csv'

# iterate through csv to get x,y,z points
with open(samples_csv) as csvfile:
    reader = csv.reader(csvfile)
    line_count = 0
    points = []
    for line in reader:
        if line_count > 0:
            x = float(line[2]) # column holding MIDX
            y = float(line[3]) # column holding MIDY
            z = float(line[4]) # column holding MIDZ
            points.append([x, y, z])
        line_count += 1
  
with vulcan.triangulation(input_tri) as tri:  # open triangulation in read mode
    for point in points:
        point_inside = tri.point_inside(*point)  # check if the x/y/z coordinate is inside of the triangulation
        print(f"point: {point}    {point_inside}")

put_faces(triangulation self, facet index number) -> void put_vertices(triangulation self, int n0) -> void

put_faces() stores a NumPy array of facets in a triangulation.

put_vertices() stores a NumPy array of nodes in a triangulation.

Important

There are two functions that can be used to add facets and vertices to a triangulation:

  • append_faces()/ append_vertices() - These will add facets and vertices to a triangulation without altering the existing facets or vertices.

  • put_faces()/ put_vertices() - These will replace the existing faces and vertices of a triangulation, overwriting all existing facets vertices.

# Create a new triangulation, then append another facet.

from maptek import vulcan
import numpy as np

new_tri = 'new2.00t'
with vulcan.triangulation(new_tri, 'w') as tri:
    # create coordinate arrays for each node
    n0 = [77888.0, 4739.0, 100.0]
    n1 = [78160.0, 4208.0, 100.0]
    n2 = [78177.0, 4759.0, 50.0]
    n3 = [78353.0, 4399.0, 50.0]
    n4 = [78462.0, 5039.0, 100.0]
    
    f0 = [0,1,2]
    f1 = [1,2,3]
    f2 = [0,2,4]
    
    # create NumPy arrays
    nodes = np.array([n0, n1, n2, n3])
    faces = np.array([f0, f1])
    
    tri.put_vertices(nodes)
    tri.put_faces(faces)
    print(f"{new_tri} was created.")
    
    # append additional node and facet
    node = np.array([n4])
    face = np.array([f2])
    
    tri.append_vertices(node)
    tri.append_faces(face)
    print(f"A new facet was appended.")
save(triangulation self, std::string const name="") -> bool

Saves the triangulation.

Note

This function can be used with or without any arguments.

If used without any arguments (tri.save()), then it will work as a normal Save command, saving the existing triangulation.

If used with arguments (tri.save("new_shape.00t")), then it will works as a Save As command, saving a copy of the triangulation under a new name.

Note:  The save() function only needs to be called if the WITH statement is not being used. WITH will save the results automatically when the script exits the function.

# Change triangulation colour, then save

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# either RGB (list) or colour index (int)
colour_index = 10
colour_rgb = [10,100,10] 

tri = vulcan.triangulation(input_tri,'w')
tri.set_colour(colour_index)
tri.save("new_shape.00t")
scale(triangulation self, point xyz_scale, point xyz_reference) -> bool

Scales a triangulation by a factor in the x/y/z directions based on a reference point.

# Scale a triangulation from a reference point by an x/y/z factor

#from pathlib import Path
from maptek import vulcan

input_tri = 'topo.00t'  # input triangulation

scale_factor = [2.0, 1.5, 1.0] # x,y,z scale factor

#scale_point = vulcan.point(*scale_factor)

with vulcan.triangulation(input_tri, 'w') as tri:  # open triangulation in write mode
    reference_point = tri.centroid()  # reference point
    tri.scale(scale_factor, reference_point)
segment_intersections(triangulation self, double x0, double y0, double z0, double x1, double y1, double z1) -> double_double_list

Gets the intersections of a line segment as a list.

Example of return results: [[78085.919, 3957.883, 150.0]]

# Get the intersections of a line segment as points

from maptek import vulcan

tri = 'topo.00t' # input triangulation

x0, y0, z0 = 77321.7, 4590.012, 437.911  # set the coordinates of the start of the line
x1, y1, z1 = 78870.711, 4455.515, 482.500  # set the coordinates of the end of the line

with vulcan.triangulation(tri) as tri:  # Open tri to get information
    # get the intersections of a line segment
    segment_intersections = tri.segment_intersections(x0, y0, z0, x1, y1, z1)
    print(f"{segment_intersections}")

segment_intersections_pt(triangulation self, point a, point b) -> point_list

Gets the intersections of a line segment as points.

Example of return result:(point(78085.919,3957.883,150.0,0.0,0,''))

# Get locations a line intersects a triangulation and return a series points.
# Example output: point(x, y, z, w, t, name)

from maptek import vulcan

tri = 'topo.00t' # input triangulation

point_1 = [77321.7, 4590.012, 437.911] #  beginning of line
point_2 = [78870.711, 4455.515, 482.500] #  end of line

with vulcan.triangulation(tri) as tri: # Open triangulation
    # Get the intersections of a line segment
    intersection_points = tri.segment_intersections_pt(point_1,point_2) 
    print(f"{intersection_points}")
set_colour(val) -> void

Sets the colour of the triangulation to RGB(list) or colour index(int).

# Change triangulation colour, then save

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# either RGB (list) or colour index (int)
colour_index = 100 # colour index number
colour_rgb = [10, 100, 10] # rgb values

# using colour index integer			
with vulcan.triangulation(input_tri, 'w') as tri: # open triangulation in write mode
    tri.set_colour(colour_index)

# or using rgb list						
with vulcan.triangulation(input_tri, 'w') as tri: # open triangulation in write mode
    tri.set_colour(colour_rgb)
set_colour_index(triangulation self, int colour) -> void

Sets the triangulation colour (index).

# Change the colour of a triangulation using a given colour index

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
colour_index = 10 # colour index number, range 0 <= 256

tri = vulcan.triangulation(input_tri,'w')
tri.set_colour(colour_index)
tri.save()

set_face(triangulation self, facet index, node 1, node 2, node 3) -> void

Add a facet using existing nodes as reference points.

# Add a facet using existing nodes as reference points.

from maptek import vulcan

new_tri = 'slope_polys.00t'

with vulcan.triangulation(new_tri, 'w') as tri:
    tri.set_face(18,0,1,2)

 
set_node(triangulation self, int k, double x, double y, double z) -> void

Sets a triangulation vertex by coordinates.

# Add a node.

from maptek import vulcan

new_tri = 'slope_polys.00t'

with vulcan.triangulation(new_tri, 'w') as tri:
    tri.set_node(18,77731.69, 4370.95, 100.0)
set_properties(triangulation self, dictionary of props)

Note:  There are many properties that can be set by using this method. When writing a script, remember that some properties cannot be used with others. For example, you cannot set a triangulation to appear as a solid shade and a wireframe at the same time. It's either one or the other.

set_properties() - Axis colouring
# Set the properties of a triangulation to colour by range

from maptek import vulcan

tri = 'topo.00t' # input triangulation

# property list
# USE_CRANGE      = use colour range: True = 1; False = 0
# MIN_CRANGE      = min colour index: int
# MAX_CRANGE      = max colour index: int
# VARY_CRANGE     = axis to colour by: X/Y/Z
# EQUALISE_RANGE  = True = 1; False = 0

with vulcan.triangulation(tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 1
    props["WIREFRAME"] = 0
    props['USE_CRANGE'] = 1
    props['MIN_CRANGE'] = 0
    props['MAX_CRANGE'] = 100
    props['VARY_CRANGE'] = 'Z'
    props["EQUALISE_RANGE"] = 1
    tri.set_properties(props)
set_properties() - Solid shading verses wireframe
# Set the shading properties of a triangulation

from maptek import vulcan

tri = 'topo.00t' # input triangulation

# property list
# With calling SHADED or WIREFRAME, only one can be active at the same time.
# SHADED:     True = 1; False = 0
# WIREFRAME:  True = 1; False = 0
# LINES:      Shading with or without lines. True = 1; False = 0

with vulcan.triangulation(tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    
    props['SHADED'] = 0 
    props['WIREFRAME'] = 1
    props['LINES'] = 0    
    
    tri.set_properties(props)


'''
case Shading::POINTS:
POINTS = True = 1; False = 0

case Shading::SMOOTH:
USE_SMOOTH = True = 1; False = 0
SMOOTH = angle for smooth shading 0 - 180

LINES = Shading with or without lines True = 1; False = 0

CONTOUR = double val, labeled as contouring level...
USE_CONOUR = True = 1; False = 0

PATTERN = pattern to use, pattern index from Vulcan (0 based)
FILL = Fill of wireframe True = 1; False = 0
'''
set_properties() - Setting colour index
# Set the colour properties of a triangulation

from maptek import vulcan

tri = 'topo.00t' # input triangulation

# property list
# USE_RGB:      True = 1; False = 0
# USE_ICOLOUR:  True = 1; False = 0
# ICOLOUR:      range: 0-255

with vulcan.triangulation(tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    
    props["USE_RGB"] = 0
    props["USE_ICOLOUR"] = 1
    props["ICOLOUR"] = 123
    
    # setting a custom colour using RGB is currently unsupported
    
    tri.set_properties(props)
set_properties() - Add contour lines
# Add contour lines to a triangulation

from maptek import vulcan

tri = 'topo.00t' # input triangulation

# property list
# SHADED:       True = 1; False = 0
# WIREFRAME:    True = 1; False = 0
# USE_CONTOUR:  True = 1; False = 0
# CONTOUR:      distance interval
# PATTERN:      1 = solid fill with contour lines; 0 = just contour lines

with vulcan.triangulation(tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 0
    props["WIREFRAME"] = 1
    props["USE_CONTOUR"] = 1
    props["CONTOUR"] = 10
    props["PATTERN"] = 1
    
    tri.set_properties(props)
set_properties() - Set the fill pattern
# Set the shading pattern of a triangulation

from maptek import vulcan

tri = 'topo.00t' # input triangulation

# property list
# SHADED:     True = 1; False = 0
# WIREFRAME:  True = 1; False = 0
# PATTERN:    pattern index, range: 0 - 47
# FILL:       True = 1; False = 0

with vulcan.triangulation(tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    
    props["SHADED"] = 0
    props["WIREFRAME"] = 1
    props["PATTERN"] = 10
    props["FILL"] = 1
    
    tri.set_properties(props)
set_properties() - Set smoothing for a triangulation
# Filename: tri_set_properties_smooth.py
# Purpose: Set smoothing for a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# property list
# SHADED: True = 1; False = 0
# WIREFRAME: True = 1; False = 0
# USE_SMOOTH: True = 1; False = 0   
# SMOOTH: Range = 1-180   

with vulcan.triangulation(input_tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 1
    props["WIREFRAME"] = 0
    props["USE_SMOOTH"] = 1
    props["SMOOTH"] = 180
    tri.set_properties(props)
set_properties() - Set translucency for a triangulation
# Filename: tri_set_properties_translucency.py
# Purpose: Set translucency for a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# property list
# SHADED: True = 1; False = 0
# WIREFRAME: True = 1; False = 0
# USE_TRANSLUCENT: True = 1; False = 0   
# TRANSLUCENT: range = 0.0 - 100.0   

with vulcan.triangulation(input_tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 1
    props["WIREFRAME"] = 0
    props["USE_TRANSLUCENT"] = 1
    props["TRANSLUCENT"] = 80.0
    tri.set_properties(props)
set_rgb(triangulation self, int_list const & rgb) -> Void
# Set the RGB colour value of a triangulation

from maptek import vulcan

tri = 'topo.00t' # input triangulation
rgb_list = [18,186,24] # RGB values

with vulcan.triangulation(tri, "w") as tri: # open triangulation in write mode
    tri.set_rgb(rgb_list) # set RGB values
set_translucency(triangulation self, double const value) -> Void
# Set the translucency value of a triangulation

from maptek import vulcan

tri = 'topo.00t' # input triangulation
translucency_value = 80 # percent translucency 

with vulcan.triangulation(tri,"w") as tri: # open triangulation in write mode
    tri.set_translucency(translucency_value) # set translucency
shortest_path(triangulation self, point start, point end) -> VulcanObj

Creates a polyline object denoting the shortest path between two points.

# Find the shortest path between two points.

from maptek import vulcan, vulcan_gui

input_tri = 'topo.00t' # input triangulation
pt1 = vulcan.point(77495.53, 4410.50, 173.37, 0.0, 0, '')
pt2 = vulcan.point(78399.41, 4539.64, 188.24, 0.0, 0, '')

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    path = tri.shortest_path(pt1, pt2)
    
    vulcan_gui.temp_object(path) # display the line in Envisage
solid_from_polygon(triangulation self, double width, int poly_position) -> Void

Creates a solid from points of a polygon, projecting them vertically.

# Make a triangulation into a solid

from maptek import vulcan

dgd_file = "pydemo.dgd.isis"  # design database we want to access
layer_name = "POINTS"  # layer we want to use


# open layer containing points and read coordinates of each point
with vulcan.dgd(dgd_file, "r") as dgd:
    if dgd.is_layer(layer_name):
        layer = dgd.get_layer(layer_name)
        print('Layer exists')
    else:
        print("Layer does not exist")
        exit()
    
    for pt in layer:
        points = pt.get_coordinates()


bench_solid = 'bench.00t'
bench_height = 30
poly_position = 1
# 0 = polygon is top of the solid to be created
# 1 = polygon is middle of the solid to be created
# 2 = polygon is bottom of the solid to be created
        
with vulcan.triangulation(bench_solid, 'w') as tri:
    [tri.add_node(*pt) for pt in points]
    tri.solid_from_polygon( bench_height, poly_position )
surface_area(triangulation self) -> double

Get the surface area of a triangulation.

# Get the surface area of a triangulation

from maptek import vulcan

input_tri = 'bench.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    area = tri.surface_area() # Get surface area
    print(f"Surface area of {input_tri}: {area}")
translate(triangulation self, point translation) -> bool

Translate a triangulation by an x/y/z shift.

# Translate the triangulation by an x/y/z shift

from maptek import vulcan

input_tri = 'bench.00t'  # input triangular

# set how much you want to move the triangulation
x_shift = 10.0
y_shift = 5.0
z_shift = -10.0

shift = vulcan.point(x_shift, y_shift, z_shift)  # point containing the x, y, z shift values

with vulcan.triangulation(input_tri, 'w') as tri:  # open triangulation in write mode to change tri
    tri.translate(shift)
update_grid(triangulation self, VGD_grid_t grid) -> void

Updates a grid with the current triangulation.

# Update a grid from a triangulation.

from maptek import vulcan

input_tri = 'slope_polys.00t' # name for resulting triangulation
input_grid = 'thortopo.00g'

grid = vulcan.grid(input_grid)
assert(grid.ok)

with vulcan.triangulation(input_tri, 'w') as tri:
    tri.update_grid(grid)
    grid.save()
volume(triangulation self) -> double

Returns the volume of a closed triangulation.

# Get the volume of a closed solid.

from maptek import vulcan

input_solid = ['stockpile_01.00t', 'stockpile_02.00t','stockpile_03.00t','stockpile_04.00t']

for solid in input_solid:
    with vulcan.triangulation(solid) as tri:
        vol = tri.volume()
        print(f"Volume of {solid} is {vol}")