-/* $Id: tess.c,v 1.2 1999/09/10 02:03:31 gareth Exp $ */
+/* $Id: tess.c,v 1.3 1999/09/10 04:32:10 gareth Exp $ */
/*
* Mesa 3-D graphics library
*****************************************************************************/
void GLAPIENTRY gluDeleteTess( GLUtesselator *tobj )
{
- DEBUGP(2, ("-> gluDeleteTess(tobj: %p)\n", tobj));
-
if ( tobj->error == GLU_NO_ERROR && ( tobj->contour_count > 0 ) )
{
- /* Was gluEndContour called? */
- tess_error_callback( tobj, GLU_TESS_ERROR4, NULL );
+ /* Was gluEndPolygon called? */
+ tess_error_callback( tobj, GLU_TESS_ERROR3, NULL );
}
/* Delete all internal structures */
tess_cleanup( tobj );
free( tobj );
-
- DEBUGP(2, ("<- gluDeleteTess()\n\n"));
}
*****************************************************************************/
void GLAPIENTRY gluTessBeginPolygon( GLUtesselator *tobj, void *polygon_data )
{
- DEBUGP(2, ("-> gluTessBeginPolygon(tobj: %p, data: %p)\n",
- tobj, polygon_data));
-
tobj->error = GLU_NO_ERROR;
if ( tobj->current_contour != NULL )
{
/* gluEndPolygon was not called */
- tess_error_callback( tobj, GLU_TESS_ERROR1, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR3, NULL );
tess_cleanup( tobj );
}
-
- DEBUGP(2, ("<- gluTessBeginPolygon(tobj: %p)\n\n", tobj));
}
*****************************************************************************/
void GLAPIENTRY gluTessBeginContour( GLUtesselator *tobj )
{
- DEBUGP(2, (" -> gluTessBeginContour(tobj: %p)\n", tobj));
TESS_CHECK_ERRORS( tobj );
if ( tobj->current_contour != NULL )
{
- tess_error_callback( tobj, GLU_TESS_ERROR2, NULL );
+ /* gluTessEndContour was not called. */
+ tess_error_callback( tobj, GLU_TESS_ERROR4, NULL );
return;
}
tobj->current_contour->maxs );
cleanup:
- DEBUGP(2, (" <- gluTessBeginContour(tobj: %p)\n\n", tobj));
return;
}
tess_contour_t *current = tobj->current_contour;
tess_vertex_t *last_vertex;
- DEBUGP(2, (" -> gluTessVertex(tobj: %p, (%.2f, %.2f, %.2f))\n",
- tobj, coords[X], coords[Y], coords[Z]));
TESS_CHECK_ERRORS( tobj );
- if ( current == NULL ) {
+ if ( current == NULL )
+ {
+ /* gluTessBeginContour was not called. */
tess_error_callback( tobj, GLU_TESS_ERROR2, NULL );
return;
}
current->last_vertex = vertex;
}
- DEBUGP(3, ("\t vertex: (%.2f, %.2f, %.2f)\n",
- current->last_vertex->coords[X],
- current->last_vertex->coords[Y],
- current->last_vertex->coords[Z]));
cleanup:
- DEBUGP(2, (" <- gluTessVertex(tobj: %p)\n", tobj));
return;
}
*****************************************************************************/
void GLAPIENTRY gluTessEndContour( GLUtesselator *tobj )
{
- DEBUGIF(2) fprintf( stderr, "\n" ); DEBUGENDIF;
- DEBUGP(2, (" -> gluTessEndContour(tobj: %p)\n", tobj));
-
TESS_CHECK_ERRORS( tobj );
- if ( tobj->current_contour == NULL ) {
+ if ( tobj->current_contour == NULL )
+ {
+ /* gluTessBeginContour was not called. */
tess_error_callback( tobj, GLU_TESS_ERROR2, NULL );
return;
}
}
cleanup:
- DEBUGP(2, (" <- gluTessEndContour(tobj: %p)\n\n", tobj));
return;
}
*****************************************************************************/
void GLAPIENTRY gluTessEndPolygon( GLUtesselator *tobj )
{
- DEBUGP(2, ("-> gluTessEndPolygon(tobj: %p)\n", tobj));
TESS_CHECK_ERRORS( tobj );
- /*
- * Ensure gluTessBeginPolygon was called, otherwise we can't do anything.
- */
- if ( tobj->current_contour != NULL ) {
- tess_error_callback( tobj, GLU_TESS_ERROR2, NULL );
+ if ( tobj->current_contour != NULL )
+ {
+ /* gluTessBeginPolygon was not called. */
+ tess_error_callback( tobj, GLU_TESS_ERROR1, NULL );
return;
}
TESS_CHECK_ERRORS( tobj );
*/
if ( tobj->contour_count == 0 )
{
- DEBUGP(2, (" contour count: 0\n"));
-
tess_cleanup( tobj );
return;
}
cleanup:
delete_all_contours( tobj );
-
- DEBUGP(2, ("<- gluTessEndPolygon(tobj: %p)\n\n", tobj));
}
*****************************************************************************/
static void tess_cleanup( GLUtesselator *tobj )
{
- DEBUGP(3, (" -> tess_cleanup(tobj: %p)\n", tobj));
-
if ( tobj->current_contour != NULL )
{
delete_current_contour( tobj );
{
delete_all_contours( tobj );
}
-
- DEBUGP(3, (" <- tess_cleanup(tobj: %p)\n", tobj));
}
{
tess_contour_t *current = tobj->current_contour;
- DEBUGP(3, (" -> inspect_current_contour(tobj: %p)\n", tobj));
-
if ( current->vertex_count < 3 )
{
delete_current_contour( tobj );
if ( save_current_contour( tobj ) == GLU_ERROR ) {
return;
}
-
- DEBUGP(3, (" <- inspect_current_contour(tobj: %p)\n", tobj));
}
/*****************************************************************************
tess_vertex_t *va, *vb, *vc;
GLdouble a[3], b[3], c[3];
- DEBUGP(3, (" -> find_normal(tobj: %p)\n", tobj));
-
if ( contour == NULL ) { return GLU_ERROR; }
va = contour->vertices;
CROSS3( c, a, b );
- if ( ( fabs( c[X] ) > EQUAL_EPSILON ) ||
- ( fabs( c[Y] ) > EQUAL_EPSILON ) ||
- ( fabs( c[Z] ) > EQUAL_EPSILON ) )
+ if ( ( ABSD( c[X] ) > EQUAL_EPSILON ) ||
+ ( ABSD( c[Y] ) > EQUAL_EPSILON ) ||
+ ( ABSD( c[Z] ) > EQUAL_EPSILON ) )
{
COPY_3V( contour->plane.normal, c );
NORMALIZE_3DV( contour->plane.normal );
contour->plane.dist = - DOT3( contour->plane.normal, va->coords );
- DEBUGP(3, (" <- find_normal(tobj: %p) (%.2f, %.2f, %.2f)\n",
- tobj, contour->plane.normal[X],
- contour->plane.normal[Y], contour->plane.normal[Z]));
return GLU_NO_ERROR;
}
- else
- {
- DEBUGP(3, (" *** skipping colinear points...\n"));
- }
}
tess_error_callback( tobj, GLU_TESS_ERROR7, NULL );
- DEBUGP(3, (" <- find_normal(tobj: %p) ERROR\n", tobj));
return GLU_ERROR;
}
/*****************************************************************************
* project_current_contour
*****************************************************************************/
-static GLdouble twice_contour_area( tess_vertex_t *vertex,
- tess_vertex_t *last_vertex );
+static GLdouble twice_contour_area( tess_vertex_t *vertex,
+ tess_vertex_t *last_vertex );
static void project_current_contour( GLUtesselator *tobj )
{
GLdouble dot, rotx, roty;
GLuint i;
- DEBUGP(3, (" -> project_current_contour(tobj: %p)\n", tobj));
-
if ( current == NULL ) { return; }
- DEBUGP(3, (" normal: (%.2f, %.2f, %.2f) dist: %.2f n: %u\n",
- current->plane.normal[X], current->plane.normal[Y],
- current->plane.normal[Z], current->plane.dist,
- current->vertex_count));
-
/* Rotate the plane normal around the y-axis. */
znormal[X] = current->plane.normal[X];
ACC_BBOX_2V( vertex->v, tobj->mins, tobj->maxs );
ACC_BBOX_2V( vertex->v, current->mins, current->maxs );
-
- DEBUGP(3, (" v %d: (%.2f, %.2f, %.2f) -> (%.2f, %.2f)\n",
- i, vertex->coords[X], vertex->coords[Y],
- vertex->coords[Z], vertex->v[X], vertex->v[Y]));
}
area = twice_contour_area( current->vertices,
current->orientation = GLU_CW;
current->area = -area;
}
-
- DEBUGP(3, (" <- project_current_contour(tobj: %p)\n", tobj));
}
/*****************************************************************************
tess_vertex_t *vertex;
GLuint i;
- DEBUGP(3, (" -> save_current_contour(tobj: %p)\n", tobj));
-
if ( current == NULL ) { return GLU_ERROR; }
if ( tobj->contours == NULL )
tobj->contour_count++;
tobj->current_contour = NULL;
- DEBUGP(3, (" <- save_current_contour()\n"));
return GLU_NO_ERROR;
}
tess_vertex_t *vertex, *next;
GLuint i;
- DEBUGP(3, (" -> delete_current_contour(contour: %p)\n", current));
-
if ( current == NULL ) { return; }
for ( vertex = current->vertices, i = 0; i < current->vertex_count; i++)
free( current );
tobj->current_contour = NULL;
-
- DEBUGP(3, (" <- delete_current_contour()\n"));
}
/*****************************************************************************
tess_vertex_t *vertex, *next_vertex;
GLuint i;
- DEBUGP(3, (" -> delete_all_contours(tobj: %p)\n", tobj));
-
if ( current != NULL )
{
delete_current_contour( tobj );
ZERO_3V( tobj->plane.normal );
tobj->plane.dist = 0.0;
-
- DEBUGP(3, (" <- delete_all_contours(tobj: %p)\n", tobj));
}