1 /* Copyright (C) 1992-1998 The Geometry Center
2  * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3  * Copyright (C) 2006-2007 Claus-Justus Heine
4  *
5  * This file is part of Geomview.
6  *
7  * Geomview is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published
9  * by the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * Geomview is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Geomview; see the file COPYING.  If not, write
19  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
20  * USA, or visit http://www.gnu.org.
21  */
22 
23 
24 /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips,
25  * Celeste Fowler */
26 
27 #ifndef PICKPDEF
28 #define	PICKPDEF
29 
30 /*
31  * Private definitions for picking.
32  */
33 
34 #include "pick.h"
35 #include "ooglutil.h"
36 
37 struct Pick {
38     Point3 got;
39 
40     float thresh;
41 
42     int want;		/* Fields wanted */
43     int  found;		/* Fields found */
44 
45     vvec gcur;              /* Path to the current primitive -
46 			       used for recursion */
47     vvec gpath;		/* Path to picked primitive */
48     Geom *gprim;		/* Picked primitive */
49 
50     HPoint3 v;		/* picked vertex, if any */
51     int vi;			/* index of picked vertex */
52 
53     HPoint3 e[2];		/* endpoints of picked edge, if any */
54     int ei[2];		/* indices of endpoints of picked edge */
55 
56     Transform Tprim;	/* gprim -> screen */
57     Transform Tmirp;
58     Transform Tw;
59     Transform Tself;
60 
61     /* for ND-viewing. */
62     TransformN *TprimN;
63     TransformN *TmirpN;
64     int        axes[4];     /* the relevant sub-space of the output of
65 			     * TprimN.
66 			     */
67     TransformN *TwN;
68     TransformN *TselfN;
69 
70     HPoint3 *f;		/* array of vertices of picked face, if any */
71     int fn;			/* number of vertices in array f */
72     int fi;			/* index of picked face */
73 
74     Transform Ts2n;		/* NDC to screen tfm */
75     Transform Tc2n;		/* NDC to camera tfm */
76     Transform Tw2n;		/* NDC to world (global) tfm */
77     float x0, y0;		/* NDC coords of original pick */
78 };
79 
80 /*
81  * PickFace() is used to test a face for a pick and modify the pick
82  * structure if necessary.
83  *   n_verts is the number of vertices in the face.
84  *   verts is the list of vertices in the face.
85  *   pick is the pick structure.
86  *   ap is the appearance (not currently used).
87  * The following fields of the pick structure will be filled in:
88  *   found - what has been found.
89  *   vi - index of the picked vertex in the verts array.
90  *   ei - indices of the endpoints of the picked edge in the verts array.
91  *   f - freed if non-NULL and set to NULL
92  * PickFace() returns nonzero if something was picked.  The calling
93  * program is responsible for using the data returned in the pick
94  * structure to fill in the actual points and correct the indices.
95  */
96 int PickFace(int n_verts, Point3 *verts, Pick *pick, Appearance *ap);
97 
98 /*
99  * PickFillIn() is used to fill in the fields of a pick structure once
100  * a pick has been found.
101  *   pick is the pick structure.
102  *   n_verts is the number of points in the face.
103  *   got is the interesection of the pick ray with the face.
104  *   vertex is the index of the picked vertex (-1 if none).
105  *   edge is the index of the first vertex of the hit line (-1 if none).
106  *   ep is the picked point on the edge.
107  * The routine fills in the following fields of the pick structure:
108  *   got - filled in with the parameter got.
109  *   found - filled in with what was found.
110  *   vi - the index of the picked vertex.
111  *   ei - the indices of the endpoints of the picked edge.
112  *   f - freed if non-null and set to null.
113  *   fn - the number of vertices in the face
114  *   gpath - the path to the picked primitive (copy of gcur)
115  * The rest of the fields are left unchanged.
116  * Returns pick->found.
117  */
118 int PickFillIn(Pick *pick, int n_verts, Point3 *got, int vertex,
119 	       int edge, Appearance *ap);
120 
121 
122 #endif /*PICKPDEF*/
123 
124 /*
125  * Local Variables: ***
126  * mode: c ***
127  * c-basic-offset: 4 ***
128  * End: ***
129  */
130