FreeWRL/FreeX3D  3.0.0
glcurveval.h
1 /*
2  * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3  * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice including the dates of first publication and
13  * either this permission notice or a reference to
14  * http://oss.sgi.com/projects/FreeB/
15  * shall be included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  *
25  * Except as contained in this notice, the name of Silicon Graphics, Inc.
26  * shall not be used in advertising or otherwise to promote the sale, use or
27  * other dealings in this Software without prior written authorization from
28  * Silicon Graphics, Inc.
29  */
30 
31 /*
32  * glcurveval.h
33  *
34  */
35 
36 #ifndef __gluglcurveval_h_
37 #define __gluglcurveval_h_
38 
39 #include "gluos.h"
40 //#include <GL/gl.h>
41 //#include <GL/glu.h>
42 #include <libnurbs2.h>
43 #include "basiccrveval.h"
44 
45 class CurveMap;
46 
47 /*for internal evaluator callback stuff*/
48 #ifndef IN_MAX_BEZIER_ORDER
49 #define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
50 #endif
51 
52 #ifndef IN_MAX_DIMENSION
53 #define IN_MAX_DIMENSION 4
54 #endif
55 
56 typedef struct curveEvalMachine{
57  REAL uprime; //cached previously evaluated uprime
58  int k; //the dimension
59  REAL u1;
60  REAL u2;
61  int ustride;
62  int uorder;
63  REAL ctlpoints[IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
64  REAL ucoeff[IN_MAX_BEZIER_ORDER];//cache the polynomial values
66 
68 public:
70  virtual ~OpenGLCurveEvaluator(void);
71  void range1f(long, REAL *, REAL *);
72  void domain1f(REAL, REAL);
73  void addMap(CurveMap *);
74 
75  void enable(long);
76  void disable(long);
77  void bgnmap1f(long);
78  void map1f(long, REAL, REAL, long, long, REAL *);
79  void mapgrid1f(long, REAL, REAL);
80  void mapmesh1f(long, long, long);
81  void evalpoint1i(long);
82  void evalcoord1f(long, REAL);
83  void endmap1f(void);
84 
85  void bgnline(void);
86  void endline(void);
87 
88  void put_vertices_call_back(int flag)
89  {
90  output_triangles = flag;
91  }
92 #ifdef _WIN32
93  void putCallBack(GLenum which, void (GLAPIENTRY *fn)() );
94 #else
95  void putCallBack(GLenum which, _GLUfuncptr fn );
96 #endif
97  void set_callback_userData(void *data)
98  {
99  userData = data;
100  }
101 
102 /*------------------begin for curveEvalMachine------------*/
103 curveEvalMachine em_vertex;
104 curveEvalMachine em_normal;
105 curveEvalMachine em_color;
106 curveEvalMachine em_texcoord;
107 int vertex_flag; //whether there is a vertex map or not
108 int normal_flag; //whether there is a normal map or not
109 int color_flag; //whether there is a color map or not
110 int texcoord_flag; //whether there is a texture map or not
111 
112 REAL global_grid_u0;
113 REAL global_grid_u1;
114 int global_grid_nu;
115 
116 void inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
117  int dimension,
118  REAL ulower,
119  REAL uupper,
120  int ustride,
121  int uorder,
122  REAL *ctlpoints);
123 
124 void inPreEvaluate(int order, REAL vprime, REAL *coeff);
125 void inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint);
126 void inDoEvalCoord1(REAL u);
127 void inMapMesh1f(int umin, int umax);
128 
129 void (GLAPIENTRY *beginCallBackN) (GLenum type);
130 void (GLAPIENTRY *endCallBackN) (void);
131 void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
132 void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
133 void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
134 void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
135 
136 void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
137 void (GLAPIENTRY *endCallBackData) (void* data);
138 void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
139 void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
140 void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
141 void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
142 
143 void* userData; //the opaque pointer for Data callback functions
144 void beginCallBack(GLenum type, void* data);
145 void endCallBack(void* data);
146 void vertexCallBack(const GLfloat *vert, void *data);
147 void normalCallBack(const GLfloat *normal, void* data);
148 void colorCallBack(const GLfloat *color, void* data);
149 void texcoordCallBack(const GLfloat *texcoord, void* data);
150 
151 
152 /*------------------end for curveEvalMachine------------*/
153 
154 private:
155  int output_triangles; //true 1; false 0
156 };
157 
158 #endif /* __gluglcurveval_h_ */