ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/triangulate.h
Revision: 2.3
Committed: Fri Feb 7 18:58:40 2014 UTC (10 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R2P1, rad5R3, HEAD
Changes since 2.2: +3 -5 lines
Log Message:
Fixed comment describing triangulate call

File Contents

# User Rev Content
1 greg 2.3 /* RCSid $Id: triangulate.h,v 2.2 2014/01/24 01:26:44 greg Exp $ */
2 greg 2.1 /*
3     * triangulate.h
4     *
5     * Adapted by Greg Ward on 1/23/14.
6     * Copyright 2014 Anyhere Software. All rights reserved.
7     *
8     */
9    
10     /* COTD Entry submitted by John W. Ratcliff [[email protected]] */
11    
12     /**** THIS IS A CODE SNIPPET WHICH WILL EFFICIEINTLY TRIANGULATE ANY
13     // ** POLYGON/CONTOUR (without holes) AS A STATIC CLASS. THIS SNIPPET
14     // ** IS COMPRISED OF 3 FILES, TRIANGULATE.H, THE HEADER FILE FOR THE
15     // ** TRIANGULATE BASE CLASS, TRIANGULATE.CPP, THE IMPLEMENTATION OF
16     // ** THE TRIANGULATE BASE CLASS, AND TEST.CPP, A SMALL TEST PROGRAM
17     // ** DEMONSTRATING THE USAGE OF THE TRIANGULATOR. THE TRIANGULATE
18     // ** BASE CLASS ALSO PROVIDES TWO USEFUL HELPER METHODS, ONE WHICH
19     // ** COMPUTES THE AREA OF A POLYGON, AND ANOTHER WHICH DOES AN EFFICENT
20     // ** POINT IN A TRIANGLE TEST.
21     // ** SUBMITTED BY JOHN W. RATCLIFF ([email protected]) July 22, 2000
22     */
23    
24     /**********************************************************************/
25     /************ HEADER FILE FOR TRIANGULATE.C ***************************/
26     /**********************************************************************/
27    
28     #ifndef TRIANGULATE_H
29     #define TRIANGULATE_H
30    
31     #ifdef __cplusplus
32     extern "C" {
33     #endif
34    
35     typedef struct {
36     double mX, mY;
37     } Vert2;
38    
39     typedef struct {
40     int nv; /* number of vertices */
41     void *p; /* client data pointer */
42     Vert2 v[3]; /* extends struct */
43     } Vert2_list;
44    
45     /* allocate a polygon list */
46     extern Vert2_list *polyAlloc(int nv);
47    
48     #define polyFree free
49    
50     /* callback for output triangle */
51 greg 2.2 typedef int tri_out_t(const Vert2_list *tp, int a, int b, int c);
52 greg 2.1
53 greg 2.3 /* triangulate a polygon, send results to the given callback function */
54 greg 2.1 extern int polyTriangulate(const Vert2_list *contour, tri_out_t *cb);
55    
56     /* compute area of a contour/polygon */
57     extern double polyArea(const Vert2_list *contour);
58    
59 greg 2.3 /* decide if point P is inside triangle defined by ABC */
60 greg 2.1 extern int insideTriangle(double Ax, double Ay,
61     double Bx, double By,
62     double Cx, double Cy,
63     double Px, double Py);
64    
65     #ifdef __cplusplus
66     }
67     #endif
68    
69     #endif