1TDOTRI(3NCARG) NCAR GRAPHICS TDOTRI(3NCARG)
2
3
4
6 TDOTRI - Order the triangles defined by a triangle list.
7
9 CALL TDOTRI (RTRI, MTRI, NTRI, RTWK, ITWK, IORD)
10
12 #include <ncarg/ncargC.h>
13
14 void c_tdotri(float *rtri, int mtri, int *ntri, float *rtwk, int *itwk,
15 int iord)
16
18 This routine, given a list of NTRI triangles in the array RTRI and a
19 real scratch array RTWK of length at least MTRI x 2 , determines the
20 order in which the triangles are to be rendered and returns a
21 permutation of the integers from 1 to NTRI in the array ITWK, defining
22 that permutation.
23
24 The caller may select any of three ways in which the triangles are to
25 be ordered, the first two of which are essentially identical: When the
26 argument IORD is given the value 0, the distances of the midpoints of
27 the triangles from the viewpoint are computed and the triangles are
28 sorted by decreasing order of these distances. When IORD is given the
29 value -1, the result is the same, except that the distances of the
30 farthest points of the triangles from the viewpoint are computed and
31 the triangles are put in decreasing order of those distances. Both of
32 these possibilities are appropriate for situations in which the
33 triangles represent smooth surfaces that do not intersect each other or
34 themselves; the occasional small errors in the resulting rendering
35 order should be acceptable.
36
37 If any of the triangles in the list intersect each other or if the
38 surfaces being depicted are too rough, then the third option should be
39 used: When IORD is given the value +1, TDOTRI executes an algorithm
40 taken from the reference "Computer Graphics Principles and Practice",
41 by Foley and Van Dam. It starts by ordering the triangles as if IORD
42 had the value -1 (using distances of the far points of the triangles
43 from the viewpoint), but then it checks for situations in which this
44 ordering is in error and fixes the errors. Executing this algorithm can
45 be time-consuming, so it should not be done unless it is really
46 necessary; one possible way to proceed might be to use IORD = -1 while
47 checking out a code and then use IORD = +1 only when doing final plots.
48
49 Sometimes, when IORD = +1, triangles must be broken into smaller
50 triangles, thereby increasing the total number of triangles in RTRI.
51 If, as a result of this, NTRI becomes equal to MTRI, no error exit is
52 taken; instead, TDOTRI just returns control to the caller. Therefore,
53 it's a good idea, after calling TDOTRI, to check the value of NTRI
54 against the dimension MTRI; if they're equal, it probably means that
55 the triangle list filled up and that using the permutation returned in
56 ITWK will result in an incorrect rendering of the triangles.
57
58 The arguments of TDOTRI are as follows:
59
60 RTRI (an input/output array, of type REAL, dimensioned 10 x MTRI) -
61 a list of triangles, probably created by means of calls to
62 TDSTRI, TDITRI, and/or TDMTRI. As described above, the number
63 of triangles in the list may increase as a result of calling
64 TDOTRI.
65
66 MTRI (an input expression of type INTEGER) - the second dimension of
67 RTRI and thus the maximum number of triangles the triangle list
68 will hold.
69
70 NTRI (an input/output variable of type INTEGER) - specifies the
71 number of triangles currently in the list. It is the user's
72 responsibility to zero this initially; its value is increased
73 by each call to a triangle-generating routine like TDSTRI or
74 TDITRI and may be increased by a call to TDOTRI.
75
76 RTWK (a scratch array of type REAL, dimensioned at least MTRI x 2).
77
78 ITWK (an output array, of type INTEGER, dimensioned at least MTRI) -
79 returned containing a permutation of the integers from 1 to
80 NTRI, specifying the order in which the triangles ought to be
81 rendered.
82
83 IORD (an input expression of type INTEGER) - says how the triangles
84 are to be ordered. The value 0 implies ordering by decreasing
85 distance of the triangle midpoints from the eye, -1 implies
86 ordering by decreasing distance of the triangle farpoints from
87 the eye, and +1 implies ordering by decreasing distance of the
88 triangle farpoints from the eye, with adjustments made by
89 running an algorithm from the reference "Computer Graphics
90 Principles and Practice", by Foley and Van Dam.
91
93 The C-binding argument descriptions are the same as the FORTRAN
94 argument descriptions.
95
97 To use TDOTRI or c_tdotri, load the NCAR Graphics libraries ncarg,
98 ncarg_gks, and ncarg_c, preferably in that order.
99
101 Online: tdclrs, tdctri, tddtri, tdgeti, tdgetr, tdgrds, tdgrid, tdgtrs,
102 tdinit, tditri, tdlbla, tdlbls, tdline, tdlnpa, tdmtri, tdpack,
103 tdpack_params, tdpara, tdplch, tdprpa, tdprpi, tdprpt, tdseti, tdsetr,
104 tdsort, tdstri, tdstrs
105
107 Copyright (C) 1987-2009
108 University Corporation for Atmospheric Research
109
110 The use of this Software is governed by a License Agreement.
111
112
113
114UNIX July 1997 TDOTRI(3NCARG)