TIN.sml

  Download

More scripts: TIN

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# TIN.SML
# Sample script for tutorial "Writing Scripts with SML".
clear();
PopupMessage("Select /LITEDATA/SURFMODL/SURFACE.RVC/ELEV_PTS");
# Get input vector with elevation points and output TIN object.
vector VecPts;
tin TINout;
GetInputVector(VecPts);
GetOutputTIN(TINout,"TINToolkit");	# initialize TIN for editing.
# Read number of vector points and get
# vector georeference information.
numeric numpts;
numpts = NumVectorPoints(VecPts);
class Georef georefV;
georefV = GetLastUsedGeorefObject(VecPts);
# Create implied georeference for TIN
class Georef georefT;
CreateImpliedGeoref(TINout,georefV.Projection);
georefT = GetLastUsedGeorefObject(TINout);
# Create arrays to hold coordinates of vector points.
array numeric xpoints [numpts];
array numeric ypoints [numpts];
array numeric zpoints [numpts];
# Loop to read point coordinates and store in arrays.
numeric i, x, y, z;
numeric mapX, mapY;
for i = 1 to numpts {
	x = VecPts.point[i].Internal.x;
	y = VecPts.point[i].Internal.y;
	z = VecPts.point[i].Internal.z;
	# Convert from object to map coordinates;
	ObjectToMap(VecPts,x,y,georefV,mapX,mapY);
	xpoints[i] = mapX;
	ypoints[i] = mapY;
	zpoints[i] = z;
}
# Create TIN object from coordinate arrays.
numeric zscale, zoffset, xytolerance;
zscale = 1;
zoffset = 0;
xytolerance = 1; # minimum allowed distance between nodes.
TINCreateFromNodes(TINout,numpts,xpoints,ypoints,zpoints,
			zscale,zoffset,xytolerance);
# Get number of TIN hulls, edges, and triangles and print to console.
numeric numhulls, numedges, numtri;
numhulls = TINNumberHulls(TINout);
numedges = TINNumberEdges(TINout);
numtri = TINNumberTriangles(TINout);
print("Number of TIN hulls = ", numhulls);
print("Number of TIN edges = ", numedges);
print("Number of TIN triangles = ", numtri);
CloseTIN(TINout);
# End of script.