1 /* Copyright (C) 1992-1998 The Geometry Center
2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3 *
4 * This file is part of Geomview.
5 *
6 * Geomview is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Geomview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Geomview; see the file COPYING. If not, write
18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA, or visit http://www.gnu.org.
20 */
21
22
23 /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */
24
25 #ifndef MESHPDEF
26 #define MESHPDEF
27
28 #include "geomclass.h"
29 #include "mesh.h"
30 #include "bsptree.h"
31
32 struct Mesh {
33 GEOMFIELDS;
34 int seq;
35 int nu, nv;
36 int umin, umax, vmin, vmax;
37 HPoint3 *p;
38 Point3 *n;
39 Point3 *nq; /* per quad normals */
40 TxST *u;
41 ColorA *c;
42 };
43
MeshRef(Mesh * m)44 static inline Ref *MeshRef(Mesh *m)
45 {
46 union castit {
47 Ref ref;
48 Mesh mesh;
49 };
50
51 return &((union castit *)m)->ref;
52 }
53
MeshGeom(Mesh * m)54 static inline Geom *MeshGeom(Mesh *m)
55 {
56 union castit {
57 Geom geom;
58 Mesh mesh;
59 };
60
61 return &((union castit *)m)->geom;
62 }
63
64 #define nuverts(m) (m)->nu
65 #define nvverts(m) (m)->nv
66 #define nuquads(m) (((m)->flag & MESH_UWRAP) ? (m)->nu : (m)->nu - 1)
67 #define nvquads(m) (((m)->flag & MESH_VWRAP) ? (m)->nv : (m)->nv - 1)
68
69 /*
70 * MESHINDEX(u, v, mesh)
71 * Returns the index of a point into the mesh->array given its u & v
72 * coordinates.
73 */
74 #define MESHINDEX(u, v, mesh) \
75 (((v)%(mesh)->nv)*(mesh)->nu + ((u)%(mesh)->nu))
76
77 /*
78 * MESHPOINT(u, v, mesh, plist)
79 * Returns plist[MESHINDEX(u, v, mesh)]
80 */
81 #define MESHPOINT(u, v, mesh, plist) ((plist)[MESHINDEX(u, v, mesh)])
82
83 extern Mesh *MeshComputeNormals(Mesh *m, int need);
84
85 #endif /* ! MESHPDEF */
86
87 /*
88 * Local Variables: ***
89 * c-basic-offset: 2 ***
90 * End: ***
91 */
92