PRO triangles_merge, tr1, tr2, ntr1 ; Description: This module merges the triangles specified in the array "tr1" with the triangles ; specified in the array "tr2". The final triangle list is returned via the array ; "tr1", and contains only unique triangles that have no repeated points as vertices. ; The final triangle list also has the vertex indices sorted in ascending order for ; each triangle. The number of triangles in the final triangle list is returned via ; "ntr1". ; By deliberately setting the second triangle list "tr2" to "0" (or even an empty ; variable), then this module will simply return "tr1" with only unique triangles ; that have no repeated points as vertices, and that have the vertex indices sorted ; in ascending order for each triangle. ; ; Input Parameters: ; ; tr1 - INTEGER/LONG ARRAY - The first triangle list of Nt1 triangles stored as a 3 by Nt1 array ; of numbers where each triplet of numbers represents the indices of ; the points corresponding to the three vertices of each triangle. ; tr2 - INTEGER/LONG ARRAY - The second triangle list of Nt2 triangles stored as a 3 by Nt2 array ; of numbers where each triplet of numbers represents the indices of ; the points corresponding to the three vertices of each triangle. ; ; Output Parameters: ; ; tr1 - LONG ARRAY - The final list of "ntr1" unique triangles stored as a 3 by "ntr1" array of ; LONGS where each triplet of numbers represents the indices of the points ; corresponding to the three vertices of each triangle. This list of triangles ; has no triangles with repeated points as vertices, and the vertex indices ; for each triangle are sorted in ascending order. ; ntr1 - LONG - The number of triangles stored in the final list of triangles "tr1". ; ; Author: Dan Bramich (dmb@ing.iac.es) ; ; History: ; ; 03/08/2008 - Module created (dmb) ;Test the dimensions of the triangle lists, and return the relevant output if both input triangle ;lists are either empty or not of the correct number type or not of the correct dimensions ;If the first triangle list is either empty or not of the correct number type or not of the correct dimensions, then replace the ;first triangle list with the second triangle list ;If both triangle lists are non-empty and of the correct dimensions, then append the second ;triangle list to the first triangle list ;Remove triangles from the output triangle list that have repeated points as vertices ;For each triangle in the output triangle list, sort the vertex indices in to ascending order, ;and calculate a unique identifying quantity ;Reduce the output triangle list to a set of unique triangles