home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


TIN.sml


# 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.



Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11