You are here: Surpac Concepts > Macros > SCL > SWA Commands > SclCreateTriangle
GEOVIA Surpac

SclCreateTriangle

Overview

The SWA (Surpac Work Area) is where all String and DTM data processed by Surpac applications is stored. A complete description of the SWA can be found here.

The SclCreateTriangle command creates a new triangle, with a specified identifier (a positive integer), in a trisolation and returns a handle to that triangle for future operations on that triangle. If a triangle with the specified number (identifier) already exists then the handle to that triangle is returned and the triangle is not modified in any way.

Synopsis

$TrisolationHandle SclCreateTriangle TriangleHandle $TriangleNumber

Description

Create a triangle with the specified identifier in the specified trisolation and return the handle to that triangle for later use by other Scl commands. If a triangle already exists with the specified identifier then the handle of that triangle is returned.

Arguments

  • TrisolationHandle
  • This is the handle to the trisolation in which the triangle is to be created. The trisolation handle must have previously been obtained by using SclCreateTrisolation or SclIterateNext to obtain the handle to an existing trisolation in the set of trisolations for a triobject.

  • TriangleHandle
  • Passed by reference. This is the variable to which the triangle handle is assigned. This triangle handle must be used in later references to the triangle for modifying the triangle attributes. When a triangle is first created it has vertex values of 0, meaning no triangle vertex at all and neighboring triangle values of 0 meaning no neighbor triangles have been defined.

    Triangles have a number of attributes that may be queried or set using the Attribute Management commands in Scl. The triangle attributes that may be operated on using these commands include:

    • v0, v1, v2 - The point handles of the 3 points that represent the vertices of the triangle.

  • TriangleNumber
  • Passed by value. This is the identifier of the triangle that is to be created in the trisolation. The triangle identifier (number) must be greater than zero. If a triangle already exists with the specified number then the handle of that triangle will be returned and the triangle will not be modified in any way.

Examples

#
# create a triobject with 2 trisolations with one triangle each
# and then save the string and DTM files and finally destroy the swa
#
SclCreateSwa SwaHandle "temporary swa"
$SwaHandle SclCreateString StringHandle 1
$StringHandle SclCreateSegment SegmentHandle 0
$SegmentHandle SclCreatePoint PointHandle1 0
# points for the first triangle
$PointHandle1 SclSetValueByName x 0.0
$PointHandle1 SclSetValueByName y 0.0
$PointHandle1 SclSetValueByName z 0.0
$SegmentHandle SclCreatePoint PointHandle2 1
$PointHandle2 SclSetValueByName x 0.0
$PointHandle2 SclSetValueByName y 2.0
$PointHandle2 SclSetValueByName z 0.0
$SegmentHandle SclCreatePoint PointHandle3 2
$PointHandle3 SclSetValueByName x 2.0
$PointHandle3 SclSetValueByName y 0.0
$PointHandle3 SclSetValueByName z 0.0
# points for the second triangle
$SegmentHandle SclCreatePoint PointHandle4 3
$PointHandle4 SclSetValueByName x 10.0
$PointHandle4 SclSetValueByName y 10.0
$PointHandle4 SclSetValueByName z 0.0
$SegmentHandle SclCreatePoint PointHandle5 4
$PointHandle5 SclSetValueByName x 11.0
$PointHandle5 SclSetValueByName y 12.0
$PointHandle5 SclSetValueByName z 0.0
$SegmentHandle SclCreatePoint PointHandle6 5
$PointHandle6 SclSetValueByName x 12.0
$PointHandle6 SclSetValueByName y 10.0
$PointHandle6 SclSetValueByName z 0.0
$SwaHandle SclCreateTriobject TriobjectHandle 1
$TriobjectHandle SclCreateTrisolation TrisolationHandle 1
$TrisolationHandle SclCreateTriangle TriangleHandle 1
$TriangleHandle SclSetValueByName v0 $PointHandle1
$TriangleHandle SclSetValueByName v1 $PointHandle2
$TriangleHandle SclSetValueByName v2 $PointHandle3
$SwaHandle SclCreateTriobject TriobjectHandle 1
$TriobjectHandle SclCreateTrisolation TrisolationHandle 2
$TrisolationHandle SclCreateTriangle TriangleHandle 1
$TriangleHandle SclSetValueByName v0 $PointHandle4
$TriangleHandle SclSetValueByName v1 $PointHandle5
$TriangleHandle SclSetValueByName v2 $PointHandle6
$SwaHandle SclSwaSaveDtmFile test1.str
SclDestroy SwaHandle
puts "Object 1 created with 2 trisolations with one triangle each"
puts "and saved to test1.str & test1.dtm"

See Also

SclSwaExists
SclCreateString

SclCreateSegment

SclCreatePoint

SclCreateTriobject

SclCreateTrisolation

SclDestroy

SclSwaSaveDtmFile

SclSwaSaveStringFile

SclSwaOpenFile

sclSwas