Vr Mapping

ON-LINE REFERENCE DOCUMENTATION

CARDINAL SYSTEMS, LLC

www.cardinalsystems.net

DTM Class Reference (PyVrDtm)

VrOne/Python DTM routines More...

Members

PyVrDtm (UseVrDtm,CgNum)
Reset ()
ResetMinMax (MinX, MinY, MinZ, MaxX, MaxY, MaxZ)
AddPoint (x, y, z)
SetAreaToModel (AreaToModel)
SetVerbose (Verbose)
SetWsToConsid (WsToConsid)
Process ()
ProcessWs ()
GetElev (x, y)
SetFreeFlag (FreeFlag)
IsDtmValid ()
SetPointsLayer (Layer)
SetBreaksLayer (Layer)
GetMinZ ()
GetMaxZ ()
GetBoundary ()
IsPointInside (x, y)
GetContour (Elev)
GetFirstContour ()
GetNextContour ()
GetFirstTriangle ()
GetNextTriangle ()
FindTriangles (x, y)
FindTrianglesFromEdge (ex1, ey1, ex2, ey2)
GetTriangle (TriNum)
GetTriangleInfo (TriNum)

Description

The PythonVrOne DTM Class contains routines for creating and working with DTM models. This includes DTM processing, contour generation, and elevation querying.

 

IMPORTANT USAGE NOTE: There are two main ways to use the DTM class:

1.Getting a reference to the main VrOne DTM object. This is done by creating a PyVrDtm object with a parameter of "True" and an optional surface number. This method allows the DTM data to be shared with the current VrOne session. Any DTMs created with this method will be active in VrOne for things such as cursor tracking.
2.Creating a new DTM object separate from the VrOne DTM object. This is done by creating a PyVrDtm object with a parameter of "False". This allows a DTM to be created that is completely separate from the active DTM in VrOne. VrOne has no knowledge of DTMs created using this method. Cursor tracking will not follow a DTM created with this method.

 

See the dtmtest.py and testslope.py scripts for sample code that use the PyVrDtm class.

 


Member Function Documentation

PyVrDtm (UseVrDtm, CgNum)

Returns a DTM object. This object is either a newly created DTM object or a reference to the VrOne DTM object depending on what value is passed in for UseVrDtm.

UseVrDtm

True = Return reference to existing VrOne DTM object. False = Return new DTM object.

CgNum

Optional. Surface number to use. 0-7, or –1 to use active surface.

returns

(Object)

 

Object

PyVrDtm oject.

Reset ()

Resets DTM parameters so a new Process command can be called. Always call this command or ResetMinMax before calling Process. This method does not need to be called if using the ProcessWs method.

ResetMinMax (MinX, MinY, MinZ, MaxX, MaxY, MaxZ)

Resets DTM parameters so points can be manually added to the DTM. This should always be called before points are added using AddPoint. All points added using AddPoint must fall within these bounds. If you are not adding points manually with AddPoint,  Reset can be used instead.

MinX

Min x of box bounding extents of points to be added to DTM.

MinY

Min y of box bounding extents of points to be added to DTM.

MinZ

Min z of box bounding extents of points to be added to DTM.

MaxX

Max x of box bounding extents of points to be added to DTM.

MaxY

Max y of box bounding extents of points to be added to DTM.

MaxZ

Max z of box bounding extents of points to be added to DTM.

AddPoint (x, y, z)

Manually adds a point to the DTM model. ResetMinMax() must be called before adding the first point. The Process method must be used after manually adding points or the points will be ignored.

x

X coordinate of point to add.

y

Y coordinate of point to add.

z

Z coordinate of point to add.

SetAreaToModel (AreaToModel)

Sets workspace area to model.

AreaToModel

0=Entire workspace, 1=Window area only

SetVerbose (Verbose)

Sets verbose mode.

Verbose

0=Verbose mode off, 1=Verbose mode on

SetWsToConsid (WsToConsid)

Sets workspace to consider.

WsToConsid

0=All Workspaces, 1= Current Workspace

Process ()

Processes the DTM TIN only. Does not place triangles or contours into the current VrOne file. This processes points and breaklines according to the current DTM parameters. To only process manually added points, call SetPointsLayer and SetBreaksLayer with empty strings before beginning processing.

ProcessWs ()

Processes the complete DTM. Ignores any manually added points and places triangles, contours, boundary line, and depressions into the current VrOne file according to the current DTM parameters. This command is equivalent to using the RunDtm command in VrOne.

GetElev (x, y)

Returns elevation of point within the DTM.

x

Floating point X coordinate of point where elevation should be computed.

y

Floating point Y coordinate of point where elevation should be computed.

returns

(z)

 

z

Return elevation.

SetFreeFlag (FreeFlag)

Determines whether DTM remains in memory after processing. This must be "True" for cursor tracking. Default value ("True" or "False") depends on currently loaded DTM parameters.

FreeFlag

True = Keep DTM in memory. False = Remove DTM from memory.

IsDtmValid ()

Returns status of DTM.

returns

(ret)

 

ret

True = DTM is valid, False = DTM is not valid.

SetPointsLayer (Layer)

Sets layer for DTM Points.

Layer

String value representing layers to use when searching for DTM points. This may be a number line.

SetBreaksLayer (Layer)

Sets layer for DTM Breaks.

Layer

String value representing layers to use when searching for DTM breaklines. This may be a number line.

GetMinZ ()

Returns minimum Z value of DTM.

returns

(ret)

 

ret

Floating point value of minimum Z coordinate in DTM.

GetMaxZ ()

Returns maximum Z value of DTM.

returns

(ret)

 

ret

Floating point value of maximum Z coordinate in DTM.

GetBoundary ()

Returns points along DTM boundary.

returns

(ret)

 

ret

List of tuples containing points that make up DTM boundary. Each tuple contains X,Y,Z floating point coordinate.

 

Example

Bndry = Cg.GetBoundary()

for coord in Bndry:

    x, y, z = coord

IsPointInside (x, y)

Returns status of point in relation to DTM boundary.

x

X coordinate of point to check.

y

Y coordinate of point to check.

returns

(ret)

 

ret

True = Point is inside DTM boundary. False = Point is outside DTM boundary.

GetContour (Elev)

Returns points for all contours at a given elevation.

Elev

Elevation of contour to return.

returns

(ret)

 

ret

List of tuples containing points that make up all contours at this elevation. Each tuple contains "code,x,y,z", where x,y,z is the floating point coordinate of the point location and code is an integer (0 when a new contour should be started).

 

Example

def SaveContour(Contour, Layer):

    Line = PyVrLine ()

    Line.SetLayer (Layer)

 

    # Go through contour points    

    for coord in Contour:

 

         code, x, y, z = coord

           

         # New contour starting if code is 0

if (code == 0 and Line.GetNumXyz() > 0):

    Line.Rec (Ws.Aws())

    Line.Reset()

 

    Line.AddPoint (x, y, z)

 

# Make sure last contour is saved

if (Line.GetNumXyz() > 0):

    Line.Rec (Ws.Aws())

    Line.Reset()

 

ContElev = 125.0

Contour = Cg.GetContour (ContElev)

    if (len(Contour) > 1):

    SaveContour (Contour, 2)

GetFirstContour ()

Used with GetNextContour to walk through all contours at a specified interval.

returns

(Stat, Elev, Contours)

 

Stat

0=More contours to follow, -1=No more contours available

 

Elev

Elevation of current contour.

 

Contours

List of tuples containing points that make up all contours at this elevation. Each tuple contains "code,x,y,z", where x,y,z is the floating point coordinate of the point location and code is an integer (0 when a new contour should be started).

 

Example

Stat, Elev, Contour = Cg.GetFirstContour (2) # Get contours with 2’ interval

SaveContour (Contour, int(Elev))

while (Stat == 0):

    Stat, Elev, Contour = Cg.GetNextContour ()

    SaveContour (Contour, int(Elev))

GetNextContour ()

Used with GetFirstContour to walk through all contours at a specified interval.

returns

(Stat, Elev, Contours)

 

Stat

0=More contours to follow, -1=No more contours available

 

Elev

Elevation of current contour.

 

Contours

List of tuples containing points that make up all contours at this elevation. Each tuple contains "code,x,y,z", where x,y,z is the floating point coordinate of the point location and code is an integer (0 when a new contour should be started).

 

Example

# Walk through all triangles

(Tri, x1, y1, z1, x2, y2, z2, x3, y3, z3) = Dtm.GetFirstTriangle ()

while (Tri):

          (Tri, x1, y1, z1, x2, y2, z2, x3, y3, z3) = Dtm.GetNextTriangle ()

GetFirstTriangle ()

Used with GetNextTriangle to walk through all triangles.

returns

(TriNum, x1, y1, z1, x2, y2, z2, x3, y3, z3)

 

TriNum

Triangle number. If 0, no triangle was found.

 

x1

X Coordinate location of triangle vertex 1.

 

y1

Y Coordinate location of triangle vertex 1.

 

z1

Z Coordinate location of triangle vertex 1.

 

x2

X Coordinate location of triangle vertex 2.

 

y2

Y Coordinate location of triangle vertex 2.

 

z2

Z Coordinate location of triangle vertex 2.

 

x3

X Coordinate location of triangle vertex 3.

 

y3

Y Coordinate location of triangle vertex 3.

 

z3

Z Coordinate location of triangle vertex 3.

GetNextTriangle ()

Used with GetFirstTriangle to walk through all triangles.

returns

(TriNum, x1, y1, z1, x2, y2, z2, x3, y3, z3)

 

TriNum

Triangle number. If 0, no triangle was found.

 

x1

X Coordinate location of triangle vertex 1.

 

y1

Y Coordinate location of triangle vertex 1.

 

z1

Z Coordinate location of triangle vertex 1.

 

x2

X Coordinate location of triangle vertex 2.

 

y2

Y Coordinate location of triangle vertex 2.

 

z2

Z Coordinate location of triangle vertex 2.

 

x3

X Coordinate location of triangle vertex 3.

 

y3

Y Coordinate location of triangle vertex 3.

 

z3

Z Coordinate location of triangle vertex 3.

FindTriangles (x, y)

Finds triangles that share point x,y. If x,y is inside a triangle, only 1 triangle is returned. If x,y is on edge, 1 (if boundary triangle) or 2 triangles will be returned. If x,y is on a vertex, multiple triangles may be returned.

x

X coordinate of search point.

y

Y coordinate of search point

returns

(Triangles)

 

Triangles

List of triangles found.

 

Example

(Triangles) = Dtm.FindTriangles (x, y)

 

print "Found %d triangles." % len(Triangles)

 

for Triangle in Triangles:

 

    (Slope, Aspect, Cx, Cy) = Dtm.GetTriangleInfo (Triangle)

FindTrianglesFromEdge (ex1, ey1, ex2, ey2)

Finds triangles that share the edge between points ex1, ey1 and ex2, ey2. Returns 1 triangle if edge is on boundary or 2 triangles if edge is inside TIN.

ex1

X coordinate of point 1.

ey1

Y coordinate of point 1.

ex2

X coordinate of point 2.

ey2

Y coordinate of point 2.

returns

(Triangles)

 

Triangles

List of triangles found.

 

Example

(Triangles) = Dtm.FindTrianglesFromEdge (x1, y1, x2, y2)

           

print "Found %d triangles." % len(Triangles)

 

for Triangle in Triangles:

 

    (Slope, Aspect, Cx, Cy) = Dtm.GetTriangleInfo (Triangle)

GetTriangle (TriNum)

Gets vertex coordinates for a single triangle.

TriNum

Triangle number.

returns

(x1, y1, z1, x2, y2, z2, x3, y3, z3)

 

x1

X coordinate of vertex 1.

 

y1

Y coordinate of vertex 1.

 

z1

Z coordinate of vertex 1.

 

x2

X coordinate of vertex 2.

 

y2

Y coordinate of vertex 2.

 

z2

Z coordinate of vertex 2.

 

x3

X coordinate of vertex 3.

 

y3

Y coordinate of vertex 3.

 

z3

Z coordinate of vertex 3.

GetTriangleInfo (TriNum)

Gets additional triangle information.

TriNum

Triangle number.

returns

(Slope, Aspect, cx, cy)

 

Slope

Slope of triangle (0.0 to 1.0)

 

Aspect

Direction of slope in radians where 0.0=north.

 

cx

Barycenter x coordinate.

 

cy

Barycenter y coordinate.