TDOTRI(3NCARG) | NCAR GRAPHICS | TDOTRI(3NCARG) |
TDOTRI - Order the triangles defined by a triangle list.
CALL TDOTRI (RTRI, MTRI, NTRI, RTWK, ITWK, IORD)
#include <ncarg/ncargC.h>
void c_tdotri(float *rtri, int mtri, int *ntri, float *rtwk, int *itwk, int iord)
This routine, given a list of NTRI triangles in the array RTRI and a real scratch array RTWK of length at least MTRI x 2 , determines the order in which the triangles are to be rendered and returns a permutation of the integers from 1 to NTRI in the array ITWK, defining that permutation.
The caller may select any of three ways in which the triangles are to be ordered, the first two of which are essentially identical: When the argument IORD is given the value 0, the distances of the midpoints of the triangles from the viewpoint are computed and the triangles are sorted by decreasing order of these distances. When IORD is given the value -1, the result is the same, except that the distances of the farthest points of the triangles from the viewpoint are computed and the triangles are put in decreasing order of those distances. Both of these possibilities are appropriate for situations in which the triangles represent smooth surfaces that do not intersect each other or themselves; the occasional small errors in the resulting rendering order should be acceptable.
If any of the triangles in the list intersect each other or if the surfaces being depicted are too rough, then the third option should be used: When IORD is given the value +1, TDOTRI executes an algorithm taken from the reference "Computer Graphics Principles and Practice", by Foley and Van Dam. It starts by ordering the triangles as if IORD had the value -1 (using distances of the far points of the triangles from the viewpoint), but then it checks for situations in which this ordering is in error and fixes the errors. Executing this algorithm can be time-consuming, so it should not be done unless it is really necessary; one possible way to proceed might be to use IORD = -1 while checking out a code and then use IORD = +1 only when doing final plots.
Sometimes, when IORD = +1, triangles must be broken into smaller triangles, thereby increasing the total number of triangles in RTRI. If, as a result of this, NTRI becomes equal to MTRI, no error exit is taken; instead, TDOTRI just returns control to the caller. Therefore, it's a good idea, after calling TDOTRI, to check the value of NTRI against the dimension MTRI; if they're equal, it probably means that the triangle list filled up and that using the permutation returned in ITWK will result in an incorrect rendering of the triangles.
The arguments of TDOTRI are as follows:
The C-binding argument descriptions are the same as the FORTRAN argument descriptions.
To use TDOTRI or c_tdotri, load the NCAR Graphics libraries ncarg, ncarg_gks, and ncarg_c, preferably in that order.
Online: tdclrs, tdctri, tddtri, tdgeti, tdgetr, tdgrds, tdgrid, tdgtrs, tdinit, tditri, tdlbla, tdlbls, tdline, tdlnpa, tdmtri, tdpack, tdpack_params, tdpara, tdplch, tdprpa, tdprpi, tdprpt, tdseti, tdsetr, tdsort, tdstri, tdstrs
Copyright (C) 1987-2009
University Corporation for Atmospheric Research
The use of this Software is governed by a License Agreement.
July 1997 | UNIX |