SclTriangulateInside
Overview
You can use SclTriangulateInside to fill the interior of a closed segment with a contiguous, non-overlapping, non-intersecting set of triangles. The triangules created are saved to a specified trisolation.
Synopsis
$SegmentHandle SclTriangulateInside $ObjectId $TrisolationId
Description
This function provides the same functionality as the TRIANGULATE INSIDE function available in the Solids modelling tools. It is exposed via SCL to provide greater flexibility when constructing solid objects from within SCL scripts. The function works best on coplanar convex polygons. It will produce acceptable results on quite complex shapes but does not work well on very complex, concave, non-coplanar shapes that self intersect when viewed in the X-Y plane.
Arguments
- SegmentHandle
- ObjectId
- TrisolationId
Pass by value. This is the handle to the segment which is to be triangulated. The segment must be closed.
Pass by value. The ID number of the object that is to be created. It is permissible to use an object number that already exists.
Pass by value. The ID number of the trisolation that is to be created. It is permissible to use a trisolation number that already exists.
Returns
The number of triangles created inside the segment. If no triangles are created then -1 is returned. The triangulation code works well with reasonable geometry. However, it will fail to produce an acceptable result with unreasonable geometry. Examples of unreasonable are shapes that self intersect, are extraordinarily irregular or extremely non-coplanar.
Examples
# Create the swa into which the strings will be loaded for the
# triangulation operation, then load the string file
SclCreateSwa SwaHandle TriangulateStrings
$SwaHandle SclSwaOpenFile intersect1.str
# get the handle to the segment to be triangulated
$SwaHandle SclCreateString StringHandle 1
$StringHandle SclCreateSegment Segment1Handle 0
# do the triangulation and report success or failure
set num_tris [$Segment1Handle SclTriangulateInside 1 1]
if {$num_tris > 0} {
puts "Triangulation successful, $num_tris triangles created"
} else {
outs "Triangulation unsuccessful"
}
# save the DTM file containing the result
$SwaHandle SclSwaSaveDtmFile "tri_inside_result1.str"
# now destroy the source swa
SclDestroy SwaHandle
|