1 /* Copyright (C) 2006 Claus-Justus Heine
2  *
3  * This file is part of Geomview.
4  *
5  * Geomview is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published
7  * by the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * Geomview is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with Geomview; see the file COPYING.  If not, write
17  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
18  * USA, or visit http://www.gnu.org.
19  */
20 
21 /* geometric types, the include structure of the various
22  * [h]point[3n].h etc. files is a little bit complicated, so I have
23  * separated the typedefs from the function definitions. This way we
24  * can use inline functions easily. This file may be included multiple
25  * times.
26  */
27 
28 #ifndef HG4TENSOR_TYPEDEF
29 # define HG4TENSOR_TYPEDEF 1
30 typedef float Hg4Coord;
31 typedef Hg4Coord Hg4Tensor1[4];
32 typedef Hg4Coord *Hg4Tensor1Ptr;
33 typedef Hg4Coord Hg4Tensor2[4][4];
34 typedef Hg4Tensor1 *Hg4Tensor2Ptr;
35 #endif
36 
37 #ifndef POINT3_TYPEDEF
38 # define POINT3_TYPEDEF
39 typedef float Pt3Coord;
40 typedef struct { Pt3Coord x, y, z; } Point3;
41 #endif
42 
43 #ifndef HPOINT3_TYPEDEF
44 # define HPOINT3_TYPEDEF 1
45 typedef Pt3Coord HPt3Coord;
46 typedef struct { HPt3Coord x, y, z, w; } HPoint3;
47 
HPoint3Point3(HPoint3 * hpt3)48 static inline Point3 *HPoint3Point3(HPoint3 *hpt3)
49 {
50   typedef union
51   {
52     HPt3Coord array[4];
53     HPoint3   hpt3;
54     Point3    pt3;
55   } HPoint3Cast;
56 
57   return &((HPoint3Cast *)hpt3)->pt3;
58 }
59 
HPoint3Data(HPoint3 * hpt3)60 static inline HPt3Coord *HPoint3Data(HPoint3 *hpt3)
61 {
62   typedef union
63   {
64     HPt3Coord array[4];
65     HPoint3   hpt3;
66     Point3    pt3;
67   } HPoint3Cast;
68 
69   return ((HPoint3Cast *)hpt3)->array;
70 }
71 
72 #endif
73 
74 #ifndef TRANSFORM3_TYPEDEF
75 # define TRANSFORM3_TYPEDEF 1
76 typedef float Tm3Coord;
77 typedef Tm3Coord Transform3[4][4];
78 typedef	Tm3Coord (*TransformPtr)[4];
79 #endif
80 
81 #ifndef HPLANE3_TYPEDEF
82 # define HPLANE3_TYPEDEF 1
83 typedef float HPl3Coord;
84 typedef struct { HPl3Coord a, b, c, d; } HPlane3;
85 #endif
86 
87 #ifndef HLINE3_TYPEDEF
88 # define HLINE3_TYPEDEF 1
89 typedef float HLn3Coord;
90 typedef struct {
91   HLn3Coord L[4][4];
92   int type;
93 } HLine3;
94 #endif
95 
96 #ifndef HPOINTN_TYPEDEF
97 # define HPOINTN_TYPEDEF 1
98 typedef float HPtNCoord;
99 typedef struct HPtN {
100 	int dim;	/* Dimension, including homogeneous divisor */
101 	int flags;	/* Space tag */
102 	int size;       /* allocated size */
103 	HPtNCoord *v;	/* Array of coordinates; v[0] is the homogenous divisor */
104 } HPointN;
105 #endif
106 
107 #ifndef TRANSFORMN_TYPEDEF
108 # define TRANSFORMN_TYPEDEF 1
109 /* N-dimensional transformation matrix.
110  * Transforms row vectors (multiplied on the left) of dimension 'idim',
111  * yielding row vectors of dimension 'odim'.
112  */
113 #include "reference.h"
114 
115 typedef struct TmN {
116 	REFERENCEFIELDS;
117 	int idim, odim;
118 	int flags;
119 	HPtNCoord *a;	/* Array of idim rows, odim columns */
120 } TransformN;
121 #endif
122