ReactOS 0.4.15-dev-7842-g558ab78
bezierPatchMesh.h File Reference
#include <GL/gl.h>
#include "bezierPatch.h"
Include dependency graph for bezierPatchMesh.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bezierPatchMesh
 

Typedefs

typedef struct bezierPatchMesh bezierPatchMesh
 

Functions

bezierPatchMeshbezierPatchMeshMake (int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array)
 
bezierPatchMeshbezierPatchMeshMake2 (int size_UVarray, int size_length_array)
 
void bezierPatchMeshPutPatch (bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints)
 
void bezierPatchMeshDelete (bezierPatchMesh *bpm)
 
void bezierPatchMeshBeginStrip (bezierPatchMesh *bpm, GLenum type)
 
void bezierPatchMeshEndStrip (bezierPatchMesh *bpm)
 
void bezierPatchMeshInsertUV (bezierPatchMesh *bpm, float u, float v)
 
void bezierPatchMeshPrint (bezierPatchMesh *bpm)
 
bezierPatchMeshbezierPatchMeshListInsert (bezierPatchMesh *list, bezierPatchMesh *bpm)
 
void bezierPatchMeshListPrint (bezierPatchMesh *list)
 
int bezierPatchMeshListTotalStrips (bezierPatchMesh *list)
 
int bezierPatchMeshListTotalVert (bezierPatchMesh *list)
 
int bezierPatchMeshNumTriangles (bezierPatchMesh *bpm)
 
int bezierPatchMeshListNumTriangles (bezierPatchMesh *list)
 
void bezierPatchMeshDelDeg (bezierPatchMesh *bpm)
 
void bezierPatchMeshEval (bezierPatchMesh *bpm)
 
void bezierPatchMeshDraw (bezierPatchMesh *bpm)
 
void bezierPatchMeshListDraw (bezierPatchMesh *list)
 
void bezierPatchMeshListEval (bezierPatchMesh *list)
 
void bezierPatchMeshListCollect (bezierPatchMesh *list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips)
 
void bezierPatchMeshListDelDeg (bezierPatchMesh *list)
 
void bezierPatchMeshListDelete (bezierPatchMesh *list)
 
bezierPatchMeshbezierPatchMeshListReverse (bezierPatchMesh *list)
 
void drawStrips (float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips)
 

Typedef Documentation

◆ bezierPatchMesh

Function Documentation

◆ bezierPatchMeshBeginStrip()

◆ bezierPatchMeshDelDeg()

void bezierPatchMeshDelDeg ( bezierPatchMesh bpm)

Definition at line 427 of file bezierPatchMesh.cc.

428{
429 if(bpm == NULL) return;
430 int i,j,k;
431 int *new_length_array;
432 GLenum *new_type_array;
433 int index_new_length_array;
434 float *new_UVarray;
435 int index_new_UVarray;
436
437 new_length_array = (int*)malloc(sizeof(int) * bpm->index_length_array);
438 assert(new_length_array);
439 new_type_array = (GLenum*)malloc(sizeof(GLenum) * bpm->index_length_array);
440 assert(new_length_array);
441 new_UVarray = (float*) malloc(sizeof(float) * bpm->index_UVarray);
442 assert(new_UVarray);
443
444 index_new_length_array = 0;
445 index_new_UVarray=0;
446 k=0;
447 for(i=0; i<bpm->index_length_array; i++){
448
449 /*(if not degenerate, we have to copy*/
450 if( (bpm->length_array[i] != 3) || (!isDegenerate(bpm->UVarray+k, bpm->UVarray+k+2, bpm->UVarray+k+4)))
451 {
452 for(j=0; j<2* bpm->length_array[i]; j++)
453 new_UVarray[index_new_UVarray++] = bpm->UVarray[k++];
454
455 new_length_array[index_new_length_array] = bpm->length_array[i];
456 new_type_array[index_new_length_array] = bpm->type_array[i];
457 index_new_length_array++;
458 }
459 else
460 {
461 k += 6;
462 }
463 }
464 free(bpm->UVarray);
465 free(bpm->length_array);
466 free(bpm->type_array);
467 bpm->UVarray=new_UVarray;
468 bpm->length_array=new_length_array;
469 bpm->type_array=new_type_array;
470 bpm->index_UVarray = index_new_UVarray;
471 bpm->index_length_array = index_new_length_array;
472
473}
static int isDegenerate(float A[2], float B[2], float C[2])
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define assert(x)
Definition: debug.h:53
unsigned int GLenum
Definition: gl.h:150
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int k
Definition: mpi.c:3369

Referenced by bezierPatchMeshListDelDeg().

◆ bezierPatchMeshDelete()

void bezierPatchMeshDelete ( bezierPatchMesh bpm)

Definition at line 223 of file bezierPatchMesh.cc.

224{
225 if(bpm->bpatch != NULL)
227 if(bpm->bpatch_normal != NULL)
229 if(bpm->bpatch_color != NULL)
231 if(bpm->bpatch_texcoord != NULL)
233
234 free(bpm->UVarray);
235 free(bpm->length_array);
236 free(bpm->vertex_array);
237 free(bpm->normal_array);
238 free(bpm->type_array);
239 free(bpm);
240}
void bezierPatchDelete(bezierPatch *b)
Definition: bezierPatch.cc:101
bezierPatch * bpatch
bezierPatch * bpatch_color
bezierPatch * bpatch_texcoord
bezierPatch * bpatch_normal

Referenced by bezierPatchMeshListDelete().

◆ bezierPatchMeshDraw()

void bezierPatchMeshDraw ( bezierPatchMesh bpm)

Definition at line 524 of file bezierPatchMesh.cc.

525{
526 int i,j,k;
527 k=0;
528 /*k is the index of the first component of the current vertex*/
529 for(i=0; i<bpm->index_length_array; i++)
530 {
531 glBegin(bpm->type_array[i]);
532 for(j=0; j<bpm->length_array[i]; j++)
533 {
536 k+= 3;
537 }
538 glEnd();
539 }
540}
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glNormal3fv(const GLfloat *v)

Referenced by bezierPatchMeshListDraw().

◆ bezierPatchMeshEndStrip()

void bezierPatchMeshEndStrip ( bezierPatchMesh bpm)

Definition at line 252 of file bezierPatchMesh.cc.

253{
254 int i;
255
256 /*if there are no vertices in this strip, then nothing needs to be done*/
257 if(bpm->counter == 0) return;
258
259 /*if the length_array is full, it should be expanded*/
261 {
262 int *temp = (int*) malloc(sizeof(int) * (bpm->size_length_array*2 + 1));
263 assert(temp);
264 GLenum *temp_type = (GLenum*) malloc(sizeof(GLenum) * (bpm->size_length_array*2 + 1));
265 assert(temp_type);
266 /*update the size*/
267 bpm->size_length_array = bpm->size_length_array*2 + 1;
268
269 /*copy*/
270 for(i=0; i<bpm->index_length_array; i++)
271 {
272 temp[i] = bpm->length_array[i];
273 temp_type[i] = bpm->type_array[i];
274 }
275
276 /*deallocate old array*/
277 free(bpm->length_array);
278 free(bpm->type_array);
279
280 /*point to the new array which is twice as bigger*/
281 bpm->length_array = temp;
282 bpm->type_array = temp_type;
283 }
284 bpm->type_array[bpm->index_length_array] = bpm->type;
285 bpm->length_array[bpm->index_length_array++] = bpm->counter;
286
287}
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by OpenGLSurfaceEvaluator::endclosedline(), OpenGLSurfaceEvaluator::endline(), OpenGLSurfaceEvaluator::endqstrip(), OpenGLSurfaceEvaluator::endtfan(), OpenGLSurfaceEvaluator::endtmesh(), and OpenGLSurfaceEvaluator::mapmesh2f().

◆ bezierPatchMeshEval()

void bezierPatchMeshEval ( bezierPatchMesh bpm)

Definition at line 479 of file bezierPatchMesh.cc.

480{
481 int i,j,k,l;
482 float u,v;
483 float u0 = bpm->bpatch->umin;
484 float u1 = bpm->bpatch->umax;
485 int uorder = bpm->bpatch->uorder;
486 float v0 = bpm->bpatch->vmin;
487 float v1 = bpm->bpatch->vmax;
488 int vorder = bpm->bpatch->vorder;
489 int dimension = bpm->bpatch->dimension;
490 int ustride = dimension * vorder;
491 int vstride = dimension;
492 float *ctlpoints = bpm->bpatch->ctlpoints;
493
494 bpm->vertex_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
495 assert(bpm->vertex_array);
496 bpm->normal_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
497 assert(bpm->normal_array);
498
499 k=0;
500 l=0;
501 for(i=0; i<bpm->index_length_array; i++)
502 {
503 for(j=0; j<bpm->length_array[i]; j++)
504 {
505 u = bpm->UVarray[k];
506 v = bpm->UVarray[k+1];
507 bezierSurfEval(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->vertex_array+l);
508 bezierSurfEvalNormal(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->normal_array+l);
509 k += 2;
510 l += 3;
511 }
512 }
513}
void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[])
Definition: bezierEval.cc:202
void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
Definition: bezierEval.cc:192
r l[0]
Definition: byte_order.h:168
const GLdouble * v
Definition: gl.h:2040
GLdouble GLdouble GLint ustride
Definition: glext.h:8308
GLdouble GLdouble GLint GLint uorder
Definition: glext.h:8308
GLfloat v0
Definition: glext.h:6061
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint vorder
Definition: glext.h:8308
GLfloat GLfloat v1
Definition: glext.h:6062
GLdouble u1
Definition: glext.h:8308
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint vstride
Definition: glext.h:8308
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
float vmax
Definition: bezierPatch.h:37
float umin
Definition: bezierPatch.h:37
float vmin
Definition: bezierPatch.h:37
float * ctlpoints
Definition: bezierPatch.h:58
float umax
Definition: bezierPatch.h:37

Referenced by bezierPatchMeshListEval().

◆ bezierPatchMeshInsertUV()

void bezierPatchMeshInsertUV ( bezierPatchMesh bpm,
float  u,
float  v 
)

Definition at line 290 of file bezierPatchMesh.cc.

291{
292 int i;
293 /*if the UVarray is full, it should be expanded*/
294 if(bpm->index_UVarray+1 >= bpm->size_UVarray)
295 {
296 float *temp = (float*) malloc(sizeof(float) * (bpm->size_UVarray * 2 + 2));
297 assert(temp);
298
299 /*update the size*/
300 bpm->size_UVarray = bpm->size_UVarray*2 + 2;
301
302 /*copy*/
303 for(i=0; i<bpm->index_UVarray; i++)
304 {
305 temp[i] = bpm->UVarray[i];
306 }
307
308 /*deallocate old array*/
309 free(bpm->UVarray);
310
311 /*pointing to the new arrays*/
312 bpm->UVarray = temp;
313 }
314 /*insert the new UV*/
315 bpm->UVarray[bpm->index_UVarray] = u;
316 bpm->index_UVarray++;
317 bpm->UVarray[bpm->index_UVarray] = v;
318 bpm->index_UVarray++;
319
320 /*update counter: one more vertex*/
321 bpm->counter++;
322
323
324}

Referenced by OpenGLSurfaceEvaluator::coord2f(), and OpenGLSurfaceEvaluator::mapmesh2f().

◆ bezierPatchMeshListCollect()

void bezierPatchMeshListCollect ( bezierPatchMesh list,
float **  vertex_array,
float **  normal_array,
int **  length_array,
GLenum **  type_array,
int num_strips 
)

Definition at line 551 of file bezierPatchMesh.cc.

552{
553 int i,j,k,l;
555 int total_num_vertices = bezierPatchMeshListTotalVert(list);
556 (*vertex_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
557 assert(*vertex_array);
558 (*normal_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
559 assert(*normal_array);
560
562
563 *length_array = (int*) malloc(sizeof(int) * (*num_strips));
564 assert(*length_array);
565
566 *type_array = (GLenum*) malloc(sizeof(GLenum) * (*num_strips));
567 assert(*type_array);
568
569 k=0;
570 l=0;
571 for(temp = list; temp != NULL; temp = temp->next)
572 {
573 int x=0;
574 for(i=0; i<temp->index_length_array; i++)
575 {
576 for(j=0; j<temp->length_array[i]; j++)
577 {
578 (*vertex_array)[k] = temp->vertex_array[x];
579 (*vertex_array)[k+1] = temp->vertex_array[x+1];
580 (*vertex_array)[k+2] = temp->vertex_array[x+2];
581
582 (*normal_array)[k] = temp->normal_array[x];
583 (*normal_array)[k+1] = temp->normal_array[x+1];
584 (*normal_array)[k+2] = temp->normal_array[x+2];
585
586 x += 3;
587 k += 3;
588 }
589 (*type_array)[l] = temp->type_array[i];
590 (*length_array)[l++] = temp->length_array[i];
591 }
592 }
593}
int bezierPatchMeshListTotalStrips(bezierPatchMesh *list)
int bezierPatchMeshListTotalVert(bezierPatchMesh *list)
Definition: list.h:37
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

◆ bezierPatchMeshListDelDeg()

void bezierPatchMeshListDelDeg ( bezierPatchMesh list)

Definition at line 66 of file bezierPatchMesh.cc.

67{
69 for(temp=list; temp != NULL; temp = temp->next)
70 {
72 }
73}
void bezierPatchMeshDelDeg(bezierPatchMesh *bpm)

◆ bezierPatchMeshListDelete()

void bezierPatchMeshListDelete ( bezierPatchMesh list)

Definition at line 75 of file bezierPatchMesh.cc.

76{
77 if(list == NULL) return;
80}
void bezierPatchMeshListDelete(bezierPatchMesh *list)
void bezierPatchMeshDelete(bezierPatchMesh *bpm)
struct list * next
Definition: list.h:38

Referenced by bezierPatchMeshListDelete(), OpenGLSurfaceEvaluator::bgnmap2f(), and OpenGLSurfaceEvaluator::endmap2f().

◆ bezierPatchMeshListDraw()

void bezierPatchMeshListDraw ( bezierPatchMesh list)

Definition at line 542 of file bezierPatchMesh.cc.

543{
545 for(temp = list; temp != NULL; temp = temp->next)
546 {
548 }
549}
void bezierPatchMeshDraw(bezierPatchMesh *bpm)

◆ bezierPatchMeshListEval()

void bezierPatchMeshListEval ( bezierPatchMesh list)

Definition at line 515 of file bezierPatchMesh.cc.

516{
518 for(temp = list; temp != NULL; temp = temp->next)
519 {
521 }
522}
void bezierPatchMeshEval(bezierPatchMesh *bpm)

◆ bezierPatchMeshListInsert()

bezierPatchMesh * bezierPatchMeshListInsert ( bezierPatchMesh list,
bezierPatchMesh bpm 
)

Definition at line 347 of file bezierPatchMesh.cc.

348{
349 bpm->next=list;
350 return bpm;
351}
#define list
Definition: rosglue.h:35
struct bezierPatchMesh * next

Referenced by bezierPatchMeshListReverse(), and OpenGLSurfaceEvaluator::map2f().

◆ bezierPatchMeshListNumTriangles()

int bezierPatchMeshListNumTriangles ( bezierPatchMesh list)

Definition at line 385 of file bezierPatchMesh.cc.

386{
387 int sum=0;
389 for(temp=list; temp != NULL; temp = temp->next)
390 {
392 }
393 return sum;
394}
int bezierPatchMeshNumTriangles(bezierPatchMesh *bpm)
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35

◆ bezierPatchMeshListPrint()

void bezierPatchMeshListPrint ( bezierPatchMesh list)

Definition at line 354 of file bezierPatchMesh.cc.

355{
357 for(temp = list; temp != NULL; temp = temp->next)
358 {
360 }
361}
void bezierPatchMeshPrint(bezierPatchMesh *bpm)

◆ bezierPatchMeshListReverse()

bezierPatchMesh * bezierPatchMeshListReverse ( bezierPatchMesh list)

Definition at line 85 of file bezierPatchMesh.cc.

86{
89 bezierPatchMesh* nextone;
90 for(temp = list; temp != NULL; temp = nextone)
91 {
92 nextone = temp->next;
94 }
95 return ret;
96}
bezierPatchMesh * bezierPatchMeshListInsert(bezierPatchMesh *list, bezierPatchMesh *bpm)
int ret

◆ bezierPatchMeshListTotalStrips()

int bezierPatchMeshListTotalStrips ( bezierPatchMesh list)

Definition at line 363 of file bezierPatchMesh.cc.

364{
365 int sum=0;
367 for(temp=list; temp != NULL; temp = temp->next)
368 {
369 sum += temp->index_length_array;
370 }
371 return sum;
372}

Referenced by bezierPatchMeshListCollect().

◆ bezierPatchMeshListTotalVert()

int bezierPatchMeshListTotalVert ( bezierPatchMesh list)

Definition at line 374 of file bezierPatchMesh.cc.

375{
376 int sum=0;
378 for(temp=list; temp != NULL; temp = temp->next)
379 {
380 sum += temp->index_UVarray;
381 }
382 return sum/2;
383}

Referenced by bezierPatchMeshListCollect().

◆ bezierPatchMeshMake()

bezierPatchMesh * bezierPatchMeshMake ( int  maptype,
float  umin,
float  umax,
int  ustride,
int  uorder,
float  vmin,
float  vmax,
int  vstride,
int  vorder,
float ctlpoints,
int  size_UVarray,
int  size_length_array 
)

Definition at line 100 of file bezierPatchMesh.cc.

101{
102 int i,j,k;
103 int dimension;
104 int the_ustride;
105 int the_vstride;
106
107 if(maptype == GL_MAP2_VERTEX_3) dimension = 3;
108 else if (maptype==GL_MAP2_VERTEX_4) dimension = 4;
109 else {
110 fprintf(stderr, "error in inMap2f, maptype=%i is wrong, maptype,map is invalid\n", maptype);
111 return NULL;
112 }
113
115 assert(ret);
116
117 ret->bpatch_normal = NULL;
118 ret->bpatch_color = NULL;
119 ret->bpatch_texcoord = NULL;
120 ret->bpatch = bezierPatchMake(umin, vmin, umax, vmax, uorder, vorder, dimension);
121
122 /*copy the control points there*/
123 the_ustride = vorder * dimension;
124 the_vstride = dimension;
125 for(i=0; i<uorder; i++)
126 for(j=0; j<vorder; j++)
127 for(k=0; k<dimension; k++)
128 ret->bpatch->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
129
130
131 ret->size_UVarray = size_UVarray;
132 ret->size_length_array = size_length_array;
133 ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
134 assert(ret->UVarray);
135 ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
136 assert(ret->length_array);
137 ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
138 assert(ret->type_array);
139
140 ret->index_UVarray = 0;
141 ret->index_length_array = 0;
142
143 ret->vertex_array = NULL;
144 ret->normal_array = NULL;
145 ret->color_array = NULL;
146 ret->texcoord_array = NULL;
147
148 ret->next = NULL;
149 return ret;
150}
bezierPatch * bezierPatchMake(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension)
Definition: bezierPatch.cc:52
#define GL_MAP2_VERTEX_4
Definition: gl.h:568
#define GL_MAP2_VERTEX_3
Definition: gl.h:567
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)

◆ bezierPatchMeshMake2()

bezierPatchMesh * bezierPatchMeshMake2 ( int  size_UVarray,
int  size_length_array 
)

Definition at line 152 of file bezierPatchMesh.cc.

153{
155 assert(ret);
156
157 ret->bpatch = NULL;
158 ret->bpatch_normal = NULL;
159 ret->bpatch_color = NULL;
160 ret->bpatch_texcoord = NULL;
161
162 ret->size_UVarray = size_UVarray;
163 ret->size_length_array = size_length_array;
164 ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
165 assert(ret->UVarray);
166 ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
167 assert(ret->length_array);
168 ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
169 assert(ret->type_array);
170
171 ret->index_UVarray = 0;
172 ret->index_length_array = 0;
173
174 ret->vertex_array = NULL;
175 ret->normal_array = NULL;
176 ret->color_array = NULL;
177 ret->texcoord_array = NULL;
178
179 ret->next = NULL;
180 return ret;
181}

Referenced by OpenGLSurfaceEvaluator::map2f().

◆ bezierPatchMeshNumTriangles()

int bezierPatchMeshNumTriangles ( bezierPatchMesh bpm)

Definition at line 396 of file bezierPatchMesh.cc.

397{
398 int i;
399 int sum=0;
400 for(i=0; i<bpm->index_length_array; i++)
401 {
402 switch(bpm->type_array[i])
403 {
404 case GL_TRIANGLES:
405 sum += bpm->length_array[i]/3;
406 break;
407 case GL_TRIANGLE_FAN:
408 if(bpm->length_array[i] > 2)
409 sum += bpm->length_array[i]-2;
410 break;
412 if(bpm->length_array[i] > 2)
413 sum += bpm->length_array[i]-2;
414 break;
415 case GL_QUAD_STRIP:
416 if(bpm->length_array[i]>2)
417 sum += (bpm->length_array[i]-2);
418 break;
419 default:
420 fprintf(stderr,"error in bezierPatchMeshListNumTriangles, type invalid\n");
421 }
422 }
423 return sum;
424}
#define GL_TRIANGLE_FAN
Definition: gl.h:196
#define GL_TRIANGLES
Definition: gl.h:194
#define GL_TRIANGLE_STRIP
Definition: gl.h:195
#define GL_QUAD_STRIP
Definition: gl.h:198

Referenced by bezierPatchMeshListNumTriangles().

◆ bezierPatchMeshPrint()

void bezierPatchMeshPrint ( bezierPatchMesh bpm)

Definition at line 326 of file bezierPatchMesh.cc.

327{
328 int i;
329 printf("the bezier patch is\n");
331 printf("index_length_array= %i\n", bpm->index_length_array);
332 printf("size_length_array =%i\n", bpm->size_length_array);
333 printf("index_UVarray =%i\n", bpm->index_UVarray);
334 printf("size_UVarray =%i\n", bpm->size_UVarray);
335 printf("UVarray is\n");
336 for(i=0; i<bpm->index_UVarray; i++)
337 printf("%f ", bpm->UVarray[i]);
338
339 printf("length_array is\n");
340 for(i=0; i<bpm->index_length_array; i++)
341 printf("%i ", bpm->length_array[i]);
342 printf("\n");
343
344}
void bezierPatchPrint(bezierPatch *b)
Definition: bezierPatch.cc:126
#define printf
Definition: freeldr.h:93

Referenced by bezierPatchMeshListPrint().

◆ bezierPatchMeshPutPatch()

void bezierPatchMeshPutPatch ( bezierPatchMesh bpm,
int  maptype,
float  umin,
float  umax,
int  ustride,
int  uorder,
float  vmin,
float  vmax,
int  vstride,
int  vorder,
float ctlpoints 
)

Definition at line 183 of file bezierPatchMesh.cc.

184{
185 switch(maptype){
186 case GL_MAP2_VERTEX_3:
187 bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
188 break;
189 case GL_MAP2_VERTEX_4:
190 bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4,ustride, vstride, ctlpoints );
191 break;
192 case GL_MAP2_NORMAL:
193 bpm->bpatch_normal = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
194 break;
195 case GL_MAP2_INDEX:
196 bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
197 break;
198 case GL_MAP2_COLOR_4:
199 bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
200 break;
202 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
203 break;
205 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 2, ustride, vstride, ctlpoints);
206 break;
208 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
209 break;
211 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
212 break;
213 default:
214 fprintf(stderr, "error in bezierPatchMeshPutPatch, maptype=%i is wrong, maptype,map is invalid\n", maptype);
215 }
216}
bezierPatch * bezierPatchMake2(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension, int ustride, int vstride, float *ctlpoints)
Definition: bezierPatch.cc:71
#define GL_MAP2_NORMAL
Definition: gl.h:562
#define GL_MAP2_INDEX
Definition: gl.h:561
#define GL_MAP2_TEXTURE_COORD_2
Definition: gl.h:564
#define GL_MAP2_TEXTURE_COORD_4
Definition: gl.h:566
#define GL_MAP2_COLOR_4
Definition: gl.h:560
#define GL_MAP2_TEXTURE_COORD_1
Definition: gl.h:563
#define GL_MAP2_TEXTURE_COORD_3
Definition: gl.h:565

Referenced by OpenGLSurfaceEvaluator::map2f().

◆ drawStrips()

void drawStrips ( float vertex_array,
float normal_array,
int length_array,
GLenum type_array,
int  num_strips 
)

Definition at line 48 of file bezierPatchMesh.cc.

49{
50 int i,j,k;
51 k=0;
52 /*k is the index of the first component of the current vertex*/
53 for(i=0; i<num_strips; i++)
54 {
55 glBegin(type_array[i]);
56 for(j=0; j<length_array[i]; j++)
57 {
58 glNormal3fv(normal_array+k);
59 glVertex3fv(vertex_array+k);
60 k += 3;
61 }
62 glEnd();
63 }
64}