mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 10:10:09 +01:00
SGI SI GLU library
This commit is contained in:
parent
24fab8e250
commit
77cc447b96
193 changed files with 57748 additions and 0 deletions
157
src/glu/sgi/Makefile.X11
Normal file
157
src/glu/sgi/Makefile.X11
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
# $Id: Makefile.X11,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
|
||||
# Mesa 3-D graphics library
|
||||
# Version: 3.5
|
||||
# Copyright (C) 1995-2001 Brian Paul
|
||||
|
||||
# Makefile for SGI SI GLU library
|
||||
|
||||
|
||||
##### MACROS #####
|
||||
|
||||
GLU_MAJOR = 1
|
||||
GLU_MINOR = 3
|
||||
GLU_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
|
||||
|
||||
VPATH = RCS
|
||||
|
||||
INCDIRS = -I../include -Iinclude -Iinternals -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess
|
||||
LIBDIR = ../lib
|
||||
|
||||
C_SOURCES = \
|
||||
libutil/error.c \
|
||||
libutil/glue.c \
|
||||
libutil/mipmap.c \
|
||||
libutil/project.c \
|
||||
libutil/quad.c \
|
||||
libutil/registry.c \
|
||||
libtess/dict.c \
|
||||
libtess/geom.c \
|
||||
libtess/memalloc.c \
|
||||
libtess/mesh.c \
|
||||
libtess/normal.c \
|
||||
libtess/priorityq.c \
|
||||
libtess/render.c \
|
||||
libtess/sweep.c \
|
||||
libtess/tess.c \
|
||||
libtess/tessmono.c
|
||||
|
||||
CC_SOURCES = \
|
||||
libnurbs/interface/bezierEval.cc \
|
||||
libnurbs/interface/bezierPatch.cc \
|
||||
libnurbs/interface/bezierPatchMesh.cc \
|
||||
libnurbs/interface/glcurveval.cc \
|
||||
libnurbs/interface/glinterface.cc \
|
||||
libnurbs/interface/glrenderer.cc \
|
||||
libnurbs/interface/glsurfeval.cc \
|
||||
libnurbs/interface/incurveeval.cc \
|
||||
libnurbs/interface/insurfeval.cc \
|
||||
libnurbs/internals/arc.cc \
|
||||
libnurbs/internals/arcsorter.cc \
|
||||
libnurbs/internals/arctess.cc \
|
||||
libnurbs/internals/backend.cc \
|
||||
libnurbs/internals/basiccrveval.cc \
|
||||
libnurbs/internals/basicsurfeval.cc \
|
||||
libnurbs/internals/bin.cc \
|
||||
libnurbs/internals/bufpool.cc \
|
||||
libnurbs/internals/cachingeval.cc \
|
||||
libnurbs/internals/ccw.cc \
|
||||
libnurbs/internals/coveandtiler.cc \
|
||||
libnurbs/internals/curve.cc \
|
||||
libnurbs/internals/curvelist.cc \
|
||||
libnurbs/internals/curvesub.cc \
|
||||
libnurbs/internals/dataTransform.cc \
|
||||
libnurbs/internals/displaylist.cc \
|
||||
libnurbs/internals/flist.cc \
|
||||
libnurbs/internals/flistsorter.cc \
|
||||
libnurbs/internals/hull.cc \
|
||||
libnurbs/internals/intersect.cc \
|
||||
libnurbs/internals/knotvector.cc \
|
||||
libnurbs/internals/mapdesc.cc \
|
||||
libnurbs/internals/mapdescv.cc \
|
||||
libnurbs/internals/maplist.cc \
|
||||
libnurbs/internals/mesher.cc \
|
||||
libnurbs/internals/monoTriangulationBackend.cc \
|
||||
libnurbs/internals/monotonizer.cc \
|
||||
libnurbs/internals/mycode.cc \
|
||||
libnurbs/internals/nurbsinterfac.cc \
|
||||
libnurbs/internals/nurbstess.cc \
|
||||
libnurbs/internals/patch.cc \
|
||||
libnurbs/internals/patchlist.cc \
|
||||
libnurbs/internals/quilt.cc \
|
||||
libnurbs/internals/reader.cc \
|
||||
libnurbs/internals/renderhints.cc \
|
||||
libnurbs/internals/slicer.cc \
|
||||
libnurbs/internals/sorter.cc \
|
||||
libnurbs/internals/splitarcs.cc \
|
||||
libnurbs/internals/subdivider.cc \
|
||||
libnurbs/internals/tobezier.cc \
|
||||
libnurbs/internals/trimline.cc \
|
||||
libnurbs/internals/trimregion.cc \
|
||||
libnurbs/internals/trimvertpool.cc \
|
||||
libnurbs/internals/uarray.cc \
|
||||
libnurbs/internals/varray.cc \
|
||||
libnurbs/nurbtess/directedLine.cc \
|
||||
libnurbs/nurbtess/gridWrap.cc \
|
||||
libnurbs/nurbtess/monoChain.cc \
|
||||
libnurbs/nurbtess/monoPolyPart.cc \
|
||||
libnurbs/nurbtess/monoTriangulation.cc \
|
||||
libnurbs/nurbtess/partitionX.cc \
|
||||
libnurbs/nurbtess/partitionY.cc \
|
||||
libnurbs/nurbtess/polyDBG.cc \
|
||||
libnurbs/nurbtess/polyUtil.cc \
|
||||
libnurbs/nurbtess/primitiveStream.cc \
|
||||
libnurbs/nurbtess/quicksort.cc \
|
||||
libnurbs/nurbtess/rectBlock.cc \
|
||||
libnurbs/nurbtess/sampleComp.cc \
|
||||
libnurbs/nurbtess/sampleCompBot.cc \
|
||||
libnurbs/nurbtess/sampleCompRight.cc \
|
||||
libnurbs/nurbtess/sampleCompTop.cc \
|
||||
libnurbs/nurbtess/sampleMonoPoly.cc \
|
||||
libnurbs/nurbtess/sampledLine.cc \
|
||||
libnurbs/nurbtess/searchTree.cc
|
||||
|
||||
SOURCES = $(C_SOURCES) $(CC_SOURCES)
|
||||
|
||||
C_OBJECTS = $(C_SOURCES:.c=.o)
|
||||
CC_OBJECTS = $(CC_SOURCES:.cc=.o)
|
||||
OBJECTS = $(C_OBJECTS) $(CC_OBJECTS)
|
||||
|
||||
|
||||
##### RULES #####
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCDIRS) $(CFLAGS) -DLIBRARYBUILD $< -o $@
|
||||
|
||||
.cc.o:
|
||||
$(CPLUSPLUS) -c $(INCDIRS) $(CCFLAGS) -DLIBRARYBUILD $< -o $@
|
||||
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
default:
|
||||
@echo "Specify a target configuration"
|
||||
|
||||
clean:
|
||||
-rm *.o */*.o */*/*.o
|
||||
|
||||
targets: $(LIBDIR)/$(GLU_LIB)
|
||||
|
||||
# Make the library:
|
||||
$(LIBDIR)/$(GLU_LIB): $(OBJECTS)
|
||||
$(MAKELIB) $(GLU_LIB) $(GLU_MAJOR) $(GLU_MINOR) $(GLU_TINY) $(OBJECTS)
|
||||
mv $(GLU_LIB)* $(LIBDIR)
|
||||
|
||||
include ../Make-config
|
||||
|
||||
include depend
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Run 'make depend' to update the dependencies if you change what's included
|
||||
# by any source file.
|
||||
#
|
||||
dep: $(SOURCES)
|
||||
makedepend -fdepend -Y -I../include $(SOURCES)
|
||||
25
src/glu/sgi/include/gluos.h
Normal file
25
src/glu/sgi/include/gluos.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
** gluos.h - operating system dependencies for GLU
|
||||
**
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/include/gluos.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOGDI
|
||||
#define NOIME
|
||||
#include <windows.h>
|
||||
|
||||
/* Disable warnings */
|
||||
#pragma warning(disable : 4101)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4761)
|
||||
|
||||
#else
|
||||
|
||||
/* Disable Microsoft-specific keywords */
|
||||
#define GLAPIENTRY
|
||||
#define WINGDIAPI
|
||||
|
||||
#endif
|
||||
256
src/glu/sgi/libnurbs/interface/bezierEval.cc
Normal file
256
src/glu/sgi/libnurbs/interface/bezierEval.cc
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierEval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "bezierEval.h"
|
||||
|
||||
#define TOLERANCE 0.0001
|
||||
|
||||
#ifndef MAX_ORDER
|
||||
#define MAX_ORDER 16
|
||||
#endif
|
||||
|
||||
#ifndef MAX_DIMENSION
|
||||
#define MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
static void normalize(float vec[3]);
|
||||
static void crossProduct(float x[3], float y[3], float ret[3]);
|
||||
static void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
|
||||
|
||||
static float binomialCoefficients[8][8] = {
|
||||
{1,0,0,0,0,0,0,0},
|
||||
{1,1,0,0,0,0,0,0},
|
||||
{1,2,1,0,0,0,0,0},
|
||||
{1,3,3,1,0,0,0,0},
|
||||
{1,4,6,4,1,0,0,0},
|
||||
{1,5,10,10,5,1,0,0},
|
||||
{1,6,15,20,15,6,1,0},
|
||||
{1,7,21,35,35,21,7,1}
|
||||
};
|
||||
|
||||
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
|
||||
{
|
||||
float uprime = (u-u0)/(u1-u0);
|
||||
float *ctlptr = ctlpoints;
|
||||
float oneMinusX = 1.0-uprime;
|
||||
float XPower = 1.0;
|
||||
|
||||
int i,k;
|
||||
for(k=0; k<dimension; k++)
|
||||
retpoint[k] = (*(ctlptr + k));
|
||||
|
||||
for(i=1; i<order; i++){
|
||||
ctlptr += stride;
|
||||
XPower *= uprime;
|
||||
for(k=0; k<dimension; k++) {
|
||||
retpoint[k] = retpoint[k]*oneMinusX + ctlptr[k]* binomialCoefficients[order-1][i] * XPower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*order = degree +1 >=1.
|
||||
*/
|
||||
void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
|
||||
{
|
||||
float uprime = (u-u0)/(u1-u0);
|
||||
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
|
||||
float* ctlptr = ctlpoints;
|
||||
int r, i,j;
|
||||
for(i=0; i<order; i++) {
|
||||
for(j=0; j<dimension; j++)
|
||||
buf[0][i][j] = ctlptr[j];
|
||||
ctlptr += stride;
|
||||
}
|
||||
for(r=1; r<order; r++){
|
||||
for(i=0; i<order-r; i++) {
|
||||
for(j=0; j<dimension; j++)
|
||||
buf[r][i][j] = (1-uprime)*buf[r-1][i][j] + uprime*buf[r-1][i+1][j];
|
||||
}
|
||||
}
|
||||
|
||||
for(j=0; j<dimension; j++)
|
||||
retpoint[j] = buf[order-1][0][j];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*order = degree +1 >=1.
|
||||
*/
|
||||
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
|
||||
{
|
||||
int i,k;
|
||||
float width = u1-u0;
|
||||
float *ctlptr = ctlpoints;
|
||||
|
||||
float buf[MAX_ORDER][MAX_DIMENSION];
|
||||
if(order == 1){
|
||||
for(k=0; k<dimension; k++)
|
||||
retDer[k]=0;
|
||||
}
|
||||
for(i=0; i<order-1; i++){
|
||||
for(k=0; k<dimension; k++) {
|
||||
buf[i][k] = (ctlptr[stride+k] - ctlptr[k])*(order-1)/width;
|
||||
}
|
||||
ctlptr += stride;
|
||||
}
|
||||
|
||||
bezierCurveEval(u0, u1, order-1, (float*) buf, MAX_DIMENSION, dimension, u, retDer);
|
||||
}
|
||||
|
||||
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
|
||||
{
|
||||
int i,k,r;
|
||||
float *ctlptr = ctlpoints;
|
||||
float width=u1-u0;
|
||||
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
|
||||
if(der<0) der=0;
|
||||
for(i=0; i<order; i++){
|
||||
for(k=0; k<dimension; k++){
|
||||
buf[0][i][k] = ctlptr[k];
|
||||
}
|
||||
ctlptr += stride;
|
||||
}
|
||||
|
||||
|
||||
for(r=1; r<=der; r++){
|
||||
for(i=0; i<order-r; i++){
|
||||
for(k=0; k<dimension; k++){
|
||||
buf[r][i][k] = (buf[r-1][i+1][k] - buf[r-1][i][k])*(order-r)/width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bezierCurveEval(u0, u1, order-der, (float *) (buf[der]), MAX_DIMENSION, dimension, u, retDer);
|
||||
}
|
||||
|
||||
/*the Bezier bivarite polynomial is:
|
||||
* sum[i:0,uorder-1][j:0,vorder-1] { ctlpoints[i*ustride+j*vstride] * B(i)*B(j)
|
||||
* where B(i) and B(j) are basis functions
|
||||
*/
|
||||
void bezierSurfEvalDerGen(int uder, int vder, 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[])
|
||||
{
|
||||
int i,j,k;
|
||||
float newPoints[MAX_ORDER][MAX_DIMENSION];
|
||||
|
||||
for(i=0; i<uorder; i++){
|
||||
|
||||
bezierCurveEvalDerGen(vder, v0, v1, vorder, ctlpoints+ustride*i, vstride, dimension, v, newPoints[i]);
|
||||
|
||||
}
|
||||
|
||||
bezierCurveEvalDerGen(uder, u0, u1, uorder, (float *) newPoints, MAX_DIMENSION, dimension, u, ret);
|
||||
}
|
||||
|
||||
|
||||
/*division by w is performed*/
|
||||
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[])
|
||||
{
|
||||
bezierSurfEvalDerGen(0, 0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, ret);
|
||||
if(dimension == 4) /*homogeneous*/{
|
||||
ret[0] /= ret[3];
|
||||
ret[1] /= ret[3];
|
||||
ret[2] /= ret[3];
|
||||
}
|
||||
}
|
||||
|
||||
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[])
|
||||
{
|
||||
float partialU[4];
|
||||
float partialV[4];
|
||||
assert(dimension>=3 && dimension <=4);
|
||||
bezierSurfEvalDerGen(1,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialU);
|
||||
bezierSurfEvalDerGen(0,1, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialV);
|
||||
|
||||
if(dimension == 3){/*inhomogeneous*/
|
||||
crossProduct(partialU, partialV, retNormal);
|
||||
|
||||
normalize(retNormal);
|
||||
|
||||
return;
|
||||
}
|
||||
else { /*homogeneous*/
|
||||
float val[4]; /*the point coordinates (without derivative)*/
|
||||
float newPartialU[MAX_DIMENSION];
|
||||
float newPartialV[MAX_DIMENSION];
|
||||
int i;
|
||||
bezierSurfEvalDerGen(0,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, val);
|
||||
|
||||
for(i=0; i<=2; i++){
|
||||
newPartialU[i] = partialU[i] * val[3] - val[i] * partialU[3];
|
||||
newPartialV[i] = partialV[i] * val[3] - val[i] * partialV[3];
|
||||
}
|
||||
crossProduct(newPartialU, newPartialV, retNormal);
|
||||
normalize(retNormal);
|
||||
}
|
||||
}
|
||||
|
||||
/*if size is 0, then nothing is done*/
|
||||
static void normalize(float vec[3])
|
||||
{
|
||||
float size = sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
|
||||
|
||||
if(size < TOLERANCE)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Warning: in oglBSpline.c normal is 0\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else {
|
||||
vec[0] = vec[0]/size;
|
||||
vec[1] = vec[1]/size;
|
||||
vec[2] = vec[2]/size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void crossProduct(float x[3], float y[3], float ret[3])
|
||||
{
|
||||
ret[0] = x[1]*y[2] - y[1]*x[2];
|
||||
ret[1] = x[2]*y[0] - y[2]*x[0];
|
||||
ret[2] = x[0]*y[1] - y[0]*x[1];
|
||||
|
||||
}
|
||||
|
||||
55
src/glu/sgi/libnurbs/interface/bezierEval.h
Normal file
55
src/glu/sgi/libnurbs/interface/bezierEval.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierEval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _BEZIEREVAL_H
|
||||
#define _BEZIEREVAL_H
|
||||
|
||||
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
|
||||
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
|
||||
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
|
||||
|
||||
|
||||
void bezierSurfEvalDerGen(int uder, int vder, 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[]);
|
||||
|
||||
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[]);
|
||||
|
||||
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[]);
|
||||
|
||||
|
||||
#endif
|
||||
205
src/glu/sgi/libnurbs/interface/bezierPatch.cc
Normal file
205
src/glu/sgi/libnurbs/interface/bezierPatch.cc
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatch.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <GL/glu.h> /*for drawing bzier patch*/
|
||||
#include "bezierPatch.h"
|
||||
#include "bezierEval.h"
|
||||
|
||||
/*
|
||||
*allocate an instance of bezierPatch. The control points are unknown. But
|
||||
*the space of this array is allocated with size of
|
||||
* uorder*vorder*dimension
|
||||
*
|
||||
*/
|
||||
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension)
|
||||
{
|
||||
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
|
||||
assert(ret);
|
||||
ret->umin = umin;
|
||||
ret->vmin = vmin;
|
||||
ret->umax = umax;
|
||||
ret->vmax = vmax;
|
||||
ret->uorder = uorder;
|
||||
ret->vorder = vorder;
|
||||
ret->dimension = dimension;
|
||||
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
|
||||
assert(ret->ctlpoints);
|
||||
|
||||
ret->next = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension, int ustride, int vstride, float* ctlpoints)
|
||||
{
|
||||
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
|
||||
assert(ret);
|
||||
ret->umin = umin;
|
||||
ret->vmin = vmin;
|
||||
ret->umax = umax;
|
||||
ret->vmax = vmax;
|
||||
ret->uorder = uorder;
|
||||
ret->vorder = vorder;
|
||||
ret->dimension = dimension;
|
||||
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
|
||||
assert(ret->ctlpoints);
|
||||
|
||||
/*copy the control points there*/
|
||||
int the_ustride = vorder * dimension;
|
||||
int the_vstride = dimension;
|
||||
for(int i=0; i<uorder; i++)
|
||||
for(int j=0; j<vorder; j++)
|
||||
for(int k=0; k<dimension; k++)
|
||||
ret->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
|
||||
|
||||
ret->next = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*deallocate the space as allocated by Make
|
||||
*/
|
||||
void bezierPatchDelete(bezierPatch *b)
|
||||
{
|
||||
free(b->ctlpoints);
|
||||
free(b);
|
||||
}
|
||||
|
||||
/*delete the whole linked list
|
||||
*/
|
||||
void bezierPatchDeleteList(bezierPatch *b)
|
||||
{
|
||||
bezierPatch *temp;
|
||||
for(temp = b; temp != NULL; temp = temp->next)
|
||||
bezierPatchDelete(temp);
|
||||
}
|
||||
|
||||
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b)
|
||||
{
|
||||
b->next = list;
|
||||
return b;
|
||||
}
|
||||
|
||||
/*print the data stored in this patch*/
|
||||
void bezierPatchPrint(bezierPatch *b)
|
||||
{
|
||||
printf("bezierPatch:\n");
|
||||
printf("umin,umax=(%f,%f), (vmin, vmax)=(%f,%f)\n", b->umin, b->umax, b->vmin, b->vmax);
|
||||
printf("uorder=%i, vorder=%i\n", b->uorder, b->vorder);
|
||||
printf("idmension = %i\n", b->dimension);
|
||||
}
|
||||
|
||||
/*print the whole list*/
|
||||
void bezierPatchPrintList(bezierPatch *list)
|
||||
{
|
||||
bezierPatch* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
bezierPatchPrint(temp);
|
||||
}
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[])
|
||||
{
|
||||
if( u >= b->umin && u<= b->umax
|
||||
&& v >= b->vmin && v<= b->vmax)
|
||||
{
|
||||
|
||||
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
}
|
||||
else if(b->next != NULL)
|
||||
bezierPatchEval(b->next, u,v, ret);
|
||||
else
|
||||
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
}
|
||||
|
||||
/*the returned normal is normlized
|
||||
*/
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[])
|
||||
{
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
if( u >= b->umin && u<= b->umax
|
||||
&& v >= b->vmin && v<= b->vmax)
|
||||
{
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
}
|
||||
else if(b->next != NULL)
|
||||
bezierPatchEvalNormal(b->next, u,v, ret);
|
||||
else
|
||||
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
|
||||
|
||||
}
|
||||
|
||||
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso)
|
||||
{
|
||||
if(bpatch->dimension == 3)
|
||||
glMap2f(GL_MAP2_VERTEX_3, bpatch->umin, bpatch->umax, 3*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
|
||||
else
|
||||
glMap2f(GL_MAP2_VERTEX_4, bpatch->umin, bpatch->umax, 4*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
|
||||
|
||||
glMapGrid2f(u_reso, bpatch->umin, bpatch->umax,
|
||||
v_reso, bpatch->vmin, bpatch->vmax);
|
||||
glEvalMesh2(GL_LINE, 0, u_reso, 0, v_reso);
|
||||
}
|
||||
|
||||
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso)
|
||||
{
|
||||
bezierPatch *temp;
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_MAP2_VERTEX_3);
|
||||
glEnable(GL_AUTO_NORMAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glColor3f(1,0,0);
|
||||
#ifdef DEBUG
|
||||
printf("mapmap\n");
|
||||
#endif
|
||||
|
||||
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
bezierPatchDraw(temp, u_reso, v_reso);
|
||||
}
|
||||
|
||||
|
||||
|
||||
111
src/glu/sgi/libnurbs/interface/bezierPatch.h
Normal file
111
src/glu/sgi/libnurbs/interface/bezierPatch.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatch.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _BEZIERPATCH_H
|
||||
#define _BEZIERPATCH_H
|
||||
|
||||
typedef struct bezierPatch{
|
||||
float umin, vmin, umax, vmax;
|
||||
int uorder; /*order= degree + 1*/
|
||||
int vorder;
|
||||
|
||||
/*
|
||||
*the control points are stored in a one dimensional array.
|
||||
*the surface is defined as:
|
||||
* s(u,v) = sum_{i,j} P(i,j) * B_i(u) * B_j(v).
|
||||
*where P(i,j) are the control points, B_i(.) are Bezier
|
||||
*basis functions.
|
||||
*Each control point can have dimension 3 or 4: (x,y,z,w).
|
||||
*The components of P(i,j) are stored in a one dimensional
|
||||
*array:
|
||||
* ctlpoints[]
|
||||
*in the order of:
|
||||
* P[0,0], P[0,1], ..., P[0,vorder-1],
|
||||
* P[1,0], P[1,1], ..., P[1,vorder-1],
|
||||
* ...
|
||||
* P[uorder-1,0], P[uorder-1,1], ..., P[uorder-1,vorder-1].
|
||||
*/
|
||||
int dimension;
|
||||
float* ctlpoints;
|
||||
|
||||
/*
|
||||
*in case we have to manage multiple bezierPatches.
|
||||
*/
|
||||
struct bezierPatch *next;
|
||||
|
||||
} bezierPatch;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension);
|
||||
|
||||
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension, int ustride, int vstride, float *ctlpoints);
|
||||
|
||||
|
||||
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b);
|
||||
|
||||
void bezierPatchDelete(bezierPatch *b);
|
||||
|
||||
void bezierPatchDeleteList(bezierPatch *b);
|
||||
|
||||
void bezierPatchPrint(bezierPatch *b);
|
||||
|
||||
void bezierPatchPrintList(bezierPatch *list);
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float retNormal[]);
|
||||
|
||||
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[]);
|
||||
|
||||
|
||||
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso);
|
||||
|
||||
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
613
src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc
Normal file
613
src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc
Normal file
|
|
@ -0,0 +1,613 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <GL/gl.h>
|
||||
#include "bezierEval.h"
|
||||
#include "bezierPatchMesh.h"
|
||||
|
||||
static int isDegenerate(float A[2], float B[2], float C[2]);
|
||||
|
||||
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips)
|
||||
{
|
||||
int i,j,k;
|
||||
k=0;
|
||||
/*k is the index of the first component of the current vertex*/
|
||||
for(i=0; i<num_strips; i++)
|
||||
{
|
||||
glBegin(type_array[i]);
|
||||
for(j=0; j<length_array[i]; j++)
|
||||
{
|
||||
glNormal3fv(normal_array+k);
|
||||
glVertex3fv(vertex_array+k);
|
||||
k += 3;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDelDeg(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshDelDeg(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDelete(bezierPatchMesh *list)
|
||||
{
|
||||
if(list == NULL) return;
|
||||
bezierPatchMeshListDelete(list->next);
|
||||
bezierPatchMeshDelete(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* ret=NULL;
|
||||
bezierPatchMesh* temp;
|
||||
bezierPatchMesh* nextone;
|
||||
for(temp = list; temp != NULL; temp = nextone)
|
||||
{
|
||||
nextone = temp->next;
|
||||
ret=bezierPatchMeshListInsert(ret, temp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*maptype is either GL_MAP2_VERTEX_3 or GL_MAP2_VERTEX_4
|
||||
*/
|
||||
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)
|
||||
{
|
||||
int i,j,k;
|
||||
int dimension;
|
||||
int the_ustride;
|
||||
int the_vstride;
|
||||
|
||||
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
|
||||
assert(ret);
|
||||
|
||||
ret->bpatch = NULL;
|
||||
ret->bpatch_normal = NULL;
|
||||
ret->bpatch_color = NULL;
|
||||
ret->bpatch_texcoord = NULL;
|
||||
|
||||
if(maptype == GL_MAP2_VERTEX_3) dimension = 3;
|
||||
else if (maptype==GL_MAP2_VERTEX_4) dimension = 4;
|
||||
else {
|
||||
fprintf(stderr, "error in inMap2f, maptype=%i is wrong, maptype,map is invalid\n", maptype);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret->bpatch = bezierPatchMake(umin, vmin, umax, vmax, uorder, vorder, dimension);
|
||||
/*copy the control points there*/
|
||||
the_ustride = vorder * dimension;
|
||||
the_vstride = dimension;
|
||||
for(i=0; i<uorder; i++)
|
||||
for(j=0; j<vorder; j++)
|
||||
for(k=0; k<dimension; k++)
|
||||
ret->bpatch->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
|
||||
|
||||
|
||||
ret->size_UVarray = size_UVarray;
|
||||
ret->size_length_array = size_length_array;
|
||||
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
|
||||
assert(ret->UVarray);
|
||||
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
|
||||
assert(ret->length_array);
|
||||
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
|
||||
assert(ret->type_array);
|
||||
|
||||
ret->index_UVarray = 0;
|
||||
ret->index_length_array = 0;
|
||||
|
||||
ret->vertex_array = NULL;
|
||||
ret->normal_array = NULL;
|
||||
ret->color_array = NULL;
|
||||
ret->texcoord_array = NULL;
|
||||
|
||||
ret->next = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array)
|
||||
{
|
||||
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
|
||||
assert(ret);
|
||||
|
||||
ret->bpatch = NULL;
|
||||
ret->bpatch_normal = NULL;
|
||||
ret->bpatch_color = NULL;
|
||||
ret->bpatch_texcoord = NULL;
|
||||
|
||||
ret->size_UVarray = size_UVarray;
|
||||
ret->size_length_array = size_length_array;
|
||||
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
|
||||
assert(ret->UVarray);
|
||||
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
|
||||
assert(ret->length_array);
|
||||
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
|
||||
assert(ret->type_array);
|
||||
|
||||
ret->index_UVarray = 0;
|
||||
ret->index_length_array = 0;
|
||||
|
||||
ret->vertex_array = NULL;
|
||||
ret->normal_array = NULL;
|
||||
ret->color_array = NULL;
|
||||
ret->texcoord_array = NULL;
|
||||
|
||||
ret->next = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints)
|
||||
{
|
||||
switch(maptype){
|
||||
case GL_MAP2_VERTEX_3:
|
||||
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_VERTEX_4:
|
||||
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4,ustride, vstride, ctlpoints );
|
||||
break;
|
||||
case GL_MAP2_NORMAL:
|
||||
bpm->bpatch_normal = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_INDEX:
|
||||
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_COLOR_4:
|
||||
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_1:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_2:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 2, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_3:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
case GL_MAP2_TEXTURE_COORD_4:
|
||||
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error in bezierPatchMeshPutPatch, maptype=%i is wrong, maptype,map is invalid\n", maptype);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*delete everything including the arrays. So if you want to output the
|
||||
*pointers of the arrays, you should not use this function to deallocate space.
|
||||
*you should dealocate manually
|
||||
*/
|
||||
void bezierPatchMeshDelete(bezierPatchMesh *bpm)
|
||||
{
|
||||
if(bpm->bpatch != NULL)
|
||||
bezierPatchDelete(bpm->bpatch);
|
||||
if(bpm->bpatch_normal != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_normal);
|
||||
if(bpm->bpatch_color != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_color);
|
||||
if(bpm->bpatch_texcoord != NULL)
|
||||
bezierPatchDelete(bpm->bpatch_texcoord);
|
||||
|
||||
free(bpm->UVarray);
|
||||
free(bpm->length_array);
|
||||
free(bpm->vertex_array);
|
||||
free(bpm->normal_array);
|
||||
free(bpm->type_array);
|
||||
free(bpm);
|
||||
}
|
||||
|
||||
/*begin a strip
|
||||
*type is the primitive type:
|
||||
*/
|
||||
void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type)
|
||||
{
|
||||
bpm->counter = 0;
|
||||
bpm->type = type;
|
||||
}
|
||||
|
||||
/*signal the end of the current strip*/
|
||||
void bezierPatchMeshEndStrip(bezierPatchMesh *bpm)
|
||||
{
|
||||
int i;
|
||||
|
||||
/*if there are no vertices in this strip, then nothing needs to be done*/
|
||||
if(bpm->counter == 0) return;
|
||||
|
||||
/*if the length_array is full, it should be expanded*/
|
||||
if(bpm->index_length_array >= bpm->size_length_array)
|
||||
{
|
||||
int *temp = (int*) malloc(sizeof(int) * (bpm->size_length_array*2 + 1));
|
||||
assert(temp);
|
||||
GLenum *temp_type = (GLenum*) malloc(sizeof(GLenum) * (bpm->size_length_array*2 + 1));
|
||||
assert(temp_type);
|
||||
/*update the size*/
|
||||
bpm->size_length_array = bpm->size_length_array*2 + 1;
|
||||
|
||||
/*copy*/
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
temp[i] = bpm->length_array[i];
|
||||
temp_type[i] = bpm->type_array[i];
|
||||
}
|
||||
|
||||
/*deallocate old array*/
|
||||
free(bpm->length_array);
|
||||
free(bpm->type_array);
|
||||
|
||||
/*point to the new array which is twice as bigger*/
|
||||
bpm->length_array = temp;
|
||||
bpm->type_array = temp_type;
|
||||
}
|
||||
bpm->type_array[bpm->index_length_array] = bpm->type;
|
||||
bpm->length_array[bpm->index_length_array++] = bpm->counter;
|
||||
|
||||
}
|
||||
|
||||
/*insert (u,v) */
|
||||
void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v)
|
||||
{
|
||||
int i;
|
||||
/*if the UVarray is full, it should be expanded*/
|
||||
if(bpm->index_UVarray+1 >= bpm->size_UVarray)
|
||||
{
|
||||
float *temp = (float*) malloc(sizeof(float) * (bpm->size_UVarray * 2 + 2));
|
||||
assert(temp);
|
||||
|
||||
/*update the size*/
|
||||
bpm->size_UVarray = bpm->size_UVarray*2 + 2;
|
||||
|
||||
/*copy*/
|
||||
for(i=0; i<bpm->index_UVarray; i++)
|
||||
{
|
||||
temp[i] = bpm->UVarray[i];
|
||||
}
|
||||
|
||||
/*deallocate old array*/
|
||||
free(bpm->UVarray);
|
||||
|
||||
/*pointing to the new arrays*/
|
||||
bpm->UVarray = temp;
|
||||
}
|
||||
/*insert the new UV*/
|
||||
bpm->UVarray[bpm->index_UVarray] = u;
|
||||
bpm->index_UVarray++;
|
||||
bpm->UVarray[bpm->index_UVarray] = v;
|
||||
bpm->index_UVarray++;
|
||||
|
||||
/*update counter: one more vertex*/
|
||||
bpm->counter++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void bezierPatchMeshPrint(bezierPatchMesh *bpm)
|
||||
{
|
||||
int i;
|
||||
printf("the bezier patch is\n");
|
||||
bezierPatchPrint(bpm->bpatch);
|
||||
printf("index_length_array= %i\n", bpm->index_length_array);
|
||||
printf("size_length_array =%i\n", bpm->size_length_array);
|
||||
printf("index_UVarray =%i\n", bpm->index_UVarray);
|
||||
printf("size_UVarray =%i\n", bpm->size_UVarray);
|
||||
printf("UVarray is\n");
|
||||
for(i=0; i<bpm->index_UVarray; i++)
|
||||
printf("%f ", bpm->UVarray[i]);
|
||||
|
||||
printf("length_array is\n");
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
printf("%i ", bpm->length_array[i]);
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
/*insert a new patch in front of the current linked list and return the new list*/
|
||||
bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm)
|
||||
{
|
||||
bpm->next=list;
|
||||
return bpm;
|
||||
}
|
||||
|
||||
/*print all the patches*/
|
||||
void bezierPatchMeshListPrint(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh *temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshPrint(temp);
|
||||
}
|
||||
}
|
||||
|
||||
int bezierPatchMeshListTotalStrips(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh *temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += temp->index_length_array;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int bezierPatchMeshListTotalVert(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh *temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += temp->index_UVarray;
|
||||
}
|
||||
return sum/2;
|
||||
}
|
||||
|
||||
int bezierPatchMeshListNumTriangles(bezierPatchMesh* list)
|
||||
{
|
||||
int sum=0;
|
||||
bezierPatchMesh* temp;
|
||||
for(temp=list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
sum += bezierPatchMeshNumTriangles(temp);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i;
|
||||
int sum=0;
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
switch(bpm->type_array[i])
|
||||
{
|
||||
case GL_TRIANGLES:
|
||||
sum += bpm->length_array[i]/3;
|
||||
break;
|
||||
case GL_TRIANGLE_FAN:
|
||||
if(bpm->length_array[i] > 2)
|
||||
sum += bpm->length_array[i]-2;
|
||||
break;
|
||||
case GL_TRIANGLE_STRIP:
|
||||
if(bpm->length_array[i] > 2)
|
||||
sum += bpm->length_array[i]-2;
|
||||
break;
|
||||
case GL_QUAD_STRIP:
|
||||
if(bpm->length_array[i]>2)
|
||||
sum += (bpm->length_array[i]-2);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"error in bezierPatchMeshListNumTriangles, type invalid\n");
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/*delete degenerate triangles*/
|
||||
void bezierPatchMeshDelDeg(bezierPatchMesh* bpm)
|
||||
{
|
||||
if(bpm == NULL) return;
|
||||
int i,j,k;
|
||||
int *new_length_array;
|
||||
GLenum *new_type_array;
|
||||
int index_new_length_array;
|
||||
float *new_UVarray;
|
||||
int index_new_UVarray;
|
||||
|
||||
new_length_array = (int*)malloc(sizeof(int) * bpm->index_length_array);
|
||||
assert(new_length_array);
|
||||
new_type_array = (GLenum*)malloc(sizeof(GLenum) * bpm->index_length_array);
|
||||
assert(new_length_array);
|
||||
new_UVarray = (float*) malloc(sizeof(float) * bpm->index_UVarray);
|
||||
assert(new_UVarray);
|
||||
|
||||
index_new_length_array = 0;
|
||||
index_new_UVarray=0;
|
||||
k=0;
|
||||
for(i=0; i<bpm->index_length_array; i++){
|
||||
|
||||
/*(if not degenerate, we have to copy*/
|
||||
if( (bpm->length_array[i] != 3) || (!isDegenerate(bpm->UVarray+k, bpm->UVarray+k+2, bpm->UVarray+k+4)))
|
||||
{
|
||||
for(j=0; j<2* bpm->length_array[i]; j++)
|
||||
new_UVarray[index_new_UVarray++] = bpm->UVarray[k++];
|
||||
|
||||
new_length_array[index_new_length_array] = bpm->length_array[i];
|
||||
new_type_array[index_new_length_array] = bpm->type_array[i];
|
||||
index_new_length_array++;
|
||||
}
|
||||
else
|
||||
{
|
||||
k += 6;
|
||||
}
|
||||
}
|
||||
free(bpm->UVarray);
|
||||
free(bpm->length_array);
|
||||
free(bpm->type_array);
|
||||
bpm->UVarray=new_UVarray;
|
||||
bpm->length_array=new_length_array;
|
||||
bpm->type_array=new_type_array;
|
||||
bpm->index_UVarray = index_new_UVarray;
|
||||
bpm->index_length_array = index_new_length_array;
|
||||
|
||||
}
|
||||
|
||||
/*(u,v) to XYZ
|
||||
*the xyz and normals are stored in vertex_array,
|
||||
*and normal_array. the spaces of both are allocated here
|
||||
*/
|
||||
void bezierPatchMeshEval(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i,j,k,l;
|
||||
float u,v;
|
||||
float u0 = bpm->bpatch->umin;
|
||||
float u1 = bpm->bpatch->umax;
|
||||
int uorder = bpm->bpatch->uorder;
|
||||
float v0 = bpm->bpatch->vmin;
|
||||
float v1 = bpm->bpatch->vmax;
|
||||
int vorder = bpm->bpatch->vorder;
|
||||
int dimension = bpm->bpatch->dimension;
|
||||
int ustride = dimension * vorder;
|
||||
int vstride = dimension;
|
||||
float *ctlpoints = bpm->bpatch->ctlpoints;
|
||||
|
||||
bpm->vertex_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
|
||||
assert(bpm->vertex_array);
|
||||
bpm->normal_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
|
||||
assert(bpm->normal_array);
|
||||
|
||||
k=0;
|
||||
l=0;
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
for(j=0; j<bpm->length_array[i]; j++)
|
||||
{
|
||||
u = bpm->UVarray[k];
|
||||
v = bpm->UVarray[k+1];
|
||||
bezierSurfEval(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->vertex_array+l);
|
||||
bezierSurfEvalNormal(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->normal_array+l);
|
||||
k += 2;
|
||||
l += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListEval(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshEval(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshDraw(bezierPatchMesh* bpm)
|
||||
{
|
||||
int i,j,k;
|
||||
k=0;
|
||||
/*k is the index of the first component of the current vertex*/
|
||||
for(i=0; i<bpm->index_length_array; i++)
|
||||
{
|
||||
glBegin(bpm->type_array[i]);
|
||||
for(j=0; j<bpm->length_array[i]; j++)
|
||||
{
|
||||
glNormal3fv(bpm->normal_array+k);
|
||||
glVertex3fv(bpm->vertex_array+k);
|
||||
k+= 3;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListDraw(bezierPatchMesh* list)
|
||||
{
|
||||
bezierPatchMesh* temp;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
bezierPatchMeshDraw(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips)
|
||||
{
|
||||
int i,j,k,l;
|
||||
bezierPatchMesh *temp;
|
||||
int total_num_vertices = bezierPatchMeshListTotalVert(list);
|
||||
(*vertex_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
|
||||
assert(*vertex_array);
|
||||
(*normal_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
|
||||
assert(*normal_array);
|
||||
|
||||
*num_strips = bezierPatchMeshListTotalStrips(list);
|
||||
|
||||
*length_array = (int*) malloc(sizeof(int) * (*num_strips));
|
||||
assert(*length_array);
|
||||
|
||||
*type_array = (GLenum*) malloc(sizeof(GLenum) * (*num_strips));
|
||||
assert(*type_array);
|
||||
|
||||
k=0;
|
||||
l=0;
|
||||
for(temp = list; temp != NULL; temp = temp->next)
|
||||
{
|
||||
int x=0;
|
||||
for(i=0; i<temp->index_length_array; i++)
|
||||
{
|
||||
for(j=0; j<temp->length_array[i]; j++)
|
||||
{
|
||||
(*vertex_array)[k] = temp->vertex_array[x];
|
||||
(*vertex_array)[k+1] = temp->vertex_array[x+1];
|
||||
(*vertex_array)[k+2] = temp->vertex_array[x+2];
|
||||
|
||||
(*normal_array)[k] = temp->normal_array[x];
|
||||
(*normal_array)[k+1] = temp->normal_array[x+1];
|
||||
(*normal_array)[k+2] = temp->normal_array[x+2];
|
||||
|
||||
x += 3;
|
||||
k += 3;
|
||||
}
|
||||
(*type_array)[l] = temp->type_array[i];
|
||||
(*length_array)[l++] = temp->length_array[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int isDegenerate(float A[2], float B[2], float C[2])
|
||||
{
|
||||
if( (A[0] == B[0] && A[1]==B[1]) ||
|
||||
(A[0] == C[0] && A[1]==C[1]) ||
|
||||
(B[0] == C[0] && B[1]==C[1])
|
||||
)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
127
src/glu/sgi/libnurbs/interface/bezierPatchMesh.h
Normal file
127
src/glu/sgi/libnurbs/interface/bezierPatchMesh.h
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatchMesh.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _BEZIERPATCHMESH_H
|
||||
#define _BEZIERPATCHMESH_H
|
||||
|
||||
#include "bezierPatch.h"
|
||||
|
||||
typedef struct bezierPatchMesh{
|
||||
bezierPatch *bpatch; /*vertex*/
|
||||
bezierPatch *bpatch_normal;
|
||||
bezierPatch *bpatch_texcoord; /*s,t,r,q*/
|
||||
bezierPatch *bpatch_color; /*RGBA*/
|
||||
|
||||
float *UVarray; /*all UV components of all vertices of all strips*/
|
||||
int *length_array; /*[i] is the number of vertices in the ith strip*/
|
||||
GLenum *type_array; /*[i] is the type of the ith primitive*/
|
||||
|
||||
/*to support dynamic insertion*/
|
||||
int size_UVarray;
|
||||
int index_UVarray;
|
||||
int size_length_array;
|
||||
int index_length_array;
|
||||
|
||||
int counter; /*track the current strip size*/
|
||||
GLenum type; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/
|
||||
|
||||
/*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/
|
||||
float *vertex_array; /*each vertex contains three components*/
|
||||
float *normal_array; /*each normal contains three components*/
|
||||
float *color_array;
|
||||
float *texcoord_array;
|
||||
|
||||
/*in case we need a linked list*/
|
||||
struct bezierPatchMesh *next;
|
||||
} bezierPatchMesh;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/*initilize patches to be null*/
|
||||
bezierPatchMesh *bezierPatchMeshMake2(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);
|
||||
|
||||
bezierPatchMesh* bezierPatchMeshListInsert(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);
|
||||
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list);
|
||||
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
399
src/glu/sgi/libnurbs/interface/glcurveval.cc
Normal file
399
src/glu/sgi/libnurbs/interface/glcurveval.cc
Normal file
|
|
@ -0,0 +1,399 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glcurveval.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glcurveval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
/* Polynomial Evaluator Interface */
|
||||
|
||||
#include "gluos.h"
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
#include "glcurveval.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
OpenGLCurveEvaluator::OpenGLCurveEvaluator(void)
|
||||
{
|
||||
//no default callback functions
|
||||
beginCallBackN = NULL;
|
||||
endCallBackN = NULL;
|
||||
vertexCallBackN = NULL;
|
||||
normalCallBackN = NULL;
|
||||
colorCallBackN = NULL;
|
||||
texcoordCallBackN = NULL;
|
||||
beginCallBackData = NULL;
|
||||
endCallBackData = NULL;
|
||||
vertexCallBackData = NULL;
|
||||
normalCallBackData = NULL;
|
||||
colorCallBackData = NULL;
|
||||
texcoordCallBackData = NULL;
|
||||
|
||||
userData = NULL;
|
||||
|
||||
vertex_flag = 0;
|
||||
normal_flag = 0;
|
||||
color_flag = 0;
|
||||
texcoord_flag = 0;
|
||||
|
||||
em_vertex.uprime = -1.0;
|
||||
em_normal.uprime = -1.0;
|
||||
em_color.uprime = -1.0;
|
||||
em_texcoord.uprime = -1.0;
|
||||
}
|
||||
|
||||
OpenGLCurveEvaluator::~OpenGLCurveEvaluator(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* added nonsense to avoid the warning messages at compile time */
|
||||
void
|
||||
OpenGLCurveEvaluator::addMap(CurveMap *m)
|
||||
{
|
||||
m = m;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::range1f(long type, REAL *from, REAL *to)
|
||||
{
|
||||
type = type;
|
||||
from = from;
|
||||
to = to;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::domain1f(REAL ulo, REAL uhi)
|
||||
{
|
||||
ulo = ulo;
|
||||
uhi = uhi;
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::bgnline(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
beginCallBack(GL_LINE_STRIP, userData);
|
||||
else
|
||||
glBegin((GLenum) GL_LINE_STRIP);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::endline(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
endCallBack(userData);
|
||||
else
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* disable - turn off a curve map
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::disable(long type)
|
||||
{
|
||||
glDisable((GLenum) type);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* enable - turn on a curve map
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::enable(long type)
|
||||
{
|
||||
glEnable((GLenum) type);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* mapgrid1f - define a lattice of points with origin and offset
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::mapgrid1f(long nu, REAL u0, REAL u1)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
global_grid_u0 = u0;
|
||||
global_grid_u1 = u1;
|
||||
global_grid_nu = nu;
|
||||
}
|
||||
else
|
||||
glMapGrid1f((GLint) nu, (GLfloat) u0, (GLfloat) u1);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnmap1 - preamble to curve definition and evaluations
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::bgnmap1f(long)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
//initialized so that no maps are set initially
|
||||
vertex_flag = 0;
|
||||
normal_flag = 0;
|
||||
color_flag = 0;
|
||||
texcoord_flag = 0;
|
||||
//no need to worry about gl states when doing callback
|
||||
}
|
||||
else
|
||||
glPushAttrib((GLbitfield) GL_EVAL_BIT);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endmap1 - postamble to a curve map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::endmap1f(void)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* map1f - pass a desription of a curve map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
OpenGLCurveEvaluator::map1f(
|
||||
long type, /* map type */
|
||||
REAL ulo, /* lower parametric bound */
|
||||
REAL uhi, /* upper parametric bound */
|
||||
long stride, /* distance to next point in REALS */
|
||||
long order, /* parametric order */
|
||||
REAL *pts /* control points */
|
||||
)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
int dimension;
|
||||
int which;
|
||||
switch(type){
|
||||
case GL_MAP1_VERTEX_3:
|
||||
which = 0;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_VERTEX_4:
|
||||
which=0;
|
||||
dimension = 4;
|
||||
break;
|
||||
case GL_MAP1_INDEX:
|
||||
which=2;
|
||||
dimension = 1;
|
||||
break;
|
||||
case GL_MAP1_COLOR_4:
|
||||
which=2;
|
||||
dimension = 4;
|
||||
break;
|
||||
case GL_MAP1_NORMAL:
|
||||
which=1;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_1:
|
||||
which=3;
|
||||
dimension = 1;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_2:
|
||||
which=3;
|
||||
dimension = 2;
|
||||
break;
|
||||
|
||||
case GL_MAP1_TEXTURE_COORD_3:
|
||||
which=3;
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP1_TEXTURE_COORD_4:
|
||||
which=3;
|
||||
dimension = 4;
|
||||
break;
|
||||
}
|
||||
inMap1f(which, dimension, ulo, uhi, stride, order, pts);
|
||||
}
|
||||
else
|
||||
glMap1f((GLenum) type, (GLfloat) ulo, (GLfloat) uhi, (GLint) stride,
|
||||
(GLint) order, (const GLfloat *) pts);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* mapmesh1f - evaluate a mesh of points on lattice
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::mapmesh1f(long style, long from, long to)
|
||||
{
|
||||
if(output_triangles)
|
||||
{
|
||||
inMapMesh1f((int) from, (int) to);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(style) {
|
||||
default:
|
||||
case N_MESHFILL:
|
||||
case N_MESHLINE:
|
||||
glEvalMesh1((GLenum) GL_LINE, (GLint) from, (GLint) to);
|
||||
break;
|
||||
case N_MESHPOINT:
|
||||
glEvalMesh1((GLenum) GL_POINT, (GLint) from, (GLint) to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* evalpoint1i - evaluate a point on a curve
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::evalpoint1i(long i)
|
||||
{
|
||||
glEvalPoint1((GLint) i);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* evalcoord1f - evaluate a point on a curve
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void OpenGLCurveEvaluator::evalcoord1f(long, REAL u)
|
||||
{
|
||||
glEvalCoord1f((GLfloat) u);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::putCallBack(GLenum which, GLvoid (GLAPIENTRY *fn)(...))
|
||||
{
|
||||
switch(which)
|
||||
{
|
||||
case GLU_NURBS_BEGIN:
|
||||
beginCallBackN = (void (GLAPIENTRY *) (GLenum)) fn;
|
||||
break;
|
||||
case GLU_NURBS_END:
|
||||
endCallBackN = (void (GLAPIENTRY *) (void)) fn;
|
||||
break;
|
||||
case GLU_NURBS_VERTEX:
|
||||
vertexCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_NORMAL:
|
||||
normalCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_COLOR:
|
||||
colorCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_TEXTURE_COORD:
|
||||
texcoordCallBackN = (void (GLAPIENTRY *) (const GLfloat*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_BEGIN_DATA:
|
||||
beginCallBackData = (void (GLAPIENTRY *) (GLenum, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_END_DATA:
|
||||
endCallBackData = (void (GLAPIENTRY *) (void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_VERTEX_DATA:
|
||||
vertexCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_NORMAL_DATA:
|
||||
normalCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_COLOR_DATA:
|
||||
colorCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
case GLU_NURBS_TEXTURE_COORD_DATA:
|
||||
texcoordCallBackData = (void (GLAPIENTRY *) (const GLfloat*, void*)) fn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::beginCallBack(GLenum which, void *data)
|
||||
{
|
||||
if(beginCallBackData)
|
||||
beginCallBackData(which, data);
|
||||
else if(beginCallBackN)
|
||||
beginCallBackN(which);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::endCallBack(void *data)
|
||||
{
|
||||
if(endCallBackData)
|
||||
endCallBackData(data);
|
||||
else if(endCallBackN)
|
||||
endCallBackN();
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::vertexCallBack(const GLfloat *vert, void* data)
|
||||
{
|
||||
if(vertexCallBackData)
|
||||
vertexCallBackData(vert, data);
|
||||
else if(vertexCallBackN)
|
||||
vertexCallBackN(vert);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::normalCallBack(const GLfloat *normal, void* data)
|
||||
{
|
||||
if(normalCallBackData)
|
||||
normalCallBackData(normal, data);
|
||||
else if(normalCallBackN)
|
||||
normalCallBackN(normal);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::colorCallBack(const GLfloat *color, void* data)
|
||||
{
|
||||
if(colorCallBackData)
|
||||
colorCallBackData(color, data);
|
||||
else if(colorCallBackN)
|
||||
colorCallBackN(color);
|
||||
}
|
||||
|
||||
void
|
||||
OpenGLCurveEvaluator::texcoordCallBack(const GLfloat *texcoord, void* data)
|
||||
{
|
||||
if(texcoordCallBackData)
|
||||
texcoordCallBackData(texcoord, data);
|
||||
else if(texcoordCallBackN)
|
||||
texcoordCallBackN(texcoord);
|
||||
}
|
||||
158
src/glu/sgi/libnurbs/interface/glcurveval.h
Normal file
158
src/glu/sgi/libnurbs/interface/glcurveval.h
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glcurveval.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glcurveval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluglcurveval_h_
|
||||
#define __gluglcurveval_h_
|
||||
|
||||
#include "gluos.h"
|
||||
#include <GL/gl.h>
|
||||
#include "basiccrveval.h"
|
||||
|
||||
class CurveMap;
|
||||
|
||||
/*for internal evaluator callback stuff*/
|
||||
#ifndef IN_MAX_BEZIER_ORDER
|
||||
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
|
||||
#endif
|
||||
|
||||
#ifndef IN_MAX_DIMENSION
|
||||
#define IN_MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
typedef struct curveEvalMachine{
|
||||
REAL uprime; //cached previously evaluated uprime
|
||||
int k; //the dimension
|
||||
REAL u1;
|
||||
REAL u2;
|
||||
int ustride;
|
||||
int uorder;
|
||||
REAL ctlpoints[IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
REAL ucoeff[IN_MAX_BEZIER_ORDER];//cache the polynomial values
|
||||
} curveEvalMachine;
|
||||
|
||||
class OpenGLCurveEvaluator : public BasicCurveEvaluator {
|
||||
public:
|
||||
OpenGLCurveEvaluator(void);
|
||||
~OpenGLCurveEvaluator(void);
|
||||
void range1f(long, REAL *, REAL *);
|
||||
void domain1f(REAL, REAL);
|
||||
void addMap(CurveMap *);
|
||||
|
||||
void enable(long);
|
||||
void disable(long);
|
||||
void bgnmap1f(long);
|
||||
void map1f(long, REAL, REAL, long, long, REAL *);
|
||||
void mapgrid1f(long, REAL, REAL);
|
||||
void mapmesh1f(long, long, long);
|
||||
void evalpoint1i(long);
|
||||
void evalcoord1f(long, REAL);
|
||||
void endmap1f(void);
|
||||
|
||||
void bgnline(void);
|
||||
void endline(void);
|
||||
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
output_triangles = flag;
|
||||
}
|
||||
void putCallBack(GLenum which, GLvoid (GLAPIENTRY *fn)(...));
|
||||
void set_callback_userData(void *data)
|
||||
{
|
||||
userData = data;
|
||||
}
|
||||
|
||||
/*------------------begin for curveEvalMachine------------*/
|
||||
curveEvalMachine em_vertex;
|
||||
curveEvalMachine em_normal;
|
||||
curveEvalMachine em_color;
|
||||
curveEvalMachine em_texcoord;
|
||||
int vertex_flag; //whether there is a vertex map or not
|
||||
int normal_flag; //whether there is a normal map or not
|
||||
int color_flag; //whether there is a color map or not
|
||||
int texcoord_flag; //whether there is a texture map or not
|
||||
|
||||
int global_grid_u0;
|
||||
int global_grid_u1;
|
||||
int global_grid_nu;
|
||||
|
||||
void inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
|
||||
int dimension,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL *ctlpoints);
|
||||
|
||||
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
|
||||
void inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint);
|
||||
void inDoEvalCoord1(REAL u);
|
||||
void inMapMesh1f(int umin, int umax);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackN) (GLenum type);
|
||||
void (GLAPIENTRY *endCallBackN) (void);
|
||||
void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
|
||||
void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
|
||||
void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
|
||||
void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
|
||||
void (GLAPIENTRY *endCallBackData) (void* data);
|
||||
void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
|
||||
void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
|
||||
void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
|
||||
void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
|
||||
|
||||
void* userData; //the opaque pointer for Data callback functions
|
||||
void beginCallBack(GLenum type, void* data);
|
||||
void endCallBack(void* data);
|
||||
void vertexCallBack(const GLfloat *vert, void *data);
|
||||
void normalCallBack(const GLfloat *normal, void* data);
|
||||
void colorCallBack(const GLfloat *color, void* data);
|
||||
void texcoordCallBack(const GLfloat *texcoord, void* data);
|
||||
|
||||
|
||||
/*------------------end for curveEvalMachine------------*/
|
||||
|
||||
private:
|
||||
int output_triangles; //true 1; false 0
|
||||
};
|
||||
|
||||
#endif /* __gluglcurveval_h_ */
|
||||
48
src/glu/sgi/libnurbs/interface/glimports.h
Normal file
48
src/glu/sgi/libnurbs/interface/glimports.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glimports.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glimports.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluimports_h_
|
||||
#define __gluimports_h_
|
||||
|
||||
#include "mystdlib.h"
|
||||
#include "mystdio.h"
|
||||
|
||||
#endif /* __gluimports_h_ */
|
||||
471
src/glu/sgi/libnurbs/interface/glinterface.cc
Normal file
471
src/glu/sgi/libnurbs/interface/glinterface.cc
Normal file
|
|
@ -0,0 +1,471 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glinterface.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
//#define DOWN_LOAD_NURBS
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
|
||||
#include "oglTrimNurbs.h"
|
||||
static int surfcount = 0;
|
||||
static oglTrimNurbs* otn = NULL;
|
||||
nurbSurf* tempNurb = NULL;
|
||||
oglTrimLoops* tempTrim = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
//for LOD
|
||||
extern "C" {void glu_LOD_eval_list(GLUnurbs *nurb, int level);}
|
||||
|
||||
void glu_LOD_eval_list(GLUnurbs *nurb, int level)
|
||||
{
|
||||
nurb->LOD_eval_list(level);
|
||||
}
|
||||
|
||||
GLUnurbs * GLAPIENTRY
|
||||
gluNewNurbsRenderer(void)
|
||||
{
|
||||
GLUnurbs *t;
|
||||
|
||||
t = new GLUnurbs();
|
||||
return t;
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluDeleteNurbsRenderer(GLUnurbs *r)
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
|
||||
gluDeleteNurbsTessellatorEXT(GLUnurbsObj *r)
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginSurface(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
surfcount++;
|
||||
tempTrim = OTL_make(10,10);
|
||||
#endif
|
||||
r->bgnsurface(0);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginCurve(GLUnurbs *r)
|
||||
{
|
||||
r->bgncurve(0);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndCurve(GLUnurbs *r)
|
||||
{
|
||||
r->endcurve();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndSurface(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
if(surfcount == 1)
|
||||
otn = OTN_make(1);
|
||||
OTN_insert(otn, tempNurb, tempTrim);
|
||||
if(surfcount >= 1)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("write file\n");
|
||||
#endif
|
||||
OTN_write(otn, "out.otn");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
r->endsurface();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginTrim(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_bgnTrim(tempTrim);
|
||||
#endif
|
||||
|
||||
r->bgntrim();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndTrim(GLUnurbs *r)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_endTrim(tempTrim);
|
||||
#endif
|
||||
r->endtrim();
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluPwlCurve(GLUnurbs *r, GLint count, INREAL array[],
|
||||
GLint stride, GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_pwlCurve(tempTrim, count, array, stride, type);
|
||||
#endif
|
||||
|
||||
int realType;
|
||||
switch(type) {
|
||||
case GLU_MAP1_TRIM_2:
|
||||
realType = N_P2D;
|
||||
break;
|
||||
case GLU_MAP1_TRIM_3:
|
||||
realType = N_P2DR;
|
||||
break;
|
||||
default:
|
||||
realType = type;
|
||||
break;
|
||||
}
|
||||
r->pwlcurve(count, array, sizeof(INREAL) * stride, realType);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsCurve(GLUnurbs *r, GLint nknots, INREAL knot[], GLint stride,
|
||||
INREAL ctlarray[], GLint order, GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
OTL_nurbsCurve(tempTrim, nknots, knot, stride, ctlarray, order, type);
|
||||
#endif
|
||||
|
||||
int realType;
|
||||
|
||||
switch(type) {
|
||||
case GLU_MAP1_TRIM_2:
|
||||
realType = N_P2D;
|
||||
break;
|
||||
case GLU_MAP1_TRIM_3:
|
||||
realType = N_P2DR;
|
||||
break;
|
||||
default:
|
||||
realType = type;
|
||||
break;
|
||||
}
|
||||
|
||||
r->nurbscurve(nknots, knot, sizeof(INREAL) * stride, ctlarray, order,
|
||||
realType);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsSurface(GLUnurbs *r, GLint sknot_count, GLfloat *sknot,
|
||||
GLint tknot_count, GLfloat *tknot,
|
||||
GLint s_stride, GLint t_stride,
|
||||
GLfloat *ctlarray, GLint sorder, GLint torder,
|
||||
GLenum type)
|
||||
{
|
||||
#ifdef DOWN_LOAD_NURBS
|
||||
{
|
||||
int dimension;
|
||||
switch(type){
|
||||
case GL_MAP2_VERTEX_3:
|
||||
dimension = 3;
|
||||
break;
|
||||
case GL_MAP2_VERTEX_4:
|
||||
dimension = 4;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error in glinterface.c++, type no implemented\n");
|
||||
exit(1);
|
||||
}
|
||||
tempNurb = nurbSurfMake(sknot_count, sknot,
|
||||
tknot_count, tknot,
|
||||
sorder, torder,
|
||||
dimension,
|
||||
ctlarray,
|
||||
s_stride, t_stride);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
r->nurbssurface(sknot_count, sknot, tknot_count, tknot,
|
||||
sizeof(INREAL) * s_stride, sizeof(INREAL) * t_stride,
|
||||
ctlarray, sorder, torder, type);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluLoadSamplingMatrices(GLUnurbs *r, const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
r->useGLMatrices(modelMatrix, projMatrix, viewport);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsProperty(GLUnurbs *r, GLenum property, GLfloat value)
|
||||
{
|
||||
GLfloat nurbsValue;
|
||||
|
||||
switch (property) {
|
||||
case GLU_AUTO_LOAD_MATRIX:
|
||||
r->setautoloadmode(value);
|
||||
return;
|
||||
|
||||
case GLU_CULLING:
|
||||
if (value != 0.0) {
|
||||
nurbsValue = N_CULLINGON;
|
||||
} else {
|
||||
nurbsValue = N_NOCULLING;
|
||||
}
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLING, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLING, nurbsValue);
|
||||
return;
|
||||
|
||||
case GLU_SAMPLING_METHOD:
|
||||
if (value == GLU_PATH_LENGTH) {
|
||||
nurbsValue = N_PATHLENGTH;
|
||||
} else if (value == GLU_PARAMETRIC_ERROR) {
|
||||
nurbsValue = N_PARAMETRICDISTANCE;
|
||||
} else if (value == GLU_DOMAIN_DISTANCE) {
|
||||
nurbsValue = N_DOMAINDISTANCE;
|
||||
r->set_is_domain_distance_sampling(1); //optimzing untrimmed case
|
||||
|
||||
} else if (value == GLU_OBJECT_PARAMETRIC_ERROR) {
|
||||
nurbsValue = N_OBJECTSPACE_PARA;
|
||||
r->setautoloadmode( 0.0 );
|
||||
r->setSamplingMatrixIdentity();
|
||||
} else if (value == GLU_OBJECT_PATH_LENGTH) {
|
||||
nurbsValue = N_OBJECTSPACE_PATH;
|
||||
r->setautoloadmode( 0.0 );
|
||||
r->setSamplingMatrixIdentity();
|
||||
} else {
|
||||
r->postError(GLU_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
|
||||
return;
|
||||
|
||||
case GLU_SAMPLING_TOLERANCE:
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, value);
|
||||
return;
|
||||
|
||||
case GLU_PARAMETRIC_TOLERANCE:
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, value);
|
||||
return;
|
||||
|
||||
|
||||
case GLU_DISPLAY_MODE:
|
||||
|
||||
if (value == GLU_FILL) {
|
||||
nurbsValue = N_FILL;
|
||||
} else if (value == GLU_OUTLINE_POLYGON) {
|
||||
nurbsValue = N_OUTLINE_POLY;
|
||||
} else if (value == GLU_OUTLINE_PATCH) {
|
||||
nurbsValue = N_OUTLINE_PATCH;
|
||||
} else {
|
||||
r->postError(GLU_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
r->setnurbsproperty(N_DISPLAY, nurbsValue);
|
||||
|
||||
break;
|
||||
|
||||
case GLU_U_STEP:
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, value);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
r->set_domain_distance_u_rate(value);
|
||||
break;
|
||||
|
||||
case GLU_V_STEP:
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
|
||||
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, value);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
r->set_domain_distance_v_rate(value);
|
||||
break;
|
||||
|
||||
case GLU_NURBS_MODE:
|
||||
if(value == GLU_NURBS_RENDERER)
|
||||
r->put_callbackFlag(0);
|
||||
else if(value == GLU_NURBS_TESSELLATOR)
|
||||
r->put_callbackFlag(1);
|
||||
else
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
break;
|
||||
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluGetNurbsProperty(GLUnurbs *r, GLenum property, GLfloat *value)
|
||||
{
|
||||
GLfloat nurbsValue;
|
||||
|
||||
switch(property) {
|
||||
case GLU_AUTO_LOAD_MATRIX:
|
||||
if (r->getautoloadmode()) {
|
||||
*value = GL_TRUE;
|
||||
} else {
|
||||
*value = GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case GLU_CULLING:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, &nurbsValue);
|
||||
if (nurbsValue == N_CULLINGON) {
|
||||
*value = GL_TRUE;
|
||||
} else {
|
||||
*value = GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case GLU_SAMPLING_METHOD:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, value);
|
||||
if(*value == N_PATHLENGTH)
|
||||
*value = GLU_PATH_LENGTH;
|
||||
else if(*value == N_PARAMETRICDISTANCE)
|
||||
*value = GLU_PARAMETRIC_ERROR;
|
||||
else if(*value == N_DOMAINDISTANCE)
|
||||
*value = GLU_DOMAIN_DISTANCE;
|
||||
else if(*value == N_OBJECTSPACE_PATH)
|
||||
*value = GLU_OBJECT_PATH_LENGTH;
|
||||
else if(*value == N_OBJECTSPACE_PARA)
|
||||
*value = GLU_OBJECT_PARAMETRIC_ERROR;
|
||||
break;
|
||||
case GLU_SAMPLING_TOLERANCE:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
|
||||
break;
|
||||
case GLU_PARAMETRIC_TOLERANCE:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
|
||||
break;
|
||||
|
||||
case GLU_U_STEP:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
|
||||
break;
|
||||
case GLU_V_STEP:
|
||||
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
|
||||
break;
|
||||
case GLU_DISPLAY_MODE:
|
||||
r->getnurbsproperty(N_DISPLAY, &nurbsValue);
|
||||
if (nurbsValue == N_FILL) {
|
||||
*value = GLU_FILL;
|
||||
} else if (nurbsValue == N_OUTLINE_POLY) {
|
||||
*value = GLU_OUTLINE_POLYGON;
|
||||
} else {
|
||||
*value = GLU_OUTLINE_PATCH;
|
||||
}
|
||||
break;
|
||||
|
||||
case GLU_NURBS_MODE:
|
||||
if(r->is_callback())
|
||||
*value = GLU_NURBS_TESSELLATOR;
|
||||
else
|
||||
*value = GLU_NURBS_RENDERER;
|
||||
break;
|
||||
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void GLAPIENTRY
|
||||
gluNurbsCallback(GLUnurbs *r, GLenum which, GLvoid (*fn)())
|
||||
{
|
||||
switch (which) {
|
||||
case GLU_NURBS_BEGIN:
|
||||
case GLU_NURBS_END:
|
||||
case GLU_NURBS_VERTEX:
|
||||
case GLU_NURBS_NORMAL:
|
||||
case GLU_NURBS_TEXTURE_COORD:
|
||||
case GLU_NURBS_COLOR:
|
||||
case GLU_NURBS_BEGIN_DATA:
|
||||
case GLU_NURBS_END_DATA:
|
||||
case GLU_NURBS_VERTEX_DATA:
|
||||
case GLU_NURBS_NORMAL_DATA:
|
||||
case GLU_NURBS_TEXTURE_COORD_DATA:
|
||||
case GLU_NURBS_COLOR_DATA:
|
||||
r->putSurfCallBack(which, (GLvoid (*)(...))fn);
|
||||
break;
|
||||
|
||||
case GLU_NURBS_ERROR:
|
||||
r->errorCallback = (void (*)( GLenum )) fn;
|
||||
break;
|
||||
default:
|
||||
r->postError(GLU_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
gluNurbsCallbackDataEXT(GLUnurbs* r, void* userData)
|
||||
{
|
||||
r->setNurbsCallbackData(userData);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void GLAPIENTRY
|
||||
gluNurbsCallbackData(GLUnurbs* r, void* userData)
|
||||
{
|
||||
gluNurbsCallbackDataEXT(r,userData);
|
||||
}
|
||||
303
src/glu/sgi/libnurbs/interface/glrenderer.cc
Normal file
303
src/glu/sgi/libnurbs/interface/glrenderer.cc
Normal file
|
|
@ -0,0 +1,303 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glrenderer.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "gluos.h"
|
||||
#include "glimports.h"
|
||||
#include "glrenderer.h"
|
||||
|
||||
GLUnurbs::GLUnurbs()
|
||||
: NurbsTessellator(curveEvaluator, surfaceEvaluator)
|
||||
{
|
||||
redefineMaps();
|
||||
defineMap(GL_MAP2_NORMAL, 0, 3);
|
||||
defineMap(GL_MAP1_NORMAL, 0, 3);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_1, 0, 1);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_1, 0, 1);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_2, 0, 2);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_2, 0, 2);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_3, 0, 3);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_3, 0, 3);
|
||||
defineMap(GL_MAP2_TEXTURE_COORD_4, 1, 4);
|
||||
defineMap(GL_MAP1_TEXTURE_COORD_4, 1, 4);
|
||||
defineMap(GL_MAP2_VERTEX_4, 1, 4);
|
||||
defineMap(GL_MAP1_VERTEX_4, 1, 4);
|
||||
defineMap(GL_MAP2_VERTEX_3, 0, 3);
|
||||
defineMap(GL_MAP1_VERTEX_3, 0, 3);
|
||||
defineMap(GL_MAP2_COLOR_4, 0, 4);
|
||||
defineMap(GL_MAP1_COLOR_4, 0, 4);
|
||||
defineMap(GL_MAP2_INDEX, 0, 1);
|
||||
defineMap(GL_MAP1_INDEX, 0, 1);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, (float) 100.0);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
set_domain_distance_u_rate(100.0);
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, (float) 100.0);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, (float) 100.0);
|
||||
|
||||
//added for optimizing untrimmed case
|
||||
set_domain_distance_v_rate(100.0);
|
||||
set_is_domain_distance_sampling(0); //since the default is path_length
|
||||
|
||||
//default autoloadmode is true
|
||||
autoloadmode = 1;
|
||||
|
||||
//default callbackFlag is 0
|
||||
callbackFlag = 0;
|
||||
|
||||
errorCallback = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::bgnrender(void)
|
||||
{
|
||||
if (autoloadmode) {
|
||||
loadGLMatrices();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::endrender(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::errorHandler(int i)
|
||||
{
|
||||
int gluError;
|
||||
|
||||
gluError = i + (GLU_NURBS_ERROR1 - 1);
|
||||
postError( gluError );
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::loadGLMatrices(void)
|
||||
{
|
||||
GLfloat vmat[4][4];
|
||||
GLint viewport[4];
|
||||
|
||||
grabGLMatrix((GLfloat (*)[4]) vmat);
|
||||
loadCullingMatrix((GLfloat (*)[4]) vmat);
|
||||
::glGetIntegerv((GLenum) GL_VIEWPORT, (GLint *) viewport);
|
||||
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::useGLMatrices(const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
GLfloat vmat[4][4];
|
||||
|
||||
multmatrix4d(vmat, (const GLfloat (*)[4]) modelMatrix,
|
||||
(const GLfloat (*)[4]) projMatrix);
|
||||
loadCullingMatrix((GLfloat (*)[4]) vmat);
|
||||
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* grabGLMatrix
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
GLUnurbs::grabGLMatrix(GLfloat vmat[4][4])
|
||||
{
|
||||
GLfloat m1[4][4], m2[4][4];
|
||||
|
||||
::glGetFloatv((GLenum) GL_MODELVIEW_MATRIX, (GLfloat *) &(m1[0][0]));
|
||||
::glGetFloatv((GLenum) GL_PROJECTION_MATRIX, (GLfloat *) &(m2[0][0]));
|
||||
multmatrix4d((GLfloat (*)[4]) vmat,
|
||||
(GLfloat (*)[4]) m1, (GLfloat (*)[4]) m2);
|
||||
}
|
||||
|
||||
//for object space tesselation: view independent
|
||||
void
|
||||
GLUnurbs::setSamplingMatrixIdentity( void )
|
||||
{
|
||||
INREAL smat[4][4] = {
|
||||
{1,0,0,0},
|
||||
{0,1,0,0},
|
||||
{0,0,1,0},
|
||||
{0,0,0,1}
|
||||
};
|
||||
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GLUnurbs::loadSamplingMatrix(const GLfloat vmat[4][4],
|
||||
const GLint viewport[4])
|
||||
{
|
||||
|
||||
/* rescale the mapping to correspond to pixels in x/y */
|
||||
REAL xsize = 0.5 * (REAL) (viewport[2]);
|
||||
REAL ysize = 0.5 * (REAL) (viewport[3]);
|
||||
|
||||
INREAL smat[4][4];
|
||||
smat[0][0] = vmat[0][0] * xsize;
|
||||
smat[1][0] = vmat[1][0] * xsize;
|
||||
smat[2][0] = vmat[2][0] * xsize;
|
||||
smat[3][0] = vmat[3][0] * xsize;
|
||||
|
||||
smat[0][1] = vmat[0][1] * ysize;
|
||||
smat[1][1] = vmat[1][1] * ysize;
|
||||
smat[2][1] = vmat[2][1] * ysize;
|
||||
smat[3][1] = vmat[3][1] * ysize;
|
||||
|
||||
smat[0][2] = 0.0;
|
||||
smat[1][2] = 0.0;
|
||||
smat[2][2] = 0.0;
|
||||
smat[3][2] = 0.0;
|
||||
|
||||
smat[0][3] = vmat[0][3];
|
||||
smat[1][3] = vmat[1][3];
|
||||
smat[2][3] = vmat[2][3];
|
||||
smat[3][3] = vmat[3][3];
|
||||
|
||||
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
void
|
||||
GLUnurbs::loadCullingMatrix(GLfloat vmat[4][4])
|
||||
{
|
||||
INREAL cmat[4][4];
|
||||
|
||||
cmat[0][0] = vmat[0][0];
|
||||
cmat[0][1] = vmat[0][1];
|
||||
cmat[0][2] = vmat[0][2];
|
||||
cmat[0][3] = vmat[0][3];
|
||||
|
||||
cmat[1][0] = vmat[1][0];
|
||||
cmat[1][1] = vmat[1][1];
|
||||
cmat[1][2] = vmat[1][2];
|
||||
cmat[1][3] = vmat[1][3];
|
||||
|
||||
cmat[2][0] = vmat[2][0];
|
||||
cmat[2][1] = vmat[2][1];
|
||||
cmat[2][2] = vmat[2][2];
|
||||
cmat[2][3] = vmat[2][3];
|
||||
|
||||
cmat[3][0] = vmat[3][0];
|
||||
cmat[3][1] = vmat[3][1];
|
||||
cmat[3][2] = vmat[3][2];
|
||||
cmat[3][3] = vmat[3][3];
|
||||
|
||||
const long rstride = sizeof(cmat[0]) / sizeof(cmat[0][0]);
|
||||
const long cstride = 1;
|
||||
|
||||
setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
//added for curves by zl
|
||||
setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
|
||||
cstride);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* A = B * MAT ; transform a 4d vector through a 4x4 matrix
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
GLUnurbs::transform4d(GLfloat A[4], GLfloat B[4], GLfloat mat[4][4])
|
||||
{
|
||||
|
||||
A[0] = B[0]*mat[0][0] + B[1]*mat[1][0] + B[2]*mat[2][0] + B[3]*mat[3][0];
|
||||
A[1] = B[0]*mat[0][1] + B[1]*mat[1][1] + B[2]*mat[2][1] + B[3]*mat[3][1];
|
||||
A[2] = B[0]*mat[0][2] + B[1]*mat[1][2] + B[2]*mat[2][2] + B[3]*mat[3][2];
|
||||
A[3] = B[0]*mat[0][3] + B[1]*mat[1][3] + B[2]*mat[2][3] + B[3]*mat[3][3];
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* new = [left][right] ; multiply two matrices together
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
GLUnurbs::multmatrix4d (GLfloat n[4][4], const GLfloat left[4][4],
|
||||
const GLfloat right[4][4])
|
||||
{
|
||||
transform4d ((GLfloat *) n[0],(GLfloat *) left[0],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[1],(GLfloat *) left[1],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[2],(GLfloat *) left[2],(GLfloat (*)[4]) right);
|
||||
transform4d ((GLfloat *) n[3],(GLfloat *) left[3],(GLfloat (*)[4]) right);
|
||||
}
|
||||
145
src/glu/sgi/libnurbs/interface/glrenderer.h
Normal file
145
src/glu/sgi/libnurbs/interface/glrenderer.h
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glrenderer.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glrenderer.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluglrenderer_h_
|
||||
#define __gluglrenderer_h_
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "nurbstess.h"
|
||||
#include "glsurfeval.h"
|
||||
#include "glcurveval.h"
|
||||
|
||||
class GLUnurbs : public NurbsTessellator {
|
||||
|
||||
public:
|
||||
GLUnurbs( void );
|
||||
void loadGLMatrices( void );
|
||||
void useGLMatrices( const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4] );
|
||||
void setSamplingMatrixIdentity( void );
|
||||
|
||||
void errorHandler( int );
|
||||
void bgnrender( void );
|
||||
void endrender( void );
|
||||
void setautoloadmode( INREAL value )
|
||||
{
|
||||
|
||||
if (value) autoloadmode = GL_TRUE;
|
||||
else autoloadmode = GL_FALSE;
|
||||
|
||||
}
|
||||
GLboolean getautoloadmode( void ) { return autoloadmode; }
|
||||
|
||||
void (GLAPIENTRY *errorCallback)( GLenum );
|
||||
void postError( int which )
|
||||
{ if (errorCallback) (*errorCallback)( (GLenum)which ); }
|
||||
|
||||
void putSurfCallBack(GLenum which, GLvoid (GLAPIENTRY *fn)(...))
|
||||
{
|
||||
curveEvaluator.putCallBack(which, fn);
|
||||
surfaceEvaluator.putCallBack(which, fn);
|
||||
}
|
||||
|
||||
int get_vertices_call_back()
|
||||
{
|
||||
return surfaceEvaluator.get_vertices_call_back();
|
||||
}
|
||||
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
surfaceEvaluator.put_vertices_call_back(flag);
|
||||
}
|
||||
|
||||
int get_callback_auto_normal()
|
||||
{
|
||||
return surfaceEvaluator.get_callback_auto_normal();
|
||||
}
|
||||
|
||||
void put_callback_auto_normal(int flag)
|
||||
{
|
||||
surfaceEvaluator.put_callback_auto_normal(flag);
|
||||
}
|
||||
|
||||
void setNurbsCallbackData(void* userData)
|
||||
{
|
||||
curveEvaluator.set_callback_userData(userData);
|
||||
surfaceEvaluator.set_callback_userData(userData);
|
||||
}
|
||||
|
||||
|
||||
//for LOD
|
||||
void LOD_eval_list(int level)
|
||||
{
|
||||
surfaceEvaluator.LOD_eval_list(level);
|
||||
}
|
||||
|
||||
//NEWCALLBACK
|
||||
int is_callback()
|
||||
{
|
||||
return callbackFlag;
|
||||
}
|
||||
void put_callbackFlag(int flag)
|
||||
{
|
||||
callbackFlag = flag;
|
||||
surfaceEvaluator.put_vertices_call_back(flag);
|
||||
curveEvaluator.put_vertices_call_back(flag);
|
||||
}
|
||||
|
||||
private:
|
||||
GLboolean autoloadmode;
|
||||
OpenGLSurfaceEvaluator surfaceEvaluator;
|
||||
OpenGLCurveEvaluator curveEvaluator;
|
||||
|
||||
void loadSamplingMatrix( const GLfloat vmat[4][4],
|
||||
const GLint viewport[4] );
|
||||
void loadCullingMatrix( GLfloat vmat[4][4] );
|
||||
static void grabGLMatrix( GLfloat vmat[4][4] );
|
||||
static void transform4d( GLfloat A[4], GLfloat B[4],
|
||||
GLfloat mat[4][4] );
|
||||
static void multmatrix4d( GLfloat n[4][4], const GLfloat left[4][4],
|
||||
const GLfloat right[4][4] );
|
||||
|
||||
int callbackFlag;
|
||||
};
|
||||
|
||||
#endif /* __gluglrenderer_h_ */
|
||||
1293
src/glu/sgi/libnurbs/interface/glsurfeval.cc
Normal file
1293
src/glu/sgi/libnurbs/interface/glsurfeval.cc
Normal file
File diff suppressed because it is too large
Load diff
404
src/glu/sgi/libnurbs/interface/glsurfeval.h
Normal file
404
src/glu/sgi/libnurbs/interface/glsurfeval.h
Normal file
|
|
@ -0,0 +1,404 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* glsurfeval.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glsurfeval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluglsurfeval_h_
|
||||
#define __gluglsurfeval_h_
|
||||
|
||||
#include "basicsurfeval.h"
|
||||
#include "bezierPatchMesh.h" //in case output triangles
|
||||
#include "GL/gl.h"
|
||||
|
||||
class SurfaceMap;
|
||||
class OpenGLSurfaceEvaluator;
|
||||
class StoredVertex;
|
||||
|
||||
#define TYPECOORD 1
|
||||
#define TYPEPOINT 2
|
||||
|
||||
/* Cache up to 3 vertices from tmeshes */
|
||||
#define VERTEX_CACHE_SIZE 3
|
||||
|
||||
/*for internal evaluator callback stuff*/
|
||||
#ifndef IN_MAX_BEZIER_ORDER
|
||||
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
|
||||
#endif
|
||||
|
||||
#ifndef IN_MAX_DIMENSION
|
||||
#define IN_MAX_DIMENSION 4
|
||||
#endif
|
||||
|
||||
typedef struct surfEvalMachine{
|
||||
REAL uprime;//cached previusly evaluated uprime.
|
||||
REAL vprime;
|
||||
int k; /*the dimension*/
|
||||
REAL u1;
|
||||
REAL u2;
|
||||
int ustride;
|
||||
int uorder;
|
||||
REAL v1;
|
||||
REAL v2;
|
||||
int vstride;
|
||||
int vorder;
|
||||
REAL ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
REAL ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
|
||||
REAL vcoeff[IN_MAX_BEZIER_ORDER];
|
||||
REAL ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
|
||||
REAL vcoeffDeriv[IN_MAX_BEZIER_ORDER];
|
||||
} surfEvalMachine;
|
||||
|
||||
|
||||
|
||||
class StoredVertex {
|
||||
public:
|
||||
StoredVertex() { type = 0; }
|
||||
~StoredVertex(void) {}
|
||||
void saveEvalCoord(REAL x, REAL y)
|
||||
{coord[0] = x; coord[1] = y; type = TYPECOORD; }
|
||||
void saveEvalPoint(long x, long y)
|
||||
{point[0] = x; point[1] = y; type = TYPEPOINT; }
|
||||
void invoke(OpenGLSurfaceEvaluator *eval);
|
||||
|
||||
private:
|
||||
int type;
|
||||
REAL coord[2];
|
||||
long point[2];
|
||||
};
|
||||
|
||||
class OpenGLSurfaceEvaluator : public BasicSurfaceEvaluator {
|
||||
public:
|
||||
OpenGLSurfaceEvaluator();
|
||||
~OpenGLSurfaceEvaluator( void );
|
||||
void polymode( long style );
|
||||
void range2f( long, REAL *, REAL * );
|
||||
void domain2f( REAL, REAL, REAL, REAL );
|
||||
void addMap( SurfaceMap * ) { }
|
||||
|
||||
void enable( long );
|
||||
void disable( long );
|
||||
void bgnmap2f( long );
|
||||
void map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long, REAL * );
|
||||
void mapgrid2f( long, REAL, REAL, long, REAL, REAL );
|
||||
void mapmesh2f( long, long, long, long, long );
|
||||
void evalcoord2f( long, REAL, REAL );
|
||||
void evalpoint2i( long, long );
|
||||
void endmap2f( void );
|
||||
|
||||
void bgnline( void );
|
||||
void endline( void );
|
||||
void bgnclosedline( void );
|
||||
void endclosedline( void );
|
||||
void bgntmesh( void );
|
||||
void swaptmesh( void );
|
||||
void endtmesh( void );
|
||||
void bgnqstrip( void );
|
||||
void endqstrip( void );
|
||||
|
||||
void bgntfan( void );
|
||||
void endtfan( void );
|
||||
void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val);
|
||||
void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val);
|
||||
|
||||
void coord2f( REAL, REAL );
|
||||
void point2i( long, long );
|
||||
|
||||
void newtmeshvert( REAL, REAL );
|
||||
void newtmeshvert( long, long );
|
||||
|
||||
void putCallBack(GLenum which, GLvoid (GLAPIENTRY *fn)(...));
|
||||
int get_vertices_call_back()
|
||||
{
|
||||
return output_triangles;
|
||||
}
|
||||
void put_vertices_call_back(int flag)
|
||||
{
|
||||
output_triangles = flag;
|
||||
}
|
||||
|
||||
void put_callback_auto_normal(int flag)
|
||||
{
|
||||
callback_auto_normal = flag;
|
||||
}
|
||||
|
||||
int get_callback_auto_normal()
|
||||
{
|
||||
return callback_auto_normal;
|
||||
}
|
||||
|
||||
void set_callback_userData(void* data)
|
||||
{
|
||||
userData = data;
|
||||
}
|
||||
|
||||
/**************begin for LOD_eval_list***********/
|
||||
void LOD_eval_list(int level);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
StoredVertex *vertexCache[VERTEX_CACHE_SIZE];
|
||||
int tmeshing;
|
||||
int which;
|
||||
int vcount;
|
||||
|
||||
GLint gl_polygon_mode[2];/*to save and restore so that
|
||||
*no side effect
|
||||
*/
|
||||
bezierPatchMesh *global_bpm; //for output triangles
|
||||
int output_triangles; //true 1 or false 0
|
||||
|
||||
|
||||
|
||||
void (GLAPIENTRY *beginCallBackN) (GLenum type);
|
||||
void (GLAPIENTRY *endCallBackN) (void);
|
||||
void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
|
||||
void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
|
||||
void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
|
||||
void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
|
||||
|
||||
void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
|
||||
void (GLAPIENTRY *endCallBackData) (void* data);
|
||||
void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
|
||||
void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
|
||||
void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
|
||||
void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
|
||||
|
||||
void beginCallBack (GLenum type, void* data);
|
||||
void endCallBack (void* data);
|
||||
void vertexCallBack (const GLfloat *vert, void* data);
|
||||
void normalCallBack (const GLfloat *normal, void* data);
|
||||
void colorCallBack (const GLfloat *color, void* data);
|
||||
void texcoordCallBack (const GLfloat *texcoord, void* data);
|
||||
|
||||
|
||||
void* userData; //the opaque pointer for Data callback functions.
|
||||
|
||||
/*LOD evaluation*/
|
||||
void LOD_triangle(REAL A[2], REAL B[2], REAL C[2],
|
||||
int level);
|
||||
void LOD_eval(int num_vert, REAL* verts, int type, int level);
|
||||
|
||||
int LOD_eval_level; //set by LOD_eval_list()
|
||||
|
||||
/*************begin for internal evaluators*****************/
|
||||
|
||||
/*the following global variables are only defined in this file.
|
||||
*They are used to cache the precomputed Bezier polynomial values.
|
||||
*These calues may be used consecutively in which case we don't have
|
||||
*recompute these values again.
|
||||
*/
|
||||
int global_uorder; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder; /*store the vorder in the previous evaluation*/
|
||||
REAL global_uprime;
|
||||
REAL global_vprime;
|
||||
REAL global_vprime_BV;
|
||||
REAL global_uprime_BU;
|
||||
int global_uorder_BV; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder_BV; /*store the vorder in the previous evaluation*/
|
||||
int global_uorder_BU; /*store the uorder in the previous evaluation*/
|
||||
int global_vorder_BU; /*store the vorder in the previous evaluation*/
|
||||
|
||||
REAL global_ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
|
||||
REAL global_vcoeff[IN_MAX_BEZIER_ORDER];
|
||||
REAL global_ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
|
||||
REAL global_vcoeffDeriv[IN_MAX_BEZIER_ORDER];
|
||||
|
||||
REAL global_BV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_PBV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_BU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL global_PBU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
|
||||
REAL* global_baseData;
|
||||
|
||||
int global_ev_k; /*the dimension*/
|
||||
REAL global_ev_u1;
|
||||
REAL global_ev_u2;
|
||||
int global_ev_ustride;
|
||||
int global_ev_uorder;
|
||||
REAL global_ev_v1;
|
||||
REAL global_ev_v2;
|
||||
int global_ev_vstride;
|
||||
int global_ev_vorder;
|
||||
REAL global_ev_ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
|
||||
|
||||
REAL global_grid_u0;
|
||||
REAL global_grid_u1;
|
||||
int global_grid_nu;
|
||||
REAL global_grid_v0;
|
||||
REAL global_grid_v1;
|
||||
int global_grid_nv;
|
||||
|
||||
/*functions*/
|
||||
void inDoDomain2WithDerivs(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL *retdu, REAL *retdv);
|
||||
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
|
||||
void inPreEvaluateWithDeriv(int order, REAL vprime, REAL *coeff, REAL *coeffDeriv);
|
||||
void inComputeFirstPartials(REAL *p, REAL *pu, REAL *pv);
|
||||
void inComputeNormal2(REAL *pu, REAL *pv, REAL *n);
|
||||
void inDoEvalCoord2(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
void inDoEvalCoord2NOGE(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
void inMap2f(int k,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL vlower,
|
||||
REAL vupper,
|
||||
int vstride,
|
||||
int vorder,
|
||||
REAL *ctlPoints);
|
||||
|
||||
void inMapGrid2f(int nu, REAL u0, REAL u1,
|
||||
int nv, REAL v0, REAL v1);
|
||||
|
||||
void inEvalMesh2(int lowU, int lowV, int highU, int highV);
|
||||
void inEvalPoint2(int i, int j);
|
||||
void inEvalCoord2f(REAL u, REAL v);
|
||||
|
||||
void inEvalULine(int n_points, REAL v, REAL* u_vals,
|
||||
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
|
||||
|
||||
void inEvalVLine(int n_points, REAL u, REAL* v_vals,
|
||||
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
|
||||
|
||||
void inEvalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
);
|
||||
void inEvalVStrip(int n_left, REAL u_left, REAL* left_val, int n_right, REAL u_right, REAL* right_val);
|
||||
|
||||
void inPreEvaluateBV(int k, int uorder, int vorder, REAL vprime, REAL *baseData);
|
||||
void inPreEvaluateBU(int k, int uorder, int vorder, REAL uprime, REAL *baseData);
|
||||
void inPreEvaluateBV_intfac(REAL v )
|
||||
{
|
||||
inPreEvaluateBV(global_ev_k, global_ev_uorder, global_ev_vorder, (v-global_ev_v1)/(global_ev_v2-global_ev_v1), global_ev_ctlPoints);
|
||||
}
|
||||
|
||||
void inPreEvaluateBU_intfac(REAL u)
|
||||
{
|
||||
inPreEvaluateBU(global_ev_k, global_ev_uorder, global_ev_vorder, (u-global_ev_u1)/(global_ev_u2-global_ev_u1), global_ev_ctlPoints);
|
||||
}
|
||||
|
||||
void inDoDomain2WithDerivsBV(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL* retdu, REAL *retdv);
|
||||
|
||||
void inDoDomain2WithDerivsBU(int k, REAL u, REAL v,
|
||||
REAL u1, REAL u2, int uorder,
|
||||
REAL v1, REAL v2, int vorder,
|
||||
REAL *baseData,
|
||||
REAL *retPoint, REAL* retdu, REAL *retdv);
|
||||
|
||||
|
||||
void inDoEvalCoord2NOGE_BV(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
|
||||
void inDoEvalCoord2NOGE_BU(REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retNormal);
|
||||
|
||||
void inBPMEval(bezierPatchMesh* bpm);
|
||||
void inBPMListEval(bezierPatchMesh* list);
|
||||
|
||||
/*-------------begin for surfEvalMachine -------------*/
|
||||
surfEvalMachine em_vertex;
|
||||
surfEvalMachine em_normal;
|
||||
surfEvalMachine em_color;
|
||||
surfEvalMachine em_texcoord;
|
||||
|
||||
int auto_normal_flag; //whether to output normla or not in callback
|
||||
//determined by GL_AUTO_NORMAL and callback_auto_normal
|
||||
int callback_auto_normal; //GLU_CALLBACK_AUTO_NORMAL_EXT
|
||||
int vertex_flag;
|
||||
int normal_flag;
|
||||
int color_flag;
|
||||
int texcoord_flag;
|
||||
|
||||
void inMap2fEM(int which, //0:vert,1:norm,2:color,3:tex
|
||||
int dimension,
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL vlower,
|
||||
REAL vupper,
|
||||
int vstride,
|
||||
int vorder,
|
||||
REAL *ctlPoints);
|
||||
|
||||
void inDoDomain2WithDerivsEM(surfEvalMachine *em, REAL u, REAL v,
|
||||
REAL *retPoint, REAL *retdu, REAL *retdv);
|
||||
void inDoDomain2EM(surfEvalMachine *em, REAL u, REAL v,
|
||||
REAL *retPoint);
|
||||
void inDoEvalCoord2EM(REAL u, REAL v);
|
||||
|
||||
void inBPMEvalEM(bezierPatchMesh* bpm);
|
||||
void inBPMListEvalEM(bezierPatchMesh* list);
|
||||
|
||||
/*-------------end for surfEvalMachine -------------*/
|
||||
|
||||
|
||||
/*************end for internal evaluators*****************/
|
||||
|
||||
};
|
||||
|
||||
inline void StoredVertex::invoke(OpenGLSurfaceEvaluator *eval)
|
||||
{
|
||||
switch(type) {
|
||||
case TYPECOORD:
|
||||
eval->coord2f(coord[0], coord[1]);
|
||||
break;
|
||||
case TYPEPOINT:
|
||||
eval->point2i(point[0], point[1]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __gluglsurfeval_h_ */
|
||||
209
src/glu/sgi/libnurbs/interface/incurveeval.cc
Normal file
209
src/glu/sgi/libnurbs/interface/incurveeval.cc
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/incurveeval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glcurveval.h"
|
||||
|
||||
|
||||
/*
|
||||
*compute the Bezier polynomials C[n,j](v) for all j at v with
|
||||
*return values stored in coeff[], where
|
||||
* C[n,j](v) = (n,j) * v^j * (1-v)^(n-j),
|
||||
* j=0,1,2,...,n.
|
||||
*order : n+1
|
||||
*vprime: v
|
||||
*coeff : coeff[j]=C[n,j](v), this array store the returned values.
|
||||
*The algorithm is a recursive scheme:
|
||||
* C[0,0]=1;
|
||||
* C[n,j](v) = (1-v)*C[n-1,j](v) + v*C[n-1,j-1](v), n>=1
|
||||
*This code is copied from opengl/soft/so_eval.c:PreEvaluate
|
||||
*/
|
||||
void OpenGLCurveEvaluator::inPreEvaluate(int order, REAL vprime, REAL *coeff)
|
||||
{
|
||||
int i, j;
|
||||
REAL oldval, temp;
|
||||
REAL oneMinusvprime;
|
||||
|
||||
/*
|
||||
* Minor optimization
|
||||
* Compute orders 1 and 2 outright, and set coeff[0], coeff[1] to
|
||||
* their i==1 loop values to avoid the initialization and the i==1 loop.
|
||||
*/
|
||||
if (order == 1) {
|
||||
coeff[0] = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
oneMinusvprime = 1-vprime;
|
||||
coeff[0] = oneMinusvprime;
|
||||
coeff[1] = vprime;
|
||||
if (order == 2) return;
|
||||
|
||||
for (i = 2; i < order; i++) {
|
||||
oldval = coeff[0] * vprime;
|
||||
coeff[0] = oneMinusvprime * coeff[0];
|
||||
for (j = 1; j < i; j++) {
|
||||
temp = oldval;
|
||||
oldval = coeff[j] * vprime;
|
||||
coeff[j] = temp + oneMinusvprime * coeff[j];
|
||||
}
|
||||
coeff[j] = oldval;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
|
||||
int k, //dimension
|
||||
REAL ulower,
|
||||
REAL uupper,
|
||||
int ustride,
|
||||
int uorder,
|
||||
REAL *ctlpoints)
|
||||
{
|
||||
int i,j,x;
|
||||
curveEvalMachine *temp_em;
|
||||
switch(which){
|
||||
case 0: //vertex
|
||||
vertex_flag = 1;
|
||||
temp_em = &em_vertex;
|
||||
break;
|
||||
case 1: //normal
|
||||
normal_flag = 1;
|
||||
temp_em = &em_normal;
|
||||
break;
|
||||
case 2: //color
|
||||
color_flag = 1;
|
||||
temp_em = &em_color;
|
||||
break;
|
||||
default:
|
||||
texcoord_flag = 1;
|
||||
temp_em = &em_texcoord;
|
||||
break;
|
||||
}
|
||||
|
||||
REAL *data = temp_em->ctlpoints;
|
||||
temp_em->uprime = -1; //initialized
|
||||
temp_em->k = k;
|
||||
temp_em->u1 = ulower;
|
||||
temp_em->u2 = uupper;
|
||||
temp_em->ustride = ustride;
|
||||
temp_em->uorder = uorder;
|
||||
/*copy the control points*/
|
||||
for(i=0; i<uorder; i++){
|
||||
for(x=0; x<k; x++){
|
||||
data[x] = ctlpoints[x];
|
||||
}
|
||||
ctlpoints += ustride;
|
||||
data += k;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint)
|
||||
{
|
||||
int j, row;
|
||||
REAL the_uprime;
|
||||
REAL p;
|
||||
REAL *data;
|
||||
|
||||
if(em->u2 == em->u1)
|
||||
return;
|
||||
the_uprime = (u-em->u1) / (em->u2-em->u1);
|
||||
/*use already cached values if possible*/
|
||||
if(em->uprime != the_uprime){
|
||||
inPreEvaluate(em->uorder, the_uprime, em->ucoeff);
|
||||
em->uprime = the_uprime;
|
||||
}
|
||||
|
||||
for(j=0; j<em->k; j++){
|
||||
data = em->ctlpoints+j;
|
||||
retPoint[j] = 0.0;
|
||||
for(row=0; row<em->uorder; row++)
|
||||
{
|
||||
retPoint[j] += em->ucoeff[row] * (*data);
|
||||
data += em->k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inDoEvalCoord1(REAL u)
|
||||
{
|
||||
REAL temp_vertex[4];
|
||||
REAL temp_normal[3];
|
||||
REAL temp_color[4];
|
||||
REAL temp_texcoord[4];
|
||||
if(texcoord_flag) //there is a texture map
|
||||
{
|
||||
inDoDomain1(&em_texcoord, u, temp_texcoord);
|
||||
texcoordCallBack(temp_texcoord, userData);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("color_flag = %i\n", color_flag);
|
||||
#endif
|
||||
if(color_flag) //there is a color map
|
||||
{
|
||||
inDoDomain1(&em_color, u, temp_color);
|
||||
colorCallBack(temp_color, userData);
|
||||
}
|
||||
if(normal_flag) //there is a normal map
|
||||
{
|
||||
inDoDomain1(&em_normal, u, temp_normal);
|
||||
normalCallBack(temp_normal, userData);
|
||||
}
|
||||
if(vertex_flag)
|
||||
{
|
||||
inDoDomain1(&em_vertex, u, temp_vertex);
|
||||
vertexCallBack(temp_vertex, userData);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCurveEvaluator::inMapMesh1f(int umin, int umax)
|
||||
{
|
||||
REAL du, u;
|
||||
int i;
|
||||
if(global_grid_nu == 0)
|
||||
return; //no points to output
|
||||
du = (global_grid_u1 - global_grid_u0) / (REAL) global_grid_nu;
|
||||
bgnline();
|
||||
for(i=umin; i<= umax; i++){
|
||||
u = (i==global_grid_nu)? global_grid_u1: global_grid_u0 + i*du;
|
||||
inDoEvalCoord1(u);
|
||||
}
|
||||
endline();
|
||||
}
|
||||
2067
src/glu/sgi/libnurbs/interface/insurfeval.cc
Normal file
2067
src/glu/sgi/libnurbs/interface/insurfeval.cc
Normal file
File diff suppressed because it is too large
Load diff
66
src/glu/sgi/libnurbs/interface/mystdio.h
Normal file
66
src/glu/sgi/libnurbs/interface/mystdio.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mystdio.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/mystdio.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumystdio_h_
|
||||
#define __glumystdio_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
inline void dprintf( char *, ... ) { }
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#ifndef NDEBUG
|
||||
#include <stdio.h>
|
||||
#define dprintf printf
|
||||
#else
|
||||
inline void dprintf( char *, ... ) { }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
inline void dprintf( char *, ... ) { }
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* __glumystdio_h_ */
|
||||
63
src/glu/sgi/libnurbs/interface/mystdlib.h
Normal file
63
src/glu/sgi/libnurbs/interface/mystdlib.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mystdlib.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/mystdlib.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumystdlib_h_
|
||||
#define __glumystdlib_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
typedef unsigned int size_t;
|
||||
extern "C" void abort( void );
|
||||
extern "C" void * malloc( size_t );
|
||||
extern "C" void free( void * );
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
typedef unsigned int size_t;
|
||||
extern "C" void abort( void );
|
||||
extern "C" void * malloc( size_t );
|
||||
extern "C" void free( void * );
|
||||
#endif
|
||||
|
||||
#endif /* __glumystdlib_h_ */
|
||||
356
src/glu/sgi/libnurbs/internals/arc.cc
Normal file
356
src/glu/sgi/libnurbs/internals/arc.cc
Normal file
|
|
@ -0,0 +1,356 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arc.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arc.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "bin.h"
|
||||
#include "bezierarc.h"
|
||||
#include "pwlarc.h"
|
||||
#include "simplemath.h"
|
||||
|
||||
/* local preprocessor definitions */
|
||||
#define ZERO 0.00001/*0.000001*/
|
||||
|
||||
const int Arc::bezier_tag = (1<<13);
|
||||
const int Arc::arc_tag = (1<<3);
|
||||
const int Arc::tail_tag = (1<<6);
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* makeSide - attach a pwl arc to an arc and mark it as a border arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::makeSide( PwlArc *pwl, arc_side side )
|
||||
{
|
||||
assert( pwl != 0);
|
||||
assert( pwlArc == 0 );
|
||||
assert( pwl->npts > 0 );
|
||||
assert( pwl->pts != 0);
|
||||
pwlArc = pwl;
|
||||
clearbezier();
|
||||
setside( side );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* numpts - count number of points on arc loop
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::numpts( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
int npts = 0;
|
||||
do {
|
||||
npts += jarc->pwlArc->npts;
|
||||
jarc = jarc->next;
|
||||
} while( jarc != this );
|
||||
return npts;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* markverts - mark each point with id of arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::markverts( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
|
||||
do {
|
||||
TrimVertex *p = jarc->pwlArc->pts;
|
||||
for( int i=0; i<jarc->pwlArc->npts; i++ )
|
||||
p[i].nuid = jarc->nuid;
|
||||
jarc = jarc->next;
|
||||
} while( jarc != this );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* getextrema - find axis extrema on arc loop
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::getextrema( Arc_ptr extrema[4] )
|
||||
{
|
||||
REAL leftpt, botpt, rightpt, toppt;
|
||||
|
||||
extrema[0] = extrema[1] = extrema[2] = extrema[3] = this;
|
||||
|
||||
leftpt = rightpt = this->tail()[0];
|
||||
botpt = toppt = this->tail()[1];
|
||||
|
||||
for( Arc_ptr jarc = this->next; jarc != this; jarc = jarc->next ) {
|
||||
if ( jarc->tail()[0] < leftpt ||
|
||||
(jarc->tail()[0] <= leftpt && jarc->rhead()[0]<=leftpt)) {
|
||||
leftpt = jarc->pwlArc->pts->param[0];
|
||||
extrema[1] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[0] > rightpt ||
|
||||
(jarc->tail()[0] >= rightpt && jarc->rhead()[0] >= rightpt)) {
|
||||
rightpt = jarc->pwlArc->pts->param[0];
|
||||
extrema[3] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[1] < botpt ||
|
||||
(jarc->tail()[1] <= botpt && jarc->rhead()[1] <= botpt )) {
|
||||
botpt = jarc->pwlArc->pts->param[1];
|
||||
extrema[2] = jarc;
|
||||
}
|
||||
if ( jarc->tail()[1] > toppt ||
|
||||
(jarc->tail()[1] >= toppt && jarc->rhead()[1] >= toppt)) {
|
||||
toppt = jarc->pwlArc->pts->param[1];
|
||||
extrema[0] = jarc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* show - print to the stdout the vertices of a pwl arc
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::show()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "\tPWLARC NP: %d FL: 1\n", pwlArc->npts );
|
||||
for( int i = 0; i < pwlArc->npts; i++ ) {
|
||||
dprintf( "\t\tVERTEX %f %f\n", pwlArc->pts[i].param[0],
|
||||
pwlArc->pts[i].param[1] );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* print - print out the vertices of all pwl arcs on a loop
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Arc::print( void )
|
||||
{
|
||||
Arc_ptr jarc = this;
|
||||
|
||||
if( ! this ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "\n\nEMPTY TRIM\n\n" );
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
dprintf( "BGNTRIM\n" );
|
||||
#endif
|
||||
do {
|
||||
jarc->show( );
|
||||
jarc = jarc->next;
|
||||
} while (jarc != this);
|
||||
#ifndef NDEBUG
|
||||
dprintf("ENDTRIM\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* isDisconnected - check if tail of arc and head of prev meet
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::isDisconnected( void )
|
||||
{
|
||||
if( pwlArc == 0 ) return 0;
|
||||
if( prev->pwlArc == 0 ) return 0;
|
||||
|
||||
REAL *p0 = tail();
|
||||
REAL *p1 = prev->rhead();
|
||||
|
||||
if( ((p0[0] - p1[0]) > ZERO) || ((p1[0] - p0[0]) > ZERO) ||
|
||||
((p0[1] - p1[1]) > ZERO) || ((p1[1] - p0[1]) > ZERO) ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "x coord = %f %f %f\n", p0[0], p1[0], p0[0] - p1[0] );
|
||||
dprintf( "y coord = %f %f %f\n", p0[1], p1[1], p0[1] - p1[1] );
|
||||
#endif
|
||||
return 1;
|
||||
} else {
|
||||
/* average two points together */
|
||||
p0[0] = p1[0] = (p1[0] + p0[0]) * 0.5;
|
||||
p0[1] = p1[1] = (p1[1] + p0[1]) * 0.5;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* neq_vert - assert that two 2D vertices are not equal
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline static int
|
||||
neq_vert( REAL *v1, REAL *v2 )
|
||||
{
|
||||
return ((v1[0] != v2[0]) || (v1[1] != v2[1] )) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* check - verify consistency of a loop, including
|
||||
* 1) if pwl, no two consecutive vertices are identical
|
||||
* 2) the circular link pointers are valid
|
||||
* 3) the geometric info at the head and tail are consistent
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Arc::check( void )
|
||||
{
|
||||
if( this == 0 ) return 1;
|
||||
Arc_ptr jarc = this;
|
||||
do {
|
||||
assert( (jarc->pwlArc != 0) || (jarc->bezierArc != 0) );
|
||||
|
||||
if (jarc->prev == 0 || jarc->next == 0) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "checkjarc:null next/prev pointer\n");
|
||||
jarc->print( );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (jarc->next->prev != jarc) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "checkjarc: pointer linkage screwed up\n");
|
||||
jarc->print( );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( jarc->pwlArc ) {
|
||||
#ifndef NDEBUG
|
||||
assert( jarc->pwlArc->npts >= 1 );
|
||||
assert( jarc->pwlArc->npts < 100000 );
|
||||
/*
|
||||
for( int i=0; i < jarc->pwlArc->npts-1; i++ )
|
||||
assert( neq_vert( jarc->pwlArc->pts[i].param,
|
||||
jarc->pwlArc->pts[i+1].param) );
|
||||
*/
|
||||
#endif
|
||||
if( jarc->prev->pwlArc ) {
|
||||
if( jarc->tail()[1] != jarc->prev->rhead()[1] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "checkjarc: geometric linkage screwed up 1\n");
|
||||
jarc->prev->show();
|
||||
jarc->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if( jarc->tail()[0] != jarc->prev->rhead()[0] ) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
dprintf( "checkjarc: geometric linkage screwed up 2\n");
|
||||
jarc->prev->show();
|
||||
jarc->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if( jarc->next->pwlArc ) {
|
||||
if( jarc->next->tail()[0] != jarc->rhead()[0] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "checkjarc: geometric linkage screwed up 3\n");
|
||||
jarc->show();
|
||||
jarc->next->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if( jarc->next->tail()[1] != jarc->rhead()[1] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "checkjarc: geometric linkage screwed up 4\n");
|
||||
jarc->show();
|
||||
jarc->next->show();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if( jarc->isbezier() ) {
|
||||
assert( jarc->pwlArc->npts == 2 );
|
||||
assert( (jarc->pwlArc->pts[0].param[0] == \
|
||||
jarc->pwlArc->pts[1].param[0]) ||\
|
||||
(jarc->pwlArc->pts[0].param[1] == \
|
||||
jarc->pwlArc->pts[1].param[1]) );
|
||||
}
|
||||
}
|
||||
jarc = jarc->next;
|
||||
} while (jarc != this);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#define TOL 0.00001
|
||||
|
||||
inline long tooclose( REAL x, REAL y )
|
||||
{
|
||||
return (abs(x-y) < TOL) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* append - append a jordan arc to a circularly linked list
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Arc_ptr
|
||||
Arc::append( Arc_ptr jarc )
|
||||
{
|
||||
if( jarc != 0 ) {
|
||||
next = jarc->next;
|
||||
prev = jarc;
|
||||
next->prev = prev->next = this;
|
||||
} else {
|
||||
next = prev = this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
139
src/glu/sgi/libnurbs/internals/arc.h
Normal file
139
src/glu/sgi/libnurbs/internals/arc.h
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arc.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arc.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluarc_h_
|
||||
#define __gluarc_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "bufpool.h"
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "pwlarc.h"
|
||||
#include "trimvertex.h"
|
||||
|
||||
class Bin;
|
||||
class Arc;
|
||||
class BezierArc;
|
||||
|
||||
typedef class Arc *Arc_ptr;
|
||||
|
||||
enum arc_side { arc_none = 0, arc_right, arc_top, arc_left, arc_bottom };
|
||||
|
||||
|
||||
class Arc: public PooledObj { /* an arc, in two list, the trim list and bin */
|
||||
|
||||
public:
|
||||
static const int bezier_tag;
|
||||
static const int arc_tag;
|
||||
static const int tail_tag;
|
||||
Arc_ptr prev; /* trim list pointer */
|
||||
Arc_ptr next; /* trim list pointer */
|
||||
Arc_ptr link; /* bin pointers */
|
||||
BezierArc * bezierArc; /* associated bezier arc */
|
||||
PwlArc * pwlArc; /* associated pwl arc */
|
||||
long type; /* curve type */
|
||||
long nuid;
|
||||
|
||||
inline Arc( Arc *, PwlArc * );
|
||||
inline Arc( arc_side, long );
|
||||
|
||||
Arc_ptr append( Arc_ptr );
|
||||
int check( void );
|
||||
int isMonotone( void );
|
||||
int isDisconnected( void );
|
||||
int numpts( void );
|
||||
void markverts( void );
|
||||
void getextrema( Arc_ptr[4] );
|
||||
void print( void );
|
||||
void show( void );
|
||||
void makeSide( PwlArc *, arc_side );
|
||||
inline int isTessellated() { return pwlArc ? 1 : 0; }
|
||||
inline long isbezier() { return type & bezier_tag; }
|
||||
inline void setbezier() { type |= bezier_tag; }
|
||||
inline void clearbezier() { type &= ~bezier_tag; }
|
||||
inline long npts() { return pwlArc->npts; }
|
||||
inline TrimVertex * pts() { return pwlArc->pts; }
|
||||
inline REAL * tail() { return pwlArc->pts[0].param; }
|
||||
inline REAL * head() { return next->pwlArc->pts[0].param; }
|
||||
inline REAL * rhead() { return pwlArc->pts[pwlArc->npts-1].param; }
|
||||
inline long ismarked() { return type & arc_tag; }
|
||||
inline void setmark() { type |= arc_tag; }
|
||||
inline void clearmark() { type &= (~arc_tag); }
|
||||
inline void clearside() { type &= ~(0x7 << 8); }
|
||||
inline void setside( arc_side s ) { clearside(); type |= (((long)s)<<8); }
|
||||
inline arc_side getside() { return (arc_side) ((type>>8) & 0x7); }
|
||||
inline int getitail() { return type & tail_tag; }
|
||||
inline void setitail() { type |= tail_tag; }
|
||||
inline void clearitail() { type &= (~tail_tag); }
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Arc - initialize a new Arc with the same type and uid of
|
||||
* a given Arc and a given pwl arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline
|
||||
Arc::Arc( Arc *j, PwlArc *p )
|
||||
{
|
||||
bezierArc = NULL;
|
||||
pwlArc = p;
|
||||
type = j->type;
|
||||
nuid = j->nuid;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Arc - initialize a new Arc with the same type and uid of
|
||||
* a given Arc and a given pwl arc
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline
|
||||
Arc::Arc( arc_side side, long _nuid )
|
||||
{
|
||||
bezierArc = NULL;
|
||||
pwlArc = NULL;
|
||||
type = 0;
|
||||
setside( side );
|
||||
nuid = _nuid;
|
||||
}
|
||||
|
||||
#endif /* __gluarc_h_ */
|
||||
174
src/glu/sgi/libnurbs/internals/arcsorter.cc
Normal file
174
src/glu/sgi/libnurbs/internals/arcsorter.cc
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arcsorter.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arcsorter.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluarcsorter_c_
|
||||
#define __gluarcsorter_c_
|
||||
|
||||
#include "glimports.h"
|
||||
#include "arc.h"
|
||||
#include "arcsorter.h"
|
||||
#include "subdivider.h"
|
||||
|
||||
ArcSorter::ArcSorter(Subdivider &s) : Sorter( sizeof( Arc ** ) ), subdivider(s)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ArcSorter::qscmp( char *, char * )
|
||||
{
|
||||
dprintf( "ArcSorter::qscmp: pure virtual called\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qsort( Arc **a, int n )
|
||||
{
|
||||
Sorter::qsort( (void *) a, n );
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qsexc( char *i, char *j )// i<-j, j<-i
|
||||
{
|
||||
Arc **jarc1 = (Arc **) i;
|
||||
Arc **jarc2 = (Arc **) j;
|
||||
Arc *tmp = *jarc1;
|
||||
*jarc1 = *jarc2;
|
||||
*jarc2 = tmp;
|
||||
}
|
||||
|
||||
void
|
||||
ArcSorter::qstexc( char *i, char *j, char *k )// i<-k, k<-j, j<-i
|
||||
{
|
||||
Arc **jarc1 = (Arc **) i;
|
||||
Arc **jarc2 = (Arc **) j;
|
||||
Arc **jarc3 = (Arc **) k;
|
||||
Arc *tmp = *jarc1;
|
||||
*jarc1 = *jarc3;
|
||||
*jarc3 = *jarc2;
|
||||
*jarc2 = tmp;
|
||||
}
|
||||
|
||||
|
||||
ArcSdirSorter::ArcSdirSorter( Subdivider &s ) : ArcSorter(s)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ArcSdirSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
Arc *jarc1 = *(Arc **) i;
|
||||
Arc *jarc2 = *(Arc **) j;
|
||||
|
||||
int v1 = (jarc1->getitail() ? 0 : (jarc1->pwlArc->npts - 1));
|
||||
int v2 = (jarc2->getitail() ? 0 : (jarc2->pwlArc->npts - 1));
|
||||
|
||||
REAL diff = jarc1->pwlArc->pts[v1].param[1] -
|
||||
jarc2->pwlArc->pts[v2].param[1];
|
||||
|
||||
if( diff < 0.0)
|
||||
return -1;
|
||||
else if( diff > 0.0)
|
||||
return 1;
|
||||
else {
|
||||
if( v1 == 0 ) {
|
||||
if( jarc2->tail()[0] < jarc1->tail()[0] ) {
|
||||
return subdivider.ccwTurn_sl( jarc2, jarc1 ) ? 1 : -1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_sr( jarc2, jarc1 ) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
if( jarc2->head()[0] < jarc1->head()[0] ) {
|
||||
return subdivider.ccwTurn_sl( jarc1, jarc2 ) ? -1 : 1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_sr( jarc1, jarc2 ) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArcTdirSorter::ArcTdirSorter( Subdivider &s ) : ArcSorter(s)
|
||||
{
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* ArcTdirSorter::qscmp -
|
||||
* compare two axis monotone arcs that are incident
|
||||
* to the line T == compare_value. Determine which of the
|
||||
* two intersects that line with a LESSER S value. If
|
||||
* jarc1 does, return 1. If jarc2 does, return -1.
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
ArcTdirSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
Arc *jarc1 = *(Arc **) i;
|
||||
Arc *jarc2 = *(Arc **) j;
|
||||
|
||||
int v1 = (jarc1->getitail() ? 0 : (jarc1->pwlArc->npts - 1));
|
||||
int v2 = (jarc2->getitail() ? 0 : (jarc2->pwlArc->npts - 1));
|
||||
|
||||
REAL diff = jarc1->pwlArc->pts[v1].param[0] -
|
||||
jarc2->pwlArc->pts[v2].param[0];
|
||||
|
||||
if( diff < 0.0)
|
||||
return 1;
|
||||
else if( diff > 0.0)
|
||||
return -1;
|
||||
else {
|
||||
if( v1 == 0 ) {
|
||||
if (jarc2->tail()[1] < jarc1->tail()[1]) {
|
||||
return subdivider.ccwTurn_tl( jarc2, jarc1 ) ? 1 : -1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_tr( jarc2, jarc1 ) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
if( jarc2->head()[1] < jarc1->head()[1] ) {
|
||||
return subdivider.ccwTurn_tl( jarc1, jarc2 ) ? -1 : 1;
|
||||
} else {
|
||||
return subdivider.ccwTurn_tr( jarc1, jarc2 ) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* __gluarcsorter_c_ */
|
||||
79
src/glu/sgi/libnurbs/internals/arcsorter.h
Normal file
79
src/glu/sgi/libnurbs/internals/arcsorter.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arcsorter.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arcsorter.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluarcsorter_h_
|
||||
#define __gluarcsorter_h_
|
||||
|
||||
#include "sorter.h"
|
||||
#include "arcsorter.h"
|
||||
|
||||
class Arc;
|
||||
class Subdivider;
|
||||
|
||||
class ArcSorter : private Sorter {
|
||||
public:
|
||||
ArcSorter(Subdivider &);
|
||||
void qsort( Arc **a, int n );
|
||||
protected:
|
||||
virtual int qscmp( char *, char * );
|
||||
Subdivider& subdivider;
|
||||
private:
|
||||
void qsexc( char *i, char *j ); // i<-j, j<-i
|
||||
void qstexc( char *i, char *j, char *k ); // i<-k, k<-j, j<-i
|
||||
};
|
||||
|
||||
|
||||
class ArcSdirSorter : public ArcSorter {
|
||||
public:
|
||||
ArcSdirSorter( Subdivider & );
|
||||
private:
|
||||
int qscmp( char *, char * );
|
||||
};
|
||||
|
||||
|
||||
class ArcTdirSorter : public ArcSorter {
|
||||
public:
|
||||
ArcTdirSorter( Subdivider & );
|
||||
private:
|
||||
int qscmp( char *, char * );
|
||||
};
|
||||
|
||||
#endif /* __gluarcsorter_h_ */
|
||||
609
src/glu/sgi/libnurbs/internals/arctess.cc
Normal file
609
src/glu/sgi/libnurbs/internals/arctess.cc
Normal file
|
|
@ -0,0 +1,609 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arctessellator.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arctess.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arctess.h"
|
||||
#include "bufpool.h"
|
||||
#include "simplemath.h"
|
||||
#include "bezierarc.h"
|
||||
#include "trimvertex.h"
|
||||
#include "trimvertpool.h"
|
||||
|
||||
#define NOELIMINATION
|
||||
|
||||
#define steps_function(large, small, rate) (max(1, 1+ (int) ((large-small)/rate)));
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ArcTessellator - construct an ArcTessellator
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ArcTessellator::ArcTessellator( TrimVertexPool& t, Pool& p )
|
||||
: trimvertexpool(t), pwlarcpool(p)
|
||||
{
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ~ArcTessellator - destroy an ArcTessellator
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ArcTessellator::~ArcTessellator( void )
|
||||
{
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* bezier - construct a bezier arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::bezier( Arc *arc, REAL s1, REAL s2, REAL t1, REAL t2 )
|
||||
{
|
||||
assert( arc != 0 );
|
||||
assert( ! arc->isTessellated() );
|
||||
|
||||
#ifndef NDEBUG
|
||||
switch( arc->getside() ) {
|
||||
case arc_left:
|
||||
assert( s1 == s2 );
|
||||
assert( t2 < t1 );
|
||||
break;
|
||||
case arc_right:
|
||||
assert( s1 == s2 );
|
||||
assert( t1 < t2 );
|
||||
break;
|
||||
case arc_top:
|
||||
assert( t1 == t2 );
|
||||
assert( s2 < s1 );
|
||||
break;
|
||||
case arc_bottom:
|
||||
assert( t1 == t2 );
|
||||
assert( s1 < s2 );
|
||||
break;
|
||||
case arc_none:
|
||||
(void) abort();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
TrimVertex *p = trimvertexpool.get(2);
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc( 2, p );
|
||||
p[0].param[0] = s1;
|
||||
p[0].param[1] = t1;
|
||||
p[1].param[0] = s2;
|
||||
p[1].param[1] = t2;
|
||||
assert( (s1 == s2) || (t1 == t2) );
|
||||
arc->setbezier();
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_left - construct a left boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_left( Arc *arc, REAL s, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
assert( t2 < t1 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
/* int nsteps = 1 + (int) ((t1 - t2) / rate ); */
|
||||
int nsteps = steps_function(t1, t2, rate);
|
||||
|
||||
|
||||
REAL stepsize = (t1 - t2) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = nsteps; i > 0; i-- ) {
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t2;
|
||||
t2 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t1;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_left );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_right - construct a right boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_right( Arc *arc, REAL s, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
assert( t1 < t2 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((t2 - t1) / rate ); */
|
||||
int nsteps = steps_function(t2,t1,rate);
|
||||
REAL stepsize = (t2 - t1) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t1;
|
||||
t1 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s;
|
||||
newvert[i].param[1] = t2;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_right );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_top - construct a top boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_top( Arc *arc, REAL t, REAL s1, REAL s2, REAL rate )
|
||||
{
|
||||
assert( s2 < s1 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((s1 - s2) / rate ); */
|
||||
int nsteps = steps_function(s1,s2,rate);
|
||||
REAL stepsize = (s1 - s2) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = nsteps; i > 0; i-- ) {
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t;
|
||||
s2 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_top );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl_bottom - construct a bottom boundary pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl_bottom( Arc *arc, REAL t, REAL s1, REAL s2, REAL rate )
|
||||
{
|
||||
assert( s1 < s2 );
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
/* int nsteps = 1 + (int) ((s2 - s1) / rate ); */
|
||||
int nsteps = steps_function(s2,s1,rate);
|
||||
REAL stepsize = (s2 - s1) / (REAL) nsteps;
|
||||
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
int i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t;
|
||||
s1 += stepsize;
|
||||
}
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t;
|
||||
|
||||
arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_bottom );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwl - construct a pwl arc and attach it to an arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::pwl( Arc *arc, REAL s1, REAL s2, REAL t1, REAL t2, REAL rate )
|
||||
{
|
||||
|
||||
/* if(rate <= 0.06) rate = 0.06;*/
|
||||
|
||||
int snsteps = 1 + (int) (abs(s2 - s1) / rate );
|
||||
int tnsteps = 1 + (int) (abs(t2 - t1) / rate );
|
||||
int nsteps = max(1,max( snsteps, tnsteps ));
|
||||
|
||||
REAL sstepsize = (s2 - s1) / (REAL) nsteps;
|
||||
REAL tstepsize = (t2 - t1) / (REAL) nsteps;
|
||||
TrimVertex *newvert = trimvertexpool.get( nsteps+1 );
|
||||
long i;
|
||||
for( i = 0; i < nsteps; i++ ) {
|
||||
newvert[i].param[0] = s1;
|
||||
newvert[i].param[1] = t1;
|
||||
s1 += sstepsize;
|
||||
t1 += tstepsize;
|
||||
}
|
||||
newvert[i].param[0] = s2;
|
||||
newvert[i].param[1] = t2;
|
||||
|
||||
/* arc->makeSide( new(pwlarcpool) PwlArc( nsteps+1, newvert ), arc_bottom ); */
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc( nsteps+1, newvert );
|
||||
|
||||
arc->clearbezier();
|
||||
arc->clearside( );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* tessellateLinear - constuct a linear pwl arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::tessellateLinear( Arc *arc, REAL geo_stepsize, REAL arc_stepsize, int isrational )
|
||||
{
|
||||
assert( arc->pwlArc == NULL );
|
||||
REAL s1, s2, t1, t2;
|
||||
|
||||
//we don't need to scale by arc_stepsize if the trim curve
|
||||
//is piecewise linear. Reason: In pwl_right, pwl_left, pwl_top, pwl_left,
|
||||
//and pwl, the nsteps is computed by deltaU (or V) /stepsize.
|
||||
//The quantity deltaU/arc_stepsize doesn't have any meaning. And
|
||||
//it causes problems: see bug 517641
|
||||
REAL stepsize = geo_stepsize; /* * arc_stepsize*/;
|
||||
|
||||
BezierArc *b = arc->bezierArc;
|
||||
|
||||
if( isrational ) {
|
||||
s1 = b->cpts[0] / b->cpts[2];
|
||||
t1 = b->cpts[1] / b->cpts[2];
|
||||
s2 = b->cpts[b->stride+0] / b->cpts[b->stride+2];
|
||||
t2 = b->cpts[b->stride+1] / b->cpts[b->stride+2];
|
||||
} else {
|
||||
s1 = b->cpts[0];
|
||||
t1 = b->cpts[1];
|
||||
s2 = b->cpts[b->stride+0];
|
||||
t2 = b->cpts[b->stride+1];
|
||||
}
|
||||
if( s1 == s2 )
|
||||
if( t1 < t2 )
|
||||
pwl_right( arc, s1, t1, t2, stepsize );
|
||||
else
|
||||
pwl_left( arc, s1, t1, t2, stepsize );
|
||||
else if( t1 == t2 )
|
||||
if( s1 < s2 )
|
||||
pwl_bottom( arc, t1, s1, s2, stepsize );
|
||||
else
|
||||
pwl_top( arc, t1, s1, s2, stepsize );
|
||||
else
|
||||
pwl( arc, s1, s2, t1, t2, stepsize );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* tessellateNonlinear - constuct a nonlinear pwl arc and attach it to an Arc
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
ArcTessellator::tessellateNonlinear( Arc *arc, REAL geo_stepsize, REAL arc_stepsize, int isrational )
|
||||
{
|
||||
assert( arc->pwlArc == NULL );
|
||||
|
||||
REAL stepsize = geo_stepsize * arc_stepsize;
|
||||
|
||||
BezierArc *bezierArc = arc->bezierArc;
|
||||
|
||||
REAL size; //bounding box size of the curve in UV
|
||||
{
|
||||
int i,j;
|
||||
REAL min_u, min_v, max_u,max_v;
|
||||
min_u = max_u = bezierArc->cpts[0];
|
||||
min_v = max_v = bezierArc->cpts[1];
|
||||
for(i=1, j=2; i<bezierArc->order; i++, j+= bezierArc->stride)
|
||||
{
|
||||
if(bezierArc->cpts[j] < min_u)
|
||||
min_u = bezierArc->cpts[j];
|
||||
if(bezierArc->cpts[j] > max_u)
|
||||
max_u = bezierArc->cpts[j];
|
||||
if(bezierArc->cpts[j+1] < min_v)
|
||||
min_v = bezierArc->cpts[j+1];
|
||||
if(bezierArc->cpts[j+1] > max_v)
|
||||
max_v = bezierArc->cpts[j+1];
|
||||
}
|
||||
|
||||
size = max_u - min_u;
|
||||
if(size < max_v - min_v)
|
||||
size = max_v - min_v;
|
||||
}
|
||||
|
||||
/*int nsteps = 1 + (int) (1.0/stepsize);*/
|
||||
|
||||
int nsteps = (int) (size/stepsize);
|
||||
if(nsteps <=0)
|
||||
nsteps=1;
|
||||
|
||||
TrimVertex *vert = trimvertexpool.get( nsteps+1 );
|
||||
REAL dp = 1.0/nsteps;
|
||||
|
||||
|
||||
arc->pwlArc = new(pwlarcpool) PwlArc();
|
||||
arc->pwlArc->pts = vert;
|
||||
|
||||
if( isrational ) {
|
||||
REAL pow_u[MAXORDER], pow_v[MAXORDER], pow_w[MAXORDER];
|
||||
trim_power_coeffs( bezierArc, pow_u, 0 );
|
||||
trim_power_coeffs( bezierArc, pow_v, 1 );
|
||||
trim_power_coeffs( bezierArc, pow_w, 2 );
|
||||
|
||||
/* compute first point exactly */
|
||||
REAL *b = bezierArc->cpts;
|
||||
vert->param[0] = b[0]/b[2];
|
||||
vert->param[1] = b[1]/b[2];
|
||||
|
||||
/* strength reduction on p = dp * step would introduce error */
|
||||
int step;
|
||||
int ocanremove = 0;
|
||||
register long order = bezierArc->order;
|
||||
for( step=1, ++vert; step<nsteps; step++, vert++ ) {
|
||||
register REAL p = dp * step;
|
||||
register REAL u = pow_u[0];
|
||||
register REAL v = pow_v[0];
|
||||
register REAL w = pow_w[0];
|
||||
for( register int i = 1; i < order; i++ ) {
|
||||
u = u * p + pow_u[i];
|
||||
v = v * p + pow_v[i];
|
||||
w = w * p + pow_w[i];
|
||||
}
|
||||
vert->param[0] = u/w;
|
||||
vert->param[1] = v/w;
|
||||
#ifndef NOELIMINATION
|
||||
REAL ds = abs(vert[0].param[0] - vert[-1].param[0]);
|
||||
REAL dt = abs(vert[0].param[1] - vert[-1].param[1]);
|
||||
int canremove = (ds<geo_stepsize && dt<geo_stepsize) ? 1 : 0;
|
||||
REAL ods=0.0, odt=0.0;
|
||||
|
||||
if( ocanremove && canremove ) {
|
||||
REAL nds = ds + ods;
|
||||
REAL ndt = dt + odt;
|
||||
if( nds<geo_stepsize && ndt<geo_stepsize ) {
|
||||
// remove previous point
|
||||
--vert;
|
||||
vert[0].param[0] = vert[1].param[0];
|
||||
vert[0].param[1] = vert[1].param[1];
|
||||
ods = nds;
|
||||
odt = ndt;
|
||||
ocanremove = 1;
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* compute last point exactly */
|
||||
b += (order - 1) * bezierArc->stride;
|
||||
vert->param[0] = b[0]/b[2];
|
||||
vert->param[1] = b[1]/b[2];
|
||||
|
||||
} else {
|
||||
REAL pow_u[MAXORDER], pow_v[MAXORDER];
|
||||
trim_power_coeffs( bezierArc, pow_u, 0 );
|
||||
trim_power_coeffs( bezierArc, pow_v, 1 );
|
||||
|
||||
/* compute first point exactly */
|
||||
REAL *b = bezierArc->cpts;
|
||||
vert->param[0] = b[0];
|
||||
vert->param[1] = b[1];
|
||||
|
||||
/* strength reduction on p = dp * step would introduce error */
|
||||
int step;
|
||||
int ocanremove = 0;
|
||||
register long order = bezierArc->order;
|
||||
for( step=1, ++vert; step<nsteps; step++, vert++ ) {
|
||||
register REAL p = dp * step;
|
||||
register REAL u = pow_u[0];
|
||||
register REAL v = pow_v[0];
|
||||
for( register int i = 1; i < bezierArc->order; i++ ) {
|
||||
u = u * p + pow_u[i];
|
||||
v = v * p + pow_v[i];
|
||||
}
|
||||
vert->param[0] = u;
|
||||
vert->param[1] = v;
|
||||
#ifndef NOELIMINATION
|
||||
REAL ds = abs(vert[0].param[0] - vert[-1].param[0]);
|
||||
REAL dt = abs(vert[0].param[1] - vert[-1].param[1]);
|
||||
int canremove = (ds<geo_stepsize && dt<geo_stepsize) ? 1 : 0;
|
||||
REAL ods=0.0, odt=0.0;
|
||||
|
||||
if( ocanremove && canremove ) {
|
||||
REAL nds = ds + ods;
|
||||
REAL ndt = dt + odt;
|
||||
if( nds<geo_stepsize && ndt<geo_stepsize ) {
|
||||
// remove previous point
|
||||
--vert;
|
||||
vert[0].param[0] = vert[1].param[0];
|
||||
vert[0].param[1] = vert[1].param[1];
|
||||
ods = nds;
|
||||
odt = ndt;
|
||||
ocanremove = 1;
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
} else {
|
||||
ocanremove = canremove;
|
||||
ods = ds;
|
||||
odt = dt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* compute last point exactly */
|
||||
b += (order - 1) * bezierArc->stride;
|
||||
vert->param[0] = b[0];
|
||||
vert->param[1] = b[1];
|
||||
}
|
||||
arc->pwlArc->npts = vert - arc->pwlArc->pts + 1;
|
||||
/*
|
||||
for( TrimVertex *vt=pwlArc->pts; vt != vert-1; vt++ ) {
|
||||
if( tooclose( vt[0].param[0], vt[1].param[0] ) )
|
||||
vt[1].param[0] = vt[0].param[0];
|
||||
if( tooclose( vt[0].param[1], vt[1].param[1] ) )
|
||||
vt[1].param[1] = vt[0].param[1];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
const REAL ArcTessellator::gl_Bernstein[][MAXORDER][MAXORDER] = {
|
||||
{
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 1, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -2, 1, 0, 0, 0, 0, 0 },
|
||||
{-2, 2, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 3, -3, 1, 0, 0, 0, 0 },
|
||||
{3, -6, 3, 0, 0, 0, 0, 0 },
|
||||
{-3, 3, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -4, 6, -4, 1, 0, 0, 0 },
|
||||
{-4, 12, -12, 4, 0, 0, 0, 0 },
|
||||
{6, -12, 6, 0, 0, 0, 0, 0 },
|
||||
{-4, 4, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 5, -10, 10, -5, 1, 0, 0 },
|
||||
{5, -20, 30, -20, 5, 0, 0, 0 },
|
||||
{-10, 30, -30, 10, 0, 0, 0, 0 },
|
||||
{10, -20, 10, 0, 0, 0, 0, 0 },
|
||||
{-5, 5, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{1, -6, 15, -20, 15, -6, 1, 0 },
|
||||
{-6, 30, -60, 60, -30, 6, 0, 0 },
|
||||
{15, -60, 90, -60, 15, 0, 0, 0 },
|
||||
{-20, 60, -60, 20, 0, 0, 0, 0 },
|
||||
{15, -30, 15, 0, 0, 0, 0, 0 },
|
||||
{-6, 6, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
},
|
||||
{
|
||||
{-1, 7, -21, 35, -35, 21, -7, 1 },
|
||||
{7, -42, 105, -140, 105, -42, 7, 0 },
|
||||
{-21, 105, -210, 210, -105, 21, 0, 0 },
|
||||
{35, -140, 210, -140, 35, 0, 0, 0 },
|
||||
{-35, 105, -105, 35, 0, 0, 0, 0 },
|
||||
{21, -42, 21, 0, 0, 0, 0, 0 },
|
||||
{-7, 7, 0, 0, 0, 0, 0, 0 },
|
||||
{1, 0, 0, 0, 0, 0, 0, 0 }
|
||||
}};
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* trim_power_coeffs - compute power basis coefficients from bezier coeffients
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ArcTessellator::trim_power_coeffs( BezierArc *bez_arc, REAL *p, int coord )
|
||||
{
|
||||
register int stride = bez_arc->stride;
|
||||
register int order = bez_arc->order;
|
||||
register REAL *base = bez_arc->cpts + coord;
|
||||
|
||||
REAL const (*mat)[MAXORDER][MAXORDER] = &gl_Bernstein[order-1];
|
||||
REAL const (*lrow)[MAXORDER] = &(*mat)[order];
|
||||
|
||||
/* WIN32 didn't like the following line within the for-loop */
|
||||
REAL const (*row)[MAXORDER] = &(*mat)[0];
|
||||
for( ; row != lrow; row++ ) {
|
||||
register REAL s = 0.0;
|
||||
register REAL *point = base;
|
||||
register REAL const *mlast = *row + order;
|
||||
for( REAL const *m = *row; m != mlast; m++, point += stride )
|
||||
s += *(m) * (*point);
|
||||
*(p++) = s;
|
||||
}
|
||||
}
|
||||
72
src/glu/sgi/libnurbs/internals/arctess.h
Normal file
72
src/glu/sgi/libnurbs/internals/arctess.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* arctess.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arctess.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluarctess_h_
|
||||
#define __gluarctess_h_
|
||||
|
||||
#include "defines.h"
|
||||
#include "types.h"
|
||||
#include "arc.h"
|
||||
|
||||
class BezierArc;
|
||||
class Pool;
|
||||
class TrimVertexPool;
|
||||
|
||||
class ArcTessellator {
|
||||
public:
|
||||
ArcTessellator( TrimVertexPool&, Pool& );
|
||||
~ArcTessellator( void );
|
||||
void bezier( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl( Arc_ptr, REAL, REAL, REAL, REAL, REAL );
|
||||
void pwl_left( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_right( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_top( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void pwl_bottom( Arc_ptr, REAL, REAL, REAL, REAL );
|
||||
void tessellateLinear( Arc_ptr, REAL, REAL, int );
|
||||
void tessellateNonlinear( Arc_ptr, REAL, REAL, int );
|
||||
private:
|
||||
static const REAL gl_Bernstein[][MAXORDER][MAXORDER];
|
||||
Pool& pwlarcpool;
|
||||
TrimVertexPool& trimvertexpool;
|
||||
static void trim_power_coeffs( BezierArc *, REAL[MAXORDER], int );
|
||||
};
|
||||
|
||||
#endif /* __gluarctess_h_ */
|
||||
591
src/glu/sgi/libnurbs/internals/backend.cc
Normal file
591
src/glu/sgi/libnurbs/internals/backend.cc
Normal file
|
|
@ -0,0 +1,591 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* backend.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/backend.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
/* Bezier surface backend
|
||||
- interprets display mode (wireframe,shaded,...)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "backend.h"
|
||||
#include "basiccrveval.h"
|
||||
#include "basicsurfeval.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
#define NOWIREFRAME
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnsurf - preamble to surface definition and evaluations
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::bgnsurf( int wiretris, int wirequads, long nuid )
|
||||
{
|
||||
/*#ifndef NOWIREFRAME*/ //need this for old version
|
||||
wireframetris = wiretris;
|
||||
wireframequads = wirequads;
|
||||
/*#endif*/
|
||||
|
||||
/*in the spec, GLU_DISPLAY_MODE is either
|
||||
* GLU_FILL
|
||||
* GLU_OUTLINE_POLY
|
||||
* GLU_OUTLINE_PATCH.
|
||||
*In fact, GLU_FLL is has the same effect as
|
||||
* set GL_FRONT_AND_BACK to be GL_FILL
|
||||
* and GLU_OUTLINE_POLY is the same as set
|
||||
* GL_FRONT_AND_BACK to be GL_LINE
|
||||
*It is more efficient to do this once at the beginning of
|
||||
*each surface than to do it for each primitive.
|
||||
* The internal has more options: outline_triangle and outline_quad
|
||||
*can be seperated. But since this is not in spec, and more importantly,
|
||||
*this is not so useful, so we don't need to keep this option.
|
||||
*/
|
||||
|
||||
surfaceEvaluator.bgnmap2f( nuid );
|
||||
|
||||
if(wiretris)
|
||||
surfaceEvaluator.polymode(N_MESHLINE);
|
||||
else
|
||||
surfaceEvaluator.polymode(N_MESHFILL);
|
||||
}
|
||||
|
||||
void
|
||||
Backend::patch( REAL ulo, REAL uhi, REAL vlo, REAL vhi )
|
||||
{
|
||||
surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::surfbbox( long type, REAL *from, REAL *to )
|
||||
{
|
||||
surfaceEvaluator.range2f( type, from, to );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* surfpts - pass a desription of a surface map
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::surfpts(
|
||||
long type, /* geometry, color, texture, normal */
|
||||
REAL *pts, /* control points */
|
||||
long ustride, /* distance to next point in u direction */
|
||||
long vstride, /* distance to next point in v direction */
|
||||
int uorder, /* u parametric order */
|
||||
int vorder, /* v parametric order */
|
||||
REAL ulo, /* u lower bound */
|
||||
REAL uhi, /* u upper bound */
|
||||
REAL vlo, /* v lower bound */
|
||||
REAL vhi ) /* v upper bound */
|
||||
{
|
||||
surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts );
|
||||
surfaceEvaluator.enable( type );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* surfgrid - define a lattice of points with origin and offset
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::surfgrid( REAL u0, REAL u1, long nu, REAL v0, REAL v1, long nv )
|
||||
{
|
||||
surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* surfmesh - evaluate a mesh of points on lattice
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::surfmesh( long u, long v, long n, long m )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( wireframequads ) {
|
||||
long v0, v1;
|
||||
long u0f = u, u1f = u+n;
|
||||
long v0f = v, v1f = v+m;
|
||||
long parity = (u & 1);
|
||||
|
||||
for( v0 = v0f, v1 = v0f++ ; v0<v1f; v0 = v1, v1++ ) {
|
||||
surfaceEvaluator.bgnline();
|
||||
for( long u = u0f; u<=u1f; u++ ) {
|
||||
if( parity ) {
|
||||
surfaceEvaluator.evalpoint2i( u, v0 );
|
||||
surfaceEvaluator.evalpoint2i( u, v1 );
|
||||
} else {
|
||||
surfaceEvaluator.evalpoint2i( u, v1 );
|
||||
surfaceEvaluator.evalpoint2i( u, v0 );
|
||||
}
|
||||
parity = 1 - parity;
|
||||
}
|
||||
surfaceEvaluator.endline();
|
||||
}
|
||||
} else {
|
||||
surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
|
||||
}
|
||||
#else
|
||||
if( wireframequads ) {
|
||||
|
||||
surfaceEvaluator.mapmesh2f( N_MESHLINE, u, u+n, v, v+m );
|
||||
} else {
|
||||
|
||||
surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endsurf - postamble to surface
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endsurf( void )
|
||||
{
|
||||
surfaceEvaluator.endmap2f();
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
void
|
||||
Backend::bgntfan( void )
|
||||
{
|
||||
surfaceEvaluator.bgntfan();
|
||||
/*
|
||||
if(wireframetris)
|
||||
surfaceEvaluator.polymode( N_MESHLINE );
|
||||
else
|
||||
surfaceEvaluator.polymode( N_MESHFILL );
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endtfan( void )
|
||||
{
|
||||
surfaceEvaluator.endtfan();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgnqstrip( void )
|
||||
{
|
||||
surfaceEvaluator.bgnqstrip();
|
||||
/*
|
||||
if(wireframequads)
|
||||
surfaceEvaluator.polymode( N_MESHLINE );
|
||||
else
|
||||
surfaceEvaluator.polymode( N_MESHFILL );
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endqstrip( void )
|
||||
{
|
||||
surfaceEvaluator.endqstrip();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
)
|
||||
{
|
||||
surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val,
|
||||
n_lower, v_lower, lower_val);
|
||||
}
|
||||
|
||||
void
|
||||
Backend::evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val
|
||||
)
|
||||
{
|
||||
surfaceEvaluator.evalVStrip(n_left, u_left, left_val,
|
||||
n_right, u_right, right_val);
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgntmesh - preamble to a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::bgntmesh( char * )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
|
||||
meshindex = 0; /* I think these need to be initialized to zero */
|
||||
npts = 0;
|
||||
|
||||
if( !wireframetris ) {
|
||||
surfaceEvaluator.bgntmesh();
|
||||
}
|
||||
#else
|
||||
|
||||
if( wireframetris ) {
|
||||
surfaceEvaluator.bgntmesh();
|
||||
surfaceEvaluator.polymode( N_MESHLINE );
|
||||
} else {
|
||||
surfaceEvaluator.bgntmesh();
|
||||
surfaceEvaluator.polymode( N_MESHFILL );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Backend::tmeshvert( GridTrimVertex *v )
|
||||
{
|
||||
if( v->isGridVert() ) {
|
||||
tmeshvert( v->g );
|
||||
} else {
|
||||
tmeshvert( v->t );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Backend::tmeshvertNOGE(TrimVertex *t)
|
||||
{
|
||||
// surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], temp, ttt);
|
||||
#ifdef USE_OPTTT
|
||||
surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
//opt for a line with the same u.
|
||||
void
|
||||
Backend::tmeshvertNOGE_BU(TrimVertex *t)
|
||||
{
|
||||
#ifdef USE_OPTTT
|
||||
surfaceEvaluator.inDoEvalCoord2NOGE_BU( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
//opt for a line with the same v.
|
||||
void
|
||||
Backend::tmeshvertNOGE_BV(TrimVertex *t)
|
||||
{
|
||||
#ifdef USE_OPTTT
|
||||
surfaceEvaluator.inDoEvalCoord2NOGE_BV( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Backend::preEvaluateBU(REAL u)
|
||||
{
|
||||
surfaceEvaluator.inPreEvaluateBU_intfac(u);
|
||||
}
|
||||
|
||||
void
|
||||
Backend::preEvaluateBV(REAL v)
|
||||
{
|
||||
surfaceEvaluator.inPreEvaluateBV_intfac(v);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* tmeshvert - evaluate a point on a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::tmeshvert( TrimVertex *t )
|
||||
{
|
||||
|
||||
const long nuid = t->nuid;
|
||||
const REAL u = t->param[0];
|
||||
const REAL v = t->param[1];
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 0;
|
||||
mesh[meshindex][3] = nuid;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
}
|
||||
#else
|
||||
|
||||
surfaceEvaluator.evalcoord2f( 0, u, v );
|
||||
//for uninitial memory read surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
//the same as tmeshvert(trimvertex), for efficiency purpose
|
||||
void
|
||||
Backend::tmeshvert( REAL u, REAL v )
|
||||
{
|
||||
|
||||
const long nuid = 0;
|
||||
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 0;
|
||||
mesh[meshindex][3] = nuid;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalcoord2f( nuid, u, v );
|
||||
}
|
||||
#else
|
||||
|
||||
surfaceEvaluator.evalcoord2f( 0, u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* tmeshvert - evaluate a grid point of a triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::tmeshvert( GridVertex *g )
|
||||
{
|
||||
const long u = g->gparam[0];
|
||||
const long v = g->gparam[1];
|
||||
|
||||
#ifndef NOWIREFRAME
|
||||
npts++;
|
||||
if( wireframetris ) {
|
||||
if( npts >= 3 ) {
|
||||
surfaceEvaluator.bgnclosedline();
|
||||
if( mesh[0][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( (long) mesh[0][3], mesh[0][0], mesh[0][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
||||
if( mesh[1][2] == 0 )
|
||||
surfaceEvaluator.evalcoord2f( (long) mesh[1][3], mesh[1][0], mesh[1][1] );
|
||||
else
|
||||
surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
surfaceEvaluator.endclosedline();
|
||||
}
|
||||
mesh[meshindex][0] = u;
|
||||
mesh[meshindex][1] = v;
|
||||
mesh[meshindex][2] = 1;
|
||||
meshindex = (meshindex+1) % 2;
|
||||
} else {
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
}
|
||||
#else
|
||||
surfaceEvaluator.evalpoint2i( u, v );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* swaptmesh - perform a swap of the triangle mesh pointers
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::swaptmesh( void )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( wireframetris ) {
|
||||
meshindex = 1 - meshindex;
|
||||
} else {
|
||||
surfaceEvaluator.swaptmesh();
|
||||
}
|
||||
#else
|
||||
surfaceEvaluator.swaptmesh();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endtmesh - postamble to triangle mesh
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endtmesh( void )
|
||||
{
|
||||
#ifndef NOWIREFRAME
|
||||
if( ! wireframetris )
|
||||
surfaceEvaluator.endtmesh();
|
||||
#else
|
||||
surfaceEvaluator.endtmesh();
|
||||
/* surfaceEvaluator.polymode( N_MESHFILL );*/
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* bgnoutline - preamble to outlined rendering
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::bgnoutline( void )
|
||||
{
|
||||
surfaceEvaluator.bgnline();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* linevert - evaluate a point on an outlined contour
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::linevert( TrimVertex *t )
|
||||
{
|
||||
surfaceEvaluator.evalcoord2f( t->nuid, t->param[0], t->param[1] );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* linevert - evaluate a grid point of an outlined contour
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::linevert( GridVertex *g )
|
||||
{
|
||||
surfaceEvaluator.evalpoint2i( g->gparam[0], g->gparam[1] );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* endoutline - postamble to outlined rendering
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::endoutline( void )
|
||||
{
|
||||
surfaceEvaluator.endline();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* triangle - output a triangle
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Backend::triangle( TrimVertex *a, TrimVertex *b, TrimVertex *c )
|
||||
{
|
||||
/* bgntmesh( "spittriangle" );*/
|
||||
bgntfan();
|
||||
tmeshvert( a );
|
||||
tmeshvert( b );
|
||||
tmeshvert( c );
|
||||
endtfan();
|
||||
/* endtmesh();*/
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgncurv( void )
|
||||
{
|
||||
curveEvaluator.bgnmap1f( 0 );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::segment( REAL ulo, REAL uhi )
|
||||
{
|
||||
curveEvaluator.domain1f( ulo, uhi );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvpts(
|
||||
long type, /* geometry, color, texture, normal */
|
||||
REAL *pts, /* control points */
|
||||
long stride, /* distance to next point */
|
||||
int order, /* parametric order */
|
||||
REAL ulo, /* lower parametric bound */
|
||||
REAL uhi ) /* upper parametric bound */
|
||||
|
||||
{
|
||||
curveEvaluator.map1f( type, ulo, uhi, stride, order, pts );
|
||||
curveEvaluator.enable( type );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvgrid( REAL u0, REAL u1, long nu )
|
||||
{
|
||||
curveEvaluator.mapgrid1f( nu, u0, u1 );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvmesh( long from, long n )
|
||||
{
|
||||
curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::curvpt(REAL u)
|
||||
{
|
||||
curveEvaluator.evalcoord1f( 0, u );
|
||||
}
|
||||
|
||||
void
|
||||
Backend::bgnline( void )
|
||||
{
|
||||
curveEvaluator.bgnline();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endline( void )
|
||||
{
|
||||
curveEvaluator.endline();
|
||||
}
|
||||
|
||||
void
|
||||
Backend::endcurv( void )
|
||||
{
|
||||
curveEvaluator.endmap1f();
|
||||
}
|
||||
119
src/glu/sgi/libnurbs/internals/backend.h
Normal file
119
src/glu/sgi/libnurbs/internals/backend.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* backend.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/backend.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glubackend_h_
|
||||
#define __glubackend_h_
|
||||
|
||||
#include "trimvertex.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
|
||||
class BasicCurveEvaluator;
|
||||
class BasicSurfaceEvaluator;
|
||||
|
||||
class Backend {
|
||||
private:
|
||||
BasicCurveEvaluator& curveEvaluator;
|
||||
BasicSurfaceEvaluator& surfaceEvaluator;
|
||||
public:
|
||||
Backend( BasicCurveEvaluator &c, BasicSurfaceEvaluator& e )
|
||||
: curveEvaluator(c), surfaceEvaluator(e) {}
|
||||
|
||||
/* surface backend routines */
|
||||
void bgnsurf( int, int, long );
|
||||
void patch( REAL, REAL, REAL, REAL );
|
||||
void surfpts( long, REAL *, long, long, int, int,
|
||||
REAL, REAL, REAL, REAL );
|
||||
void surfbbox( long, REAL *, REAL * );
|
||||
void surfgrid( REAL, REAL, long, REAL, REAL, long );
|
||||
void surfmesh( long, long, long, long );
|
||||
void bgntmesh( char * );
|
||||
void endtmesh( void );
|
||||
void swaptmesh( void );
|
||||
void tmeshvert( GridTrimVertex * );
|
||||
void tmeshvert( TrimVertex * );
|
||||
void tmeshvert( GridVertex * );
|
||||
void tmeshvert( REAL u, REAL v );
|
||||
void linevert( TrimVertex * );
|
||||
void linevert( GridVertex * );
|
||||
void bgnoutline( void );
|
||||
void endoutline( void );
|
||||
void endsurf( void );
|
||||
void triangle( TrimVertex*, TrimVertex*, TrimVertex* );
|
||||
|
||||
void bgntfan();
|
||||
void endtfan();
|
||||
void bgnqstrip();
|
||||
void endqstrip();
|
||||
void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
);
|
||||
void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL v_right, REAL* right_val
|
||||
);
|
||||
void tmeshvertNOGE(TrimVertex *t);
|
||||
void tmeshvertNOGE_BU(TrimVertex *t);
|
||||
void tmeshvertNOGE_BV(TrimVertex *t);
|
||||
void preEvaluateBU(REAL u);
|
||||
void preEvaluateBV(REAL v);
|
||||
|
||||
|
||||
/* curve backend routines */
|
||||
void bgncurv( void );
|
||||
void segment( REAL, REAL );
|
||||
void curvpts( long, REAL *, long, int, REAL, REAL );
|
||||
void curvgrid( REAL, REAL, long );
|
||||
void curvmesh( long, long );
|
||||
void curvpt( REAL );
|
||||
void bgnline( void );
|
||||
void endline( void );
|
||||
void endcurv( void );
|
||||
private:
|
||||
#ifndef NOWIREFRAME
|
||||
int wireframetris;
|
||||
int wireframequads;
|
||||
int npts;
|
||||
REAL mesh[3][4];
|
||||
int meshindex;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __glubackend_h_ */
|
||||
140
src/glu/sgi/libnurbs/internals/basiccrveval.cc
Normal file
140
src/glu/sgi/libnurbs/internals/basiccrveval.cc
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basiccrveval.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basiccrveval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "basiccrveval.h"
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::domain1f( REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "domain1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::range1f( long type, REAL *, REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "range1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::enable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "enable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::disable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "disable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::bgnmap1f( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgnmap1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::map1f( long, REAL, REAL, long, long, REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "map1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::mapgrid1f( long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "mapgrid1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::mapmesh1f( long, long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "mapmesh1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::evalcoord1f( long, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "evalcoord1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::endmap1f( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endmap1f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::bgnline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgnline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicCurveEvaluator::endline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endline\n" );
|
||||
#endif
|
||||
}
|
||||
67
src/glu/sgi/libnurbs/internals/basiccrveval.h
Normal file
67
src/glu/sgi/libnurbs/internals/basiccrveval.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basiccurveeval.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basiccrveval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glubasiccrveval_h_
|
||||
#define __glubasiccrveval_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "displaymode.h"
|
||||
#include "cachingeval.h"
|
||||
|
||||
class BasicCurveEvaluator : public CachingEvaluator {
|
||||
public:
|
||||
virtual void domain1f( REAL, REAL );
|
||||
virtual void range1f( long, REAL *, REAL * );
|
||||
|
||||
virtual void enable( long );
|
||||
virtual void disable( long );
|
||||
virtual void bgnmap1f( long );
|
||||
virtual void map1f( long, REAL, REAL, long, long, REAL * );
|
||||
virtual void mapgrid1f( long, REAL, REAL );
|
||||
virtual void mapmesh1f( long, long, long );
|
||||
virtual void evalcoord1f( long, REAL );
|
||||
virtual void endmap1f( void );
|
||||
|
||||
virtual void bgnline( void );
|
||||
virtual void endline( void );
|
||||
};
|
||||
|
||||
#endif /* __glubasiccrveval_h_ */
|
||||
230
src/glu/sgi/libnurbs/internals/basicsurfeval.cc
Normal file
230
src/glu/sgi/libnurbs/internals/basicsurfeval.cc
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basicsurfaceevaluator.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basicsurfeval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "basicsurfeval.h"
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::domain2f( REAL, REAL, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "domain2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::polymode( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "polymode\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::range2f( long type, REAL *from, REAL *to )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "range2f type %ld, from (%g,%g), to (%g,%g)\n",
|
||||
type, from[0], from[1], to[0], to[1] );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::enable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "enable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::disable( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "disable\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnmap2f( long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgnmap2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endmap2f( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endmap2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long,
|
||||
REAL * )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "map2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::mapgrid2f( long, REAL, REAL, long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "mapgrid2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::mapmesh2f( long, long, long, long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "mapmesh2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::evalcoord2f( long, REAL, REAL )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "evalcoord2f\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::evalpoint2i( long, long )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "evalpoint2i\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgnline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnclosedline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgnclosedline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endclosedline( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endclosedline\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgntfan( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgntfan\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endtfan( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgntmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgntmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::swaptmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "swaptmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endtmesh( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endtmesh\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::bgnqstrip( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgnqstrip\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
BasicSurfaceEvaluator::endqstrip( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endqstrip\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
95
src/glu/sgi/libnurbs/internals/basicsurfeval.h
Normal file
95
src/glu/sgi/libnurbs/internals/basicsurfeval.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* basicsurfeval.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basicsurfeval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glubasicsurfeval_h_
|
||||
#define __glubasicsurfeval_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "displaymode.h"
|
||||
#include "cachingeval.h"
|
||||
|
||||
class BasicSurfaceEvaluator : public CachingEvaluator {
|
||||
public:
|
||||
virtual void range2f( long, REAL *, REAL * );
|
||||
virtual void domain2f( REAL, REAL, REAL, REAL );
|
||||
|
||||
virtual void enable( long );
|
||||
virtual void disable( long );
|
||||
virtual void bgnmap2f( long );
|
||||
virtual void map2f( long, REAL, REAL, long, long,
|
||||
REAL, REAL, long, long,
|
||||
REAL * );
|
||||
virtual void mapgrid2f( long, REAL, REAL, long, REAL, REAL );
|
||||
virtual void mapmesh2f( long, long, long, long, long );
|
||||
virtual void evalcoord2f( long, REAL, REAL );
|
||||
virtual void evalpoint2i( long, long );
|
||||
virtual void endmap2f( void );
|
||||
|
||||
virtual void polymode( long );
|
||||
virtual void bgnline( void );
|
||||
virtual void endline( void );
|
||||
virtual void bgnclosedline( void );
|
||||
virtual void endclosedline( void );
|
||||
virtual void bgntmesh( void );
|
||||
virtual void swaptmesh( void );
|
||||
virtual void endtmesh( void );
|
||||
virtual void bgnqstrip( void );
|
||||
virtual void endqstrip( void );
|
||||
|
||||
virtual void bgntfan( void );
|
||||
virtual void endtfan( void );
|
||||
|
||||
virtual void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
||||
int n_lower, REAL v_lower, REAL* lower_val
|
||||
) = 0;
|
||||
|
||||
virtual void evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
||||
int n_right, REAL u_right, REAL* right_val
|
||||
) = 0;
|
||||
virtual void inDoEvalCoord2NOGE(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inDoEvalCoord2NOGE_BU(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inDoEvalCoord2NOGE_BV(REAL u, REAL v, REAL* ret_point, REAL* ret_normal) = 0;
|
||||
virtual void inPreEvaluateBV_intfac(REAL v ) = 0;
|
||||
virtual void inPreEvaluateBU_intfac(REAL u ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __glubasicsurfeval_h_ */
|
||||
57
src/glu/sgi/libnurbs/internals/bezierarc.h
Normal file
57
src/glu/sgi/libnurbs/internals/bezierarc.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bezierarc.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bezierarc.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glubezierarc_h
|
||||
#define __glubezierarc_h
|
||||
|
||||
#include "myassert.h"
|
||||
|
||||
class Mapdesc;
|
||||
|
||||
struct BezierArc : public PooledObj { /* a bezier arc */
|
||||
REAL * cpts; /* control points of arc */
|
||||
int order; /* order of arc */
|
||||
int stride; /* REAL distance between points */
|
||||
long type; /* curve type */
|
||||
Mapdesc * mapdesc;
|
||||
};
|
||||
|
||||
#endif /* __glubezierarc_h */
|
||||
168
src/glu/sgi/libnurbs/internals/bin.cc
Normal file
168
src/glu/sgi/libnurbs/internals/bin.cc
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bin.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bin.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "bin.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Constructor and destructor
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
Bin::Bin()
|
||||
{
|
||||
head = NULL;
|
||||
}
|
||||
|
||||
Bin::~Bin()
|
||||
{
|
||||
assert( head == NULL);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* remove_this_arc - remove given Arc_ptr from bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::remove_this_arc( Arc_ptr arc )
|
||||
{
|
||||
Arc_ptr *j;
|
||||
for( j = &(head); (*j != 0) && (*j != arc); j = &((*j)->link) );
|
||||
|
||||
if( *j != 0 ) {
|
||||
if( *j == current )
|
||||
current = (*j)->link;
|
||||
*j = (*j)->link;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* numarcs - count number of arcs in bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Bin::numarcs()
|
||||
{
|
||||
long count = 0;
|
||||
for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* adopt - place an orphaned arcs into their new parents bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::adopt()
|
||||
{
|
||||
markall();
|
||||
|
||||
Arc_ptr orphan;
|
||||
while( (orphan = removearc()) != NULL ) {
|
||||
for( Arc_ptr parent = orphan->next; parent != orphan; parent = parent->next ) {
|
||||
if (! parent->ismarked() ) {
|
||||
orphan->link = parent->link;
|
||||
parent->link = orphan;
|
||||
orphan->clearmark();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* show - print out descriptions of the arcs in the bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::show( char *name )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "%s\n", name );
|
||||
for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
||||
jarc->show( );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* markall - mark all arcs with an identifying tag
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::markall()
|
||||
{
|
||||
for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() )
|
||||
jarc->setmark();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* listBezier - print out all arcs that are untessellated border arcs
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Bin::listBezier( void )
|
||||
{
|
||||
for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() ) {
|
||||
if( jarc->isbezier( ) ) {
|
||||
assert( jarc->pwlArc->npts == 2 );
|
||||
TrimVertex *pts = jarc->pwlArc->pts;
|
||||
REAL s1 = pts[0].param[0];
|
||||
REAL t1 = pts[0].param[1];
|
||||
REAL s2 = pts[1].param[0];
|
||||
REAL t2 = pts[1].param[1];
|
||||
#ifndef NDEBUG
|
||||
dprintf( "arc (%g,%g) (%g,%g)\n", s1, t1, s2, t2 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
127
src/glu/sgi/libnurbs/internals/bin.h
Normal file
127
src/glu/sgi/libnurbs/internals/bin.h
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bin.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bin.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glubin_h_
|
||||
#define __glubin_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Bin
|
||||
{ /* a linked list of jordan arcs */
|
||||
private:
|
||||
Arc_ptr head;/*first arc on list */
|
||||
Arc_ptr current; /* current arc on list */
|
||||
public:
|
||||
Bin();
|
||||
~Bin();
|
||||
inline Arc_ptr firstarc( void );
|
||||
inline Arc_ptr nextarc( void );
|
||||
inline Arc_ptr removearc( void );
|
||||
inline int isnonempty( void ) { return (head ? 1 : 0); }
|
||||
inline void addarc( Arc_ptr );
|
||||
void remove_this_arc( Arc_ptr );
|
||||
int numarcs( void );
|
||||
void adopt( void );
|
||||
void markall( void );
|
||||
void show( char * );
|
||||
void listBezier( void );
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Bin::addarc - add an Arc_ptr to head of linked list of Arc_ptr
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void
|
||||
Bin::addarc( Arc_ptr jarc )
|
||||
{
|
||||
jarc->link = head;
|
||||
head = jarc;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Bin::removearc - remove first Arc_ptr from bin
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::removearc( void )
|
||||
{
|
||||
Arc_ptr jarc = head;
|
||||
|
||||
if( jarc ) head = jarc->link;
|
||||
return jarc;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* BinIter::nextarc - return current arc in bin and advance pointer to next arc
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::nextarc( void )
|
||||
{
|
||||
Arc_ptr jarc = current;
|
||||
|
||||
#ifdef DEBUG
|
||||
assert( jarc->check() != 0 );
|
||||
#endif
|
||||
|
||||
if( jarc ) current = jarc->link;
|
||||
return jarc;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* BinIter::firstarc - set current arc to first arc of bin advance to next arc
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline Arc_ptr
|
||||
Bin::firstarc( void )
|
||||
{
|
||||
current = head;
|
||||
return nextarc( );
|
||||
}
|
||||
|
||||
#endif /* __glubin_h_ */
|
||||
109
src/glu/sgi/libnurbs/internals/bufpool.cc
Normal file
109
src/glu/sgi/libnurbs/internals/bufpool.cc
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bufpool.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bufpool.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "bufpool.h"
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool - allocate a new pool of buffers
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
Pool::Pool( int _buffersize, int initpoolsize, char *n )
|
||||
{
|
||||
buffersize= (_buffersize < sizeof(Buffer)) ? sizeof(Buffer) : _buffersize;
|
||||
initsize = initpoolsize * buffersize;
|
||||
nextsize = initsize;
|
||||
name = n;
|
||||
magic = is_allocated;
|
||||
nextblock = 0;
|
||||
curblock = 0;
|
||||
freelist = 0;
|
||||
nextfree = 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* ~Pool - free a pool of buffers and the pool itself
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Pool::~Pool( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
while( nextblock ) {
|
||||
delete [] blocklist[--nextblock];
|
||||
blocklist[nextblock] = 0;
|
||||
}
|
||||
magic = is_free;
|
||||
}
|
||||
|
||||
|
||||
void Pool::grow( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
curblock = new char[nextsize];
|
||||
blocklist[nextblock++] = curblock;
|
||||
nextfree = nextsize;
|
||||
nextsize *= 2;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::clear - free buffers associated with pool but keep pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Pool::clear( void )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
while( nextblock ) {
|
||||
delete [] blocklist[--nextblock];
|
||||
blocklist[nextblock] = 0;
|
||||
}
|
||||
curblock = 0;
|
||||
freelist = 0;
|
||||
nextfree = 0;
|
||||
if( nextsize > initsize )
|
||||
nextsize /= 2;
|
||||
}
|
||||
145
src/glu/sgi/libnurbs/internals/bufpool.h
Normal file
145
src/glu/sgi/libnurbs/internals/bufpool.h
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bufpool.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bufpool.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glubufpool_h_
|
||||
#define __glubufpool_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "mystdlib.h"
|
||||
|
||||
#define NBLOCKS 32
|
||||
|
||||
class Buffer {
|
||||
friend class Pool;
|
||||
Buffer * next; /* next buffer on free list */
|
||||
};
|
||||
|
||||
class Pool {
|
||||
public:
|
||||
Pool( int, int, char * );
|
||||
~Pool( void );
|
||||
inline void* new_buffer( void );
|
||||
inline void free_buffer( void * );
|
||||
void clear( void );
|
||||
|
||||
private:
|
||||
void grow( void );
|
||||
|
||||
protected:
|
||||
Buffer *freelist; /* linked list of free buffers */
|
||||
char *blocklist[NBLOCKS]; /* blocks of malloced memory */
|
||||
int nextblock; /* next free block index */
|
||||
char *curblock; /* last malloced block */
|
||||
int buffersize; /* bytes per buffer */
|
||||
int nextsize; /* size of next block of memory */
|
||||
int nextfree; /* byte offset past next free buffer */
|
||||
int initsize;
|
||||
enum Magic { is_allocated = 0xf3a1, is_free = 0xf1a2 };
|
||||
char *name; /* name of the pool */
|
||||
Magic magic; /* marker for valid pool */
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::free_buffer - return a buffer to a pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void
|
||||
Pool::free_buffer( void *b )
|
||||
{
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
/* add buffer to singly connected free list */
|
||||
|
||||
((Buffer *) b)->next = freelist;
|
||||
freelist = (Buffer *) b;
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Pool::new_buffer - allocate a buffer from a pool
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
inline void *
|
||||
Pool::new_buffer( void )
|
||||
{
|
||||
void *buffer;
|
||||
|
||||
assert( (this != 0) && (magic == is_allocated) );
|
||||
|
||||
/* find free buffer */
|
||||
|
||||
if( freelist ) {
|
||||
buffer = (void *) freelist;
|
||||
freelist = freelist->next;
|
||||
} else {
|
||||
if( ! nextfree )
|
||||
grow( );
|
||||
nextfree -= buffersize;;
|
||||
buffer = (void *) (curblock + nextfree);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
class PooledObj {
|
||||
public:
|
||||
inline void * operator new( size_t, Pool & );
|
||||
inline void * operator new( size_t, void *);
|
||||
inline void * operator new( size_t s)
|
||||
{ return ::new char[s]; }
|
||||
inline void operator delete( void * ) { assert( 0 ); }
|
||||
inline void deleteMe( Pool & );
|
||||
};
|
||||
|
||||
inline void *
|
||||
PooledObj::operator new( size_t, Pool& pool )
|
||||
{
|
||||
return pool.new_buffer();
|
||||
}
|
||||
|
||||
inline void
|
||||
PooledObj::deleteMe( Pool& pool )
|
||||
{
|
||||
pool.free_buffer( (void *) this );
|
||||
}
|
||||
|
||||
#endif /* __glubufpool_h_ */
|
||||
80
src/glu/sgi/libnurbs/internals/cachingeval.cc
Normal file
80
src/glu/sgi/libnurbs/internals/cachingeval.cc
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* cachingeval.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/cachingeval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "cachingeval.h"
|
||||
|
||||
int
|
||||
CachingEvaluator::canRecord( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CachingEvaluator::canPlayAndRecord( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CachingEvaluator::createHandle( int )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::beginOutput( ServiceMode, int )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::endOutput( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::discardRecording( int )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CachingEvaluator::playRecording( int )
|
||||
{
|
||||
}
|
||||
56
src/glu/sgi/libnurbs/internals/cachingeval.h
Normal file
56
src/glu/sgi/libnurbs/internals/cachingeval.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* cachingeval.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/cachingeval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glucachingval_h_
|
||||
#define __glucachingval_h_
|
||||
|
||||
class CachingEvaluator {
|
||||
public:
|
||||
enum ServiceMode { play, record, playAndRecord };
|
||||
virtual int canRecord( void );
|
||||
virtual int canPlayAndRecord( void );
|
||||
virtual int createHandle( int handle );
|
||||
virtual void beginOutput( ServiceMode, int handle );
|
||||
virtual void endOutput( void );
|
||||
virtual void discardRecording( int handle );
|
||||
virtual void playRecording( int handle );
|
||||
};
|
||||
#endif /* __glucachingval_h_ */
|
||||
567
src/glu/sgi/libnurbs/internals/ccw.cc
Normal file
567
src/glu/sgi/libnurbs/internals/ccw.cc
Normal file
|
|
@ -0,0 +1,567 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ccw.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/ccw.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "subdivider.h"
|
||||
#include "types.h"
|
||||
#include "arc.h"
|
||||
#include "trimvertex.h"
|
||||
#include "simplemath.h"
|
||||
|
||||
inline int
|
||||
Subdivider::bbox( TrimVertex *a, TrimVertex *b, TrimVertex *c, int p )
|
||||
{
|
||||
return bbox( a->param[p], b->param[p], c->param[p],
|
||||
a->param[1-p], b->param[1-p], c->param[1-p] );
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_sr( Arc_ptr j1, Arc_ptr j2 ) // dir = 1
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
dprintf( "arc_ccw_turn, p = %d\n", 0 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (0 == v1->param[0])
|
||||
if( v1->param[0] == v1next->param[0] && v2->param[0] == v2next->param[0] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[0] < v2->param[0] || v1next->param[0] < v1->param[0] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[1] < v2->param[1] )
|
||||
return 0;
|
||||
else if( v1->param[1] > v2->param[1] )
|
||||
return 1;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[0] < v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case a\n" );
|
||||
#endif
|
||||
assert( v1->param[0] <= v1next->param[0] );
|
||||
assert( v2->param[0] <= v1next->param[0] );
|
||||
switch( bbox( v2, v2next, v1next, 1 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "decr\n" );
|
||||
#endif
|
||||
v1 = v1next--;
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else if( v1next->param[0] > v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case b\n" );
|
||||
#endif
|
||||
assert( v1->param[0] <= v2next->param[0] );
|
||||
assert( v2->param[0] <= v2next->param[0] );
|
||||
switch( bbox( v1, v1next, v2next, 1 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case ab\n" );
|
||||
#endif
|
||||
if( v1next->param[1] < v2next->param[1] )
|
||||
return 0;
|
||||
else if( v1next->param[1] > v2next->param[1] )
|
||||
return 1;
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_sl( Arc_ptr j1, Arc_ptr j2 ) // dir = 0
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
dprintf( "arc_ccw_turn, p = %d\n", 0 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (0 == v1->param[0])
|
||||
if( v1->param[0] == v1next->param[0] && v2->param[0] == v2next->param[0] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[0] > v2->param[0] || v1next->param[0] > v1->param[0] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[1] < v2->param[1] )
|
||||
return 1;
|
||||
else if( v1->param[1] > v2->param[1] )
|
||||
return 0;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[0] > v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case c\n" );
|
||||
#endif
|
||||
assert( v1->param[0] >= v1next->param[0] );
|
||||
assert( v2->param[0] >= v1next->param[0] );
|
||||
switch( bbox( v2next, v2, v1next, 1 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v1 = v1next--;
|
||||
#ifdef DEBUG
|
||||
dprintf( "decr\n" );
|
||||
#endif
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else if( v1next->param[0] < v2next->param[0] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case d\n" );
|
||||
#endif
|
||||
assert( v1->param[0] >= v2next->param[0] );
|
||||
assert( v2->param[0] >= v2next->param[0] );
|
||||
switch( bbox( v1next, v1, v2next, 1 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "case cd\n" );
|
||||
#endif
|
||||
if( v1next->param[1] < v2next->param[1] )
|
||||
return 1;
|
||||
else if( v1next->param[1] > v2next->param[1] )
|
||||
return 0;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_tr( Arc_ptr j1, Arc_ptr j2 ) // dir = 1
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
dprintf( "arc_ccw_turn, p = %d\n", 1 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (1 == v1->param[1])
|
||||
if( v1->param[1] == v1next->param[1] && v2->param[1] == v2next->param[1] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[1] < v2->param[1] || v1next->param[1] < v1->param[1] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[0] < v2->param[0] )
|
||||
return 1;
|
||||
else if( v1->param[0] > v2->param[0] )
|
||||
return 0;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[1] < v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case a\n" );
|
||||
#endif
|
||||
assert( v1->param[1] <= v1next->param[1] );
|
||||
assert( v2->param[1] <= v1next->param[1] );
|
||||
switch( bbox( v2, v2next, v1next, 0 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "decr\n" );
|
||||
#endif
|
||||
v1 = v1next--;
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else if( v1next->param[1] > v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case b\n" );
|
||||
#endif
|
||||
assert( v1->param[1] <= v2next->param[1] );
|
||||
assert( v2->param[1] <= v2next->param[1] );
|
||||
switch( bbox( v1, v1next, v2next, 0 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 ) {
|
||||
return sgn;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "case ab\n" );
|
||||
#endif
|
||||
if( v1next->param[0] < v2next->param[0] )
|
||||
return 1;
|
||||
else if( v1next->param[0] > v2next->param[0] )
|
||||
return 0;
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
v2 = v2next++;
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::ccwTurn_tl( Arc_ptr j1, Arc_ptr j2 )
|
||||
{
|
||||
register TrimVertex *v1 = &j1->pwlArc->pts[j1->pwlArc->npts-1];
|
||||
register TrimVertex *v1last = &j1->pwlArc->pts[0];
|
||||
register TrimVertex *v2 = &j2->pwlArc->pts[0];
|
||||
register TrimVertex *v2last = &j2->pwlArc->pts[j2->pwlArc->npts-1];
|
||||
register TrimVertex *v1next = v1-1;
|
||||
register TrimVertex *v2next = v2+1;
|
||||
int sgn;
|
||||
|
||||
assert( v1 != v1last );
|
||||
assert( v2 != v2last );
|
||||
|
||||
#ifndef NDEBUG
|
||||
dprintf( "arc_ccw_turn, p = %d\n", 1 );
|
||||
#endif
|
||||
|
||||
// the arcs lie on the line (1 == v1->param[1])
|
||||
if( v1->param[1] == v1next->param[1] && v2->param[1] == v2next->param[1] )
|
||||
return 0;
|
||||
|
||||
if( v2next->param[1] > v2->param[1] || v1next->param[1] > v1->param[1] )
|
||||
::mylongjmp( jumpbuffer, 28 );
|
||||
|
||||
if( v1->param[0] < v2->param[0] )
|
||||
return 0;
|
||||
else if( v1->param[0] > v2->param[0] )
|
||||
return 1;
|
||||
|
||||
while( 1 ) {
|
||||
if( v1next->param[1] > v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case c\n" );
|
||||
#endif
|
||||
assert( v1->param[1] >= v1next->param[1] );
|
||||
assert( v2->param[1] >= v1next->param[1] );
|
||||
switch( bbox( v2next, v2, v1next, 0 ) ) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v2, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v1 = v1next--;
|
||||
#ifdef DEBUG
|
||||
dprintf( "decr\n" );
|
||||
#endif
|
||||
if( v1 == v1last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 1;
|
||||
}
|
||||
} else if( v1next->param[1] < v2next->param[1] ) {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "case d\n" );
|
||||
assert( v1->param[1] >= v2next->param[1] );
|
||||
assert( v2->param[1] >= v2next->param[1] );
|
||||
#endif
|
||||
switch( bbox( v1next, v1, v2next, 0 ) ) {
|
||||
case -1:
|
||||
return 1;
|
||||
case 0:
|
||||
sgn = ccw( v1next, v1, v2next );
|
||||
if( sgn != -1 )
|
||||
return sgn;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
dprintf( "case cd\n" );
|
||||
#endif
|
||||
if( v1next->param[0] < v2next->param[0] )
|
||||
return 0;
|
||||
else if( v1next->param[0] > v2next->param[0] )
|
||||
return 1;
|
||||
else {
|
||||
v2 = v2next++;
|
||||
#ifdef DEBUG
|
||||
dprintf( "incr\n" );
|
||||
#endif
|
||||
if( v2 == v2last ) {
|
||||
#ifdef DEBUG
|
||||
dprintf( "no good results\n" );
|
||||
#endif
|
||||
return 0; // ill-conditioned, guess answer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
int
|
||||
Subdivider::bbox( register REAL sa, register REAL sb, register REAL sc,
|
||||
register REAL ta, register REAL tb, register REAL tc )
|
||||
#else
|
||||
int
|
||||
Subdivider::bbox( register REAL sa, register REAL sb, register REAL sc,
|
||||
register REAL , register REAL , register REAL )
|
||||
#endif
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
assert( tc >= ta );
|
||||
assert( tc <= tb );
|
||||
#endif
|
||||
|
||||
if( sa < sb ) {
|
||||
if( sc <= sa ) {
|
||||
return -1;
|
||||
} else if( sb <= sc ) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if( sa > sb ) {
|
||||
if( sc >= sa ) {
|
||||
return 1;
|
||||
} else if( sb >= sc ) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if( sc > sa ) {
|
||||
return 1;
|
||||
} else if( sb > sc ) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* ccw - determine how three points are oriented by computing their
|
||||
* determinant.
|
||||
* Return 1 if the vertices are ccw oriented,
|
||||
* 0 if they are cw oriented, or
|
||||
* -1 if the computation is ill-conditioned.
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Subdivider::ccw( TrimVertex *a, TrimVertex *b, TrimVertex *c )
|
||||
{
|
||||
REAL d = det3( a, b, c );
|
||||
if( abs(d) < 0.0001 ) return -1;
|
||||
return (d < 0.0) ? 0 : 1;
|
||||
}
|
||||
442
src/glu/sgi/libnurbs/internals/coveandtiler.cc
Normal file
442
src/glu/sgi/libnurbs/internals/coveandtiler.cc
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* coveandtiler.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/coveandtiler.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "coveandtiler.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
#include "uarray.h"
|
||||
#include "backend.h"
|
||||
|
||||
|
||||
const int CoveAndTiler::MAXSTRIPSIZE = 1000;
|
||||
|
||||
CoveAndTiler::CoveAndTiler( Backend& b )
|
||||
: backend( b )
|
||||
{ }
|
||||
|
||||
CoveAndTiler::~CoveAndTiler( void )
|
||||
{ }
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( GridVertex &gv )
|
||||
{
|
||||
backend.tmeshvert( &gv );
|
||||
}
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( TrimVertex *tv )
|
||||
{
|
||||
backend.tmeshvert( tv );
|
||||
}
|
||||
|
||||
inline void
|
||||
CoveAndTiler::output( GridTrimVertex& g )
|
||||
{
|
||||
backend.tmeshvert( &g );
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveAndTile( void )
|
||||
{
|
||||
long ustart = (top.ustart >= bot.ustart) ? top.ustart : bot.ustart;
|
||||
long uend = (top.uend <= bot.uend) ? top.uend : bot.uend;
|
||||
if( ustart <= uend ) {
|
||||
tile( bot.vindex, ustart, uend );
|
||||
if( top.ustart >= bot.ustart )
|
||||
coveUpperLeft();
|
||||
else
|
||||
coveLowerLeft();
|
||||
|
||||
if( top.uend <= bot.uend )
|
||||
coveUpperRight();
|
||||
else
|
||||
coveLowerRight();
|
||||
} else {
|
||||
TrimVertex blv, tlv, *bl, *tl;
|
||||
GridTrimVertex bllv, tllv;
|
||||
TrimVertex *lf = left.first();
|
||||
TrimVertex *ll = left.last();
|
||||
if( lf->param[0] >= ll->param[0] ) {
|
||||
blv.param[0] = lf->param[0];
|
||||
blv.param[1] = ll->param[1];
|
||||
blv.nuid = 0; // XXX
|
||||
assert( blv.param[1] == bot.vval );
|
||||
bl = &blv;
|
||||
tl = lf;
|
||||
tllv.set( lf );
|
||||
if( ll->param[0] > uarray.uarray[top.ustart-1] ) {
|
||||
bllv.set( ll );
|
||||
assert( ll->param[0] <= uarray.uarray[bot.ustart] );
|
||||
} else {
|
||||
bllv.set( top.ustart-1, bot.vindex );
|
||||
}
|
||||
coveUpperLeftNoGrid( bl );
|
||||
} else {
|
||||
tlv.param[0] = ll->param[0];
|
||||
tlv.param[1] = lf->param[1];
|
||||
tlv.nuid = 0; // XXX
|
||||
assert( tlv.param[1] == top.vval );
|
||||
tl = &tlv;
|
||||
bl = ll;
|
||||
bllv.set( ll );
|
||||
if( lf->param[0] > uarray.uarray[bot.ustart-1] ) {
|
||||
assert( lf->param[0] <= uarray.uarray[bot.ustart] );
|
||||
tllv.set( lf );
|
||||
} else {
|
||||
tllv.set( bot.ustart-1, top.vindex );
|
||||
}
|
||||
coveLowerLeftNoGrid( tl );
|
||||
}
|
||||
|
||||
TrimVertex brv, trv, *br, *tr;
|
||||
GridTrimVertex brrv, trrv;
|
||||
TrimVertex *rf = right.first();
|
||||
TrimVertex *rl = right.last();
|
||||
|
||||
if( rf->param[0] <= rl->param[0] ) {
|
||||
brv.param[0] = rf->param[0];
|
||||
brv.param[1] = rl->param[1];
|
||||
brv.nuid = 0; // XXX
|
||||
assert( brv.param[1] == bot.vval );
|
||||
br = &brv;
|
||||
tr = rf;
|
||||
trrv.set( rf );
|
||||
if( rl->param[0] < uarray.uarray[top.uend+1] ) {
|
||||
assert( rl->param[0] >= uarray.uarray[top.uend] );
|
||||
brrv.set( rl );
|
||||
} else {
|
||||
brrv.set( top.uend+1, bot.vindex );
|
||||
}
|
||||
coveUpperRightNoGrid( br );
|
||||
} else {
|
||||
trv.param[0] = rl->param[0];
|
||||
trv.param[1] = rf->param[1];
|
||||
trv.nuid = 0; // XXX
|
||||
assert( trv.param[1] == top.vval );
|
||||
tr = &trv;
|
||||
br = rl;
|
||||
brrv.set( rl );
|
||||
if( rf->param[0] < uarray.uarray[bot.uend+1] ) {
|
||||
assert( rf->param[0] >= uarray.uarray[bot.uend] );
|
||||
trrv.set( rf );
|
||||
} else {
|
||||
trrv.set( bot.uend+1, top.vindex );
|
||||
}
|
||||
coveLowerRightNoGrid( tr );
|
||||
}
|
||||
|
||||
backend.bgntmesh( "doit" );
|
||||
output(trrv);
|
||||
output(tllv);
|
||||
output( tr );
|
||||
output( tl );
|
||||
output( br );
|
||||
output( bl );
|
||||
output(brrv);
|
||||
output(bllv);
|
||||
backend.endtmesh();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::tile( long vindex, long ustart, long uend )
|
||||
{
|
||||
long numsteps = uend - ustart;
|
||||
|
||||
if( numsteps == 0 ) return;
|
||||
|
||||
if( numsteps > MAXSTRIPSIZE ) {
|
||||
long umid = ustart + (uend - ustart) / 2;
|
||||
tile( vindex, ustart, umid );
|
||||
tile( vindex, umid, uend );
|
||||
} else {
|
||||
backend.surfmesh( ustart, vindex-1, numsteps, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperRight( void )
|
||||
{
|
||||
GridVertex tgv( top.uend, top.vindex );
|
||||
GridVertex gv( top.uend, bot.vindex );
|
||||
|
||||
right.first();
|
||||
backend.bgntmesh( "coveUpperRight" );
|
||||
output( right.next() );
|
||||
output( tgv );
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
coveUR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperRightNoGrid( TrimVertex* br )
|
||||
{
|
||||
backend.bgntmesh( "coveUpperRight" );
|
||||
output( right.first() );
|
||||
output( right.next() );
|
||||
backend.swaptmesh();
|
||||
output( br );
|
||||
coveUR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUR( )
|
||||
{
|
||||
GridVertex gv( top.uend, bot.vindex );
|
||||
TrimVertex *vert = right.next();
|
||||
if( vert == NULL ) return;
|
||||
|
||||
assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.nextu() >= bot.uend ) {
|
||||
for( ; vert; vert = right.next() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
vert = right.next();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
if( gv.nextu() == bot.uend ) {
|
||||
for( ; vert; vert = right.next() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperLeft( void )
|
||||
{
|
||||
GridVertex tgv( top.ustart, top.vindex );
|
||||
GridVertex gv( top.ustart, bot.vindex );
|
||||
|
||||
left.first();
|
||||
backend.bgntmesh( "coveUpperLeft" );
|
||||
output( tgv );
|
||||
output( left.next() );
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
coveUL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUpperLeftNoGrid( TrimVertex* bl )
|
||||
{
|
||||
backend.bgntmesh( "coveUpperLeftNoGrid" );
|
||||
output( left.first() );
|
||||
output( left.next() );
|
||||
output( bl );
|
||||
backend.swaptmesh();
|
||||
coveUL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveUL()
|
||||
{
|
||||
GridVertex gv( top.ustart, bot.vindex );
|
||||
TrimVertex *vert = left.next();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.prevu() <= bot.ustart ) {
|
||||
for( ; vert; vert = left.next() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] > uarray.uarray[gv.gparam[0]] ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
vert = left.next();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
if( gv.prevu() == bot.ustart ) {
|
||||
for( ; vert; vert = left.next() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerLeft( void )
|
||||
{
|
||||
GridVertex bgv( bot.ustart, bot.vindex );
|
||||
GridVertex gv( bot.ustart, top.vindex );
|
||||
|
||||
left.last();
|
||||
backend.bgntmesh( "coveLowerLeft" );
|
||||
output( left.prev() );
|
||||
output( bgv );
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
coveLL();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerLeftNoGrid( TrimVertex* tl )
|
||||
{
|
||||
backend.bgntmesh( "coveLowerLeft" );
|
||||
output( left.last() );
|
||||
output( left.prev() );
|
||||
backend.swaptmesh();
|
||||
output( tl );
|
||||
coveLL( );
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLL()
|
||||
{
|
||||
GridVertex gv( bot.ustart, top.vindex );
|
||||
TrimVertex *vert = left.prev();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] <= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.prevu() <= top.ustart ) {
|
||||
for( ; vert; vert = left.prev() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] > uarray.uarray[gv.gparam[0]] ){
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
vert = left.prev();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
backend.swaptmesh();
|
||||
output( gv );
|
||||
if( gv.prevu() == top.ustart ) {
|
||||
for( ; vert; vert = left.prev() ) {
|
||||
output( vert );
|
||||
backend.swaptmesh();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerRight( void )
|
||||
{
|
||||
GridVertex bgv( bot.uend, bot.vindex );
|
||||
GridVertex gv( bot.uend, top.vindex );
|
||||
|
||||
right.last();
|
||||
backend.bgntmesh( "coveLowerRight" );
|
||||
output( bgv );
|
||||
output( right.prev() );
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
coveLR();
|
||||
backend.endtmesh( );
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLowerRightNoGrid( TrimVertex* tr )
|
||||
{
|
||||
backend.bgntmesh( "coveLowerRIght" );
|
||||
output( right.last() );
|
||||
output( right.prev() );
|
||||
output( tr );
|
||||
backend.swaptmesh();
|
||||
coveLR();
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
void
|
||||
CoveAndTiler::coveLR( )
|
||||
{
|
||||
GridVertex gv( bot.uend, top.vindex );
|
||||
TrimVertex *vert = right.prev();
|
||||
if( vert == NULL ) return;
|
||||
assert( vert->param[0] >= uarray.uarray[gv.gparam[0]] );
|
||||
|
||||
if( gv.nextu() >= top.uend ) {
|
||||
for( ; vert; vert = right.prev() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
} else while( 1 ) {
|
||||
if( vert->param[0] < uarray.uarray[gv.gparam[0]] ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
vert = right.prev();
|
||||
if( vert == NULL ) break;
|
||||
} else {
|
||||
output( gv );
|
||||
backend.swaptmesh();
|
||||
if( gv.nextu() == top.uend ) {
|
||||
for( ; vert; vert = right.prev() ) {
|
||||
backend.swaptmesh();
|
||||
output( vert );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
78
src/glu/sgi/libnurbs/internals/coveandtiler.h
Normal file
78
src/glu/sgi/libnurbs/internals/coveandtiler.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* coveandtiler.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/coveandtiler.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glucoveandtiler_h
|
||||
#define __glucoveandtiler_h
|
||||
|
||||
#include "trimregion.h"
|
||||
|
||||
class Backend;
|
||||
class TrimVertex;
|
||||
class GridVertex;
|
||||
class GridTrimVertex;
|
||||
|
||||
class CoveAndTiler : virtual public TrimRegion {
|
||||
public:
|
||||
CoveAndTiler( Backend& );
|
||||
~CoveAndTiler( void );
|
||||
void coveAndTile( void );
|
||||
private:
|
||||
Backend& backend;
|
||||
static const int MAXSTRIPSIZE;
|
||||
void tile( long, long, long );
|
||||
void coveLowerLeft( void );
|
||||
void coveLowerRight( void );
|
||||
void coveUpperLeft( void );
|
||||
void coveUpperRight( void );
|
||||
void coveUpperLeftNoGrid( TrimVertex * );
|
||||
void coveUpperRightNoGrid( TrimVertex * );
|
||||
void coveLowerLeftNoGrid( TrimVertex * );
|
||||
void coveLowerRightNoGrid( TrimVertex * );
|
||||
void coveLL( void );
|
||||
void coveLR( void );
|
||||
void coveUL( void );
|
||||
void coveUR( void );
|
||||
inline void output( GridTrimVertex& );
|
||||
inline void output( GridVertex& );
|
||||
inline void output( TrimVertex* );
|
||||
};
|
||||
|
||||
#endif /* __glucoveandtiler_h */
|
||||
201
src/glu/sgi/libnurbs/internals/curve.cc
Normal file
201
src/glu/sgi/libnurbs/internals/curve.cc
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curve.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curve.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "mymath.h"
|
||||
#include "curve.h"
|
||||
#include "mapdesc.h"
|
||||
#include "types.h"
|
||||
#include "quilt.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Curve::Curve - copy curve from quilt and transform control points
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Curve::Curve( Quilt_ptr geo, REAL pta, REAL ptb, Curve *c )
|
||||
{
|
||||
mapdesc = geo->mapdesc;
|
||||
next = c;
|
||||
needsSampling = mapdesc->isRangeSampling() ? 1 : 0;
|
||||
cullval = mapdesc->isCulling() ? CULL_ACCEPT : CULL_TRIVIAL_ACCEPT;
|
||||
order = geo->qspec[0].order;
|
||||
stride = MAXCOORDS;
|
||||
|
||||
REAL *ps = geo->cpts;
|
||||
Quiltspec_ptr qs = geo->qspec;
|
||||
ps += qs->offset;
|
||||
ps += qs->index * qs->order * qs->stride;
|
||||
REAL *pend = ps + qs->order * qs->stride;
|
||||
|
||||
if( needsSampling )
|
||||
mapdesc->xformSampling( ps, qs->order, qs->stride, spts, stride );
|
||||
|
||||
if( cullval == CULL_ACCEPT )
|
||||
mapdesc->xformCulling( ps, qs->order, qs->stride, cpts, stride );
|
||||
|
||||
/* set untrimmed curve range */
|
||||
range[0] = qs->breakpoints[qs->index];
|
||||
range[1] = qs->breakpoints[qs->index+1];
|
||||
range[2] = range[1] - range[0];
|
||||
|
||||
if( range[0] != pta ) {
|
||||
Curve lower( *this, pta, 0 );
|
||||
lower.next = next;
|
||||
*this = lower;
|
||||
}
|
||||
if( range[1] != ptb ) {
|
||||
Curve lower( *this, ptb, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Curve::Curve - subdivide a curve along an isoparametric line
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Curve::Curve( Curve& upper, REAL value, Curve *c )
|
||||
{
|
||||
Curve &lower = *this;
|
||||
|
||||
lower.next = c;
|
||||
lower.mapdesc = upper.mapdesc;
|
||||
lower.needsSampling = upper.needsSampling;
|
||||
lower.order = upper.order;
|
||||
lower.stride = upper.stride;
|
||||
lower.cullval = upper.cullval;
|
||||
|
||||
REAL d = (value - upper.range[0]) / upper.range[2];
|
||||
|
||||
if( needsSampling )
|
||||
mapdesc->subdivide( upper.spts, lower.spts, d, upper.stride, upper.order );
|
||||
|
||||
if( cullval == CULL_ACCEPT )
|
||||
mapdesc->subdivide( upper.cpts, lower.cpts, d, upper.stride, upper.order );
|
||||
|
||||
lower.range[0] = upper.range[0];
|
||||
lower.range[1] = value;
|
||||
lower.range[2] = value - upper.range[0];
|
||||
upper.range[0] = value;
|
||||
upper.range[2] = upper.range[1] - value;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Curve::clamp - clamp the sampling rate to a given maximum
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Curve::clamp( void )
|
||||
{
|
||||
if( stepsize < minstepsize )
|
||||
stepsize = mapdesc->clampfactor * minstepsize;
|
||||
}
|
||||
|
||||
void
|
||||
Curve::setstepsize( REAL max )
|
||||
{
|
||||
stepsize = ( max >= 1.0 ) ? (range[2] / max) : range[2];
|
||||
minstepsize = stepsize;
|
||||
}
|
||||
|
||||
void
|
||||
Curve::getstepsize( void )
|
||||
{
|
||||
minstepsize= 0;
|
||||
|
||||
if( mapdesc->isConstantSampling() ) {
|
||||
// fixed number of samples per patch in each direction
|
||||
// maxrate is number of s samples per patch
|
||||
setstepsize( mapdesc->maxrate );
|
||||
} else if( mapdesc->isDomainSampling() ) {
|
||||
// maxrate is number of s samples per unit s length of domain
|
||||
setstepsize( mapdesc->maxrate * range[2] );
|
||||
} else {
|
||||
// upper bound on path length between sample points
|
||||
|
||||
assert( order <= MAXORDER );
|
||||
|
||||
/* points have been transformed, therefore they are homogeneous */
|
||||
REAL tmp[MAXORDER][MAXCOORDS];
|
||||
const int tstride = sizeof(tmp[0]) / sizeof(REAL);
|
||||
int val = mapdesc->project( spts, stride, &tmp[0][0], tstride, order );
|
||||
|
||||
if( val == 0 ) {
|
||||
// control points cross infinity, therefore derivatives are undefined
|
||||
setstepsize( mapdesc->maxrate );
|
||||
} else {
|
||||
REAL t = mapdesc->getProperty( N_PIXEL_TOLERANCE );
|
||||
if( mapdesc->isParametricDistanceSampling() ) {
|
||||
REAL d = mapdesc->calcPartialVelocity( &tmp[0][0], tstride, order, 2, range[2] );
|
||||
stepsize = (d > 0.0) ? ::sqrtf( 8.0 * t / d ) : range[2];
|
||||
minstepsize = ( mapdesc->maxrate > 0.0 ) ? (range[2] / mapdesc->maxrate) : 0.0;
|
||||
} else if( mapdesc->isPathLengthSampling() ) {
|
||||
// t is upper bound on path (arc) length
|
||||
REAL d = mapdesc->calcPartialVelocity( &tmp[0][0], tstride, order, 1, range[2] );
|
||||
stepsize = ( d > 0.0 ) ? (t / d) : range[2];
|
||||
minstepsize = ( mapdesc->maxrate > 0.0 ) ? (range[2] / mapdesc->maxrate) : 0.0;
|
||||
} else {
|
||||
// control points cross infinity, therefore partials are undefined
|
||||
setstepsize( mapdesc->maxrate );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Curve::needsSamplingSubdivision( void )
|
||||
{
|
||||
return ( stepsize < minstepsize ) ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
Curve::cullCheck( void )
|
||||
{
|
||||
if( cullval == CULL_ACCEPT )
|
||||
cullval = mapdesc->cullCheck( cpts, order, stride );
|
||||
return cullval;
|
||||
}
|
||||
|
||||
76
src/glu/sgi/libnurbs/internals/curve.h
Normal file
76
src/glu/sgi/libnurbs/internals/curve.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curve.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curve.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glucurve_h_
|
||||
#define __glucurve_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Mapdesc;
|
||||
class Quilt;
|
||||
|
||||
|
||||
class Curve {
|
||||
public:
|
||||
friend class Curvelist;
|
||||
Curve( Quilt *, REAL, REAL, Curve * );
|
||||
Curve( Curve&, REAL, Curve * );
|
||||
Curve * next;
|
||||
private:
|
||||
Mapdesc * mapdesc;
|
||||
int stride;
|
||||
int order;
|
||||
int cullval;
|
||||
int needsSampling;
|
||||
REAL cpts[MAXORDER*MAXCOORDS];
|
||||
REAL spts[MAXORDER*MAXCOORDS];
|
||||
REAL stepsize;
|
||||
REAL minstepsize;
|
||||
REAL range[3];
|
||||
|
||||
void clamp( void );
|
||||
void setstepsize( REAL );
|
||||
void getstepsize( void );
|
||||
int cullCheck( void );
|
||||
int needsSamplingSubdivision( void );
|
||||
};
|
||||
#endif /* __glucurve_h_ */
|
||||
112
src/glu/sgi/libnurbs/internals/curvelist.cc
Normal file
112
src/glu/sgi/libnurbs/internals/curvelist.cc
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curvelist.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curvelist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "quilt.h"
|
||||
#include "curvelist.h"
|
||||
#include "curve.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "types.h"
|
||||
|
||||
Curvelist::Curvelist( Quilt *quilts, REAL pta, REAL ptb )
|
||||
{
|
||||
curve = 0;
|
||||
for( Quilt *q = quilts; q; q = q->next )
|
||||
curve = new Curve( q, pta, ptb, curve );
|
||||
range[0] = pta;
|
||||
range[1] = ptb;
|
||||
range[2] = ptb - pta;
|
||||
}
|
||||
|
||||
Curvelist::Curvelist( Curvelist &upper, REAL value )
|
||||
{
|
||||
Curvelist &lower = *this;
|
||||
curve = 0;
|
||||
for( Curve *c = upper.curve; c; c = c->next )
|
||||
curve = new Curve( *c, value, curve );
|
||||
|
||||
lower.range[0] = upper.range[0];
|
||||
lower.range[1] = value;
|
||||
lower.range[2] = value - upper.range[0];
|
||||
upper.range[0] = value;
|
||||
upper.range[2] = upper.range[1] - value;
|
||||
}
|
||||
|
||||
Curvelist::~Curvelist()
|
||||
{
|
||||
while( curve ) {
|
||||
Curve *c = curve;
|
||||
curve = curve->next;
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Curvelist::cullCheck( void )
|
||||
{
|
||||
for( Curve *c = curve; c; c = c->next )
|
||||
if( c->cullCheck() == CULL_TRIVIAL_REJECT )
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
|
||||
void
|
||||
Curvelist::getstepsize( void )
|
||||
{
|
||||
stepsize = range[2];
|
||||
Curve *c;
|
||||
for( c = curve; c; c = c->next ) {
|
||||
c->getstepsize();
|
||||
c->clamp();
|
||||
stepsize = ((c->stepsize < stepsize) ? c->stepsize : stepsize);
|
||||
if( c->needsSamplingSubdivision() ) break;
|
||||
}
|
||||
needsSubdivision = ( c ) ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
Curvelist::needsSamplingSubdivision( void )
|
||||
{
|
||||
return needsSubdivision;
|
||||
}
|
||||
|
||||
68
src/glu/sgi/libnurbs/internals/curvelist.h
Normal file
68
src/glu/sgi/libnurbs/internals/curvelist.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curvelist.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curvelist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glucurvelist_h_
|
||||
#define __glucurvelist_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Mapdesc;
|
||||
class Quilt;
|
||||
class Curve;
|
||||
|
||||
class Curvelist
|
||||
{
|
||||
friend class Subdivider;
|
||||
public:
|
||||
Curvelist( Quilt *, REAL, REAL );
|
||||
Curvelist( Curvelist &, REAL );
|
||||
~Curvelist( void );
|
||||
int cullCheck( void );
|
||||
void getstepsize( void );
|
||||
int needsSamplingSubdivision();
|
||||
private:
|
||||
Curve *curve;
|
||||
float range[3];
|
||||
int needsSubdivision;
|
||||
float stepsize;
|
||||
};
|
||||
#endif /* __glucurvelist_h_ */
|
||||
105
src/glu/sgi/libnurbs/internals/curvesub.cc
Normal file
105
src/glu/sgi/libnurbs/internals/curvesub.cc
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* curvesub.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curvesub.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "subdivider.h"
|
||||
#include "renderhints.h"
|
||||
#include "backend.h"
|
||||
#include "quilt.h"
|
||||
#include "curvelist.h"
|
||||
#include "curve.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* drawCurves - main curve rendering entry point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Subdivider::drawCurves( void )
|
||||
{
|
||||
REAL from[1], to[1];
|
||||
Flist bpts;
|
||||
qlist->getRange( from, to, bpts );
|
||||
|
||||
renderhints.init( );
|
||||
|
||||
backend.bgncurv();
|
||||
for( int i=bpts.start; i<bpts.end-1; i++ ) {
|
||||
REAL pta, ptb;
|
||||
pta = bpts.pts[i];
|
||||
ptb = bpts.pts[i+1];
|
||||
|
||||
qlist->downloadAll( &pta, &ptb, backend );
|
||||
|
||||
Curvelist curvelist( qlist, pta, ptb );
|
||||
samplingSplit( curvelist, renderhints.maxsubdivisions );
|
||||
}
|
||||
backend.endcurv();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* samplingSplit - recursively subdivide patch, cull check each subpatch
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Subdivider::samplingSplit( Curvelist& curvelist, int subdivisions )
|
||||
{
|
||||
if( curvelist.cullCheck() == CULL_TRIVIAL_REJECT ) return;
|
||||
|
||||
curvelist.getstepsize();
|
||||
|
||||
if( curvelist.needsSamplingSubdivision() && (subdivisions > 0) ) {
|
||||
REAL mid = ( curvelist.range[0] + curvelist.range[1] ) * 0.5;
|
||||
Curvelist lowerlist( curvelist, mid );
|
||||
samplingSplit( lowerlist, subdivisions-1 ); // lower
|
||||
samplingSplit( curvelist, subdivisions-1 ); // upper
|
||||
} else {
|
||||
long nu = 1 + ((long) (curvelist.range[2] / curvelist.stepsize));
|
||||
backend.curvgrid( curvelist.range[0], curvelist.range[1], nu );
|
||||
backend.curvmesh( 0, nu );
|
||||
}
|
||||
}
|
||||
|
||||
206
src/glu/sgi/libnurbs/internals/dataTransform.cc
Normal file
206
src/glu/sgi/libnurbs/internals/dataTransform.cc
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/dataTransform.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "trimvertex.h"
|
||||
#include "dataTransform.h"
|
||||
|
||||
extern directedLine* arcLoopToDLineLoop(Arc_ptr loop);
|
||||
|
||||
static directedLine* copy_loop(Arc_ptr loop, Real2* vertArray, int& index, directedLine dline_buf[], sampledLine sline_buf[], int& index_dline)
|
||||
{
|
||||
directedLine *ret;
|
||||
int old_index = index;
|
||||
int i = index;
|
||||
int j;
|
||||
for(j=0; j<loop->pwlArc->npts-1; j++, i++)
|
||||
{
|
||||
vertArray[i][0] = loop->pwlArc->pts[j].param[0];
|
||||
vertArray[i][1] = loop->pwlArc->pts[j].param[1];
|
||||
}
|
||||
loop->clearmark();
|
||||
|
||||
for(Arc_ptr jarc = loop->next; jarc != loop; jarc=jarc->next)
|
||||
{
|
||||
for(j=0; j<jarc->pwlArc->npts-1; j++, i++)
|
||||
{
|
||||
vertArray[i][0] = jarc->pwlArc->pts[j].param[0];
|
||||
vertArray[i][1] = jarc->pwlArc->pts[j].param[1];
|
||||
}
|
||||
jarc->clearmark();
|
||||
}
|
||||
//copy the first vertex again
|
||||
vertArray[i][0] = loop->pwlArc->pts[0].param[0];
|
||||
vertArray[i][1] = loop->pwlArc->pts[0].param[1];
|
||||
i++;
|
||||
index=i;
|
||||
|
||||
directedLine* dline;
|
||||
sampledLine* sline;
|
||||
sline = &sline_buf[index_dline];
|
||||
dline = &dline_buf[index_dline];
|
||||
sline->init(2, &vertArray[old_index]);
|
||||
dline->init(INCREASING, sline);
|
||||
ret = dline;
|
||||
index_dline++;
|
||||
|
||||
for(i=old_index+1; i<= index-2; i++)
|
||||
{
|
||||
sline = &sline_buf[index_dline];
|
||||
dline = &dline_buf[index_dline];
|
||||
sline->init(2, &vertArray[i]);
|
||||
dline->init(INCREASING, sline);
|
||||
ret->insert(dline);
|
||||
index_dline++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int num_edges(Bin& bin)
|
||||
{
|
||||
int sum=0;
|
||||
for(Arc_ptr jarc = bin.firstarc(); jarc; jarc=bin.nextarc())
|
||||
sum += jarc->pwlArc->npts-1;
|
||||
return sum;
|
||||
}
|
||||
/*
|
||||
directedLine* bin_to_DLineLoops(Bin& bin)
|
||||
{
|
||||
directedLine *ret=NULL;
|
||||
directedLine *temp;
|
||||
|
||||
int numedges = num_edges(bin);
|
||||
directedLine* dline_buf = new directedLine[numedges]; //not work for N32?
|
||||
sampledLine* sline_buf=new sampledLine[numedges];
|
||||
|
||||
Real2* vertArray = new Real2[numedges*2];
|
||||
int index = 0;
|
||||
int index_dline = 0;
|
||||
bin.markall();
|
||||
|
||||
for(Arc_ptr jarc = bin.firstarc(); jarc; jarc=bin.nextarc())
|
||||
{
|
||||
if(jarc->ismarked())
|
||||
{
|
||||
assert(jarc->check() != 0);
|
||||
Arc_ptr jarchead = jarc;
|
||||
do {
|
||||
jarc->clearmark();
|
||||
jarc = jarc->next;
|
||||
} while(jarc != jarchead);
|
||||
temp=copy_loop(jarchead, vertArray, index, dline_buf, sline_buf, index_dline);
|
||||
ret = temp->insertPolygon(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
directedLine* bin_to_DLineLoops(Bin& bin)
|
||||
{
|
||||
directedLine *ret=NULL;
|
||||
directedLine *temp;
|
||||
bin.markall();
|
||||
for(Arc_ptr jarc=bin.firstarc(); jarc; jarc=bin.nextarc()){
|
||||
if(jarc->ismarked()) {
|
||||
assert(jarc->check() != 0);
|
||||
Arc_ptr jarchead = jarc;
|
||||
do {
|
||||
jarc->clearmark();
|
||||
jarc = jarc->next;
|
||||
} while(jarc != jarchead);
|
||||
temp = arcLoopToDLineLoop(jarc);
|
||||
ret = temp->insertPolygon(ret);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
directedLine* o_pwlcurve_to_DLines(directedLine* original, O_pwlcurve* pwl)
|
||||
{
|
||||
directedLine* ret = original;
|
||||
for(Int i=0; i<pwl->npts-1; i++)
|
||||
{
|
||||
sampledLine* sline = new sampledLine(2);
|
||||
sline->setPoint(0, pwl->pts[i].param);
|
||||
sline->setPoint(1, pwl->pts[i+1].param);
|
||||
directedLine* dline = new directedLine(INCREASING, sline);
|
||||
if(ret == NULL)
|
||||
ret = dline;
|
||||
else
|
||||
ret->insert(dline);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
directedLine* o_curve_to_DLineLoop(O_curve* cur)
|
||||
{
|
||||
directedLine *ret;
|
||||
if(cur == NULL)
|
||||
return NULL;
|
||||
assert(cur->curvetype == ct_pwlcurve);
|
||||
ret = o_pwlcurve_to_DLines(NULL, cur->curve.o_pwlcurve);
|
||||
for(O_curve* temp = cur->next; temp != NULL; temp = temp->next)
|
||||
{
|
||||
assert(temp->curvetype == ct_pwlcurve);
|
||||
ret = o_pwlcurve_to_DLines(ret, temp->curve.o_pwlcurve);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
directedLine* o_trim_to_DLineLoops(O_trim* trim)
|
||||
{
|
||||
O_trim* temp;
|
||||
directedLine *ret;
|
||||
if(trim == NULL)
|
||||
return NULL;
|
||||
ret = o_curve_to_DLineLoop(trim->o_curve);
|
||||
|
||||
for(temp=trim->next; temp != NULL; temp = temp->next)
|
||||
{
|
||||
ret = ret->insertPolygon(o_curve_to_DLineLoop(temp->o_curve));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
66
src/glu/sgi/libnurbs/internals/dataTransform.h
Normal file
66
src/glu/sgi/libnurbs/internals/dataTransform.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/dataTransform.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _DATA_TRANSFORM_H
|
||||
#define _DATA_TRANSFORM_H
|
||||
|
||||
#include "reader.h"
|
||||
#include "directedLine.h"
|
||||
#include "bin.h"
|
||||
directedLine* bin_to_DLineLoops(Bin& bin);
|
||||
|
||||
/*transform the pwlcurve into a number of directedline lines
|
||||
*insert these directedlines into orignal which is supposed to be
|
||||
*the part of the trimming loop obtained so far.
|
||||
*return the updated trimkming loop.
|
||||
*/
|
||||
directedLine* o_pwlcurve_to_DLines(directedLine* original, O_pwlcurve* pwl);
|
||||
|
||||
/*transform a trim loop (curve) into a directedLine loop
|
||||
*/
|
||||
directedLine* o_curve_to_DLineLoop(O_curve* curve);
|
||||
|
||||
/*transform a list of trim loops (trim) into
|
||||
*a list of polygons represented as directedLine*.
|
||||
*/
|
||||
directedLine* o_trim_to_DLineLoops(O_trim* trim);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
56
src/glu/sgi/libnurbs/internals/defines.h
Normal file
56
src/glu/sgi/libnurbs/internals/defines.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* defines.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/defines.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gludefines_h_
|
||||
#define __gludefines_h_
|
||||
|
||||
/* culling constants */
|
||||
#define CULL_TRIVIAL_REJECT 0
|
||||
#define CULL_TRIVIAL_ACCEPT 1
|
||||
#define CULL_ACCEPT 2
|
||||
|
||||
/* maximum order of a B-Spline */
|
||||
#define MAXORDER 24
|
||||
|
||||
/* maximum dimension of any B-spline range space */
|
||||
#define MAXCOORDS 5
|
||||
|
||||
#endif /* __gludefines_h_ */
|
||||
84
src/glu/sgi/libnurbs/internals/displaylist.cc
Normal file
84
src/glu/sgi/libnurbs/internals/displaylist.cc
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* displaylist.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/displaylist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "nurbstess.h"
|
||||
#include "displaylist.h"
|
||||
|
||||
|
||||
DisplayList::DisplayList( NurbsTessellator *_nt ) :
|
||||
dlnodePool( sizeof( Dlnode ), 1, "dlnodepool" )
|
||||
{
|
||||
lastNode = &nodes;
|
||||
nt = _nt;
|
||||
}
|
||||
|
||||
DisplayList::~DisplayList( void )
|
||||
{
|
||||
for( Dlnode *nextNode; nodes; nodes = nextNode ) {
|
||||
nextNode = nodes->next;
|
||||
if( nodes->cleanup != 0 ) (nt->*nodes->cleanup)( nodes->arg );
|
||||
//nodes->deleteMe(dlnodePool);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DisplayList::play( void )
|
||||
{
|
||||
for( Dlnode *node = nodes; node; node = node->next )
|
||||
if( node->work != 0 ) (nt->*node->work)( node->arg );
|
||||
}
|
||||
|
||||
void
|
||||
DisplayList::endList( void )
|
||||
{
|
||||
*lastNode = 0;
|
||||
}
|
||||
|
||||
void
|
||||
DisplayList::append( PFVS work, void *arg, PFVS cleanup )
|
||||
{
|
||||
Dlnode *node = new(dlnodePool) Dlnode( work, arg, cleanup );
|
||||
*lastNode = node;
|
||||
lastNode = &(node->next);
|
||||
}
|
||||
|
||||
84
src/glu/sgi/libnurbs/internals/displaylist.h
Normal file
84
src/glu/sgi/libnurbs/internals/displaylist.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* displaylist.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/displaylist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gludisplaylist_h_
|
||||
#define __gludisplaylist_h_
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mysetjmp.h"
|
||||
#include "mystdio.h"
|
||||
#include "bufpool.h"
|
||||
|
||||
class NurbsTessellator;
|
||||
|
||||
typedef void (NurbsTessellator::*PFVS)( void * );
|
||||
|
||||
struct Dlnode : public PooledObj {
|
||||
Dlnode( PFVS, void *, PFVS );
|
||||
PFVS work;
|
||||
void * arg;
|
||||
PFVS cleanup;
|
||||
Dlnode * next;
|
||||
};
|
||||
|
||||
inline
|
||||
Dlnode::Dlnode( PFVS _work, void *_arg, PFVS _cleanup )
|
||||
{
|
||||
work = _work;
|
||||
arg = _arg;
|
||||
cleanup = _cleanup;
|
||||
}
|
||||
|
||||
class DisplayList {
|
||||
public:
|
||||
DisplayList( NurbsTessellator * );
|
||||
~DisplayList( void );
|
||||
void play( void );
|
||||
void append( PFVS work, void *arg, PFVS cleanup );
|
||||
void endList( void );
|
||||
private:
|
||||
Dlnode *nodes;
|
||||
Pool dlnodePool;
|
||||
Dlnode **lastNode;
|
||||
NurbsTessellator *nt;
|
||||
};
|
||||
|
||||
#endif /* __gludisplaylist_h_ */
|
||||
47
src/glu/sgi/libnurbs/internals/displaymode.h
Normal file
47
src/glu/sgi/libnurbs/internals/displaymode.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/displaymode.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gludisplaymode_h_
|
||||
#define __gludisplaymode_h_
|
||||
|
||||
#define N_MESHFILL 0
|
||||
#define N_MESHLINE 1
|
||||
#define N_MESHPOINT 2
|
||||
|
||||
#endif /* __gludisplaymode_h_ */
|
||||
120
src/glu/sgi/libnurbs/internals/flist.cc
Normal file
120
src/glu/sgi/libnurbs/internals/flist.cc
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flist.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "flist.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::Flist - initialize a REAL number array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
Flist::Flist( void )
|
||||
{
|
||||
npts = 0;
|
||||
pts = 0;
|
||||
start = end = 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::~Flist - free a REAL number array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
Flist::~Flist( void )
|
||||
{
|
||||
if( npts ) delete[] pts;
|
||||
}
|
||||
|
||||
void
|
||||
Flist::add( REAL x )
|
||||
{
|
||||
pts[end++] = x;
|
||||
assert( end <= npts );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::filter - remove duplicate numbers from array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
void Flist::filter( void )
|
||||
{
|
||||
sorter.qsort( pts, end );
|
||||
start = 0;
|
||||
|
||||
int j = 0;
|
||||
for( int i = 1; i < end; i++ ) {
|
||||
if( pts[i] == pts[i-j-1] )
|
||||
j++;
|
||||
pts[i-j] = pts[i];
|
||||
}
|
||||
end -= j;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::grow - ensure that array is large enough
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
void Flist::grow( int maxpts )
|
||||
{
|
||||
if( npts < maxpts ) {
|
||||
if( npts ) delete[] pts;
|
||||
npts = 2 * maxpts;
|
||||
pts = new REAL[npts];
|
||||
assert( pts != 0 );
|
||||
}
|
||||
start = end = 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Flist::taper - ignore head and tail of array
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
void Flist::taper( REAL from, REAL to )
|
||||
{
|
||||
while( pts[start] != from )
|
||||
start++;
|
||||
|
||||
while( pts[end-1] != to )
|
||||
end--;
|
||||
}
|
||||
|
||||
|
||||
65
src/glu/sgi/libnurbs/internals/flist.h
Normal file
65
src/glu/sgi/libnurbs/internals/flist.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flist.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluflist_h_
|
||||
#define __gluflist_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "flistsorter.h"
|
||||
|
||||
class Flist {
|
||||
public:
|
||||
REAL * pts; /* head of array */
|
||||
int npts; /* number of points in array */
|
||||
int start; /* first important point index */
|
||||
int end; /* last important point index */
|
||||
|
||||
Flist( void );
|
||||
~Flist( void );
|
||||
void add( REAL x );
|
||||
void filter( void );
|
||||
void grow( int);
|
||||
void taper( REAL , REAL );
|
||||
protected:
|
||||
FlistSorter sorter;
|
||||
};
|
||||
|
||||
#endif /* __gluflist_h_ */
|
||||
83
src/glu/sgi/libnurbs/internals/flistsorter.cc
Normal file
83
src/glu/sgi/libnurbs/internals/flistsorter.cc
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flistsorter.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flistsorter.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "flistsorter.h"
|
||||
|
||||
FlistSorter::FlistSorter( void ) : Sorter( sizeof( REAL ) )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FlistSorter::qsort( REAL *p, int n )
|
||||
{
|
||||
Sorter::qsort( (char *)p, n );
|
||||
}
|
||||
|
||||
int
|
||||
FlistSorter::qscmp( char *i, char *j )
|
||||
{
|
||||
REAL f0 = *(REAL *)i;
|
||||
REAL f1 = *(REAL *)j;
|
||||
return (f0 < f1) ? -1 : 1;
|
||||
}
|
||||
|
||||
void
|
||||
FlistSorter::qsexc( char *i, char *j )
|
||||
{
|
||||
REAL *f0 = (REAL *)i;
|
||||
REAL *f1 = (REAL *)j;
|
||||
REAL tmp = *f0;
|
||||
*f0 = *f1;
|
||||
*f1 = tmp;
|
||||
}
|
||||
|
||||
void
|
||||
FlistSorter::qstexc( char *i, char *j, char *k )
|
||||
{
|
||||
REAL *f0 = (REAL *)i;
|
||||
REAL *f1 = (REAL *)j;
|
||||
REAL *f2 = (REAL *)k;
|
||||
REAL tmp = *f0;
|
||||
*f0 = *f2;
|
||||
*f2 = *f1;
|
||||
*f1 = tmp;
|
||||
}
|
||||
58
src/glu/sgi/libnurbs/internals/flistsorter.h
Normal file
58
src/glu/sgi/libnurbs/internals/flistsorter.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* flistsorter.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flistsorter.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluflistsorter_h_
|
||||
#define __gluflistsorter_h_
|
||||
|
||||
#include "sorter.h"
|
||||
#include "types.h"
|
||||
|
||||
class FlistSorter : public Sorter {
|
||||
public:
|
||||
FlistSorter(void);
|
||||
void qsort( REAL *a, int n );
|
||||
|
||||
protected:
|
||||
virtual int qscmp( char *, char * );
|
||||
virtual void qsexc( char *i, char *j ); // i<-j, j<-i
|
||||
virtual void qstexc( char *i, char *j, char *k ); // i<-k, k<-j, j<-i
|
||||
};
|
||||
#endif /* __gluflistsorter_h_ */
|
||||
52
src/glu/sgi/libnurbs/internals/gridline.h
Normal file
52
src/glu/sgi/libnurbs/internals/gridline.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gridline.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/gridline.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glugridline_h_
|
||||
#define __glugridline_h_
|
||||
|
||||
struct Gridline {
|
||||
long v;
|
||||
REAL vval;
|
||||
long vindex;
|
||||
long ustart;
|
||||
long uend;
|
||||
};
|
||||
#endif /* __glugridline_h_ */
|
||||
95
src/glu/sgi/libnurbs/internals/gridtrimvertex.h
Normal file
95
src/glu/sgi/libnurbs/internals/gridtrimvertex.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gridtrimvertex.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/gridtrimvertex.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glugridtrimvertex_h_
|
||||
#define __glugridtrimvertex_h_
|
||||
|
||||
#include "mystdlib.h"
|
||||
#include "bufpool.h"
|
||||
#include "trimvertex.h"
|
||||
#include "gridvertex.h"
|
||||
|
||||
class GridTrimVertex : public PooledObj
|
||||
{
|
||||
private:
|
||||
TrimVertex dummyt;
|
||||
GridVertex dummyg;
|
||||
public:
|
||||
GridTrimVertex() { g = 0; t = 0; }
|
||||
TrimVertex *t;
|
||||
GridVertex *g;
|
||||
|
||||
inline void set( long, long );
|
||||
inline void set( REAL, REAL );
|
||||
inline void set( TrimVertex * );
|
||||
inline void clear( void ) { t = 0; g = 0; };
|
||||
inline int isGridVert() { return g ? 1 : 0 ; }
|
||||
inline int isTrimVert() { return t ? 1 : 0 ; }
|
||||
inline void output();
|
||||
};
|
||||
|
||||
inline void
|
||||
GridTrimVertex::set( long x, long y )
|
||||
{
|
||||
g = &dummyg;
|
||||
dummyg.gparam[0] = x;
|
||||
dummyg.gparam[1] = y;
|
||||
}
|
||||
|
||||
inline void
|
||||
GridTrimVertex::set( REAL x, REAL y )
|
||||
{
|
||||
g = 0;
|
||||
t = &dummyt;
|
||||
dummyt.param[0] = x;
|
||||
dummyt.param[1] = y;
|
||||
dummyt.nuid = 0;
|
||||
}
|
||||
|
||||
inline void
|
||||
GridTrimVertex::set( TrimVertex *v )
|
||||
{
|
||||
g = 0;
|
||||
t = v;
|
||||
}
|
||||
|
||||
typedef GridTrimVertex *GridTrimVertex_p;
|
||||
#endif /* __glugridtrimvertex_h_ */
|
||||
54
src/glu/sgi/libnurbs/internals/gridvertex.h
Normal file
54
src/glu/sgi/libnurbs/internals/gridvertex.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gridvertex.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/gridvertex.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glugridvertex_h_
|
||||
#define __glugridvertex_h_
|
||||
|
||||
struct GridVertex {
|
||||
long gparam[2];
|
||||
GridVertex( void ) {}
|
||||
GridVertex( long u, long v ) { gparam[0] = u, gparam[1] = v; }
|
||||
void set( long u, long v ) { gparam[0] = u, gparam[1] = v; }
|
||||
long nextu() { return gparam[0]++; }
|
||||
long prevu() { return gparam[0]--; }
|
||||
};
|
||||
|
||||
#endif /* __glugridvertex_h_ */
|
||||
167
src/glu/sgi/libnurbs/internals/hull.cc
Normal file
167
src/glu/sgi/libnurbs/internals/hull.cc
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* hull.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/hull.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "hull.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
#include "gridline.h"
|
||||
#include "trimline.h"
|
||||
#include "uarray.h"
|
||||
#include "trimregion.h"
|
||||
|
||||
Hull::Hull( void )
|
||||
{}
|
||||
|
||||
Hull::~Hull( void )
|
||||
{}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Hull:init - this routine does the initialization needed before any
|
||||
* calls to nextupper or nextlower can be made.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Hull::init( void )
|
||||
{
|
||||
TrimVertex *lfirst = left.first();
|
||||
TrimVertex *llast = left.last();
|
||||
if( lfirst->param[0] <= llast->param[0] ) {
|
||||
fakeleft.init( left.first() );
|
||||
upper.left = &fakeleft;
|
||||
lower.left = &left;
|
||||
} else {
|
||||
fakeleft.init( left.last() );
|
||||
lower.left = &fakeleft;
|
||||
upper.left = &left;
|
||||
}
|
||||
upper.left->last();
|
||||
lower.left->first();
|
||||
|
||||
if( top.ustart <= top.uend ) {
|
||||
upper.line = ⊤
|
||||
upper.index = top.ustart;
|
||||
} else
|
||||
upper.line = 0;
|
||||
|
||||
if( bot.ustart <= bot.uend ) {
|
||||
lower.line = ⊥
|
||||
lower.index = bot.ustart;
|
||||
} else
|
||||
lower.line = 0;
|
||||
|
||||
TrimVertex *rfirst = right.first();
|
||||
TrimVertex *rlast = right.last();
|
||||
if( rfirst->param[0] <= rlast->param[0] ) {
|
||||
fakeright.init( right.last() );
|
||||
lower.right = &fakeright;
|
||||
upper.right = &right;
|
||||
} else {
|
||||
fakeright.init( right.first() );
|
||||
upper.right = &fakeright;
|
||||
lower.right = &right;
|
||||
}
|
||||
upper.right->first();
|
||||
lower.right->last();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* nextupper - find next vertex on upper hull of trim region.
|
||||
* - if vertex is on trim curve, set vtop point to
|
||||
* that vertex. if vertex is on grid, set vtop to
|
||||
* point to temporary area and stuff coordinants into
|
||||
* temporary vertex. Also, place grid coords in temporary
|
||||
* grid vertex.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
GridTrimVertex *
|
||||
Hull::nextupper( GridTrimVertex *gv )
|
||||
{
|
||||
if( upper.left ) {
|
||||
gv->set( upper.left->prev() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
upper.left = 0;
|
||||
}
|
||||
|
||||
if( upper.line ) {
|
||||
assert( upper.index <= upper.line->uend );
|
||||
gv->set( uarray.uarray[upper.index], upper.line->vval );
|
||||
gv->set( upper.index, upper.line->vindex );
|
||||
if( upper.index++ == upper.line->uend ) upper.line = 0;
|
||||
return gv;
|
||||
}
|
||||
|
||||
if( upper.right ) {
|
||||
gv->set( upper.right->next() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
upper.right = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GridTrimVertex *
|
||||
Hull::nextlower( register GridTrimVertex *gv )
|
||||
{
|
||||
if( lower.left ) {
|
||||
gv->set( lower.left->next() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
lower.left = 0;
|
||||
}
|
||||
|
||||
if( lower.line ) {
|
||||
gv->set( uarray.uarray[lower.index], lower.line->vval );
|
||||
gv->set( lower.index, lower.line->vindex );
|
||||
if( lower.index++ == lower.line->uend ) lower.line = 0;
|
||||
return gv;
|
||||
}
|
||||
|
||||
if( lower.right ) {
|
||||
gv->set( lower.right->prev() );
|
||||
if( gv->isTrimVert() ) return gv;
|
||||
lower.right = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
74
src/glu/sgi/libnurbs/internals/hull.h
Normal file
74
src/glu/sgi/libnurbs/internals/hull.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* hull.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/hull.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluhull_h_
|
||||
#define __gluhull_h_
|
||||
|
||||
#include "trimline.h"
|
||||
#include "trimregion.h"
|
||||
|
||||
class GridTrimVertex;
|
||||
class Gridline;
|
||||
class Uarray;
|
||||
|
||||
class Hull : virtual public TrimRegion {
|
||||
public:
|
||||
Hull( void );
|
||||
~Hull( void );
|
||||
void init( void );
|
||||
GridTrimVertex * nextlower( GridTrimVertex * );
|
||||
GridTrimVertex * nextupper( GridTrimVertex * );
|
||||
private:
|
||||
struct Side {
|
||||
Trimline *left;
|
||||
Gridline *line;
|
||||
Trimline *right;
|
||||
long index;
|
||||
};
|
||||
|
||||
Side lower;
|
||||
Side upper;
|
||||
Trimline fakeleft;
|
||||
Trimline fakeright;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __gluhull_h_ */
|
||||
662
src/glu/sgi/libnurbs/internals/intersect.cc
Normal file
662
src/glu/sgi/libnurbs/internals/intersect.cc
Normal file
|
|
@ -0,0 +1,662 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* intersect.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/intersect.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "subdivider.h"
|
||||
#include "arc.h"
|
||||
#include "bin.h"
|
||||
#include "backend.h"
|
||||
#include "trimvertpool.h"
|
||||
|
||||
/*#define NOTDEF*/
|
||||
|
||||
enum i_result { INTERSECT_VERTEX, INTERSECT_EDGE };
|
||||
|
||||
/* local functions */
|
||||
static int arc_classify( Arc_ptr, int, REAL );
|
||||
static enum i_result pwlarc_intersect( PwlArc *, int, REAL, int, int[3] );
|
||||
|
||||
|
||||
void
|
||||
Subdivider::partition( Bin & bin, Bin & left, Bin & intersections,
|
||||
Bin & right, Bin & unknown, int param, REAL value )
|
||||
{
|
||||
Bin headonleft, headonright, tailonleft, tailonright;
|
||||
|
||||
for( Arc_ptr jarc = bin.removearc(); jarc; jarc = bin.removearc() ) {
|
||||
|
||||
REAL tdiff = jarc->tail()[param] - value;
|
||||
REAL hdiff = jarc->head()[param] - value;
|
||||
|
||||
if( tdiff > 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
right.addarc( jarc );
|
||||
} else if( hdiff == 0.0 ) {
|
||||
tailonright.addarc( jarc );
|
||||
} else {
|
||||
Arc_ptr jtemp;
|
||||
switch( arc_split(jarc, param, value, 0) ) {
|
||||
case 2:
|
||||
tailonright.addarc( jarc );
|
||||
headonleft.addarc( jarc->next );
|
||||
break;
|
||||
case 31:
|
||||
assert( jarc->head()[param] > value );
|
||||
right.addarc( jarc );
|
||||
tailonright.addarc( jtemp = jarc->next );
|
||||
headonleft.addarc( jtemp->next );
|
||||
break;
|
||||
case 32:
|
||||
assert( jarc->head()[param] <= value );
|
||||
tailonright .addarc( jarc );
|
||||
headonleft.addarc( jtemp = jarc->next );
|
||||
left.addarc( jtemp->next );
|
||||
break;
|
||||
case 4:
|
||||
right.addarc( jarc );
|
||||
tailonright.addarc( jtemp = jarc->next );
|
||||
headonleft.addarc( jtemp = jtemp->next );
|
||||
left.addarc( jtemp->next );
|
||||
}
|
||||
}
|
||||
} else if( tdiff == 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
headonright.addarc( jarc );
|
||||
} else if( hdiff == 0.0 ) {
|
||||
unknown.addarc( jarc );
|
||||
} else {
|
||||
headonleft.addarc( jarc );
|
||||
}
|
||||
} else {
|
||||
if( hdiff > 0.0 ) {
|
||||
Arc_ptr jtemp;
|
||||
switch( arc_split(jarc, param, value, 1) ) {
|
||||
case 2:
|
||||
tailonleft.addarc( jarc );
|
||||
headonright.addarc( jarc->next );
|
||||
break;
|
||||
case 31:
|
||||
assert( jarc->head()[param] < value );
|
||||
left.addarc( jarc );
|
||||
tailonleft.addarc( jtemp = jarc->next );
|
||||
headonright.addarc( jtemp->next );
|
||||
break;
|
||||
case 32:
|
||||
assert( jarc->head()[param] >= value );
|
||||
tailonleft.addarc( jarc );
|
||||
headonright.addarc( jtemp = jarc->next );
|
||||
right.addarc( jtemp->next );
|
||||
break;
|
||||
case 4:
|
||||
left.addarc( jarc );
|
||||
tailonleft.addarc( jtemp = jarc->next );
|
||||
headonright.addarc( jtemp = jtemp->next );
|
||||
right.addarc( jtemp->next );
|
||||
}
|
||||
} else if( hdiff == 0.0 ) {
|
||||
tailonleft.addarc( jarc );
|
||||
} else {
|
||||
left.addarc( jarc );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( param == 0 ) {
|
||||
classify_headonleft_s( headonleft, intersections, left, value );
|
||||
classify_tailonleft_s( tailonleft, intersections, left, value );
|
||||
classify_headonright_s( headonright, intersections, right, value );
|
||||
classify_tailonright_s( tailonright, intersections, right, value );
|
||||
} else {
|
||||
classify_headonleft_t( headonleft, intersections, left, value );
|
||||
classify_tailonleft_t( tailonleft, intersections, left, value );
|
||||
classify_headonright_t( headonright, intersections, right, value );
|
||||
classify_tailonright_t( tailonright, intersections, right, value );
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
vert_interp( TrimVertex *n, TrimVertex *l, TrimVertex *r, int p, REAL val )
|
||||
{
|
||||
assert( val > l->param[p]);
|
||||
assert( val < r->param[p]);
|
||||
|
||||
n->nuid = l->nuid;
|
||||
|
||||
n->param[p] = val;
|
||||
if( l->param[1-p] != r->param[1-p] ) {
|
||||
REAL ratio = (val - l->param[p]) / (r->param[p] - l->param[p]);
|
||||
n->param[1-p] = l->param[1-p] +
|
||||
ratio * (r->param[1-p] - l->param[1-p]);
|
||||
} else {
|
||||
n->param[1-p] = l->param[1-p];
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Subdivider::arc_split( Arc_ptr jarc, int param, REAL value, int dir )
|
||||
{
|
||||
int maxvertex = jarc->pwlArc->npts;
|
||||
Arc_ptr jarc1, jarc2, jarc3;
|
||||
TrimVertex* v = jarc->pwlArc->pts;
|
||||
|
||||
int loc[3];
|
||||
switch( pwlarc_intersect( jarc->pwlArc, param, value, dir, loc ) ) {
|
||||
|
||||
// When the parameter value lands on a vertex, life is sweet
|
||||
case INTERSECT_VERTEX: {
|
||||
jarc1 = new(arcpool) Arc( jarc, new( pwlarcpool) PwlArc( maxvertex-loc[1], &v[loc[1]] ) );
|
||||
jarc->pwlArc->npts = loc[1] + 1;
|
||||
jarc1->next = jarc->next;
|
||||
jarc1->next->prev = jarc1;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
assert(jarc->check() != 0);
|
||||
return 2;
|
||||
}
|
||||
|
||||
// When the parameter value intersects an edge, we have to
|
||||
// interpolate a new vertex. There are special cases
|
||||
// if the new vertex is adjacent to one or both of the
|
||||
// endpoints of the arc.
|
||||
case INTERSECT_EDGE: {
|
||||
int i, j;
|
||||
if( dir == 0 ) {
|
||||
i = loc[0];
|
||||
j = loc[2];
|
||||
} else {
|
||||
i = loc[2];
|
||||
j = loc[0];
|
||||
}
|
||||
|
||||
#ifndef NOTDEF
|
||||
// The split is between vertices at index j and i, in that
|
||||
// order (j < i)
|
||||
|
||||
// JEB: This code is my idea of how to do the split without
|
||||
// increasing the number of links. I'm doing this so that
|
||||
// the is_rect routine can recognize rectangles created by
|
||||
// subdivision. In exchange for simplifying the curve list,
|
||||
// however, it costs in allocated space and vertex copies.
|
||||
|
||||
TrimVertex *newjunk = trimvertexpool.get(maxvertex -i+1 /*-j*/);
|
||||
int k;
|
||||
for(k=0; k<maxvertex-i; k++)
|
||||
{
|
||||
newjunk[k+1] = v[i+k];
|
||||
newjunk[k+1].nuid = jarc->nuid;
|
||||
}
|
||||
|
||||
TrimVertex *vcopy = trimvertexpool.get(maxvertex);
|
||||
for(k=0; k<maxvertex; k++)
|
||||
{
|
||||
vcopy[k].param[0] = v[k].param[0];
|
||||
vcopy[k].param[1] = v[k].param[1];
|
||||
}
|
||||
jarc->pwlArc->pts=vcopy;
|
||||
|
||||
v[i].nuid = jarc->nuid;
|
||||
v[j].nuid = jarc->nuid;
|
||||
vert_interp( &newjunk[0], &v[loc[0]], &v[loc[2]], param, value );
|
||||
|
||||
if( showingDegenerate() )
|
||||
backend.triangle( &v[i], &newjunk[0], &v[j] );
|
||||
|
||||
vcopy[j+1].param[0]=newjunk[0].param[0];
|
||||
vcopy[j+1].param[1]=newjunk[0].param[1];
|
||||
|
||||
|
||||
jarc1 = new(arcpool) Arc( jarc,
|
||||
new(pwlarcpool) PwlArc(maxvertex-i+1 , newjunk ) );
|
||||
|
||||
jarc->pwlArc->npts = j+2;
|
||||
jarc1->next = jarc->next;
|
||||
jarc1->next->prev = jarc1;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
assert(jarc->check() != 0);
|
||||
|
||||
return 2;
|
||||
#endif //not NOTDEF
|
||||
// JEB: This is the original version:
|
||||
#ifdef NOTDEF
|
||||
|
||||
TrimVertex *newjunk = trimvertexpool.get(3);
|
||||
v[i].nuid = jarc->nuid;
|
||||
v[j].nuid = jarc->nuid;
|
||||
newjunk[0] = v[j];
|
||||
newjunk[2] = v[i];
|
||||
vert_interp( &newjunk[1], &v[loc[0]], &v[loc[2]], param, value );
|
||||
|
||||
if( showingDegenerate() )
|
||||
backend.triangle( &newjunk[2], &newjunk[1], &newjunk[0] );
|
||||
|
||||
// New vertex adjacent to both endpoints
|
||||
if (maxvertex == 2) {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc->pwlArc->npts = 2;
|
||||
jarc->pwlArc->pts = newjunk;
|
||||
jarc1->next = jarc->next;
|
||||
jarc1->next->prev = jarc1;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
assert(jarc->check() != 0);
|
||||
|
||||
return 2;
|
||||
|
||||
// New vertex adjacent to ending point of arc
|
||||
} else if (maxvertex - j == 2) {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk ) );
|
||||
jarc2 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc->pwlArc->npts = maxvertex-1;
|
||||
jarc2->next = jarc->next;
|
||||
jarc2->next->prev = jarc2;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
jarc1->next = jarc2;
|
||||
jarc2->prev = jarc1;
|
||||
assert(jarc->check() != 0);
|
||||
return 31;
|
||||
|
||||
// New vertex adjacent to starting point of arc
|
||||
} else if (i == 1) {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc2 = new(arcpool) Arc( jarc,
|
||||
new(pwlarcpool) PwlArc( maxvertex-1, &jarc->pwlArc->pts[1] ) );
|
||||
jarc->pwlArc->npts = 2;
|
||||
jarc->pwlArc->pts = newjunk;
|
||||
jarc2->next = jarc->next;
|
||||
jarc2->next->prev = jarc2;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
jarc1->next = jarc2;
|
||||
jarc2->prev = jarc1;
|
||||
assert(jarc->check() != 0);
|
||||
return 32;
|
||||
|
||||
// It's somewhere in the middle
|
||||
} else {
|
||||
jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk ) );
|
||||
jarc2 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
|
||||
jarc3 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( maxvertex-i, v+i ) );
|
||||
jarc->pwlArc->npts = j + 1;
|
||||
jarc3->next = jarc->next;
|
||||
jarc3->next->prev = jarc3;
|
||||
jarc->next = jarc1;
|
||||
jarc1->prev = jarc;
|
||||
jarc1->next = jarc2;
|
||||
jarc2->prev = jarc1;
|
||||
jarc2->next = jarc3;
|
||||
jarc3->prev = jarc2;
|
||||
assert(jarc->check() != 0);
|
||||
return 4;
|
||||
}
|
||||
#endif // NOTDEF
|
||||
}
|
||||
default:
|
||||
return -1; //picked -1 since it's not used
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* pwlarc_intersect - find intersection of pwlArc and isoparametric line
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static enum i_result
|
||||
pwlarc_intersect(
|
||||
PwlArc *pwlArc,
|
||||
int param,
|
||||
REAL value,
|
||||
int dir,
|
||||
int loc[3] )
|
||||
{
|
||||
assert( pwlArc->npts > 0 );
|
||||
|
||||
if( dir ) {
|
||||
TrimVertex *v = pwlArc->pts;
|
||||
int imin = 0;
|
||||
int imax = pwlArc->npts - 1;
|
||||
assert( value > v[imin].param[param] );
|
||||
assert( value < v[imax].param[param] );
|
||||
while( (imax - imin) > 1 ) {
|
||||
int imid = (imax + imin)/2;
|
||||
if( v[imid].param[param] > value )
|
||||
imax = imid;
|
||||
else if( v[imid].param[param] < value )
|
||||
imin = imid;
|
||||
else {
|
||||
loc[1] = imid;
|
||||
return INTERSECT_VERTEX;
|
||||
}
|
||||
}
|
||||
loc[0] = imin;
|
||||
loc[2] = imax;
|
||||
return INTERSECT_EDGE;
|
||||
} else {
|
||||
TrimVertex *v = pwlArc->pts;
|
||||
int imax = 0;
|
||||
int imin = pwlArc->npts - 1;
|
||||
assert( value > v[imin].param[param] );
|
||||
assert( value < v[imax].param[param] );
|
||||
while( (imin - imax) > 1 ) {
|
||||
int imid = (imax + imin)/2;
|
||||
if( v[imid].param[param] > value )
|
||||
imax = imid;
|
||||
else if( v[imid].param[param] < value )
|
||||
imin = imid;
|
||||
else {
|
||||
loc[1] = imid;
|
||||
return INTERSECT_VERTEX;
|
||||
}
|
||||
}
|
||||
loc[0] = imin;
|
||||
loc[2] = imax;
|
||||
return INTERSECT_EDGE;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* arc_classify - determine which side of a line a jarc lies
|
||||
*----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
arc_classify( Arc_ptr jarc, int param, REAL value )
|
||||
{
|
||||
REAL tdiff, hdiff;
|
||||
if( param == 0 ) {
|
||||
tdiff = jarc->tail()[0] - value;
|
||||
hdiff = jarc->head()[0] - value;
|
||||
} else {
|
||||
tdiff = jarc->tail()[1] - value;
|
||||
hdiff = jarc->head()[1] - value;
|
||||
}
|
||||
|
||||
if( tdiff > 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
return 0x11;
|
||||
} else if( hdiff == 0.0 ) {
|
||||
return 0x12;
|
||||
} else {
|
||||
return 0x10;
|
||||
}
|
||||
} else if( tdiff == 0.0 ) {
|
||||
if( hdiff > 0.0 ) {
|
||||
return 0x21;
|
||||
} else if( hdiff == 0.0 ) {
|
||||
return 0x22;
|
||||
} else {
|
||||
return 0x20;
|
||||
}
|
||||
} else {
|
||||
if( hdiff > 0.0 ) {
|
||||
return 0x01;
|
||||
} else if( hdiff == 0.0 ) {
|
||||
return 0x02;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonleft_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at left, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x02 );
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_sl( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->next->tail()[1] > j->next->head()[1] )
|
||||
in.addarc(j);
|
||||
else
|
||||
out.addarc(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonleft_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at left, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x02 );
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_tl( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if (j->next->tail()[0] > j->next->head()[0] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonleft_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at left */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x20 );
|
||||
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_sl( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[1] > j->prev->head()[1] )
|
||||
in.addarc( j );
|
||||
else
|
||||
out.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonleft_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at left */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x20 );
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
if( ccwTurn_tl( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[0] > j->prev->head()[0] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonright_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at right, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x12);
|
||||
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_sr( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->next->tail()[1] > j->next->head()[1] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_tailonright_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail at right, head on line */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x12);
|
||||
|
||||
j->clearitail();
|
||||
|
||||
REAL diff = j->next->head()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_tr( j, j->next ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
in.addarc( j );
|
||||
} else {
|
||||
if( j->next->tail()[0] > j->next->head()[0] )
|
||||
in.addarc( j );
|
||||
else
|
||||
out.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonright_s( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at right */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 0, val ) == 0x21 );
|
||||
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[0] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_sr( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[1] > j->prev->head()[1] )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::classify_headonright_t( Bin& bin, Bin& in, Bin& out, REAL val )
|
||||
{
|
||||
/* tail on line, head at right */
|
||||
Arc_ptr j;
|
||||
|
||||
while( (j = bin.removearc()) != NULL ) {
|
||||
assert( arc_classify( j, 1, val ) == 0x21 );
|
||||
|
||||
j->setitail();
|
||||
|
||||
REAL diff = j->prev->tail()[1] - val;
|
||||
if( diff > 0.0 ) {
|
||||
if( ccwTurn_tr( j->prev, j ) )
|
||||
out.addarc( j );
|
||||
else
|
||||
in.addarc( j );
|
||||
} else if( diff < 0.0 ) {
|
||||
out.addarc( j );
|
||||
} else {
|
||||
if( j->prev->tail()[0] > j->prev->head()[0] )
|
||||
in.addarc( j );
|
||||
else
|
||||
out.addarc( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
93
src/glu/sgi/libnurbs/internals/jarcloc.h
Normal file
93
src/glu/sgi/libnurbs/internals/jarcloc.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* jarcloc.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/jarcloc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glujarcloc_h_
|
||||
#define __glujarcloc_h_
|
||||
|
||||
#include "arc.h"
|
||||
|
||||
class Jarcloc {
|
||||
private:
|
||||
Arc_ptr arc;
|
||||
TrimVertex *p;
|
||||
TrimVertex *plast;
|
||||
public:
|
||||
inline void init( Arc_ptr a, long first, long last ) { arc = a; p=&a->pwlArc->pts[first]; plast = &a->pwlArc->pts[last]; }
|
||||
inline TrimVertex * getnextpt( void );
|
||||
inline TrimVertex * getprevpt( void );
|
||||
inline void reverse();
|
||||
};
|
||||
|
||||
inline void
|
||||
Jarcloc::reverse()
|
||||
{
|
||||
if( plast == &arc->pwlArc->pts[0] )
|
||||
plast = &arc->pwlArc->pts[arc->pwlArc->npts - 1];
|
||||
else
|
||||
plast = &arc->pwlArc->pts[0];
|
||||
}
|
||||
|
||||
inline TrimVertex *
|
||||
Jarcloc::getnextpt()
|
||||
{
|
||||
assert( p <= plast );
|
||||
if( p == plast ) {
|
||||
arc = arc->next;
|
||||
p = &arc->pwlArc->pts[0];
|
||||
plast = &arc->pwlArc->pts[arc->pwlArc->npts - 1];
|
||||
assert( p < plast );
|
||||
}
|
||||
return p++;
|
||||
}
|
||||
|
||||
inline TrimVertex *
|
||||
Jarcloc::getprevpt()
|
||||
{
|
||||
assert( p >= plast );
|
||||
if( p == plast ) {
|
||||
arc = arc->prev;
|
||||
p = &arc->pwlArc->pts[arc->pwlArc->npts - 1];
|
||||
plast = &arc->pwlArc->pts[0];
|
||||
assert( p > plast );
|
||||
}
|
||||
return p--;
|
||||
}
|
||||
#endif /* __glujarcloc_h_ */
|
||||
138
src/glu/sgi/libnurbs/internals/knotvector.cc
Normal file
138
src/glu/sgi/libnurbs/internals/knotvector.cc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* knotvector.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/knotvector.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "knotvector.h"
|
||||
#include "defines.h"
|
||||
|
||||
|
||||
void Knotvector::init( long _knotcount, long _stride, long _order, INREAL *_knotlist )
|
||||
{
|
||||
knotcount = _knotcount;
|
||||
stride = _stride;
|
||||
order = _order;
|
||||
knotlist = new Knot[_knotcount];
|
||||
assert( knotlist != 0 );
|
||||
|
||||
for( int i = 0; i != _knotcount; i++ )
|
||||
knotlist[i] = (Knot) _knotlist[i];
|
||||
}
|
||||
|
||||
Knotvector::Knotvector( void )
|
||||
{
|
||||
knotlist = 0;
|
||||
}
|
||||
|
||||
Knotvector::~Knotvector( void )
|
||||
{
|
||||
if( knotlist ) delete[] knotlist;
|
||||
}
|
||||
|
||||
int Knotvector::validate( void )
|
||||
{
|
||||
/* kindex is used as an array index so subtract one first,
|
||||
* this propagates throughout the code so study carefully */
|
||||
long kindex = knotcount-1;
|
||||
|
||||
if( order < 1 || order > MAXORDER ) {
|
||||
// spline order un-supported
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if( knotcount < (2 * order) ) {
|
||||
// too few knots
|
||||
return( 2 );
|
||||
}
|
||||
|
||||
if( identical( knotlist[kindex-(order-1)], knotlist[order-1]) ) {
|
||||
// valid knot range is empty
|
||||
return( 3 );
|
||||
}
|
||||
|
||||
for( long i = 0; i < kindex; i++)
|
||||
if( knotlist[i] > knotlist[i+1] ) {
|
||||
// decreasing knot sequence
|
||||
return( 4 );
|
||||
}
|
||||
|
||||
/* check for valid multiplicity */
|
||||
|
||||
/* kindex is currently the index of the last knot.
|
||||
* In the next loop it is decremented to ignore the last knot
|
||||
* and the loop stops when kindex is 2 so as to ignore the first
|
||||
* knot as well. These knots are not used in computing
|
||||
* knot multiplicities.
|
||||
*/
|
||||
|
||||
long multi = 1;
|
||||
for( ; kindex >= 1; kindex-- ) {
|
||||
if( knotlist[kindex] - knotlist[kindex-1] < TOLERANCE ) {
|
||||
multi++;
|
||||
continue;
|
||||
}
|
||||
if ( multi > order ) {
|
||||
// knot multiplicity greater than order of spline
|
||||
return( 5 );
|
||||
}
|
||||
multi = 1;
|
||||
}
|
||||
|
||||
if ( multi > order ) {
|
||||
// knot multiplicity greater than order of spline
|
||||
return( 5 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Knotvector::show( char *msg )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "%s\n", msg );
|
||||
dprintf( "order = %ld, count = %ld\n", order, knotcount );
|
||||
|
||||
for( int i=0; i<knotcount; i++ )
|
||||
dprintf( "knot[%d] = %g\n", i, knotlist[i] );
|
||||
#endif
|
||||
}
|
||||
|
||||
68
src/glu/sgi/libnurbs/internals/knotvector.h
Normal file
68
src/glu/sgi/libnurbs/internals/knotvector.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* knotvector.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/knotvector.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluknotvector_h_
|
||||
#define __gluknotvector_h_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct Knotvector { /* a knot vector */
|
||||
Knotvector( void );
|
||||
~Knotvector( void );
|
||||
void init( long, long, long, INREAL * );
|
||||
int validate( void );
|
||||
void show( char * );
|
||||
|
||||
long order; /* order of spline */
|
||||
long knotcount; /* number of knots */
|
||||
long stride; /* bytes between points */
|
||||
Knot * knotlist; /* global knot vector */
|
||||
};
|
||||
|
||||
/* tolerance to test knot coincidence */
|
||||
#define TOLERANCE 1.0e-5
|
||||
|
||||
inline int
|
||||
identical( Knot x, Knot y )
|
||||
{
|
||||
return ((x-y) < TOLERANCE) ? 1 : 0;
|
||||
}
|
||||
#endif /* __gluknotvector_h_ */
|
||||
843
src/glu/sgi/libnurbs/internals/mapdesc.cc
Normal file
843
src/glu/sgi/libnurbs/internals/mapdesc.cc
Normal file
|
|
@ -0,0 +1,843 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mapdesc.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mapdesc.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "mystring.h"
|
||||
#include "mymath.h"
|
||||
#include "backend.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "mapdesc.h"
|
||||
|
||||
Mapdesc::Mapdesc( long _type, int _israt, int _ncoords, Backend& b )
|
||||
: backend( b )
|
||||
{
|
||||
type = _type;
|
||||
isrational = _israt;
|
||||
ncoords = _ncoords;
|
||||
hcoords = _ncoords + (_israt ? 0 : 1 );
|
||||
inhcoords = _ncoords - (_israt ? 1 : 0 );
|
||||
mask = ((1<<(inhcoords*2))-1);
|
||||
next = 0;
|
||||
|
||||
assert( hcoords <= MAXCOORDS );
|
||||
assert( inhcoords >= 1 );
|
||||
|
||||
pixel_tolerance = 1.0;
|
||||
error_tolerance = 1.0;
|
||||
bbox_subdividing = N_NOBBOXSUBDIVISION;
|
||||
culling_method = N_NOCULLING;
|
||||
sampling_method = N_NOSAMPLING;
|
||||
clampfactor = N_NOCLAMPING;
|
||||
minsavings = N_NOSAVINGSSUBDIVISION;
|
||||
s_steps = 0.0;
|
||||
t_steps = 0.0;
|
||||
maxrate = ( s_steps < 0.0 ) ? 0.0 : s_steps;
|
||||
maxsrate = ( s_steps < 0.0 ) ? 0.0 : s_steps;
|
||||
maxtrate = ( t_steps < 0.0 ) ? 0.0 : t_steps;
|
||||
identify( bmat );
|
||||
identify( cmat );
|
||||
identify( smat );
|
||||
for( int i = 0; i != inhcoords; i++ )
|
||||
bboxsize[i] = 1.0;
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::setBboxsize( INREAL *mat )
|
||||
{
|
||||
for( int i = 0; i != inhcoords; i++ )
|
||||
bboxsize[i] = (REAL) mat[i];
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::identify( REAL dest[MAXCOORDS][MAXCOORDS] )
|
||||
{
|
||||
memset( dest, 0, sizeof( dest ) );
|
||||
for( int i=0; i != hcoords; i++ )
|
||||
dest[i][i] = 1.0;
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::surfbbox( REAL bb[2][MAXCOORDS] )
|
||||
{
|
||||
backend.surfbbox( type, bb[0], bb[1] );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::copy( REAL dest[MAXCOORDS][MAXCOORDS], long n, INREAL *src,
|
||||
long rstride, long cstride )
|
||||
{
|
||||
assert( n >= 0 );
|
||||
for( int i=0; i != n; i++ )
|
||||
for( int j=0; j != n; j++ )
|
||||
dest[i][j] = src[i*rstride + j*cstride];
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* copyPt - copy a homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::copyPt( REAL *d, REAL *s )
|
||||
{
|
||||
assert( hcoords > 0 );
|
||||
switch( hcoords ) {
|
||||
case 4:
|
||||
d[3] = s[3];
|
||||
d[2] = s[2];
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 3:
|
||||
d[2] = s[2];
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 2:
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 1:
|
||||
d[0] = s[0];
|
||||
break;
|
||||
case 5:
|
||||
d[4] = s[4];
|
||||
d[3] = s[3];
|
||||
d[2] = s[2];
|
||||
d[1] = s[1];
|
||||
d[0] = s[0];
|
||||
break;
|
||||
default:
|
||||
memcpy( d, s, hcoords * sizeof( REAL ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* sumPt - compute affine combination of two homogeneous points
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::sumPt( REAL *dst, REAL *src1, REAL *src2, register REAL alpha, register REAL beta )
|
||||
{
|
||||
assert( hcoords > 0 );
|
||||
switch( hcoords ) {
|
||||
case 4:
|
||||
dst[3] = src1[3] * alpha + src2[3] * beta;
|
||||
dst[2] = src1[2] * alpha + src2[2] * beta;
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 3:
|
||||
dst[2] = src1[2] * alpha + src2[2] * beta;
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 2:
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 1:
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
case 5:
|
||||
dst[4] = src1[4] * alpha + src2[4] * beta;
|
||||
dst[3] = src1[3] * alpha + src2[3] * beta;
|
||||
dst[2] = src1[2] * alpha + src2[2] * beta;
|
||||
dst[1] = src1[1] * alpha + src2[1] * beta;
|
||||
dst[0] = src1[0] * alpha + src2[0] * beta;
|
||||
break;
|
||||
default: {
|
||||
for( int i = 0; i != hcoords; i++ )
|
||||
dst[i] = src1[i] * alpha + src2[i] * beta;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* clipbits - compute bit-vector indicating point/window position
|
||||
* of a (transformed) homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
unsigned int
|
||||
Mapdesc::clipbits( REAL *p )
|
||||
{
|
||||
assert( inhcoords >= 0 );
|
||||
assert( inhcoords <= 3 );
|
||||
|
||||
register int nc = inhcoords;
|
||||
register REAL pw = p[nc];
|
||||
register REAL nw = -pw;
|
||||
register unsigned int bits = 0;
|
||||
|
||||
if( pw == 0.0 ) return mask;
|
||||
|
||||
if( pw > 0.0 ) {
|
||||
switch( nc ) {
|
||||
case 3:
|
||||
if( p[2] <= pw ) bits |= (1<<5);
|
||||
if( p[2] >= nw ) bits |= (1<<4);
|
||||
if( p[1] <= pw ) bits |= (1<<3);
|
||||
if( p[1] >= nw ) bits |= (1<<2);
|
||||
if( p[0] <= pw ) bits |= (1<<1);
|
||||
if( p[0] >= nw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 2:
|
||||
if( p[1] <= pw ) bits |= (1<<3);
|
||||
if( p[1] >= nw ) bits |= (1<<2);
|
||||
if( p[0] <= pw ) bits |= (1<<1);
|
||||
if( p[0] >= nw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 1:
|
||||
if( p[0] <= pw ) bits |= (1<<1);
|
||||
if( p[0] >= nw ) bits |= (1<<0);
|
||||
return bits;
|
||||
default: {
|
||||
int bit = 1;
|
||||
for( int i=0; i<nc; i++ ) {
|
||||
if( p[i] >= nw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
if( p[i] <= pw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
}
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch( nc ) {
|
||||
case 3:
|
||||
if( p[2] <= nw ) bits |= (1<<5);
|
||||
if( p[2] >= pw ) bits |= (1<<4);
|
||||
if( p[1] <= nw ) bits |= (1<<3);
|
||||
if( p[1] >= pw ) bits |= (1<<2);
|
||||
if( p[0] <= nw ) bits |= (1<<1);
|
||||
if( p[0] >= pw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 2:
|
||||
if( p[1] <= nw ) bits |= (1<<3);
|
||||
if( p[1] >= pw ) bits |= (1<<2);
|
||||
if( p[0] <= nw ) bits |= (1<<1);
|
||||
if( p[0] >= pw ) bits |= (1<<0);
|
||||
return bits;
|
||||
case 1:
|
||||
if( p[0] <= nw ) bits |= (1<<1);
|
||||
if( p[0] >= pw ) bits |= (1<<0);
|
||||
return bits;
|
||||
default: {
|
||||
int bit = 1;
|
||||
for( int i=0; i<nc; i++ ) {
|
||||
if( p[i] >= pw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
if( p[i] <= nw ) bits |= bit;
|
||||
bit <<= 1;
|
||||
}
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformRational - transform a homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformRational( Maxmatrix mat, REAL *d, REAL *s )
|
||||
{
|
||||
assert( hcoords >= 0 );
|
||||
|
||||
if( hcoords == 3 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
REAL z = s[2];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+z*mat[2][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+z*mat[2][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+z*mat[2][2];
|
||||
} else if( hcoords == 4 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
REAL z = s[2];
|
||||
REAL w = s[3];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+z*mat[2][0]+w*mat[3][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+z*mat[2][1]+w*mat[3][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+z*mat[2][2]+w*mat[3][2];
|
||||
d[3] = x*mat[0][3]+y*mat[1][3]+z*mat[2][3]+w*mat[3][3];
|
||||
} else {
|
||||
for( int i=0; i != hcoords; i++ ) {
|
||||
d[i] = 0;
|
||||
for( int j = 0; j != hcoords; j++ )
|
||||
d[i] += s[j] * mat[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformNonrational - transform a inhomogeneous point to a homogeneous point
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformNonrational( Maxmatrix mat, REAL *d, REAL *s )
|
||||
{
|
||||
if( inhcoords == 2 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+mat[2][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+mat[2][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+mat[2][2];
|
||||
} else if( inhcoords == 3 ) {
|
||||
REAL x = s[0];
|
||||
REAL y = s[1];
|
||||
REAL z = s[2];
|
||||
d[0] = x*mat[0][0]+y*mat[1][0]+z*mat[2][0]+mat[3][0];
|
||||
d[1] = x*mat[0][1]+y*mat[1][1]+z*mat[2][1]+mat[3][1];
|
||||
d[2] = x*mat[0][2]+y*mat[1][2]+z*mat[2][2]+mat[3][2];
|
||||
d[3] = x*mat[0][3]+y*mat[1][3]+z*mat[2][3]+mat[3][3];
|
||||
} else {
|
||||
assert( inhcoords >= 0 );
|
||||
for( int i=0; i != hcoords; i++ ) {
|
||||
d[i] = mat[inhcoords][i];
|
||||
for( int j = 0; j < inhcoords; j++ )
|
||||
d[i] += s[j] * mat[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformAndCullCheck - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description and
|
||||
* check if they are either completely inside, completely outside,
|
||||
* or intersecting the viewing frustrum.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::xformAndCullCheck(
|
||||
REAL *pts, int uorder, int ustride, int vorder, int vstride )
|
||||
{
|
||||
assert( uorder > 0 );
|
||||
assert( vorder > 0 );
|
||||
|
||||
unsigned int inbits = mask;
|
||||
unsigned int outbits = 0;
|
||||
|
||||
REAL *p = pts;
|
||||
for( REAL *pend = p + uorder * ustride; p != pend; p += ustride ) {
|
||||
REAL *q = p;
|
||||
for( REAL *qend = q + vorder * vstride; q != qend; q += vstride ) {
|
||||
REAL cpts[MAXCOORDS];
|
||||
xformCulling( cpts, q );
|
||||
unsigned int bits = clipbits( cpts );
|
||||
outbits |= bits;
|
||||
inbits &= bits;
|
||||
if( ( outbits == mask ) && ( inbits != mask ) ) return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
if( outbits != mask ) {
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
} else if( inbits == mask ) {
|
||||
return CULL_TRIVIAL_ACCEPT;
|
||||
} else {
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* cullCheck - check if a set of homogeneous transformed points are
|
||||
* either completely inside, completely outside,
|
||||
* or intersecting the viewing frustrum.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::cullCheck( REAL *pts, int uorder, int ustride, int vorder, int vstride )
|
||||
{
|
||||
unsigned int inbits = mask;
|
||||
unsigned int outbits = 0;
|
||||
|
||||
REAL *p = pts;
|
||||
for( REAL *pend = p + uorder * ustride; p != pend; p += ustride ) {
|
||||
REAL *q = p;
|
||||
for( REAL *qend = q + vorder * vstride; q != qend; q += vstride ) {
|
||||
unsigned int bits = clipbits( q );
|
||||
outbits |= bits;
|
||||
inbits &= bits;
|
||||
if( ( outbits == mask ) && ( inbits != mask ) ) return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
if( outbits != mask ) {
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
} else if( inbits == mask ) {
|
||||
return CULL_TRIVIAL_ACCEPT;
|
||||
} else {
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* cullCheck - check if a set of homogeneous transformed points are
|
||||
* either completely inside, completely outside,
|
||||
* or intersecting the viewing frustrum.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::cullCheck( REAL *pts, int order, int stride )
|
||||
{
|
||||
unsigned int inbits = mask;
|
||||
unsigned int outbits = 0;
|
||||
|
||||
REAL *p = pts;
|
||||
for( REAL *pend = p + order * stride; p != pend; p += stride ) {
|
||||
unsigned int bits = clipbits( p );
|
||||
outbits |= bits;
|
||||
inbits &= bits;
|
||||
if( ( outbits == mask ) && ( inbits != mask ) ) return CULL_ACCEPT;
|
||||
}
|
||||
|
||||
if( outbits != mask ) {
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
} else if( inbits == mask ) {
|
||||
return CULL_TRIVIAL_ACCEPT;
|
||||
} else {
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformSampling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into sampling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformSampling( REAL *pts, int order, int stride, REAL *sp, int outstride )
|
||||
{
|
||||
xformMat( smat, pts, order, stride, sp, outstride );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformBounding( REAL *pts, int order, int stride, REAL *sp, int outstride )
|
||||
{
|
||||
xformMat( bmat, pts, order, stride, sp, outstride );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformCulling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into culling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformCulling( REAL *pts, int order, int stride, REAL *cp, int outstride )
|
||||
{
|
||||
xformMat( cmat, pts, order, stride, cp, outstride );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformCulling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into culling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformCulling( REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *cp, int outustride, int outvstride )
|
||||
{
|
||||
xformMat( cmat, pts, uorder, ustride, vorder, vstride, cp, outustride, outvstride );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* xformSampling - transform a set of points that may be EITHER
|
||||
* homogeneous or inhomogeneous depending on the map description
|
||||
* into sampling space
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Mapdesc::xformSampling( REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *sp, int outustride, int outvstride )
|
||||
{
|
||||
xformMat( smat, pts, uorder, ustride, vorder, vstride, sp, outustride, outvstride );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformBounding( REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *sp, int outustride, int outvstride )
|
||||
{
|
||||
xformMat( bmat, pts, uorder, ustride, vorder, vstride, sp, outustride, outvstride );
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformMat(
|
||||
Maxmatrix mat,
|
||||
REAL * pts,
|
||||
int order,
|
||||
int stride,
|
||||
REAL * cp,
|
||||
int outstride )
|
||||
{
|
||||
if( isrational ) {
|
||||
REAL *pend = pts + order * stride;
|
||||
for( REAL *p = pts ; p != pend; p += stride ) {
|
||||
xformRational( mat, cp, p );
|
||||
cp += outstride;
|
||||
}
|
||||
} else {
|
||||
REAL *pend = pts + order * stride;
|
||||
for( REAL *p = pts ; p != pend; p += stride ) {
|
||||
xformNonrational( mat, cp, p );
|
||||
cp += outstride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::xformMat( Maxmatrix mat, REAL *pts,
|
||||
int uorder, int ustride,
|
||||
int vorder, int vstride,
|
||||
REAL *cp, int outustride, int outvstride )
|
||||
{
|
||||
if( isrational ) {
|
||||
REAL *pend = pts + uorder * ustride;
|
||||
for( REAL *p = pts ; p != pend; p += ustride ) {
|
||||
REAL *cpts2 = cp;
|
||||
REAL *qend = p + vorder * vstride;
|
||||
for( REAL *q = p; q != qend; q += vstride ) {
|
||||
xformRational( mat, cpts2, q );
|
||||
cpts2 += outvstride;
|
||||
}
|
||||
cp += outustride;
|
||||
}
|
||||
} else {
|
||||
REAL *pend = pts + uorder * ustride;
|
||||
for( REAL *p = pts ; p != pend; p += ustride ) {
|
||||
REAL *cpts2 = cp;
|
||||
REAL *qend = p + vorder * vstride;
|
||||
for( REAL *q = p; q != qend; q += vstride ) {
|
||||
xformNonrational( mat, cpts2, q );
|
||||
cpts2 += outvstride;
|
||||
}
|
||||
cp += outustride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* subdivide - subdivide a curve along an isoparametric line
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Mapdesc::subdivide( REAL *src, REAL *dst, REAL v, int stride, int order )
|
||||
{
|
||||
REAL mv = 1.0 - v;
|
||||
|
||||
for( REAL *send=src+stride*order; src!=send; send-=stride, dst+=stride ) {
|
||||
copyPt( dst, src );
|
||||
REAL *qpnt = src + stride;
|
||||
for( REAL *qp=src; qpnt!=send; qp=qpnt, qpnt+=stride )
|
||||
sumPt( qp, qp, qpnt, mv, v );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* subdivide - subdivide a patch along an isoparametric line
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Mapdesc::subdivide( REAL *src, REAL *dst, REAL v,
|
||||
int so, int ss, int to, int ts )
|
||||
{
|
||||
REAL mv = 1.0 - v;
|
||||
|
||||
for( REAL *slast = src+ss*so; src != slast; src += ss, dst += ss ) {
|
||||
REAL *sp = src;
|
||||
REAL *dp = dst;
|
||||
for( REAL *send = src+ts*to; sp != send; send -= ts, dp += ts ) {
|
||||
copyPt( dp, sp );
|
||||
REAL *qp = sp;
|
||||
for( REAL *qpnt = sp+ts; qpnt != send; qp = qpnt, qpnt += ts )
|
||||
sumPt( qp, qp, qpnt, mv, v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define sign(x) ((x > 0) ? 1 : ((x < 0.0) ? -1 : 0))
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* project - project a set of homogeneous coordinates into inhomogeneous ones
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::project( REAL *src, int rstride, int cstride,
|
||||
REAL *dest, int trstride, int tcstride,
|
||||
int nrows, int ncols )
|
||||
{
|
||||
int s = sign( src[inhcoords] );
|
||||
REAL *rlast = src + nrows * rstride;
|
||||
REAL *trptr = dest;
|
||||
for( REAL *rptr=src; rptr != rlast; rptr+=rstride, trptr+=trstride ) {
|
||||
REAL *clast = rptr + ncols * cstride;
|
||||
REAL *tcptr = trptr;
|
||||
for( REAL *cptr = rptr; cptr != clast; cptr+=cstride, tcptr+=tcstride ) {
|
||||
REAL *coordlast = cptr + inhcoords;
|
||||
if( sign( *coordlast ) != s ) return 0;
|
||||
REAL *tcoord = tcptr;
|
||||
for( REAL *coord = cptr; coord != coordlast; coord++, tcoord++ ) {
|
||||
*tcoord = *coord / *coordlast;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* project - project a set of homogeneous coordinates into inhomogeneous ones
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Mapdesc::project( REAL *src, int stride, REAL *dest, int tstride, int ncols )
|
||||
{
|
||||
int s = sign( src[inhcoords] );
|
||||
|
||||
REAL *clast = src + ncols * stride;
|
||||
for( REAL *cptr = src, *tcptr = dest; cptr != clast; cptr+=stride, tcptr+=tstride ) {
|
||||
REAL *coordlast = cptr + inhcoords;
|
||||
if( sign( *coordlast ) != s ) return 0;
|
||||
for( REAL *coord = cptr, *tcoord = tcptr; coord != coordlast; coord++, tcoord++ )
|
||||
*tcoord = *coord / *coordlast;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
Mapdesc::bboxTooBig(
|
||||
REAL *p,
|
||||
int rstride,
|
||||
int cstride,
|
||||
int nrows,
|
||||
int ncols,
|
||||
REAL bb[2][MAXCOORDS] )
|
||||
{
|
||||
REAL bbpts[MAXORDER][MAXORDER][MAXCOORDS];
|
||||
const int trstride = sizeof(bbpts[0]) / sizeof(REAL);
|
||||
const int tcstride = sizeof(bbpts[0][0]) / sizeof(REAL);
|
||||
|
||||
// points have been transformed, therefore they are homogeneous
|
||||
// project points
|
||||
int val = project( p, rstride, cstride,
|
||||
&bbpts[0][0][0], trstride, tcstride, nrows, ncols );
|
||||
if( val == 0 ) return -1;
|
||||
|
||||
// compute bounding box
|
||||
bbox( bb, &bbpts[0][0][0], trstride, tcstride, nrows, ncols );
|
||||
|
||||
// find out if bounding box can't fit in unit cube
|
||||
if( bbox_subdividing == N_BBOXROUND ) {
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
if( ceilf(bb[1][k]) - floorf(bb[0][k]) > bboxsize[k] ) return 1;
|
||||
} else {
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
if( bb[1][k] - bb[0][k] > bboxsize[k] ) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::bbox(
|
||||
REAL bb[2][MAXCOORDS],
|
||||
REAL *p,
|
||||
int rstride,
|
||||
int cstride,
|
||||
int nrows,
|
||||
int ncols )
|
||||
{
|
||||
int k;
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
bb[0][k] = bb[1][k] = p[k];
|
||||
|
||||
for( int i=0; i != nrows; i++ )
|
||||
for( int j=0; j != ncols; j++ )
|
||||
for( k=0; k != inhcoords; k++ ) {
|
||||
REAL x = p[i*rstride + j*cstride + k];
|
||||
if( x < bb[0][k] ) bb[0][k] = x;
|
||||
else if( x > bb[1][k] ) bb[1][k] = x;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcVelocityRational - calculate upper bound on first partial derivative
|
||||
* of a homogeneous set of points and bounds on each row of points.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcVelocityRational( REAL *p, int stride, int ncols )
|
||||
{
|
||||
REAL tmp[MAXORDER][MAXCOORDS];
|
||||
|
||||
assert( ncols <= MAXORDER );
|
||||
|
||||
const int tstride = sizeof(tmp[0]) / sizeof(REAL);
|
||||
|
||||
if( project( p, stride, &tmp[0][0], tstride, ncols ) ) {
|
||||
return calcPartialVelocity( &tmp[0][0], tstride, ncols, 1, 1.0 );
|
||||
} else { /* XXX */
|
||||
return calcPartialVelocity( &tmp[0][0], tstride, ncols, 1, 1.0 );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcVelocityNonrational - calculate upper bound on first partial
|
||||
* derivative of a inhomogeneous set of points.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcVelocityNonrational( REAL *pts, int stride, int ncols )
|
||||
{
|
||||
return calcPartialVelocity( pts, stride, ncols, 1, 1.0 );
|
||||
}
|
||||
|
||||
int
|
||||
Mapdesc::isProperty( long property )
|
||||
{
|
||||
switch ( property ) {
|
||||
case N_PIXEL_TOLERANCE:
|
||||
case N_ERROR_TOLERANCE:
|
||||
case N_CULLING:
|
||||
case N_BBOX_SUBDIVIDING:
|
||||
case N_S_STEPS:
|
||||
case N_T_STEPS:
|
||||
case N_SAMPLINGMETHOD:
|
||||
case N_CLAMPFACTOR:
|
||||
case N_MINSAVINGS:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
REAL
|
||||
Mapdesc::getProperty( long property )
|
||||
{
|
||||
switch ( property ) {
|
||||
case N_PIXEL_TOLERANCE:
|
||||
return pixel_tolerance;
|
||||
case N_ERROR_TOLERANCE:
|
||||
return error_tolerance;
|
||||
case N_CULLING:
|
||||
return culling_method;
|
||||
case N_BBOX_SUBDIVIDING:
|
||||
return bbox_subdividing;
|
||||
case N_S_STEPS:
|
||||
return s_steps;
|
||||
case N_T_STEPS:
|
||||
return t_steps;
|
||||
case N_SAMPLINGMETHOD:
|
||||
return sampling_method;
|
||||
case N_CLAMPFACTOR:
|
||||
return clampfactor;
|
||||
case N_MINSAVINGS:
|
||||
return minsavings;
|
||||
default:
|
||||
abort();
|
||||
return -1; //not necessary, needed to shut up compiler
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mapdesc::setProperty( long property, REAL value )
|
||||
{
|
||||
|
||||
switch ( property ) {
|
||||
case N_PIXEL_TOLERANCE:
|
||||
pixel_tolerance = value;
|
||||
break;
|
||||
case N_ERROR_TOLERANCE:
|
||||
error_tolerance = value;
|
||||
break;
|
||||
case N_CULLING:
|
||||
culling_method = value;
|
||||
break;
|
||||
case N_BBOX_SUBDIVIDING:
|
||||
if( value <= 0.0 ) value = N_NOBBOXSUBDIVISION;
|
||||
bbox_subdividing = value;
|
||||
break;
|
||||
case N_S_STEPS:
|
||||
if( value < 0.0 ) value = 0.0;
|
||||
s_steps = value;
|
||||
maxrate = ( value < 0.0 ) ? 0.0 : value;
|
||||
maxsrate = ( value < 0.0 ) ? 0.0 : value;
|
||||
break;
|
||||
case N_T_STEPS:
|
||||
if( value < 0.0 ) value = 0.0;
|
||||
t_steps = value;
|
||||
maxtrate = ( value < 0.0 ) ? 0.0 : value;
|
||||
break;
|
||||
case N_SAMPLINGMETHOD:
|
||||
sampling_method = value;
|
||||
break;
|
||||
case N_CLAMPFACTOR:
|
||||
if( value <= 0.0 ) value = N_NOCLAMPING;
|
||||
clampfactor = value;
|
||||
break;
|
||||
case N_MINSAVINGS:
|
||||
if( value <= 0.0 ) value = N_NOSAVINGSSUBDIVISION;
|
||||
minsavings = value;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
277
src/glu/sgi/libnurbs/internals/mapdesc.h
Normal file
277
src/glu/sgi/libnurbs/internals/mapdesc.h
Normal file
|
|
@ -0,0 +1,277 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mapdesc.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mapdesc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumapdesc_h_
|
||||
#define __glumapdesc_h_
|
||||
|
||||
#include "mystdio.h"
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
#include "bufpool.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
typedef REAL Maxmatrix[MAXCOORDS][MAXCOORDS];
|
||||
|
||||
class Backend;
|
||||
|
||||
class Mapdesc : public PooledObj {
|
||||
friend class Maplist;
|
||||
|
||||
public:
|
||||
Mapdesc( long, int, int, Backend & );
|
||||
int isProperty( long );
|
||||
REAL getProperty( long );
|
||||
void setProperty( long, REAL );
|
||||
int isConstantSampling( void );
|
||||
int isDomainSampling( void );
|
||||
int isRangeSampling( void );
|
||||
int isSampling( void );
|
||||
int isParametricDistanceSampling( void );
|
||||
int isObjectSpaceParaSampling( void );
|
||||
int isObjectSpacePathSampling( void );
|
||||
int isSurfaceAreaSampling( void );
|
||||
int isPathLengthSampling( void );
|
||||
int isCulling( void );
|
||||
int isBboxSubdividing( void );
|
||||
long getType( void );
|
||||
|
||||
/* curve routines */
|
||||
void subdivide( REAL *, REAL *, REAL, int, int );
|
||||
int cullCheck( REAL *, int, int );
|
||||
void xformBounding( REAL *, int, int, REAL *, int );
|
||||
void xformCulling( REAL *, int, int, REAL *, int );
|
||||
void xformSampling( REAL *, int, int, REAL *, int );
|
||||
void xformMat( Maxmatrix, REAL *, int, int, REAL *, int );
|
||||
REAL calcPartialVelocity ( REAL *, int, int, int, REAL );
|
||||
int project( REAL *, int, REAL *, int, int );
|
||||
REAL calcVelocityRational( REAL *, int, int );
|
||||
REAL calcVelocityNonrational( REAL *, int, int );
|
||||
|
||||
/* surface routines */
|
||||
void subdivide( REAL *, REAL *, REAL, int, int, int, int );
|
||||
int cullCheck( REAL *, int, int, int, int );
|
||||
void xformBounding( REAL *, int, int, int, int, REAL *, int, int );
|
||||
void xformCulling( REAL *, int, int, int, int, REAL *, int, int );
|
||||
void xformSampling( REAL *, int, int, int, int, REAL *, int, int );
|
||||
void xformMat( Maxmatrix, REAL *, int, int, int, int, REAL *, int, int );
|
||||
REAL calcPartialVelocity ( REAL *, REAL *, int, int, int, int, int, int, REAL, REAL, int );
|
||||
int project( REAL *, int, int, REAL *, int, int, int, int);
|
||||
void surfbbox( REAL bb[2][MAXCOORDS] );
|
||||
|
||||
int bboxTooBig( REAL *, int, int, int, int, REAL [2][MAXCOORDS] );
|
||||
int xformAndCullCheck( REAL *, int, int, int, int );
|
||||
|
||||
void identify( REAL[MAXCOORDS][MAXCOORDS] );
|
||||
void setBboxsize( INREAL *);
|
||||
inline void setBmat( INREAL*, long, long );
|
||||
inline void setCmat( INREAL*, long, long );
|
||||
inline void setSmat( INREAL*, long, long );
|
||||
inline int isRational( void );
|
||||
inline int getNcoords( void );
|
||||
|
||||
REAL pixel_tolerance; /* pathlength sampling tolerance */
|
||||
REAL error_tolerance; /* parametric error sampling tolerance*/
|
||||
REAL object_space_error_tolerance; /* object space tess*/
|
||||
REAL clampfactor;
|
||||
REAL minsavings;
|
||||
REAL maxrate;
|
||||
REAL maxsrate;
|
||||
REAL maxtrate;
|
||||
REAL bboxsize[MAXCOORDS];
|
||||
|
||||
private:
|
||||
long type;
|
||||
int isrational;
|
||||
int ncoords;
|
||||
int hcoords;
|
||||
int inhcoords;
|
||||
int mask;
|
||||
Maxmatrix bmat;
|
||||
Maxmatrix cmat;
|
||||
Maxmatrix smat;
|
||||
REAL s_steps; /* max samples in s direction */
|
||||
REAL t_steps; /* max samples in t direction */
|
||||
REAL sampling_method;
|
||||
REAL culling_method; /* check for culling */
|
||||
REAL bbox_subdividing;
|
||||
Mapdesc * next;
|
||||
Backend & backend;
|
||||
|
||||
void bbox( REAL [2][MAXCOORDS], REAL *, int, int, int, int );
|
||||
REAL maxDifference( int, REAL *, int );
|
||||
static void copy( Maxmatrix, long, INREAL *, long, long );
|
||||
|
||||
/* individual control point routines */
|
||||
static void transform4d( float[4], float[4], float[4][4] );
|
||||
static void multmatrix4d ( float[4][4], const float[4][4],
|
||||
const float[4][4] );
|
||||
void copyPt( REAL *, REAL * );
|
||||
void sumPt( REAL *, REAL *, REAL *, REAL, REAL );
|
||||
void xformSampling( REAL *, REAL * );
|
||||
void xformCulling( REAL *, REAL * );
|
||||
void xformRational( Maxmatrix, REAL *, REAL * );
|
||||
void xformNonrational( Maxmatrix, REAL *, REAL * );
|
||||
unsigned int clipbits( REAL * );
|
||||
};
|
||||
|
||||
inline void
|
||||
Mapdesc::setBmat( INREAL *mat, long rstride, long cstride )
|
||||
{
|
||||
copy( bmat, hcoords, mat, rstride, cstride );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::setCmat( INREAL *mat, long rstride, long cstride )
|
||||
{
|
||||
copy( cmat, hcoords, mat, rstride, cstride );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::setSmat( INREAL *mat, long rstride, long cstride )
|
||||
{
|
||||
copy( smat, hcoords, mat, rstride, cstride );
|
||||
}
|
||||
|
||||
inline long
|
||||
Mapdesc::getType( void )
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::xformCulling( REAL *d, REAL *s )
|
||||
{
|
||||
if( isrational )
|
||||
xformRational( cmat, d, s );
|
||||
else
|
||||
xformNonrational( cmat, d, s );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mapdesc::xformSampling( REAL *d, REAL *s )
|
||||
{
|
||||
if( isrational )
|
||||
xformRational( smat, d, s );
|
||||
else
|
||||
xformNonrational( smat, d, s );
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isRational( void )
|
||||
{
|
||||
return isrational ? 1 : 0;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::getNcoords( void )
|
||||
{
|
||||
return ncoords;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isConstantSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_FIXEDRATE) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isDomainSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_DOMAINDISTANCE) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isParametricDistanceSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_PARAMETRICDISTANCE) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isObjectSpaceParaSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_OBJECTSPACE_PARA) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isObjectSpacePathSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_OBJECTSPACE_PATH) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isSurfaceAreaSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_SURFACEAREA) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isPathLengthSampling( void )
|
||||
{
|
||||
return ((sampling_method == N_PATHLENGTH) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isRangeSampling( void )
|
||||
{
|
||||
return ( isParametricDistanceSampling() || isPathLengthSampling() ||
|
||||
isSurfaceAreaSampling() ||
|
||||
isObjectSpaceParaSampling() ||
|
||||
isObjectSpacePathSampling());
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isSampling( void )
|
||||
{
|
||||
return isRangeSampling() || isConstantSampling() || isDomainSampling();
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isCulling( void )
|
||||
{
|
||||
return ((culling_method != N_NOCULLING) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int
|
||||
Mapdesc::isBboxSubdividing( void )
|
||||
{
|
||||
return ((bbox_subdividing != N_NOBBOXSUBDIVISION) ? 1 : 0);
|
||||
}
|
||||
#endif /* __glumapdesc_h_ */
|
||||
241
src/glu/sgi/libnurbs/internals/mapdescv.cc
Normal file
241
src/glu/sgi/libnurbs/internals/mapdescv.cc
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mapdescv.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mapdescv.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "mystring.h"
|
||||
#include "mymath.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "mapdesc.h"
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcPartialVelocity - calculate maximum magnitude of a given partial
|
||||
* derivative
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcPartialVelocity (
|
||||
REAL *p,
|
||||
int stride,
|
||||
int ncols,
|
||||
int partial,
|
||||
REAL range )
|
||||
{
|
||||
REAL tmp[MAXORDER][MAXCOORDS];
|
||||
REAL mag[MAXORDER];
|
||||
|
||||
assert( ncols <= MAXORDER );
|
||||
|
||||
int j, k, t;
|
||||
// copy inhomogeneous control points into temporary array
|
||||
for( j=0; j != ncols; j++ )
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
tmp[j][k] = p[j*stride + k];
|
||||
|
||||
for( t=0; t != partial; t++ )
|
||||
for( j=0; j != ncols-t-1; j++ )
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
tmp[j][k] = tmp[j+1][k] - tmp[j][k];
|
||||
|
||||
// compute magnitude and store in mag array
|
||||
for( j=0; j != ncols-partial; j++ ) {
|
||||
mag[j] = 0.0;
|
||||
for( k=0; k != inhcoords; k++ )
|
||||
mag[j] += tmp[j][k] * tmp[j][k];
|
||||
}
|
||||
|
||||
// compute scale factor
|
||||
REAL fac = 1;
|
||||
REAL invt = 1.0 / range;
|
||||
for( t = ncols-1; t != ncols-1-partial; t-- )
|
||||
fac *= t * invt;
|
||||
|
||||
// compute max magnitude of all entries in array
|
||||
REAL max = 0.0;
|
||||
for( j=0; j != ncols-partial; j++ )
|
||||
if( mag[j] > max ) max = mag[j];
|
||||
max = fac * ::sqrtf( (float) max );
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* calcPartialVelocity - calculate maximum magnitude of a given partial
|
||||
* derivative
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
REAL
|
||||
Mapdesc::calcPartialVelocity (
|
||||
REAL *dist,
|
||||
REAL *p,
|
||||
int rstride,
|
||||
int cstride,
|
||||
int nrows,
|
||||
int ncols,
|
||||
int spartial,
|
||||
int tpartial,
|
||||
REAL srange,
|
||||
REAL trange,
|
||||
int side )
|
||||
{
|
||||
REAL tmp[MAXORDER][MAXORDER][MAXCOORDS];
|
||||
REAL mag[MAXORDER][MAXORDER];
|
||||
|
||||
assert( nrows <= MAXORDER );
|
||||
assert( ncols <= MAXORDER );
|
||||
|
||||
REAL *tp = &tmp[0][0][0];
|
||||
REAL *mp = &mag[0][0];
|
||||
const int istride = sizeof( tmp[0]) / sizeof( tmp[0][0][0] );
|
||||
const int jstride = sizeof( tmp[0][0]) / sizeof( tmp[0][0][0] );
|
||||
const int kstride = sizeof( tmp[0][0][0]) / sizeof( tmp[0][0][0] );
|
||||
const int mistride = sizeof( mag[0]) / sizeof( mag[0][0] );
|
||||
const int mjstride = sizeof( mag[0][0]) / sizeof( mag[0][0] );
|
||||
const int idist = nrows * istride;
|
||||
const int jdist = ncols * jstride;
|
||||
const int kdist = inhcoords * kstride;
|
||||
const int id = idist - spartial * istride;
|
||||
const int jd = jdist - tpartial * jstride;
|
||||
|
||||
{
|
||||
// copy control points
|
||||
REAL *ti = tp;
|
||||
REAL *qi = p;
|
||||
REAL *til = tp + idist;
|
||||
for( ; ti != til; ) {
|
||||
REAL *tj = ti;
|
||||
REAL *qj = qi;
|
||||
REAL *tjl = ti + jdist;
|
||||
for( ; tj != tjl; ) {
|
||||
for( int k=0; k != inhcoords; k++ ) {
|
||||
tj[k] = qj[k];
|
||||
}
|
||||
tj += jstride;
|
||||
qj += cstride;
|
||||
}
|
||||
ti += istride;
|
||||
qi += rstride;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// compute (s)-partial derivative control points
|
||||
REAL *til = tp + idist - istride;
|
||||
const REAL *till = til - ( spartial * istride );
|
||||
for( ; til != till; til -= istride )
|
||||
for( REAL *ti = tp; ti != til; ti += istride )
|
||||
for( REAL *tj = ti, *tjl = tj + jdist; tj != tjl; tj += jstride )
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
tj[k] = tj[k+istride] - tj[k];
|
||||
}
|
||||
|
||||
{
|
||||
// compute (s,t)-partial derivative control points
|
||||
REAL *tjl = tp + jdist - jstride;
|
||||
const REAL *tjll = tjl - ( tpartial * jstride );
|
||||
for( ; tjl != tjll; tjl -= jstride )
|
||||
for( REAL *tj = tp; tj != tjl; tj += jstride )
|
||||
for( REAL *ti = tj, *til = ti + id; ti != til; ti += istride )
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
ti[k] = ti[k+jstride] - ti[k];
|
||||
|
||||
}
|
||||
|
||||
REAL max = 0.0;
|
||||
{
|
||||
// compute magnitude and store in mag array
|
||||
memset( (void *) mp, 0, sizeof( mag ) );
|
||||
for( REAL *ti = tp, *mi = mp, *til = tp + id; ti != til; ti += istride, mi += mistride )
|
||||
for( REAL *tj = ti, *mj = mi, *tjl = ti + jd; tj != tjl; tj += jstride, mj += mjstride ) {
|
||||
for( int k=0; k != inhcoords; k++ )
|
||||
*mj += tj[k] * tj[k];
|
||||
if( *mj > max ) max = *mj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int i, j;
|
||||
|
||||
// compute scale factor
|
||||
REAL fac = 1.0;
|
||||
{
|
||||
REAL invs = 1.0 / srange;
|
||||
REAL invt = 1.0 / trange;
|
||||
for( int s = nrows-1, slast = s-spartial; s != slast; s-- )
|
||||
fac *= s * invs;
|
||||
for( int t = ncols-1, tlast = t-tpartial; t != tlast; t-- )
|
||||
fac *= t * invt;
|
||||
}
|
||||
|
||||
if( side == 0 ) {
|
||||
// compute max magnitude of first and last column
|
||||
dist[0] = 0.0;
|
||||
dist[1] = 0.0;
|
||||
for( i=0; i != nrows-spartial; i++ ) {
|
||||
j = 0;
|
||||
if( mag[i][j] > dist[0] ) dist[0] = mag[i][j];
|
||||
|
||||
j = ncols-tpartial-1;
|
||||
if( mag[i][j] > dist[1] ) dist[1] = mag[i][j];
|
||||
}
|
||||
dist[0] = fac * ::sqrtf( dist[0] );
|
||||
dist[1] = fac * ::sqrtf( dist[1] );
|
||||
} else if( side == 1 ) {
|
||||
// compute max magnitude of first and last row
|
||||
dist[0] = 0.0;
|
||||
dist[1] = 0.0;
|
||||
for( j=0; j != ncols-tpartial; j++ ) {
|
||||
i = 0;
|
||||
if( mag[i][j] > dist[0] ) dist[0] = mag[i][j];
|
||||
|
||||
i = nrows-spartial-1;
|
||||
if( mag[i][j] > dist[1] ) dist[1] = mag[i][j];
|
||||
}
|
||||
dist[0] = fac * ::sqrtf( dist[0] );
|
||||
dist[1] = fac * ::sqrtf( dist[1] );
|
||||
}
|
||||
|
||||
max = fac * ::sqrtf( (float) max );
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
117
src/glu/sgi/libnurbs/internals/maplist.cc
Normal file
117
src/glu/sgi/libnurbs/internals/maplist.cc
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* maplist.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/maplist.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "mymath.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "maplist.h"
|
||||
#include "mapdesc.h"
|
||||
#include "backend.h"
|
||||
|
||||
Maplist::Maplist( Backend& b )
|
||||
: mapdescPool( sizeof( Mapdesc ), 10, "mapdesc pool" ),
|
||||
backend( b )
|
||||
{
|
||||
maps = 0; lastmap = &maps;
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::initialize( void )
|
||||
{
|
||||
freeMaps();
|
||||
define( N_P2D, 0, 2 );
|
||||
define( N_P2DR, 1, 3 );
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::add( long type, int israt, int ncoords )
|
||||
{
|
||||
*lastmap = new(mapdescPool) Mapdesc( type, israt, ncoords, backend );
|
||||
lastmap = &((*lastmap)->next);
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::define( long type, int israt, int ncoords )
|
||||
{
|
||||
Mapdesc *m = locate( type );
|
||||
assert( m == NULL || ( m->isrational == israt && m->ncoords == ncoords ) );
|
||||
add( type, israt, ncoords );
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::remove( Mapdesc *m )
|
||||
{
|
||||
for( Mapdesc **curmap = &maps; *curmap; curmap = &((*curmap)->next) ) {
|
||||
if( *curmap == m ) {
|
||||
*curmap = m->next;
|
||||
m->deleteMe( mapdescPool );
|
||||
return;
|
||||
}
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
Maplist::freeMaps( void )
|
||||
{
|
||||
mapdescPool.clear();
|
||||
maps = 0;
|
||||
lastmap = &maps;
|
||||
}
|
||||
|
||||
Mapdesc *
|
||||
Maplist::find( long type )
|
||||
{
|
||||
Mapdesc *val = locate( type );
|
||||
assert( val != 0 );
|
||||
return val;
|
||||
}
|
||||
|
||||
Mapdesc *
|
||||
Maplist::locate( long type )
|
||||
{
|
||||
Mapdesc *m;
|
||||
for( m = maps; m; m = m->next )
|
||||
if( m->getType() == type ) break;
|
||||
return m;
|
||||
}
|
||||
87
src/glu/sgi/libnurbs/internals/maplist.h
Normal file
87
src/glu/sgi/libnurbs/internals/maplist.h
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* maplist.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/maplist.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumaplist_h_
|
||||
#define __glumaplist_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
#include "bufpool.h"
|
||||
|
||||
class Backend;
|
||||
class Mapdesc;
|
||||
|
||||
class Maplist {
|
||||
public:
|
||||
Maplist( Backend & );
|
||||
void define( long, int, int );
|
||||
inline void undefine( long );
|
||||
inline int isMap( long );
|
||||
|
||||
void initialize( void );
|
||||
Mapdesc * find( long );
|
||||
Mapdesc * locate( long );
|
||||
|
||||
private:
|
||||
Pool mapdescPool;
|
||||
Mapdesc * maps;
|
||||
Mapdesc ** lastmap;
|
||||
Backend & backend;
|
||||
|
||||
void add( long, int, int );
|
||||
void remove( Mapdesc * );
|
||||
void freeMaps( void );
|
||||
};
|
||||
|
||||
inline int
|
||||
Maplist::isMap( long type )
|
||||
{
|
||||
return (locate( type ) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline void
|
||||
Maplist::undefine( long type )
|
||||
{
|
||||
Mapdesc *m = locate( type );
|
||||
assert( m != 0 );
|
||||
remove( m );
|
||||
}
|
||||
#endif /* __glumaplist_h_ */
|
||||
488
src/glu/sgi/libnurbs/internals/mesher.cc
Normal file
488
src/glu/sgi/libnurbs/internals/mesher.cc
Normal file
|
|
@ -0,0 +1,488 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mesher.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mesher.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "mesher.h"
|
||||
#include "gridvertex.h"
|
||||
#include "gridtrimvertex.h"
|
||||
#include "jarcloc.h"
|
||||
#include "gridline.h"
|
||||
#include "trimline.h"
|
||||
#include "uarray.h"
|
||||
#include "backend.h"
|
||||
|
||||
|
||||
const float Mesher::ZERO = 0.0;
|
||||
|
||||
Mesher::Mesher( Backend& b )
|
||||
: backend( b ),
|
||||
p( sizeof( GridTrimVertex ), 100, "GridTrimVertexPool" )
|
||||
{
|
||||
stacksize = 0;
|
||||
vdata = 0;
|
||||
lastedge = 0; //needed to prevent purify UMR
|
||||
}
|
||||
|
||||
Mesher::~Mesher( void )
|
||||
{
|
||||
if( vdata ) delete[] vdata;
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::init( unsigned int npts )
|
||||
{
|
||||
p.clear();
|
||||
if( stacksize < npts ) {
|
||||
stacksize = 2 * npts;
|
||||
if( vdata ) delete[] vdata;
|
||||
vdata = new GridTrimVertex_p[stacksize];
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::push( GridTrimVertex *gt )
|
||||
{
|
||||
assert( itop+1 != stacksize );
|
||||
vdata[++itop] = gt;
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::pop( long )
|
||||
{
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::openMesh()
|
||||
{
|
||||
backend.bgntmesh( "addedge" );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::closeMesh()
|
||||
{
|
||||
backend.endtmesh();
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::swapMesh()
|
||||
{
|
||||
backend.swaptmesh();
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::clearStack()
|
||||
{
|
||||
itop = -1;
|
||||
last[0] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::finishLower( GridTrimVertex *gtlower )
|
||||
{
|
||||
for( push(gtlower);
|
||||
nextlower( gtlower=new(p) GridTrimVertex );
|
||||
push(gtlower) )
|
||||
addLower();
|
||||
addLast();
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::finishUpper( GridTrimVertex *gtupper )
|
||||
{
|
||||
for( push(gtupper);
|
||||
nextupper( gtupper=new(p) GridTrimVertex );
|
||||
push(gtupper) )
|
||||
addUpper();
|
||||
addLast();
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::mesh( void )
|
||||
{
|
||||
GridTrimVertex *gtlower, *gtupper;
|
||||
|
||||
Hull::init( );
|
||||
nextupper( gtupper = new(p) GridTrimVertex );
|
||||
nextlower( gtlower = new(p) GridTrimVertex );
|
||||
|
||||
clearStack();
|
||||
openMesh();
|
||||
push(gtupper);
|
||||
|
||||
nextupper( gtupper = new(p) GridTrimVertex );
|
||||
nextlower( gtlower );
|
||||
|
||||
assert( gtupper->t && gtlower->t );
|
||||
|
||||
if( gtupper->t->param[0] < gtlower->t->param[0] ) {
|
||||
push(gtupper);
|
||||
lastedge = 1;
|
||||
if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else if( gtupper->t->param[0] > gtlower->t->param[0] ) {
|
||||
push(gtlower);
|
||||
lastedge = 0;
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if( lastedge == 0 ) {
|
||||
push(gtupper);
|
||||
lastedge = 1;
|
||||
if( nextupper(gtupper=new(p) GridTrimVertex) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
push(gtlower);
|
||||
lastedge = 0;
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while ( 1 ) {
|
||||
if( gtupper->t->param[0] < gtlower->t->param[0] ) {
|
||||
push(gtupper);
|
||||
addUpper();
|
||||
if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else if( gtupper->t->param[0] > gtlower->t->param[0] ) {
|
||||
push(gtlower);
|
||||
addLower();
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if( lastedge == 0 ) {
|
||||
push(gtupper);
|
||||
addUpper();
|
||||
if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishLower(gtlower);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
push(gtlower);
|
||||
addLower();
|
||||
if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
|
||||
finishUpper(gtupper);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline int
|
||||
Mesher::isCcw( int ilast )
|
||||
{
|
||||
REAL area = det3( vdata[ilast]->t, vdata[itop-1]->t, vdata[itop-2]->t );
|
||||
return (area < ZERO) ? 0 : 1;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mesher::isCw( int ilast )
|
||||
{
|
||||
REAL area = det3( vdata[ilast]->t, vdata[itop-1]->t, vdata[itop-2]->t );
|
||||
return (area > -ZERO) ? 0 : 1;
|
||||
}
|
||||
|
||||
inline int
|
||||
Mesher::equal( int x, int y )
|
||||
{
|
||||
return( last[0] == vdata[x] && last[1] == vdata[y] );
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::copy( int x, int y )
|
||||
{
|
||||
last[0] = vdata[x]; last[1] = vdata[y];
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::move( int x, int y )
|
||||
{
|
||||
vdata[x] = vdata[y];
|
||||
}
|
||||
|
||||
inline void
|
||||
Mesher::output( int x )
|
||||
{
|
||||
backend.tmeshvert( vdata[x] );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* addedge - addedge an edge to the triangulation
|
||||
*
|
||||
* This code has been re-written to generate large triangle meshes
|
||||
* from a monotone polygon. Although smaller triangle meshes
|
||||
* could be generated faster and with less code, larger meshes
|
||||
* actually give better SYSTEM performance. This is because
|
||||
* vertices are processed in the backend slower than they are
|
||||
* generated by this code and any decrease in the number of vertices
|
||||
* results in a decrease in the time spent in the backend.
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Mesher::addLast( )
|
||||
{
|
||||
register int ilast = itop;
|
||||
|
||||
if( lastedge == 0 ) {
|
||||
if( equal( 0, 1 ) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
} else if( equal( ilast-2, ilast-1) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( 0, ilast );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast );
|
||||
output( 0 );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
}
|
||||
} else {
|
||||
if( equal( 1, 0) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
} else if( equal( ilast-1, ilast-2) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, 0 );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( 0 );
|
||||
output( ilast );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
}
|
||||
}
|
||||
closeMesh();
|
||||
//for( register long k=0; k<=ilast; k++ ) pop( k );
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::addUpper( )
|
||||
{
|
||||
register int ilast = itop;
|
||||
|
||||
if( lastedge == 0 ) {
|
||||
if( equal( 0, 1 ) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
} else if( equal( ilast-2, ilast-1) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( 0, ilast );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast );
|
||||
output( 0 );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
}
|
||||
lastedge = 1;
|
||||
//for( register long k=0; k<ilast-1; k++ ) pop( k );
|
||||
move( 0, ilast-1 );
|
||||
move( 1, ilast );
|
||||
itop = 1;
|
||||
} else {
|
||||
if( ! isCcw( ilast ) ) return;
|
||||
do {
|
||||
itop--;
|
||||
} while( (itop > 1) && isCcw( ilast ) );
|
||||
|
||||
if( equal( ilast-1, ilast-2 ) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i=ilast-3; i>=itop-1; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, itop-1 );
|
||||
} else if( equal( itop, itop-1 ) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = itop+1; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast );
|
||||
output( ilast-1 );
|
||||
for( register int i=ilast-2; i>=itop-1; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, itop-1 );
|
||||
}
|
||||
//for( register int k=itop; k<ilast; k++ ) pop( k );
|
||||
move( itop, ilast );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Mesher::addLower()
|
||||
{
|
||||
register int ilast = itop;
|
||||
|
||||
if( lastedge == 1 ) {
|
||||
if( equal( 1, 0) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i = 2; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
} else if( equal( ilast-1, ilast-2) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i = ilast-3; i >= 0; i-- ) {
|
||||
swapMesh();
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, 0 );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( 0 );
|
||||
output( ilast );
|
||||
for( register int i = 1; i < ilast; i++ ) {
|
||||
output( i );
|
||||
swapMesh();
|
||||
}
|
||||
copy( ilast-1, ilast );
|
||||
}
|
||||
|
||||
lastedge = 0;
|
||||
//for( register long k=0; k<ilast-1; k++ ) pop( k );
|
||||
move( 0, ilast-1 );
|
||||
move( 1, ilast );
|
||||
itop = 1;
|
||||
} else {
|
||||
if( ! isCw( ilast ) ) return;
|
||||
do {
|
||||
itop--;
|
||||
} while( (itop > 1) && isCw( ilast ) );
|
||||
|
||||
if( equal( ilast-2, ilast-1) ) {
|
||||
swapMesh();
|
||||
output( ilast );
|
||||
for( register int i=ilast-3; i>=itop-1; i--) {
|
||||
output( i );
|
||||
swapMesh( );
|
||||
}
|
||||
copy( itop-1, ilast );
|
||||
} else if( equal( itop-1, itop) ) {
|
||||
output( ilast );
|
||||
swapMesh();
|
||||
for( register int i=itop+1; i<ilast; i++ ) {
|
||||
swapMesh( );
|
||||
output( i );
|
||||
}
|
||||
copy( ilast, ilast-1 );
|
||||
} else {
|
||||
closeMesh(); openMesh();
|
||||
output( ilast-1 );
|
||||
output( ilast );
|
||||
for( register int i=ilast-2; i>=itop-1; i-- ) {
|
||||
output( i );
|
||||
swapMesh( );
|
||||
}
|
||||
copy( itop-1, ilast );
|
||||
}
|
||||
//for( register int k=itop; k<ilast; k++ ) pop( k );
|
||||
move( itop, ilast );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
89
src/glu/sgi/libnurbs/internals/mesher.h
Normal file
89
src/glu/sgi/libnurbs/internals/mesher.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mesher.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mesher.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumesher_h_
|
||||
#define __glumesher_h_
|
||||
|
||||
#include "hull.h"
|
||||
|
||||
class TrimRegion;
|
||||
class Backend;
|
||||
class Pool;
|
||||
class GridTrimVertex;
|
||||
|
||||
|
||||
class Mesher : virtual public TrimRegion, public Hull {
|
||||
public:
|
||||
Mesher( Backend & );
|
||||
~Mesher( void );
|
||||
void init( unsigned int );
|
||||
void mesh( void );
|
||||
|
||||
private:
|
||||
static const float ZERO;
|
||||
Backend& backend;
|
||||
|
||||
Pool p;
|
||||
unsigned int stacksize;
|
||||
GridTrimVertex ** vdata;
|
||||
GridTrimVertex * last[2];
|
||||
int itop;
|
||||
int lastedge;
|
||||
|
||||
inline void openMesh( void );
|
||||
inline void swapMesh( void );
|
||||
inline void closeMesh( void );
|
||||
inline int isCcw( int );
|
||||
inline int isCw( int );
|
||||
inline void clearStack( void );
|
||||
inline void push( GridTrimVertex * );
|
||||
inline void pop( long );
|
||||
inline void move( int, int );
|
||||
inline int equal( int, int );
|
||||
inline void copy( int, int );
|
||||
inline void output( int );
|
||||
void addUpper( void );
|
||||
void addLower( void );
|
||||
void addLast( void );
|
||||
void finishUpper( GridTrimVertex * );
|
||||
void finishLower( GridTrimVertex * );
|
||||
};
|
||||
#endif /* __glumesher_h_ */
|
||||
397
src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc
Normal file
397
src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "monoTriangulation.h"
|
||||
#include "polyUtil.h"
|
||||
#include "backend.h"
|
||||
#include "arc.h"
|
||||
|
||||
void reflexChain::outputFan(Real v[2], Backend* backend)
|
||||
{
|
||||
Int i;
|
||||
TrimVertex trimVert;
|
||||
backend->bgntfan();
|
||||
|
||||
/*
|
||||
trimVert.param[0]=v[0];
|
||||
trimVert.param[1]=v[1];
|
||||
backend->tmeshvert(&trimVert);
|
||||
*/
|
||||
backend->tmeshvert(v[0], v[1]);
|
||||
|
||||
if(isIncreasing) {
|
||||
for(i=0; i<index_queue; i++)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[i][0];
|
||||
trimVert.param[1]=queue[i][1];
|
||||
backend->tmeshvert(&trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[i][0], queue[i][1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i=index_queue-1; i>=0; i--)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[i][0];
|
||||
trimVert.param[1]=queue[i][1];
|
||||
backend->tmeshvert(&trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[i][0], queue[i][1]);
|
||||
}
|
||||
}
|
||||
backend->endtfan();
|
||||
}
|
||||
|
||||
void reflexChain::processNewVertex(Real v[2], Backend* backend)
|
||||
{
|
||||
Int i,j,k;
|
||||
Int isReflex;
|
||||
TrimVertex trimVert;
|
||||
/*if there are at most one vertex in the queue, then simply insert
|
||||
*/
|
||||
if(index_queue <=1){
|
||||
insert(v);
|
||||
return;
|
||||
}
|
||||
|
||||
/*there are at least two vertices in the queue*/
|
||||
j=index_queue-1;
|
||||
|
||||
for(i=j; i>=1; i--) {
|
||||
if(isIncreasing) {
|
||||
isReflex = (area(queue[i-1], queue[i], v) <= 0.0);
|
||||
}
|
||||
else /*decreasing*/{
|
||||
isReflex = (area(v, queue[i], queue[i-1]) <= 0.0);
|
||||
}
|
||||
if(isReflex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*if i<j then vertices: i+1--j are convex
|
||||
* output triangle fan:
|
||||
* v, and queue[i], i+1, ..., j
|
||||
*/
|
||||
if(i<j)
|
||||
{
|
||||
backend->bgntfan();
|
||||
/*
|
||||
trimVert.param[0]=v[0];
|
||||
trimVert.param[1]=v[1];
|
||||
backend->tmeshvert(& trimVert);
|
||||
*/
|
||||
backend->tmeshvert(v[0], v[1]);
|
||||
|
||||
if(isIncreasing) {
|
||||
for(k=i; k<=j; k++)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[k][0];
|
||||
trimVert.param[1]=queue[k][1];
|
||||
backend->tmeshvert(& trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[k][0], queue[k][1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(k=j; k>=i; k--)
|
||||
{
|
||||
/*
|
||||
trimVert.param[0]=queue[k][0];
|
||||
trimVert.param[1]=queue[k][1];
|
||||
backend->tmeshvert(& trimVert);
|
||||
*/
|
||||
backend->tmeshvert(queue[k][0], queue[k][1]);
|
||||
}
|
||||
}
|
||||
|
||||
backend->endtfan();
|
||||
}
|
||||
|
||||
/*delete vertices i+1--j from the queue*/
|
||||
index_queue = i+1;
|
||||
/*finally insert v at the end of the queue*/
|
||||
insert(v);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void monoTriangulationRec(Real* topVertex, Real* botVertex,
|
||||
vertexArray* inc_chain, Int inc_current,
|
||||
vertexArray* dec_chain, Int dec_current,
|
||||
Backend* backend)
|
||||
{
|
||||
assert( inc_chain != NULL && dec_chain != NULL);
|
||||
assert( ! (inc_current>=inc_chain->getNumElements() &&
|
||||
dec_current>=dec_chain->getNumElements()));
|
||||
Int inc_nVertices;
|
||||
Int dec_nVertices;
|
||||
Real** inc_array ;
|
||||
Real** dec_array ;
|
||||
Int i;
|
||||
assert( ! ( (inc_chain==NULL) && (dec_chain==NULL)));
|
||||
|
||||
if(inc_current>=inc_chain->getNumElements()) /*no more vertices on inc_chain*/
|
||||
{
|
||||
|
||||
dec_array = dec_chain->getArray();
|
||||
dec_nVertices = dec_chain->getNumElements();
|
||||
reflexChain rChain(20,0);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the dec_chain*/
|
||||
for(i=dec_current; i<dec_nVertices; i++){
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
|
||||
}
|
||||
else if(dec_current>= dec_chain->getNumElements()) /*no more vertices on dec_chain*/
|
||||
{
|
||||
inc_array = inc_chain->getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
reflexChain rChain(20,1);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the inc_chain*/
|
||||
for(i=inc_current; i<inc_nVertices; i++){
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
}
|
||||
else /*neither chain is empty*/
|
||||
{
|
||||
inc_array = inc_chain -> getArray();
|
||||
dec_array = dec_chain -> getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
dec_nVertices= dec_chain->getNumElements();
|
||||
/*if top of inc_chain is 'lower' than top of dec_chain, process all the
|
||||
*vertices on the dec_chain which are higher than top of inc_chain
|
||||
*/
|
||||
if(compV2InY(inc_array[inc_current], dec_array[dec_current]) <= 0)
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 0);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=dec_current; i<dec_nVertices; i++)
|
||||
{
|
||||
if(compV2InY(inc_array[inc_current], dec_array[i]) <= 0)
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(inc_array[inc_current], backend);
|
||||
monoTriangulationRec(dec_array[i-1], botVertex,
|
||||
inc_chain, inc_current,
|
||||
dec_chain, i,
|
||||
backend);
|
||||
}
|
||||
else /*compV2InY(inc_array[inc_current], dec_array[dec_current]) > 0*/
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 1);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=inc_current; i<inc_nVertices; i++)
|
||||
{
|
||||
if(compV2InY(inc_array[i], dec_array[dec_current]) >0)
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(dec_array[dec_current], backend);
|
||||
monoTriangulationRec(inc_array[i-1], botVertex,
|
||||
inc_chain, i,
|
||||
dec_chain, dec_current,
|
||||
backend);
|
||||
}
|
||||
}/*end case neither is empty*/
|
||||
}
|
||||
|
||||
|
||||
void monoTriangulationFunBackend(Arc_ptr loop, Int (*compFun)(Real*, Real*), Backend* backend)
|
||||
{
|
||||
Int i;
|
||||
/*find the top vertex, bottom vertex, inccreasing chain, and decreasing chain,
|
||||
*then call monoTriangulationRec
|
||||
*/
|
||||
Arc_ptr tempV;
|
||||
Arc_ptr topV;
|
||||
Arc_ptr botV;
|
||||
topV = botV = loop;
|
||||
for(tempV = loop->next; tempV != loop; tempV = tempV->next)
|
||||
{
|
||||
if(compFun(topV->tail(), tempV->tail())<0) {
|
||||
topV = tempV;
|
||||
}
|
||||
if(compFun(botV->tail(), tempV->tail())>0) {
|
||||
botV = tempV;
|
||||
}
|
||||
}
|
||||
|
||||
/*creat increase and decrease chains*/
|
||||
vertexArray inc_chain(20); /*this is a dynamic array*/
|
||||
for(i=1; i<=topV->pwlArc->npts-2; i++) { /*the first vertex is the top vertex which doesn't belong to inc_chain*/
|
||||
inc_chain.appendVertex(topV->pwlArc->pts[i].param);
|
||||
}
|
||||
for(tempV = topV->next; tempV != botV; tempV = tempV->next)
|
||||
{
|
||||
for(i=0; i<=tempV->pwlArc->npts-2; i++){
|
||||
inc_chain.appendVertex(tempV->pwlArc->pts[i].param);
|
||||
}
|
||||
}
|
||||
|
||||
vertexArray dec_chain(20);
|
||||
for(tempV = topV->prev; tempV != botV; tempV = tempV->prev)
|
||||
{
|
||||
for(i=tempV->pwlArc->npts-2; i>=0; i--){
|
||||
dec_chain.appendVertex(tempV->pwlArc->pts[i].param);
|
||||
}
|
||||
}
|
||||
for(i=botV->pwlArc->npts-2; i>=1; i--){
|
||||
dec_chain.appendVertex(tempV->pwlArc->pts[i].param);
|
||||
}
|
||||
|
||||
monoTriangulationRecFunBackend(topV->tail(), botV->tail(), &inc_chain, 0, &dec_chain, 0, compFun, backend);
|
||||
|
||||
}
|
||||
|
||||
/*if compFun == compV2InY, top to bottom: V-monotone
|
||||
*if compFun == compV2InX, right to left: U-monotone
|
||||
*/
|
||||
void monoTriangulationRecFunBackend(Real* topVertex, Real* botVertex,
|
||||
vertexArray* inc_chain, Int inc_current,
|
||||
vertexArray* dec_chain, Int dec_current,
|
||||
Int (*compFun)(Real*, Real*),
|
||||
Backend* backend)
|
||||
{
|
||||
assert( inc_chain != NULL && dec_chain != NULL);
|
||||
assert( ! (inc_current>=inc_chain->getNumElements() &&
|
||||
dec_current>=dec_chain->getNumElements()));
|
||||
Int inc_nVertices;
|
||||
Int dec_nVertices;
|
||||
Real** inc_array ;
|
||||
Real** dec_array ;
|
||||
Int i;
|
||||
assert( ! ( (inc_chain==NULL) && (dec_chain==NULL)));
|
||||
|
||||
if(inc_current>=inc_chain->getNumElements()) /*no more vertices on inc_chain*/
|
||||
{
|
||||
|
||||
dec_array = dec_chain->getArray();
|
||||
dec_nVertices = dec_chain->getNumElements();
|
||||
reflexChain rChain(20,0);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the dec_chain*/
|
||||
for(i=dec_current; i<dec_nVertices; i++){
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
|
||||
}
|
||||
else if(dec_current>= dec_chain->getNumElements()) /*no more vertices on dec_chain*/
|
||||
{
|
||||
inc_array = inc_chain->getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
reflexChain rChain(20,1);
|
||||
/*put the top vertex into the reflex chain*/
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
/*process all the vertices on the inc_chain*/
|
||||
for(i=inc_current; i<inc_nVertices; i++){
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
}
|
||||
/*process the bottom vertex*/
|
||||
rChain.processNewVertex(botVertex, backend);
|
||||
}
|
||||
else /*neither chain is empty*/
|
||||
{
|
||||
inc_array = inc_chain -> getArray();
|
||||
dec_array = dec_chain -> getArray();
|
||||
inc_nVertices= inc_chain->getNumElements();
|
||||
dec_nVertices= dec_chain->getNumElements();
|
||||
/*if top of inc_chain is 'lower' than top of dec_chain, process all the
|
||||
*vertices on the dec_chain which are higher than top of inc_chain
|
||||
*/
|
||||
if(compFun(inc_array[inc_current], dec_array[dec_current]) <= 0)
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 0);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=dec_current; i<dec_nVertices; i++)
|
||||
{
|
||||
if(compFun(inc_array[inc_current], dec_array[i]) <= 0)
|
||||
rChain.processNewVertex(dec_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(inc_array[inc_current], backend);
|
||||
monoTriangulationRecFunBackend(dec_array[i-1], botVertex,
|
||||
inc_chain, inc_current,
|
||||
dec_chain, i,
|
||||
compFun,
|
||||
backend);
|
||||
}
|
||||
else /*compFun(inc_array[inc_current], dec_array[dec_current]) > 0*/
|
||||
{
|
||||
|
||||
reflexChain rChain(20, 1);
|
||||
rChain.processNewVertex(topVertex, backend);
|
||||
for(i=inc_current; i<inc_nVertices; i++)
|
||||
{
|
||||
if(compFun(inc_array[i], dec_array[dec_current]) >0)
|
||||
rChain.processNewVertex(inc_array[i], backend);
|
||||
else
|
||||
break;
|
||||
}
|
||||
rChain.outputFan(dec_array[dec_current], backend);
|
||||
monoTriangulationRecFunBackend(inc_array[i-1], botVertex,
|
||||
inc_chain, i,
|
||||
dec_chain, dec_current,
|
||||
compFun,
|
||||
backend);
|
||||
}
|
||||
}/*end case neither is empty*/
|
||||
}
|
||||
262
src/glu/sgi/libnurbs/internals/monotonizer.cc
Normal file
262
src/glu/sgi/libnurbs/internals/monotonizer.cc
Normal file
|
|
@ -0,0 +1,262 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* monotonizer.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/monotonizer.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "arc.h"
|
||||
#include "arctess.h"
|
||||
#include "bezierarc.h"
|
||||
#include "bin.h"
|
||||
#include "mapdesc.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "subdivider.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Subdivider::decompose - break all curves into monotone arcs
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Subdivider::decompose( Bin& bin, REAL geo_stepsize )
|
||||
{
|
||||
Arc_ptr jarc;
|
||||
for( jarc=bin.firstarc(); jarc; jarc=bin.nextarc() ) {
|
||||
if( ! jarc->isTessellated() ) {
|
||||
/* points have not been transformed, therefore they may be either
|
||||
homogeneous or inhomogeneous */
|
||||
tessellate( jarc, geo_stepsize );
|
||||
if( jarc->isDisconnected() || jarc->next->isDisconnected() )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for( jarc=bin.firstarc(); jarc; jarc=bin.nextarc() ) {
|
||||
monotonize( jarc, bin );
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
for( jarc=bin.firstarc(); jarc; jarc=bin.nextarc() ) {
|
||||
assert( isMonotone( jarc ) != 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Subdivider::tessellate( Arc_ptr jarc, REAL geo_stepsize )
|
||||
{
|
||||
BezierArc *b = jarc->bezierArc;
|
||||
Mapdesc *mapdesc = b->mapdesc;
|
||||
|
||||
if( mapdesc->isRational() ) {
|
||||
REAL max = mapdesc->calcVelocityRational( b->cpts, b->stride, b->order );
|
||||
REAL arc_stepsize = (max > 1.0) ? (1.0/max) : 1.0;
|
||||
if( jarc->bezierArc->order != 2 )
|
||||
arctessellator.tessellateNonlinear( jarc, geo_stepsize, arc_stepsize, 1 );
|
||||
else {
|
||||
arctessellator.tessellateLinear( jarc, geo_stepsize, arc_stepsize, 1 );
|
||||
}
|
||||
} else {
|
||||
REAL max = mapdesc->calcVelocityNonrational( b->cpts, b->stride, b->order );
|
||||
REAL arc_stepsize = (max > 1.0) ? (1.0/max) : 1.0;
|
||||
if( jarc->bezierArc->order != 2 )
|
||||
arctessellator.tessellateNonlinear( jarc, geo_stepsize, arc_stepsize, 0 );
|
||||
else {
|
||||
arctessellator.tessellateLinear( jarc, geo_stepsize, arc_stepsize, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Subdivider::monotonize - break up a jordan arc into s,t-monotone
|
||||
* components. This code will remove degenerate segments, including
|
||||
* arcs of only a single point.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Subdivider::monotonize( Arc_ptr jarc, Bin& bin )
|
||||
{
|
||||
TrimVertex *firstvert = jarc->pwlArc->pts;
|
||||
TrimVertex *lastvert = firstvert + (jarc->pwlArc->npts - 1);
|
||||
long uid = jarc->nuid;
|
||||
arc_side side = jarc->getside();
|
||||
dir sdir = none;
|
||||
dir tdir = none;
|
||||
int degenerate = 1;
|
||||
|
||||
int nudegenerate;
|
||||
int change;
|
||||
|
||||
TrimVertex *vert;
|
||||
for( vert = firstvert; vert != lastvert; vert++ ) {
|
||||
|
||||
nudegenerate = 1;
|
||||
change = 0;
|
||||
|
||||
/* check change relative to s axis, clear degenerate bit if needed */
|
||||
REAL sdiff = vert[1].param[0] - vert[0].param[0];
|
||||
if( sdiff == 0 ) {
|
||||
if( sdir != same ) {
|
||||
sdir = same;
|
||||
change = 1;
|
||||
}
|
||||
} else if( sdiff < 0.0 ) {
|
||||
if( sdir != down ) {
|
||||
sdir = down;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
} else {
|
||||
if( sdir != up ) {
|
||||
sdir = up;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
}
|
||||
|
||||
/* check change relative to t axis, clear degenerate bit if needed */
|
||||
REAL tdiff = vert[1].param[1] - vert[0].param[1];
|
||||
if( tdiff == 0 ) {
|
||||
if( tdir != same ) {
|
||||
tdir = same;
|
||||
change = 1;
|
||||
}
|
||||
} else if( tdiff < 0.0 ) {
|
||||
if( tdir != down ) {
|
||||
tdir = down;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
} else {
|
||||
if( tdir != up ) {
|
||||
tdir = up;
|
||||
change = 1;
|
||||
}
|
||||
nudegenerate = 0;
|
||||
}
|
||||
|
||||
if( change ) {
|
||||
if( ! degenerate ) {
|
||||
/* make last segment into separate pwl curve */
|
||||
jarc->pwlArc->npts = vert - firstvert + 1;
|
||||
jarc = (new(arcpool) Arc( side, uid ))->append( jarc );
|
||||
jarc->pwlArc = new(pwlarcpool) PwlArc();
|
||||
bin.addarc( jarc );
|
||||
}
|
||||
firstvert = jarc->pwlArc->pts = vert;
|
||||
degenerate = nudegenerate;
|
||||
}
|
||||
}
|
||||
jarc->pwlArc->npts = vert - firstvert + 1;
|
||||
|
||||
if( degenerate ) {
|
||||
/* remove jarc from circularly linked list */
|
||||
jarc->prev->next = jarc->next;
|
||||
jarc->next->prev = jarc->prev;
|
||||
|
||||
assert( jarc->prev->check( ) != 0 );
|
||||
assert( jarc->next->check( ) != 0 );
|
||||
|
||||
/* remove jarc from bin */
|
||||
bin.remove_this_arc( jarc );
|
||||
|
||||
jarc->pwlArc->deleteMe( pwlarcpool ); jarc->pwlArc = 0;
|
||||
jarc->deleteMe( arcpool );
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Subdivider::isMonotone - return true if arc is monotone AND non-degenerate
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Subdivider::isMonotone( Arc_ptr jarc )
|
||||
{
|
||||
TrimVertex *firstvert = jarc->pwlArc->pts;
|
||||
TrimVertex *lastvert = firstvert + (jarc->pwlArc->npts - 1);
|
||||
|
||||
if( firstvert == lastvert ) return 1;
|
||||
|
||||
TrimVertex *vert = firstvert;
|
||||
enum dir sdir;
|
||||
enum dir tdir;
|
||||
|
||||
REAL diff = vert[1].param[0] - vert[0].param[0];
|
||||
if( diff == 0.0 )
|
||||
sdir = same;
|
||||
else if( diff < 0.0 )
|
||||
sdir = down;
|
||||
else
|
||||
sdir = up;
|
||||
|
||||
diff = vert[1].param[1] - vert[0].param[1];
|
||||
if( diff == 0.0 )
|
||||
tdir = same;
|
||||
else if( diff < 0.0 )
|
||||
tdir = down;
|
||||
else
|
||||
tdir = up;
|
||||
|
||||
if( (sdir == same) && (tdir == same) ) return 0;
|
||||
|
||||
for( ++vert ; vert != lastvert; vert++ ) {
|
||||
diff = vert[1].param[0] - vert[0].param[0];
|
||||
if( diff == 0.0 ) {
|
||||
if( sdir != same ) return 0;
|
||||
} else if( diff < 0.0 ) {
|
||||
if( sdir != down ) return 0;
|
||||
} else {
|
||||
if( sdir != up ) return 0;
|
||||
}
|
||||
|
||||
diff = vert[1].param[1] - vert[0].param[1];
|
||||
if( diff == 0.0 ) {
|
||||
if( tdir != same ) return 0;
|
||||
} else if( diff < 0.0 ) {
|
||||
if( tdir != down ) return 0;
|
||||
} else {
|
||||
if( tdir != up ) return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
47
src/glu/sgi/libnurbs/internals/monotonizer.h
Normal file
47
src/glu/sgi/libnurbs/internals/monotonizer.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/**************************************************************************
|
||||
* *
|
||||
* Copyright (C) 1999, Silicon Graphics, Inc. *
|
||||
* *
|
||||
* These coded instructions, statements, and computer programs contain *
|
||||
* unpublished proprietary information of Silicon Graphics, Inc., and *
|
||||
* are protected by Federal copyright law. They may not be disclosed *
|
||||
* to third parties or copied or duplicated in any form, in whole or *
|
||||
* in part, without the prior written consent of Silicon Graphics, Inc. *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* monotonizer.h
|
||||
*
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/monotonizer.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumonotonizer_h_
|
||||
#define __glumonotonizer_h_
|
||||
|
||||
#include "mysetjmp.h"
|
||||
#include "types.h"
|
||||
|
||||
class Arc;
|
||||
class ArcTessellator;
|
||||
class Pool;
|
||||
class Bin;
|
||||
class PwlArcPool;
|
||||
class Mapdesc;
|
||||
|
||||
class Monotonizer {
|
||||
ArcTessellator& arctessellator;
|
||||
Pool& arcpool;
|
||||
Pool& pwlarcpool;
|
||||
jmp_buf& nurbsJmpBuf;
|
||||
|
||||
enum dir { down, same, up, none };
|
||||
void tessellate( Arc *, REAL );
|
||||
void monotonize( Arc *, Bin & );
|
||||
int isMonotone( Arc * );
|
||||
public:
|
||||
Monotonizer( ArcTessellator& at, Pool& ap, Pool& p, jmp_buf& j )
|
||||
: arctessellator(at), arcpool(ap), pwlarcpool(p), nurbsJmpBuf(j) {}
|
||||
int decompose( Bin &, REAL );
|
||||
};
|
||||
#endif /* __glumonotonizer_h_ */
|
||||
57
src/glu/sgi/libnurbs/internals/myassert.h
Normal file
57
src/glu/sgi/libnurbs/internals/myassert.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* myassert.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/myassert.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumyassert_h_
|
||||
#define __glumyassert_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
#define assert(EX) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
#define assert(EX) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* __glumyassert_h_ */
|
||||
69
src/glu/sgi/libnurbs/internals/mycode.cc
Normal file
69
src/glu/sgi/libnurbs/internals/mycode.cc
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
**
|
||||
** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
*/
|
||||
/*
|
||||
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mycode.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "mymath.h"
|
||||
|
||||
#ifdef NEEDCEILF
|
||||
|
||||
float ceilf( float x )
|
||||
{
|
||||
if( x < 0 ) {
|
||||
float nx = -x;
|
||||
int ix = (int) nx;
|
||||
return (float) -ix;
|
||||
} else {
|
||||
int ix = (int) x;
|
||||
if( x == (float) ix ) return x;
|
||||
return (float) (ix+1);
|
||||
}
|
||||
}
|
||||
|
||||
float floorf( float x )
|
||||
{
|
||||
if( x < 0 ) {
|
||||
float nx = -x;
|
||||
int ix = (int) nx;
|
||||
if( nx == (float) ix ) return x;
|
||||
return (float) -(ix+1);
|
||||
} else {
|
||||
int ix = (int) x;
|
||||
return (float) ix;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
64
src/glu/sgi/libnurbs/internals/mymath.h
Normal file
64
src/glu/sgi/libnurbs/internals/mymath.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mymath.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mymath.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumymath_h_
|
||||
#define __glumymath_h_
|
||||
|
||||
#ifdef GLBUILD
|
||||
#define sqrtf gl_fsqrt
|
||||
#endif
|
||||
|
||||
#if GLBUILD | STANDALONE
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
#define ceilf myceilf
|
||||
#define floorf myfloorf
|
||||
#define sqrtf sqrt
|
||||
extern "C" double sqrt(double);
|
||||
extern "C" float ceilf(float);
|
||||
extern "C" float floorf(float);
|
||||
#define NEEDCEILF
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#endif /* __glumymath_h_ */
|
||||
91
src/glu/sgi/libnurbs/internals/mysetjmp.h
Normal file
91
src/glu/sgi/libnurbs/internals/mysetjmp.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mysetjmp.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mysetjmp.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumysetjmp_h_
|
||||
#define __glumysetjmp_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
struct JumpBuffer;
|
||||
extern "C" JumpBuffer *newJumpbuffer( void );
|
||||
extern "C" void deleteJumpbuffer(JumpBuffer *);
|
||||
extern "C" void mylongjmp( JumpBuffer *, int );
|
||||
extern "C" int mysetjmp( JumpBuffer * );
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
#define setjmp gl_setjmp
|
||||
#define longjmp gl_longjmp
|
||||
#endif
|
||||
|
||||
#if LIBRARYBUILD | GLBUILD
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct JumpBuffer {
|
||||
jmp_buf buf;
|
||||
};
|
||||
|
||||
inline JumpBuffer *
|
||||
newJumpbuffer( void )
|
||||
{
|
||||
return (JumpBuffer *) malloc( sizeof( JumpBuffer ) );
|
||||
}
|
||||
|
||||
inline void
|
||||
deleteJumpbuffer(JumpBuffer *jb)
|
||||
{
|
||||
free( (void *) jb);
|
||||
}
|
||||
|
||||
inline void
|
||||
mylongjmp( JumpBuffer *j, int code )
|
||||
{
|
||||
::longjmp( j->buf, code );
|
||||
}
|
||||
|
||||
inline int
|
||||
mysetjmp( JumpBuffer *j )
|
||||
{
|
||||
return ::setjmp( j->buf );
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __glumysetjmp_h_ */
|
||||
62
src/glu/sgi/libnurbs/internals/mystring.h
Normal file
62
src/glu/sgi/libnurbs/internals/mystring.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mystring.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mystring.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glumystring_h_
|
||||
#define __glumystring_h_
|
||||
|
||||
#ifdef STANDALONE
|
||||
typedef unsigned int size_t;
|
||||
extern "C" void * memcpy(void *, const void *, size_t);
|
||||
extern "C" void * memset(void *, int, size_t);
|
||||
#endif
|
||||
|
||||
#ifdef GLBUILD
|
||||
#define memcpy(a,b,c) bcopy(b,a,c)
|
||||
#define memset(a,b,c) bzero(a,c)
|
||||
extern "C" void bcopy(const void *, void *, int);
|
||||
extern "C" void bzero(void *, int);
|
||||
#endif
|
||||
|
||||
#ifdef LIBRARYBUILD
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#endif /* __glumystring_h_ */
|
||||
126
src/glu/sgi/libnurbs/internals/nurbsconsts.h
Normal file
126
src/glu/sgi/libnurbs/internals/nurbsconsts.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nurbsconsts.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/nurbsconsts.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glunurbsconsts_h_
|
||||
#define __glunurbsconsts_h_
|
||||
|
||||
/* NURBS Properties - one set per map,
|
||||
each takes a single INREAL arg */
|
||||
#define N_SAMPLING_TOLERANCE 1
|
||||
#define N_S_RATE 6
|
||||
#define N_T_RATE 7
|
||||
#define N_CLAMPFACTOR 13
|
||||
#define N_NOCLAMPING 0.0
|
||||
#define N_MINSAVINGS 14
|
||||
#define N_NOSAVINGSSUBDIVISION 0.0
|
||||
|
||||
/* NURBS Properties - one set per map,
|
||||
each takes an enumerated value */
|
||||
#define N_CULLING 2
|
||||
#define N_NOCULLING 0.0
|
||||
#define N_CULLINGON 1.0
|
||||
#define N_SAMPLINGMETHOD 10
|
||||
#define N_NOSAMPLING 0.0
|
||||
#define N_FIXEDRATE 3.0
|
||||
#define N_DOMAINDISTANCE 2.0
|
||||
#define N_PARAMETRICDISTANCE 5.0
|
||||
#define N_PATHLENGTH 6.0
|
||||
#define N_SURFACEAREA 7.0
|
||||
#define N_OBJECTSPACE_PARA 8.0
|
||||
#define N_OBJECTSPACE_PATH 9.0
|
||||
#define N_BBOX_SUBDIVIDING 17
|
||||
#define N_NOBBOXSUBDIVISION 0.0
|
||||
#define N_BBOXTIGHT 1.0
|
||||
#define N_BBOXROUND 2.0
|
||||
|
||||
/* NURBS Rendering Properties - one set per renderer
|
||||
each takes an enumerated value */
|
||||
#define N_DISPLAY 3
|
||||
#define N_FILL 1.0
|
||||
#define N_OUTLINE_POLY 2.0
|
||||
#define N_OUTLINE_TRI 3.0
|
||||
#define N_OUTLINE_QUAD 4.0
|
||||
#define N_OUTLINE_PATCH 5.0
|
||||
#define N_OUTLINE_PARAM 6.0
|
||||
#define N_OUTLINE_PARAM_S 7.0
|
||||
#define N_OUTLINE_PARAM_ST 8.0
|
||||
#define N_OUTLINE_SUBDIV 9.0
|
||||
#define N_OUTLINE_SUBDIV_S 10.0
|
||||
#define N_OUTLINE_SUBDIV_ST 11.0
|
||||
#define N_ISOLINE_S 12.0
|
||||
#define N_ERRORCHECKING 4
|
||||
#define N_NOMSG 0.0
|
||||
#define N_MSG 1.0
|
||||
|
||||
/* GL 4.0 propeties not defined above */
|
||||
#ifndef N_PIXEL_TOLERANCE
|
||||
#define N_PIXEL_TOLERANCE N_SAMPLING_TOLERANCE
|
||||
#define N_ERROR_TOLERANCE 20
|
||||
#define N_SUBDIVISIONS 5
|
||||
#define N_TILES 8
|
||||
#define N_TMP1 9
|
||||
#define N_TMP2 N_SAMPLINGMETHOD
|
||||
#define N_TMP3 11
|
||||
#define N_TMP4 12
|
||||
#define N_TMP5 N_CLAMPFACTOR
|
||||
#define N_TMP6 N_MINSAVINGS
|
||||
#define N_S_STEPS N_S_RATE
|
||||
#define N_T_STEPS N_T_RATE
|
||||
#endif
|
||||
|
||||
/* NURBS Rendering Properties - one set per map,
|
||||
each takes an INREAL matrix argument */
|
||||
#define N_CULLINGMATRIX 1
|
||||
#define N_SAMPLINGMATRIX 2
|
||||
#define N_BBOXMATRIX 3
|
||||
|
||||
|
||||
/* NURBS Rendering Properties - one set per map,
|
||||
each takes an INREAL vector argument */
|
||||
#define N_BBOXSIZE 4
|
||||
|
||||
/* type argument for trimming curves */
|
||||
#ifndef N_P2D
|
||||
#define N_P2D 0x8
|
||||
#define N_P2DR 0xd
|
||||
#endif
|
||||
|
||||
#endif /* __glunurbsconsts_h_ */
|
||||
539
src/glu/sgi/libnurbs/internals/nurbsinterfac.cc
Normal file
539
src/glu/sgi/libnurbs/internals/nurbsinterfac.cc
Normal file
|
|
@ -0,0 +1,539 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nurbsinterfac.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/nurbsinterfac.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "nurbstess.h"
|
||||
#include "bufpool.h"
|
||||
#include "quilt.h"
|
||||
#include "displaylist.h"
|
||||
#include "knotvector.h"
|
||||
#include "mapdesc.h"
|
||||
|
||||
#define THREAD( work, arg, cleanup ) \
|
||||
if( dl ) {\
|
||||
arg->save = 1;\
|
||||
dl->append( (PFVS)&NurbsTessellator::work, (void *) arg, (PFVS)&NurbsTessellator::cleanup );\
|
||||
} else {\
|
||||
arg->save = 0;\
|
||||
work( arg );\
|
||||
}
|
||||
|
||||
#define THREAD2( work ) \
|
||||
if( dl ) {\
|
||||
dl->append( (PFVS)&NurbsTessellator::work, 0, 0 );\
|
||||
} else {\
|
||||
work( );\
|
||||
}
|
||||
|
||||
NurbsTessellator::NurbsTessellator( BasicCurveEvaluator &c, BasicSurfaceEvaluator& e)
|
||||
: subdivider( renderhints, backend ),
|
||||
backend( c, e ),
|
||||
maplist( backend ),
|
||||
o_pwlcurvePool( sizeof( O_pwlcurve ), 32, "o_pwlcurvePool" ),
|
||||
o_nurbscurvePool( sizeof( O_nurbscurve ), 32, "o_nurbscurvePool"),
|
||||
o_curvePool( sizeof( O_curve ), 32, "o_curvePool" ),
|
||||
o_trimPool( sizeof( O_trim ), 32, "o_trimPool" ),
|
||||
o_surfacePool( sizeof( O_surface ), 1, "o_surfacePool" ),
|
||||
o_nurbssurfacePool( sizeof( O_nurbssurface ), 4, "o_nurbssurfacePool" ),
|
||||
propertyPool( sizeof( Property ), 32, "propertyPool" ),
|
||||
quiltPool( sizeof( Quilt ), 32, "quiltPool" )
|
||||
{
|
||||
dl = 0;
|
||||
inSurface = 0;
|
||||
inCurve = 0;
|
||||
inTrim = 0;
|
||||
playBack = 0;
|
||||
jumpbuffer = newJumpbuffer();
|
||||
subdivider.setJumpbuffer( jumpbuffer );
|
||||
}
|
||||
|
||||
NurbsTessellator::~NurbsTessellator( void )
|
||||
{
|
||||
if( inTrim ) {
|
||||
do_nurbserror( 12 );
|
||||
endtrim();
|
||||
}
|
||||
|
||||
if( inSurface ) {
|
||||
*nextNurbssurface = 0;
|
||||
do_freeall();
|
||||
}
|
||||
|
||||
if (jumpbuffer) {
|
||||
deleteJumpbuffer(jumpbuffer);
|
||||
jumpbuffer= 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* bgnsurface - allocate and initialize an o_surface structure
|
||||
*
|
||||
* Client: GL user
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::bgnsurface( long nuid )
|
||||
{
|
||||
O_surface *o_surface = new(o_surfacePool) O_surface;
|
||||
o_surface->nuid = nuid;
|
||||
THREAD( do_bgnsurface, o_surface, do_freebgnsurface );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* bgncurve - allocate an initialize an o_curve structure
|
||||
*
|
||||
* Client: GL user
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::bgncurve( long nuid )
|
||||
{
|
||||
O_curve *o_curve = new(o_curvePool) O_curve;
|
||||
o_curve->nuid = nuid;
|
||||
THREAD( do_bgncurve, o_curve, do_freebgncurve );
|
||||
}
|
||||
/*-----------------------------------------------------------------------------
|
||||
* endcurve -
|
||||
*
|
||||
* Client:
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::endcurve( void )
|
||||
{
|
||||
THREAD2( do_endcurve );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* endsurface - user level end of surface call
|
||||
*
|
||||
* Client: GL user
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::endsurface( void )
|
||||
{
|
||||
THREAD2( do_endsurface );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* bgntrim - allocate and initialize a new trim loop structure (o_trim )
|
||||
*
|
||||
* Client: GL user
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::bgntrim( void )
|
||||
{
|
||||
O_trim *o_trim = new(o_trimPool) O_trim;
|
||||
THREAD( do_bgntrim, o_trim, do_freebgntrim );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* endtrim -
|
||||
*
|
||||
* Client: GL user
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::endtrim( void )
|
||||
{
|
||||
THREAD2( do_endtrim );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* pwlcurve -
|
||||
*
|
||||
* count - number of points on curve
|
||||
* array - array of points on curve
|
||||
* byte_stride - distance between points in bytes
|
||||
* type - valid data flag
|
||||
*
|
||||
* Client: Gl user
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::pwlcurve( long count, INREAL array[], long byte_stride, long type )
|
||||
{
|
||||
Mapdesc *mapdesc = maplist.locate( type );
|
||||
|
||||
if( mapdesc == 0 ) {
|
||||
do_nurbserror( 35 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (type != N_P2D) && (type != N_P2DR) ) {
|
||||
do_nurbserror( 22 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
if( count < 0 ) {
|
||||
do_nurbserror( 33 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
if( byte_stride < 0 ) {
|
||||
do_nurbserror( 34 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NOTDEF
|
||||
if( mapdesc->isRational() ) {
|
||||
INREAL *p = array;
|
||||
INREAL x = p[0]; INREAL y = p[1]; INREAL w = p[2];
|
||||
p = (INREAL *) (((char *) p) + byte_stride);
|
||||
for( long i = 1; i != count; i++ ) {
|
||||
if( p[0] == x && p[1] == y && p[2] == w ) break;
|
||||
x = p[0]; y = p[1]; w = p[2];
|
||||
p = (INREAL *) (((char *) p) + byte_stride);
|
||||
}
|
||||
if( i != count ) {
|
||||
do_nurbserror( 37 );
|
||||
dprintf( "point %d (%f,%f)\n", i, x, y );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
INREAL *p = array;
|
||||
INREAL x = p[0]; INREAL y = p[1];
|
||||
p = (INREAL *) (((char *) p) + byte_stride);
|
||||
for( long i = 1; i != count; i++ ) {
|
||||
if( p[0] == x && p[1] == y ) break;
|
||||
x = p[0]; y = p[1];
|
||||
p = (INREAL *) (((char *) p) + byte_stride);
|
||||
}
|
||||
if( i != count ) {
|
||||
do_nurbserror( 37 );
|
||||
dprintf( "point %d (%f,%f)\n", i, x, y );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
O_pwlcurve *o_pwlcurve = new(o_pwlcurvePool) O_pwlcurve( type, count, array, byte_stride, extTrimVertexPool.get((int)count) );
|
||||
THREAD( do_pwlcurve, o_pwlcurve, do_freepwlcurve );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* nurbscurve -
|
||||
*
|
||||
* Client: GL user
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::nurbscurve(
|
||||
long nknots, /* number of p knots */
|
||||
INREAL knot[], /* nondecreasing knot values in p */
|
||||
long byte_stride, /* distance in bytes between control points */
|
||||
INREAL ctlarray[], /* pointer to first control point */
|
||||
long order, /* order of spline */
|
||||
long type ) /* description of range space */
|
||||
{
|
||||
|
||||
Mapdesc *mapdesc = maplist.locate( type );
|
||||
|
||||
if( mapdesc == 0 ) {
|
||||
do_nurbserror( 35 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( ctlarray == 0 ) {
|
||||
do_nurbserror( 36 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( byte_stride < 0 ) {
|
||||
do_nurbserror( 34 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Knotvector knots;
|
||||
|
||||
knots.init( nknots, byte_stride, order, knot );
|
||||
if( do_check_knots( &knots, "curve" ) ) return;
|
||||
|
||||
O_nurbscurve *o_nurbscurve = new(o_nurbscurvePool) O_nurbscurve(type);
|
||||
o_nurbscurve->bezier_curves = new(quiltPool) Quilt(mapdesc);
|
||||
o_nurbscurve->bezier_curves->toBezier( knots,ctlarray, mapdesc->getNcoords() );
|
||||
|
||||
THREAD( do_nurbscurve, o_nurbscurve, do_freenurbscurve );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* nurbssurface -
|
||||
*
|
||||
* Client: User routine
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::nurbssurface(
|
||||
long sknot_count, /* number of s knots */
|
||||
INREAL sknot[], /* nondecreasing knot values in s */
|
||||
long tknot_count, /* number of t knots */
|
||||
INREAL tknot[], /* nondecreasing knot values in t */
|
||||
long s_byte_stride, /* s step size in memory bytes */
|
||||
long t_byte_stride, /* t step size in memory bytes */
|
||||
INREAL ctlarray[], /* pointer to first control point */
|
||||
long sorder, /* order of the spline in s parameter */
|
||||
long torder, /* order of the spline in t parameter */
|
||||
long type) /* description of range space */
|
||||
{
|
||||
Mapdesc *mapdesc = maplist.locate( type );
|
||||
|
||||
if( mapdesc == 0 ) {
|
||||
do_nurbserror( 35 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( s_byte_stride < 0 ) {
|
||||
do_nurbserror( 34 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( t_byte_stride < 0 ) {
|
||||
do_nurbserror( 34 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Knotvector sknotvector, tknotvector;
|
||||
|
||||
sknotvector.init( sknot_count, s_byte_stride, sorder, sknot );
|
||||
if( do_check_knots( &sknotvector, "surface" ) ) return;
|
||||
|
||||
tknotvector.init( tknot_count, t_byte_stride, torder, tknot );
|
||||
if( do_check_knots( &tknotvector, "surface" ) ) return;
|
||||
|
||||
O_nurbssurface *o_nurbssurface = new(o_nurbssurfacePool) O_nurbssurface(type);
|
||||
o_nurbssurface->bezier_patches = new(quiltPool) Quilt(mapdesc);
|
||||
|
||||
o_nurbssurface->bezier_patches->toBezier( sknotvector, tknotvector,
|
||||
ctlarray, mapdesc->getNcoords() );
|
||||
THREAD( do_nurbssurface, o_nurbssurface, do_freenurbssurface );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* setnurbsproperty -
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::setnurbsproperty( long tag, INREAL value )
|
||||
{
|
||||
if( ! renderhints.isProperty( tag ) ) {
|
||||
do_nurbserror( 26 );
|
||||
} else {
|
||||
Property *prop = new(propertyPool) Property( tag, value );
|
||||
THREAD( do_setnurbsproperty, prop, do_freenurbsproperty );
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* setnurbsproperty -
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::setnurbsproperty( long type, long tag, INREAL value )
|
||||
{
|
||||
Mapdesc *mapdesc = maplist.locate( type );
|
||||
|
||||
if( mapdesc == 0 ) {
|
||||
do_nurbserror( 35 );
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! mapdesc->isProperty( tag ) ) {
|
||||
do_nurbserror( 26 );
|
||||
return;
|
||||
}
|
||||
|
||||
Property *prop = new(propertyPool) Property( type, tag, value );
|
||||
THREAD( do_setnurbsproperty2, prop, do_freenurbsproperty );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* getnurbsproperty -
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::getnurbsproperty( long tag, INREAL *value )
|
||||
{
|
||||
if( renderhints.isProperty( tag ) ) {
|
||||
*value = renderhints.getProperty( tag );
|
||||
} else {
|
||||
do_nurbserror( 26 );
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* getnurbsproperty -
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::getnurbsproperty( long type, long tag, INREAL *value )
|
||||
{
|
||||
Mapdesc *mapdesc = maplist.locate( type );
|
||||
|
||||
if( mapdesc == 0 )
|
||||
do_nurbserror( 35 );
|
||||
|
||||
if( mapdesc->isProperty( tag ) ) {
|
||||
*value = mapdesc->getProperty( tag );
|
||||
} else {
|
||||
do_nurbserror( 26 );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* setnurbsproperty - accept a user supplied matrix as culling or sampling mat
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::setnurbsproperty( long type, long purpose, INREAL *mat )
|
||||
{
|
||||
// XXX - cannot be put in display list
|
||||
Mapdesc *mapdesc = maplist.locate( type );
|
||||
|
||||
if( mapdesc == 0 ) {
|
||||
do_nurbserror( 35 );
|
||||
isDataValid = 0;
|
||||
} else if( purpose == N_BBOXSIZE ) {
|
||||
mapdesc->setBboxsize( mat );
|
||||
} else {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "ERRORRORRORR!!!\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* setnurbsproperty - accept a user supplied matrix as culling or sampling mat
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::setnurbsproperty( long type, long purpose, INREAL *mat,
|
||||
long rstride, long cstride )
|
||||
{
|
||||
// XXX - cannot be put in display list
|
||||
Mapdesc *mapdesc = maplist.locate( type );
|
||||
|
||||
if( mapdesc == 0 ) {
|
||||
do_nurbserror( 35 );
|
||||
isDataValid = 0;
|
||||
} else if( purpose == N_CULLINGMATRIX ) {
|
||||
mapdesc->setCmat( mat, rstride, cstride );
|
||||
} else if( purpose == N_SAMPLINGMATRIX ) {
|
||||
mapdesc->setSmat( mat, rstride, cstride );
|
||||
} else if( purpose == N_BBOXMATRIX ) {
|
||||
mapdesc->setBmat( mat, rstride, cstride );
|
||||
} else {
|
||||
#ifndef NDEBUG
|
||||
dprintf( "ERRORRORRORR!!!\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::redefineMaps( void )
|
||||
{
|
||||
maplist.initialize();
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::defineMap( long type, long rational, long ncoords )
|
||||
{
|
||||
maplist.define( type, (int) rational, (int) ncoords );
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::discardRecording( void *_dl )
|
||||
{
|
||||
delete (DisplayList *) _dl;
|
||||
}
|
||||
|
||||
void *
|
||||
NurbsTessellator::beginRecording( void )
|
||||
{
|
||||
dl = new DisplayList( this );
|
||||
return (void *) dl;
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::endRecording( void )
|
||||
{
|
||||
dl->endList();
|
||||
dl = 0;
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::playRecording( void *_dl )
|
||||
{
|
||||
playBack = 1;
|
||||
bgnrender();
|
||||
((DisplayList *)_dl)->play();
|
||||
endrender();
|
||||
playBack = 0;
|
||||
}
|
||||
|
||||
693
src/glu/sgi/libnurbs/internals/nurbstess.cc
Normal file
693
src/glu/sgi/libnurbs/internals/nurbstess.cc
Normal file
|
|
@ -0,0 +1,693 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nurbstess.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/nurbstess.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mysetjmp.h"
|
||||
#include "mystdio.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "nurbstess.h"
|
||||
#include "bufpool.h"
|
||||
#include "quilt.h"
|
||||
#include "knotvector.h"
|
||||
#include "mapdesc.h"
|
||||
#include "maplist.h"
|
||||
|
||||
void
|
||||
NurbsTessellator::set_domain_distance_u_rate(REAL u_rate)
|
||||
{
|
||||
subdivider.set_domain_distance_u_rate(u_rate);
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::set_domain_distance_v_rate(REAL v_rate)
|
||||
{
|
||||
subdivider.set_domain_distance_v_rate(v_rate);
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::set_is_domain_distance_sampling(int flag)
|
||||
{
|
||||
subdivider.set_is_domain_distance_sampling(flag);
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::resetObjects( void )
|
||||
{
|
||||
subdivider.clear();
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::makeobj( int )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "makeobj\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::closeobj( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "closeobj\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::bgnrender( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "bgnrender\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::endrender( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
dprintf( "endrender\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_freebgnsurface - free o_surface structure
|
||||
*
|
||||
* Client: do_freeall(), bgnsurface()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_freebgnsurface( O_surface *o_surface )
|
||||
{
|
||||
o_surface->deleteMe( o_surfacePool );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_bgnsurface - begin the display of a surface
|
||||
*
|
||||
* Client: bgnsurface()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_bgnsurface( O_surface *o_surface )
|
||||
{
|
||||
if( inSurface ) {
|
||||
do_nurbserror( 27 );
|
||||
endsurface();
|
||||
}
|
||||
inSurface = 1;
|
||||
|
||||
if( ! playBack ) bgnrender();
|
||||
|
||||
isTrimModified = 0;
|
||||
isSurfaceModified = 0;
|
||||
isDataValid = 1;
|
||||
numTrims = 0;
|
||||
currentSurface = o_surface;
|
||||
nextTrim = &( currentSurface->o_trim );
|
||||
nextNurbssurface = &( currentSurface->o_nurbssurface );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_bgncurve - begin the display of a curve
|
||||
*
|
||||
* Client: bgncurve()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_bgncurve( O_curve *o_curve )
|
||||
{
|
||||
if ( inCurve ) {
|
||||
do_nurbserror( 6 );
|
||||
endcurve();
|
||||
}
|
||||
|
||||
inCurve = 1;
|
||||
currentCurve = o_curve;
|
||||
currentCurve->curvetype = ct_none;
|
||||
|
||||
if( inTrim ) {
|
||||
if( *nextCurve != o_curve ) {
|
||||
isCurveModified = 1;
|
||||
*nextCurve = o_curve;
|
||||
}
|
||||
} else {
|
||||
if( ! playBack ) bgnrender();
|
||||
isDataValid = 1;
|
||||
}
|
||||
nextCurve = &(o_curve->next);
|
||||
nextPwlcurve = &(o_curve->curve.o_pwlcurve);
|
||||
nextNurbscurve = &(o_curve->curve.o_nurbscurve);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_endcurve -
|
||||
*
|
||||
* Client: endcurve()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::do_endcurve( void )
|
||||
{
|
||||
if( ! inCurve ) {
|
||||
do_nurbserror( 7 );
|
||||
return;
|
||||
}
|
||||
inCurve = 0;
|
||||
|
||||
*nextCurve = 0;
|
||||
if (currentCurve->curvetype == ct_nurbscurve)
|
||||
*nextNurbscurve = 0;
|
||||
else
|
||||
*nextPwlcurve = 0;
|
||||
|
||||
if ( ! inTrim ) {
|
||||
if( ! isDataValid ) {
|
||||
do_freecurveall( currentCurve );
|
||||
return;
|
||||
}
|
||||
|
||||
int errval;
|
||||
errval = ::mysetjmp( jumpbuffer );
|
||||
if( errval == 0 ) {
|
||||
if( currentCurve->curvetype == ct_nurbscurve ) {
|
||||
subdivider.beginQuilts();
|
||||
for( O_nurbscurve *n = currentCurve->curve.o_nurbscurve; n != 0; n = n->next )
|
||||
subdivider.addQuilt( n->bezier_curves );
|
||||
subdivider.endQuilts();
|
||||
subdivider.drawCurves();
|
||||
if( ! playBack ) endrender();
|
||||
} else {
|
||||
/* XXX */
|
||||
if( ! playBack ) endrender();
|
||||
/*do_draw_pwlcurve( currentCurve->curve.o_pwlcurve ) */;
|
||||
do_nurbserror( 9 );
|
||||
}
|
||||
} else {
|
||||
if( ! playBack ) endrender();
|
||||
do_nurbserror( errval );
|
||||
}
|
||||
do_freecurveall( currentCurve );
|
||||
resetObjects();
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_endsurface - mark end of surface, display surface, free immediate data
|
||||
*
|
||||
* Client:
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_endsurface( void )
|
||||
{
|
||||
if( inTrim ) {
|
||||
do_nurbserror( 12 );
|
||||
endtrim();
|
||||
}
|
||||
|
||||
if( ! inSurface ) {
|
||||
do_nurbserror( 13 );
|
||||
return;
|
||||
}
|
||||
inSurface = 0;
|
||||
|
||||
*nextNurbssurface = 0;
|
||||
|
||||
if( ! isDataValid ) {
|
||||
do_freeall( );
|
||||
return;
|
||||
}
|
||||
|
||||
if( *nextTrim != 0 ) {
|
||||
isTrimModified = 1;
|
||||
*nextTrim = 0;
|
||||
}
|
||||
|
||||
int errval;
|
||||
|
||||
errval = ::mysetjmp( jumpbuffer );
|
||||
if( errval == 0 ) {
|
||||
if( numTrims > 0 ) {
|
||||
|
||||
subdivider.beginTrims();
|
||||
for( O_trim *trim = currentSurface->o_trim; trim; trim = trim->next ) {
|
||||
subdivider.beginLoop();
|
||||
for( O_curve *curve = trim->o_curve; curve; curve = curve->next ) {
|
||||
curve->used = 0;
|
||||
assert( curve->curvetype != ct_none );
|
||||
if (curve->curvetype == ct_pwlcurve) {
|
||||
O_pwlcurve *c = curve->curve.o_pwlcurve;
|
||||
subdivider.addArc( c->npts, c->pts, curve->nuid );
|
||||
} else {
|
||||
Quilt *quilt = curve->curve.o_nurbscurve->bezier_curves;
|
||||
Quiltspec *qspec = quilt->qspec;
|
||||
REAL *cpts = quilt->cpts + qspec->offset;
|
||||
REAL *cptsend = cpts + (qspec->width * qspec->order * qspec->stride);
|
||||
for( ; cpts != cptsend; cpts += qspec->order*qspec->stride )
|
||||
subdivider.addArc( cpts, quilt, curve->nuid );
|
||||
}
|
||||
}
|
||||
subdivider.endLoop();
|
||||
}
|
||||
subdivider.endTrims();
|
||||
}
|
||||
|
||||
subdivider.beginQuilts();
|
||||
for( O_nurbssurface *n = currentSurface->o_nurbssurface; n; n = n->next )
|
||||
subdivider.addQuilt( n->bezier_patches );
|
||||
subdivider.endQuilts();
|
||||
subdivider.drawSurfaces( currentSurface->nuid );
|
||||
if( ! playBack ) endrender();
|
||||
} else {
|
||||
if( ! playBack ) endrender();
|
||||
do_nurbserror( errval );
|
||||
}
|
||||
|
||||
do_freeall( );
|
||||
resetObjects();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_freeall - free all data allocated in immediate mode
|
||||
*
|
||||
* Client:
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_freeall( void )
|
||||
{
|
||||
for( O_trim *o_trim = currentSurface->o_trim; o_trim; ) {
|
||||
O_trim *next_o_trim = o_trim->next;
|
||||
for( O_curve *curve = o_trim->o_curve; curve; ) {
|
||||
O_curve *next_o_curve = curve->next;
|
||||
do_freecurveall( curve );
|
||||
curve = next_o_curve;
|
||||
}
|
||||
if( o_trim->save == 0 ) do_freebgntrim( o_trim );
|
||||
o_trim = next_o_trim;
|
||||
}
|
||||
|
||||
O_nurbssurface *nurbss, *next_nurbss;
|
||||
for( nurbss= currentSurface->o_nurbssurface; nurbss; nurbss = next_nurbss) {
|
||||
next_nurbss = nurbss->next;
|
||||
if( nurbss->save == 0 )
|
||||
do_freenurbssurface( nurbss );
|
||||
else
|
||||
nurbss->used = 0;
|
||||
}
|
||||
|
||||
if( currentSurface->save == 0 ) do_freebgnsurface( currentSurface );
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::do_freecurveall( O_curve *curve )
|
||||
{
|
||||
assert( curve->curvetype != ct_none );
|
||||
|
||||
if( curve->curvetype == ct_nurbscurve ) {
|
||||
O_nurbscurve *ncurve, *next_ncurve;
|
||||
for( ncurve=curve->curve.o_nurbscurve; ncurve; ncurve=next_ncurve ) {
|
||||
next_ncurve = ncurve->next;
|
||||
if( ncurve->save == 0 )
|
||||
do_freenurbscurve( ncurve );
|
||||
else
|
||||
ncurve->used = 0;
|
||||
}
|
||||
} else {
|
||||
O_pwlcurve *pcurve, *next_pcurve;
|
||||
for( pcurve=curve->curve.o_pwlcurve; pcurve; pcurve=next_pcurve ) {
|
||||
next_pcurve = pcurve->next;
|
||||
if( pcurve->save == 0 )
|
||||
do_freepwlcurve( pcurve );
|
||||
else
|
||||
pcurve->used = 0;
|
||||
}
|
||||
}
|
||||
if( curve->save == 0 )
|
||||
do_freebgncurve( curve );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_freebgntrim - free the space allocated for a trim loop
|
||||
*
|
||||
* Client:
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_freebgntrim( O_trim *o_trim )
|
||||
{
|
||||
o_trim->deleteMe( o_trimPool );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_bgntrim - link in a trim loop to the current trimmed surface description
|
||||
*
|
||||
* Client: bgntrim()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_bgntrim( O_trim *o_trim )
|
||||
{
|
||||
|
||||
if( ! inSurface ) {
|
||||
do_nurbserror( 15 );
|
||||
bgnsurface( 0 );
|
||||
inSurface = 2;
|
||||
}
|
||||
|
||||
if( inTrim ) {
|
||||
do_nurbserror( 16 );
|
||||
endtrim();
|
||||
}
|
||||
inTrim = 1;
|
||||
|
||||
if( *nextTrim != o_trim ) {
|
||||
isTrimModified = 1;
|
||||
*nextTrim = o_trim;
|
||||
}
|
||||
|
||||
currentTrim = o_trim;
|
||||
nextTrim = &(o_trim->next);
|
||||
nextCurve = &(o_trim->o_curve);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_endtrim - mark the end of the current trim loop
|
||||
*
|
||||
* Client: endtrim()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_endtrim( void )
|
||||
{
|
||||
if( ! inTrim ) {
|
||||
do_nurbserror( 17 );
|
||||
return;
|
||||
}
|
||||
inTrim = 0;
|
||||
|
||||
if( currentTrim->o_curve == 0 ) {
|
||||
do_nurbserror( 18 );
|
||||
isDataValid = 0;
|
||||
}
|
||||
|
||||
numTrims++;
|
||||
|
||||
if( *nextCurve != 0 ) {
|
||||
isTrimModified = 1;
|
||||
*nextCurve = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_freepwlcurve -
|
||||
*
|
||||
* Client:
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_freepwlcurve( O_pwlcurve *o_pwlcurve )
|
||||
{
|
||||
o_pwlcurve->deleteMe( o_pwlcurvePool );
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::do_freebgncurve( O_curve *o_curve )
|
||||
{
|
||||
o_curve->deleteMe( o_curvePool );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_pwlcurve - link in pwl trim loop to the current surface description
|
||||
*
|
||||
* Client: pwlcurve()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_pwlcurve( O_pwlcurve *o_pwlcurve )
|
||||
{
|
||||
if( ! inTrim ) {
|
||||
do_nurbserror( 19 );
|
||||
if( o_pwlcurve->save == 0 )
|
||||
do_freepwlcurve(o_pwlcurve );
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! inCurve ) {
|
||||
bgncurve( 0 );
|
||||
inCurve = 2;
|
||||
}
|
||||
|
||||
if( o_pwlcurve->used ) {
|
||||
do_nurbserror( 20 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
} else
|
||||
o_pwlcurve->used = 1;
|
||||
|
||||
if( currentCurve->curvetype == ct_none ) {
|
||||
currentCurve->curvetype = ct_pwlcurve;
|
||||
} else if( currentCurve->curvetype != ct_pwlcurve ) {
|
||||
do_nurbserror( 21 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( *nextPwlcurve != o_pwlcurve ) {
|
||||
isCurveModified = 1;
|
||||
*nextPwlcurve = o_pwlcurve;
|
||||
}
|
||||
nextPwlcurve = &(o_pwlcurve->next);
|
||||
|
||||
if( o_pwlcurve->owner != currentCurve ) {
|
||||
isCurveModified = 1;
|
||||
o_pwlcurve->owner = currentCurve;
|
||||
}
|
||||
|
||||
if( (inCurve == 2) )
|
||||
endcurve();
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_freenurbscurve -
|
||||
*
|
||||
* Client:
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_freenurbscurve( O_nurbscurve *o_nurbscurve )
|
||||
{
|
||||
o_nurbscurve->bezier_curves->deleteMe( quiltPool );
|
||||
o_nurbscurve->deleteMe( o_nurbscurvePool );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_nurbscurve -
|
||||
*
|
||||
* Client: nurbscurve()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_nurbscurve( O_nurbscurve *o_nurbscurve )
|
||||
{
|
||||
if ( ! inCurve ) {
|
||||
bgncurve( 0 );
|
||||
inCurve = 2;
|
||||
}
|
||||
|
||||
if( o_nurbscurve->used ) {
|
||||
/* error - curve was already called in current surface */
|
||||
do_nurbserror( 23 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
} else
|
||||
o_nurbscurve->used = 1;
|
||||
|
||||
if( currentCurve->curvetype == ct_none ) {
|
||||
currentCurve->curvetype = ct_nurbscurve;
|
||||
} else if( currentCurve->curvetype != ct_nurbscurve ) {
|
||||
do_nurbserror( 24 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( *nextNurbscurve != o_nurbscurve ) {
|
||||
isCurveModified = 1;
|
||||
*nextNurbscurve = o_nurbscurve;
|
||||
}
|
||||
|
||||
nextNurbscurve = &(o_nurbscurve->next);
|
||||
|
||||
if( o_nurbscurve->owner != currentCurve ) {
|
||||
isCurveModified = 1;
|
||||
o_nurbscurve->owner = currentCurve;
|
||||
}
|
||||
|
||||
if( o_nurbscurve->owner == 0 )
|
||||
isCurveModified = 1;
|
||||
|
||||
if( inCurve == 2 )
|
||||
endcurve();
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_freenurbssurface -
|
||||
*
|
||||
* Client:
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::do_freenurbssurface( O_nurbssurface *o_nurbssurface )
|
||||
{
|
||||
o_nurbssurface->bezier_patches->deleteMe( quiltPool );
|
||||
o_nurbssurface->deleteMe( o_nurbssurfacePool );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_nurbssurface -
|
||||
*
|
||||
* Client: nurbssurface()
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
NurbsTessellator::do_nurbssurface( O_nurbssurface *o_nurbssurface )
|
||||
{
|
||||
if( ! inSurface ) {
|
||||
bgnsurface( 0 );
|
||||
inSurface = 2;
|
||||
}
|
||||
|
||||
if( o_nurbssurface->used ) {
|
||||
/* error - surface was already called in current block */
|
||||
do_nurbserror( 25 );
|
||||
isDataValid = 0;
|
||||
return;
|
||||
} else
|
||||
o_nurbssurface->used = 1;
|
||||
|
||||
if( *nextNurbssurface != o_nurbssurface ) {
|
||||
isSurfaceModified = 1;
|
||||
*nextNurbssurface = o_nurbssurface;
|
||||
}
|
||||
|
||||
if( o_nurbssurface->owner != currentSurface ) {
|
||||
isSurfaceModified = 1;
|
||||
o_nurbssurface->owner = currentSurface;
|
||||
}
|
||||
nextNurbssurface = &(o_nurbssurface->next);
|
||||
|
||||
if( inSurface == 2 )
|
||||
endsurface();
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_freenurbsproperty
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::do_freenurbsproperty( Property *prop )
|
||||
{
|
||||
prop->deleteMe( propertyPool );
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* do_setnurbsproperty -
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
NurbsTessellator::do_setnurbsproperty( Property *prop )
|
||||
{
|
||||
renderhints.setProperty( prop->tag, prop->value );
|
||||
if( prop->save == 0 )
|
||||
do_freenurbsproperty( prop );
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::do_setnurbsproperty2( Property *prop )
|
||||
{
|
||||
Mapdesc *mapdesc = maplist.find( prop->type );
|
||||
|
||||
mapdesc->setProperty( prop->tag, prop->value );
|
||||
if( prop->save == 0 )
|
||||
do_freenurbsproperty( prop );
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::errorHandler( int )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
NurbsTessellator::do_nurbserror( int msg )
|
||||
{
|
||||
errorHandler( msg );
|
||||
}
|
||||
|
||||
int
|
||||
NurbsTessellator::do_check_knots( Knotvector *knots, char *msg )
|
||||
{
|
||||
int status = knots->validate();
|
||||
if( status ) {
|
||||
do_nurbserror( status );
|
||||
if( renderhints.errorchecking != N_NOMSG ) knots->show( msg );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
178
src/glu/sgi/libnurbs/internals/nurbstess.h
Normal file
178
src/glu/sgi/libnurbs/internals/nurbstess.h
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nurbstess.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/nurbstess.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glunurbstess_h_
|
||||
#define __glunurbstess_h_
|
||||
|
||||
#include "mysetjmp.h"
|
||||
#include "subdivider.h"
|
||||
#include "renderhints.h"
|
||||
#include "backend.h"
|
||||
#include "maplist.h"
|
||||
#include "reader.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
class Knotvector;
|
||||
class Quilt;
|
||||
class DisplayList;
|
||||
class BasicCurveEvaluator;
|
||||
class BasicSurfaceEvaluator;
|
||||
|
||||
class NurbsTessellator {
|
||||
public:
|
||||
NurbsTessellator( BasicCurveEvaluator &c,
|
||||
BasicSurfaceEvaluator &e );
|
||||
~NurbsTessellator( void );
|
||||
|
||||
void getnurbsproperty( long, INREAL * );
|
||||
void getnurbsproperty( long, long, INREAL * );
|
||||
void setnurbsproperty( long, INREAL );
|
||||
void setnurbsproperty( long, long, INREAL );
|
||||
void setnurbsproperty( long, long, INREAL * );
|
||||
void setnurbsproperty( long, long, INREAL *, long, long );
|
||||
|
||||
// called before a tessellation begins/ends
|
||||
virtual void bgnrender( void );
|
||||
virtual void endrender( void );
|
||||
|
||||
// called to make a display list of the output vertices
|
||||
virtual void makeobj( int n );
|
||||
virtual void closeobj( void );
|
||||
|
||||
// called when a error occurs
|
||||
virtual void errorHandler( int );
|
||||
|
||||
void bgnsurface( long );
|
||||
void endsurface( void );
|
||||
void bgntrim( void );
|
||||
void endtrim( void );
|
||||
void bgncurve( long );
|
||||
void endcurve( void );
|
||||
void pwlcurve( long, INREAL[], long, long );
|
||||
void nurbscurve( long, INREAL[], long, INREAL[], long, long );
|
||||
void nurbssurface( long, INREAL[], long, INREAL[], long, long,
|
||||
INREAL[], long, long, long );
|
||||
|
||||
void defineMap( long, long, long );
|
||||
void redefineMaps( void );
|
||||
|
||||
// recording of input description
|
||||
void discardRecording( void * );
|
||||
void * beginRecording( void );
|
||||
void endRecording( void );
|
||||
void playRecording( void * );
|
||||
|
||||
//for optimizing untrimmed nurbs in the case of domain distance sampling
|
||||
void set_domain_distance_u_rate(REAL u_rate);
|
||||
void set_domain_distance_v_rate(REAL v_rate);
|
||||
void set_is_domain_distance_sampling(int flag);
|
||||
|
||||
|
||||
protected:
|
||||
Renderhints renderhints;
|
||||
Maplist maplist;
|
||||
Backend backend;
|
||||
|
||||
private:
|
||||
|
||||
void resetObjects( void );
|
||||
int do_check_knots( Knotvector *, char * );
|
||||
void do_nurbserror( int );
|
||||
void do_bgncurve( O_curve * );
|
||||
void do_endcurve( void );
|
||||
void do_freeall( void );
|
||||
void do_freecurveall( O_curve * );
|
||||
void do_freebgntrim( O_trim * );
|
||||
void do_freebgncurve( O_curve * );
|
||||
void do_freepwlcurve( O_pwlcurve * );
|
||||
void do_freenurbscurve( O_nurbscurve * );
|
||||
void do_freenurbssurface( O_nurbssurface * );
|
||||
void do_freebgnsurface( O_surface * );
|
||||
void do_bgnsurface( O_surface * );
|
||||
void do_endsurface( void );
|
||||
void do_bgntrim( O_trim * );
|
||||
void do_endtrim( void );
|
||||
void do_pwlcurve( O_pwlcurve * );
|
||||
void do_nurbscurve( O_nurbscurve * );
|
||||
void do_nurbssurface( O_nurbssurface * );
|
||||
void do_freenurbsproperty( Property * );
|
||||
void do_setnurbsproperty( Property * );
|
||||
void do_setnurbsproperty2( Property * );
|
||||
|
||||
Subdivider subdivider;
|
||||
JumpBuffer* jumpbuffer;
|
||||
Pool o_pwlcurvePool;
|
||||
Pool o_nurbscurvePool;
|
||||
Pool o_curvePool;
|
||||
Pool o_trimPool;
|
||||
Pool o_surfacePool;
|
||||
Pool o_nurbssurfacePool;
|
||||
Pool propertyPool;
|
||||
public:
|
||||
Pool quiltPool;
|
||||
private:
|
||||
TrimVertexPool extTrimVertexPool;
|
||||
|
||||
int inSurface; /* bgnsurface seen */
|
||||
int inCurve; /* bgncurve seen */
|
||||
int inTrim; /* bgntrim seen */
|
||||
int isCurveModified; /* curve changed */
|
||||
int isTrimModified; /* trim curves changed */
|
||||
int isSurfaceModified; /* surface changed */
|
||||
int isDataValid; /* all data is good */
|
||||
int numTrims; /* valid trim regions */
|
||||
int playBack;
|
||||
|
||||
O_trim** nextTrim; /* place to link o_trim */
|
||||
O_curve** nextCurve; /* place to link o_curve */
|
||||
O_nurbscurve** nextNurbscurve; /* place to link o_nurbscurve */
|
||||
O_pwlcurve** nextPwlcurve; /* place to link o_pwlcurve */
|
||||
O_nurbssurface** nextNurbssurface; /* place to link o_nurbssurface */
|
||||
|
||||
O_surface* currentSurface;
|
||||
O_trim* currentTrim;
|
||||
O_curve* currentCurve;
|
||||
|
||||
DisplayList *dl;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __glunurbstess_h_ */
|
||||
506
src/glu/sgi/libnurbs/internals/patch.cc
Normal file
506
src/glu/sgi/libnurbs/internals/patch.cc
Normal file
|
|
@ -0,0 +1,506 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* patch.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/patch.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "mymath.h"
|
||||
#include "mystring.h"
|
||||
#include "patch.h"
|
||||
#include "mapdesc.h"
|
||||
#include "quilt.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "simplemath.h" //for abs function in ::singleStep();
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Patch - copy patch from quilt and transform control points
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Patch::Patch( Quilt_ptr geo, REAL *pta, REAL *ptb, Patch *n )
|
||||
{
|
||||
/* pspec[i].range is uninit here */
|
||||
mapdesc = geo->mapdesc;
|
||||
cullval = mapdesc->isCulling() ? CULL_ACCEPT : CULL_TRIVIAL_ACCEPT;
|
||||
notInBbox = mapdesc->isBboxSubdividing() ? 1 : 0;
|
||||
needsSampling = mapdesc->isRangeSampling() ? 1 : 0;
|
||||
pspec[0].order = geo->qspec[0].order;
|
||||
pspec[1].order = geo->qspec[1].order;
|
||||
pspec[0].stride = pspec[1].order * MAXCOORDS;
|
||||
pspec[1].stride = MAXCOORDS;
|
||||
|
||||
/* transform control points to sampling and culling spaces */
|
||||
REAL *ps = geo->cpts;
|
||||
geo->select( pta, ptb );
|
||||
ps += geo->qspec[0].offset;
|
||||
ps += geo->qspec[1].offset;
|
||||
ps += geo->qspec[0].index * geo->qspec[0].order * geo->qspec[0].stride;
|
||||
ps += geo->qspec[1].index * geo->qspec[1].order * geo->qspec[1].stride;
|
||||
|
||||
if( needsSampling ) {
|
||||
mapdesc->xformSampling( ps, geo->qspec[0].order, geo->qspec[0].stride,
|
||||
geo->qspec[1].order, geo->qspec[1].stride,
|
||||
spts, pspec[0].stride, pspec[1].stride );
|
||||
}
|
||||
|
||||
if( cullval == CULL_ACCEPT ) {
|
||||
mapdesc->xformCulling( ps, geo->qspec[0].order, geo->qspec[0].stride,
|
||||
geo->qspec[1].order, geo->qspec[1].stride,
|
||||
cpts, pspec[0].stride, pspec[1].stride );
|
||||
}
|
||||
|
||||
if( notInBbox ) {
|
||||
mapdesc->xformBounding( ps, geo->qspec[0].order, geo->qspec[0].stride,
|
||||
geo->qspec[1].order, geo->qspec[1].stride,
|
||||
bpts, pspec[0].stride, pspec[1].stride );
|
||||
}
|
||||
|
||||
/* set scale range */
|
||||
pspec[0].range[0] = geo->qspec[0].breakpoints[geo->qspec[0].index];
|
||||
pspec[0].range[1] = geo->qspec[0].breakpoints[geo->qspec[0].index+1];
|
||||
pspec[0].range[2] = pspec[0].range[1] - pspec[0].range[0];
|
||||
|
||||
pspec[1].range[0] = geo->qspec[1].breakpoints[geo->qspec[1].index];
|
||||
pspec[1].range[1] = geo->qspec[1].breakpoints[geo->qspec[1].index+1];
|
||||
pspec[1].range[2] = pspec[1].range[1] - pspec[1].range[0];
|
||||
|
||||
// may need to subdivide to match range of sub-patch
|
||||
if( pspec[0].range[0] != pta[0] ) {
|
||||
assert( pspec[0].range[0] < pta[0] );
|
||||
Patch lower( *this, 0, pta[0], 0 );
|
||||
*this = lower;
|
||||
}
|
||||
|
||||
if( pspec[0].range[1] != ptb[0] ) {
|
||||
assert( pspec[0].range[1] > ptb[0] );
|
||||
Patch upper( *this, 0, ptb[0], 0 );
|
||||
}
|
||||
|
||||
if( pspec[1].range[0] != pta[1] ) {
|
||||
assert( pspec[1].range[0] < pta[1] );
|
||||
Patch lower( *this, 1, pta[1], 0 );
|
||||
*this = lower;
|
||||
}
|
||||
|
||||
if( pspec[1].range[1] != ptb[1] ) {
|
||||
assert( pspec[1].range[1] > ptb[1] );
|
||||
Patch upper( *this, 1, ptb[1], 0 );
|
||||
}
|
||||
checkBboxConstraint();
|
||||
next = n;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Patch - subdivide a patch along an isoparametric line
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Patch::Patch( Patch& upper, int param, REAL value, Patch *n )
|
||||
{
|
||||
Patch& lower = *this;
|
||||
|
||||
lower.cullval = upper.cullval;
|
||||
lower.mapdesc = upper.mapdesc;
|
||||
lower.notInBbox = upper.notInBbox;
|
||||
lower.needsSampling = upper.needsSampling;
|
||||
lower.pspec[0].order = upper.pspec[0].order;
|
||||
lower.pspec[1].order = upper.pspec[1].order;
|
||||
lower.pspec[0].stride = upper.pspec[0].stride;
|
||||
lower.pspec[1].stride = upper.pspec[1].stride;
|
||||
lower.next = n;
|
||||
|
||||
/* reset scale range */
|
||||
switch( param ) {
|
||||
case 0: {
|
||||
REAL d = (value-upper.pspec[0].range[0]) / upper.pspec[0].range[2];
|
||||
if( needsSampling )
|
||||
mapdesc->subdivide( upper.spts, lower.spts, d, pspec[1].order,
|
||||
pspec[1].stride, pspec[0].order, pspec[0].stride );
|
||||
|
||||
if( cullval == CULL_ACCEPT )
|
||||
mapdesc->subdivide( upper.cpts, lower.cpts, d, pspec[1].order,
|
||||
pspec[1].stride, pspec[0].order, pspec[0].stride );
|
||||
|
||||
if( notInBbox )
|
||||
mapdesc->subdivide( upper.bpts, lower.bpts, d, pspec[1].order,
|
||||
pspec[1].stride, pspec[0].order, pspec[0].stride );
|
||||
|
||||
lower.pspec[0].range[0] = upper.pspec[0].range[0];
|
||||
lower.pspec[0].range[1] = value;
|
||||
lower.pspec[0].range[2] = value - upper.pspec[0].range[0];
|
||||
upper.pspec[0].range[0] = value;
|
||||
upper.pspec[0].range[2] = upper.pspec[0].range[1] - value;
|
||||
|
||||
lower.pspec[1].range[0] = upper.pspec[1].range[0];
|
||||
lower.pspec[1].range[1] = upper.pspec[1].range[1];
|
||||
lower.pspec[1].range[2] = upper.pspec[1].range[2];
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
REAL d = (value-upper.pspec[1].range[0]) / upper.pspec[1].range[2];
|
||||
if( needsSampling )
|
||||
mapdesc->subdivide( upper.spts, lower.spts, d, pspec[0].order,
|
||||
pspec[0].stride, pspec[1].order, pspec[1].stride );
|
||||
if( cullval == CULL_ACCEPT )
|
||||
mapdesc->subdivide( upper.cpts, lower.cpts, d, pspec[0].order,
|
||||
pspec[0].stride, pspec[1].order, pspec[1].stride );
|
||||
if( notInBbox )
|
||||
mapdesc->subdivide( upper.bpts, lower.bpts, d, pspec[0].order,
|
||||
pspec[0].stride, pspec[1].order, pspec[1].stride );
|
||||
lower.pspec[0].range[0] = upper.pspec[0].range[0];
|
||||
lower.pspec[0].range[1] = upper.pspec[0].range[1];
|
||||
lower.pspec[0].range[2] = upper.pspec[0].range[2];
|
||||
|
||||
lower.pspec[1].range[0] = upper.pspec[1].range[0];
|
||||
lower.pspec[1].range[1] = value;
|
||||
lower.pspec[1].range[2] = value - upper.pspec[1].range[0];
|
||||
upper.pspec[1].range[0] = value;
|
||||
upper.pspec[1].range[2] = upper.pspec[1].range[1] - value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// inherit bounding box
|
||||
if( mapdesc->isBboxSubdividing() && ! notInBbox )
|
||||
memcpy( lower.bb, upper.bb, sizeof( bb ) );
|
||||
|
||||
lower.checkBboxConstraint();
|
||||
upper.checkBboxConstraint();
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* clamp - clamp the sampling rate to a given maximum
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Patch::clamp( void )
|
||||
{
|
||||
if( mapdesc->clampfactor != N_NOCLAMPING ) {
|
||||
pspec[0].clamp( mapdesc->clampfactor );
|
||||
pspec[1].clamp( mapdesc->clampfactor );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Patchspec::clamp( REAL clampfactor )
|
||||
{
|
||||
if( sidestep[0] < minstepsize )
|
||||
sidestep[0] = clampfactor * minstepsize;
|
||||
if( sidestep[1] < minstepsize )
|
||||
sidestep[1] = clampfactor * minstepsize;
|
||||
if( stepsize < minstepsize )
|
||||
stepsize = clampfactor * minstepsize;
|
||||
}
|
||||
|
||||
void
|
||||
Patch::checkBboxConstraint( void )
|
||||
{
|
||||
if( notInBbox &&
|
||||
mapdesc->bboxTooBig( bpts, pspec[0].stride, pspec[1].stride,
|
||||
pspec[0].order, pspec[1].order, bb ) != 1 ) {
|
||||
notInBbox = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Patch::bbox( void )
|
||||
{
|
||||
if( mapdesc->isBboxSubdividing() )
|
||||
mapdesc->surfbbox( bb );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* getstepsize - compute the sampling density across the patch
|
||||
* and determine if patch needs to be subdivided
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Patch::getstepsize( void )
|
||||
{
|
||||
pspec[0].minstepsize = pspec[1].minstepsize = 0;
|
||||
pspec[0].needsSubdivision = pspec[1].needsSubdivision = 0;
|
||||
|
||||
if( mapdesc->isConstantSampling() ) {
|
||||
// fixed number of samples per patch in each direction
|
||||
// maxsrate is number of s samples per patch
|
||||
// maxtrate is number of t samples per patch
|
||||
pspec[0].getstepsize( mapdesc->maxsrate );
|
||||
pspec[1].getstepsize( mapdesc->maxtrate );
|
||||
|
||||
} else if( mapdesc->isDomainSampling() ) {
|
||||
// maxsrate is number of s samples per unit s length of domain
|
||||
// maxtrate is number of t samples per unit t length of domain
|
||||
pspec[0].getstepsize( mapdesc->maxsrate * pspec[0].range[2] );
|
||||
pspec[1].getstepsize( mapdesc->maxtrate * pspec[1].range[2] );
|
||||
|
||||
} else if( ! needsSampling ) {
|
||||
pspec[0].singleStep();
|
||||
pspec[1].singleStep();
|
||||
} else {
|
||||
// upper bound on path length between sample points
|
||||
REAL tmp[MAXORDER][MAXORDER][MAXCOORDS];
|
||||
const int trstride = sizeof(tmp[0]) / sizeof(REAL);
|
||||
const int tcstride = sizeof(tmp[0][0]) / sizeof(REAL);
|
||||
|
||||
assert( pspec[0].order <= MAXORDER );
|
||||
|
||||
/* points have been transformed, therefore they are homogeneous */
|
||||
|
||||
int val = mapdesc->project( spts, pspec[0].stride, pspec[1].stride,
|
||||
&tmp[0][0][0], trstride, tcstride,
|
||||
pspec[0].order, pspec[1].order );
|
||||
if( val == 0 ) {
|
||||
// control points cross infinity, therefore partials are undefined
|
||||
pspec[0].getstepsize( mapdesc->maxsrate );
|
||||
pspec[1].getstepsize( mapdesc->maxtrate );
|
||||
} else {
|
||||
REAL t1 = mapdesc->getProperty( N_PIXEL_TOLERANCE );
|
||||
// REAL t2 = mapdesc->getProperty( N_ERROR_TOLERANCE );
|
||||
pspec[0].minstepsize = ( mapdesc->maxsrate > 0.0 ) ?
|
||||
(pspec[0].range[2] / mapdesc->maxsrate) : 0.0;
|
||||
pspec[1].minstepsize = ( mapdesc->maxtrate > 0.0 ) ?
|
||||
(pspec[1].range[2] / mapdesc->maxtrate) : 0.0;
|
||||
if( mapdesc->isParametricDistanceSampling() ||
|
||||
mapdesc->isObjectSpaceParaSampling() ) {
|
||||
|
||||
REAL t2;
|
||||
t2 = mapdesc->getProperty( N_ERROR_TOLERANCE );
|
||||
|
||||
// t2 is upper bound on the distance between surface and tessellant
|
||||
REAL ssv[2], ttv[2];
|
||||
REAL ss = mapdesc->calcPartialVelocity( ssv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 2, 0, pspec[0].range[2], pspec[1].range[2], 0 );
|
||||
REAL st = mapdesc->calcPartialVelocity( 0, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 1, 1, pspec[0].range[2], pspec[1].range[2], -1 );
|
||||
REAL tt = mapdesc->calcPartialVelocity( ttv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 0, 2, pspec[0].range[2], pspec[1].range[2], 1 );
|
||||
//make sure that ss st and tt are nonnegative:
|
||||
if(ss <0) ss = -ss;
|
||||
if(st <0) st = -st;
|
||||
if(tt <0) tt = -tt;
|
||||
|
||||
if( ss != 0.0 && tt != 0.0 ) {
|
||||
/* printf( "ssv[0] %g ssv[1] %g ttv[0] %g ttv[1] %g\n",
|
||||
ssv[0], ssv[1], ttv[0], ttv[1] ); */
|
||||
REAL ttq = ::sqrtf( (float) ss );
|
||||
REAL ssq = ::sqrtf( (float) tt );
|
||||
REAL ds = ::sqrtf( 4 * t2 * ttq / ( ss * ttq + st * ssq ) );
|
||||
REAL dt = ::sqrtf( 4 * t2 * ssq / ( tt * ssq + st * ttq ) );
|
||||
pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
|
||||
REAL scutoff = 2.0 * t2 / ( pspec[0].range[2] * pspec[0].range[2]);
|
||||
pspec[0].sidestep[0] = (ssv[0] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[0] ) : pspec[0].range[2];
|
||||
pspec[0].sidestep[1] = (ssv[1] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[1] ) : pspec[0].range[2];
|
||||
|
||||
pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
|
||||
REAL tcutoff = 2.0 * t2 / ( pspec[1].range[2] * pspec[1].range[2]);
|
||||
pspec[1].sidestep[0] = (ttv[0] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[0] ) : pspec[1].range[2];
|
||||
pspec[1].sidestep[1] = (ttv[1] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[1] ) : pspec[1].range[2];
|
||||
} else if( ss != 0.0 ) {
|
||||
REAL x = pspec[1].range[2] * st;
|
||||
REAL ds = ( ::sqrtf( x * x + 8.0 * t2 * ss ) - x ) / ss;
|
||||
pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
|
||||
REAL scutoff = 2.0 * t2 / ( pspec[0].range[2] * pspec[0].range[2]);
|
||||
pspec[0].sidestep[0] = (ssv[0] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[0] ) : pspec[0].range[2];
|
||||
pspec[0].sidestep[1] = (ssv[1] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[1] ) : pspec[0].range[2];
|
||||
pspec[1].singleStep();
|
||||
} else if( tt != 0.0 ) {
|
||||
REAL x = pspec[0].range[2] * st;
|
||||
REAL dt = ( ::sqrtf( x * x + 8.0 * t2 * tt ) - x ) / tt;
|
||||
pspec[0].singleStep();
|
||||
REAL tcutoff = 2.0 * t2 / ( pspec[1].range[2] * pspec[1].range[2]);
|
||||
pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
|
||||
pspec[1].sidestep[0] = (ttv[0] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[0] ) : pspec[1].range[2];
|
||||
pspec[1].sidestep[1] = (ttv[1] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[1] ) : pspec[1].range[2];
|
||||
} else {
|
||||
if( 4.0 * t2 > st * pspec[0].range[2] * pspec[1].range[2] ) {
|
||||
pspec[0].singleStep();
|
||||
pspec[1].singleStep();
|
||||
} else {
|
||||
REAL area = 4.0 * t2 / st;
|
||||
REAL ds = ::sqrtf( area * pspec[0].range[2] / pspec[1].range[2] );
|
||||
REAL dt = ::sqrtf( area * pspec[1].range[2] / pspec[0].range[2] );
|
||||
pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
|
||||
pspec[0].sidestep[0] = pspec[0].range[2];
|
||||
pspec[0].sidestep[1] = pspec[0].range[2];
|
||||
|
||||
pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
|
||||
pspec[1].sidestep[0] = pspec[1].range[2];
|
||||
pspec[1].sidestep[1] = pspec[1].range[2];
|
||||
}
|
||||
}
|
||||
} else if( mapdesc->isPathLengthSampling() ||
|
||||
mapdesc->isObjectSpacePathSampling()) {
|
||||
// t1 is upper bound on path length
|
||||
REAL msv[2], mtv[2];
|
||||
REAL ms = mapdesc->calcPartialVelocity( msv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 1, 0, pspec[0].range[2], pspec[1].range[2], 0 );
|
||||
REAL mt = mapdesc->calcPartialVelocity( mtv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 0, 1, pspec[0].range[2], pspec[1].range[2], 1 );
|
||||
REAL side_scale = 1.0;
|
||||
|
||||
if( ms != 0.0 ) {
|
||||
if( mt != 0.0 ) {
|
||||
/* REAL d = t1 / ( ms * ms + mt * mt );*/
|
||||
/* REAL ds = mt * d;*/
|
||||
REAL ds = t1 / (2.0*ms);
|
||||
/* REAL dt = ms * d;*/
|
||||
REAL dt = t1 / (2.0*mt);
|
||||
pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
|
||||
pspec[0].sidestep[0] = ( msv[0] * pspec[0].range[2] > t1 ) ? (side_scale* t1 / msv[0]) : pspec[0].range[2];
|
||||
pspec[0].sidestep[1] = ( msv[1] * pspec[0].range[2] > t1 ) ? (side_scale* t1 / msv[1]) : pspec[0].range[2];
|
||||
|
||||
pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
|
||||
pspec[1].sidestep[0] = ( mtv[0] * pspec[1].range[2] > t1 ) ? (side_scale*t1 / mtv[0]) : pspec[1].range[2];
|
||||
pspec[1].sidestep[1] = ( mtv[1] * pspec[1].range[2] > t1 ) ? (side_scale*t1 / mtv[1]) : pspec[1].range[2];
|
||||
} else {
|
||||
pspec[0].stepsize = ( t1 < ms * pspec[0].range[2] ) ? (t1 / ms) : pspec[0].range[2];
|
||||
pspec[0].sidestep[0] = ( msv[0] * pspec[0].range[2] > t1 ) ? (t1 / msv[0]) : pspec[0].range[2];
|
||||
pspec[0].sidestep[1] = ( msv[1] * pspec[0].range[2] > t1 ) ? (t1 / msv[1]) : pspec[0].range[2];
|
||||
|
||||
pspec[1].singleStep();
|
||||
}
|
||||
} else {
|
||||
if( mt != 0.0 ) {
|
||||
pspec[0].singleStep();
|
||||
|
||||
pspec[1].stepsize = ( t1 < mt * pspec[1].range[2] ) ? (t1 / mt) : pspec[1].range[2];
|
||||
pspec[1].sidestep[0] = ( mtv[0] * pspec[1].range[2] > t1 ) ? (t1 / mtv[0]) : pspec[1].range[2];
|
||||
pspec[1].sidestep[1] = ( mtv[1] * pspec[1].range[2] > t1 ) ? (t1 / mtv[1]) : pspec[1].range[2];
|
||||
} else {
|
||||
pspec[0].singleStep();
|
||||
pspec[1].singleStep();
|
||||
}
|
||||
}
|
||||
} else if( mapdesc->isSurfaceAreaSampling() ) {
|
||||
// t is the square root of area
|
||||
/*
|
||||
REAL msv[2], mtv[2];
|
||||
REAL ms = mapdesc->calcPartialVelocity( msv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 1, 0, pspec[0].range[2], pspec[1].range[2], 0 );
|
||||
REAL mt = mapdesc->calcPartialVelocity( mtv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 0, 1, pspec[0].range[2], pspec[1].range[2], 1 );
|
||||
if( ms != 0.0 && mt != 0.0 ) {
|
||||
REAL d = 1.0 / (ms * mt);
|
||||
t *= M_SQRT2;
|
||||
REAL ds = t * ::sqrtf( d * pspec[0].range[2] / pspec[1].range[2] );
|
||||
REAL dt = t * ::sqrtf( d * pspec[1].range[2] / pspec[0].range[2] );
|
||||
pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
|
||||
pspec[0].sidestep[0] = ( msv[0] * pspec[0].range[2] > t ) ? (t / msv[0]) : pspec[0].range[2];
|
||||
pspec[0].sidestep[1] = ( msv[1] * pspec[0].range[2] > t ) ? (t / msv[1]) : pspec[0].range[2];
|
||||
|
||||
pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
|
||||
pspec[1].sidestep[0] = ( mtv[0] * pspec[1].range[2] > t ) ? (t / mtv[0]) : pspec[1].range[2];
|
||||
pspec[1].sidestep[1] = ( mtv[1] * pspec[1].range[2] > t ) ? (t / mtv[1]) : pspec[1].range[2];
|
||||
} else {
|
||||
pspec[0].singleStep();
|
||||
pspec[1].singleStep();
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
pspec[0].singleStep();
|
||||
pspec[1].singleStep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
dprintf( "sidesteps %g %g %g %g, stepsize %g %g\n",
|
||||
pspec[0].sidestep[0], pspec[0].sidestep[1],
|
||||
pspec[1].sidestep[0], pspec[1].sidestep[1],
|
||||
pspec[0].stepsize, pspec[1].stepsize );
|
||||
#endif
|
||||
|
||||
if( mapdesc->minsavings != N_NOSAVINGSSUBDIVISION ) {
|
||||
REAL savings = 1./(pspec[0].stepsize * pspec[1].stepsize) ;
|
||||
savings-= (2./( pspec[0].sidestep[0] + pspec[0].sidestep[1] )) *
|
||||
(2./( pspec[1].sidestep[0] + pspec[1].sidestep[1] ));
|
||||
|
||||
savings *= pspec[0].range[2] * pspec[1].range[2];
|
||||
if( savings > mapdesc->minsavings ) {
|
||||
pspec[0].needsSubdivision = pspec[1].needsSubdivision = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( pspec[0].stepsize < pspec[0].minstepsize ) pspec[0].needsSubdivision = 1;
|
||||
if( pspec[1].stepsize < pspec[1].minstepsize ) pspec[1].needsSubdivision = 1;
|
||||
needsSampling = (needsSampling ? needsSamplingSubdivision() : 0);
|
||||
}
|
||||
|
||||
void
|
||||
Patchspec::singleStep()
|
||||
{
|
||||
stepsize = sidestep[0] = sidestep[1] = abs(range[2]);
|
||||
}
|
||||
|
||||
void
|
||||
Patchspec::getstepsize( REAL max ) // max is number of samples for entire patch
|
||||
{
|
||||
stepsize = ( max >= 1.0 ) ? range[2] / max : range[2];
|
||||
if (stepsize < 0.0) {
|
||||
stepsize = -stepsize;
|
||||
}
|
||||
sidestep[0] = sidestep[1] = minstepsize = stepsize;
|
||||
}
|
||||
|
||||
int
|
||||
Patch::needsSamplingSubdivision( void )
|
||||
{
|
||||
return (pspec[0].needsSubdivision || pspec[1].needsSubdivision) ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
Patch::needsNonSamplingSubdivision( void )
|
||||
{
|
||||
return notInBbox;
|
||||
}
|
||||
|
||||
int
|
||||
Patch::needsSubdivision( int param )
|
||||
{
|
||||
return pspec[param].needsSubdivision;
|
||||
}
|
||||
|
||||
int
|
||||
Patch::cullCheck( void )
|
||||
{
|
||||
if( cullval == CULL_ACCEPT )
|
||||
cullval = mapdesc->cullCheck( cpts, pspec[0].order, pspec[0].stride,
|
||||
pspec[1].order, pspec[1].stride );
|
||||
return cullval;
|
||||
}
|
||||
|
||||
100
src/glu/sgi/libnurbs/internals/patch.h
Normal file
100
src/glu/sgi/libnurbs/internals/patch.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* patch.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/patch.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glupatch_h_
|
||||
#define __glupatch_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
|
||||
class Quilt;
|
||||
class Mapdesc;
|
||||
|
||||
|
||||
struct Pspec {
|
||||
REAL range[3];
|
||||
REAL sidestep[2];
|
||||
REAL stepsize;
|
||||
REAL minstepsize;
|
||||
int needsSubdivision;
|
||||
};
|
||||
|
||||
struct Patchspec : public Pspec {
|
||||
int order;
|
||||
int stride;
|
||||
void clamp( REAL );
|
||||
void getstepsize( REAL );
|
||||
void singleStep( void );
|
||||
};
|
||||
|
||||
class Patch {
|
||||
public:
|
||||
friend class Subdivider;
|
||||
friend class Quilt;
|
||||
friend class Patchlist;
|
||||
Patch( Quilt *, REAL*, REAL *, Patch * );
|
||||
Patch( Patch &, int, REAL, Patch * );
|
||||
void bbox( void );
|
||||
void clamp( void );
|
||||
void getstepsize( void );
|
||||
int cullCheck( void );
|
||||
int needsSubdivision( int );
|
||||
int needsSamplingSubdivision( void );
|
||||
int needsNonSamplingSubdivision( void );
|
||||
|
||||
int get_uorder() {return pspec[0].order;}
|
||||
int get_vorder() {return pspec[1].order;}
|
||||
|
||||
private:
|
||||
|
||||
Mapdesc* mapdesc;
|
||||
Patch* next;
|
||||
int cullval;
|
||||
int notInBbox;
|
||||
int needsSampling;
|
||||
REAL cpts[MAXORDER*MAXORDER*MAXCOORDS]; //culling pts
|
||||
REAL spts[MAXORDER*MAXORDER*MAXCOORDS]; //sampling pts
|
||||
REAL bpts[MAXORDER*MAXORDER*MAXCOORDS]; //bbox pts
|
||||
Patchspec pspec[2];
|
||||
void checkBboxConstraint( void );
|
||||
REAL bb[2][MAXCOORDS];
|
||||
};
|
||||
#endif /* __glupatch_h_ */
|
||||
172
src/glu/sgi/libnurbs/internals/patchlist.cc
Normal file
172
src/glu/sgi/libnurbs/internals/patchlist.cc
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* patchlist.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/patchlist.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "myassert.h"
|
||||
#include "mystdio.h"
|
||||
#include "quilt.h"
|
||||
#include "patchlist.h"
|
||||
#include "patch.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
Patchlist::Patchlist( Quilt *quilts, REAL *pta, REAL *ptb )
|
||||
{
|
||||
patch = 0;
|
||||
for( Quilt *q = quilts; q; q = q->next )
|
||||
patch = new Patch( q, pta, ptb, patch );
|
||||
pspec[0].range[0] = pta[0];
|
||||
pspec[0].range[1] = ptb[0];
|
||||
pspec[0].range[2] = ptb[0] - pta[0];
|
||||
|
||||
pspec[1].range[0] = pta[1];
|
||||
pspec[1].range[1] = ptb[1];
|
||||
pspec[1].range[2] = ptb[1] - pta[1];
|
||||
}
|
||||
|
||||
Patchlist::Patchlist( Patchlist &upper, int param, REAL value)
|
||||
{
|
||||
Patchlist &lower = *this;
|
||||
patch = 0;
|
||||
for( Patch *p = upper.patch; p; p = p->next )
|
||||
patch = new Patch( *p, param, value, patch );
|
||||
|
||||
if( param == 0 ) {
|
||||
lower.pspec[0].range[0] = upper.pspec[0].range[0];
|
||||
lower.pspec[0].range[1] = value;
|
||||
lower.pspec[0].range[2] = value - upper.pspec[0].range[0];
|
||||
upper.pspec[0].range[0] = value;
|
||||
upper.pspec[0].range[2] = upper.pspec[0].range[1] - value;
|
||||
lower.pspec[1] = upper.pspec[1];
|
||||
} else {
|
||||
lower.pspec[0] = upper.pspec[0];
|
||||
lower.pspec[1].range[0] = upper.pspec[1].range[0];
|
||||
lower.pspec[1].range[1] = value;
|
||||
lower.pspec[1].range[2] = value - upper.pspec[1].range[0];
|
||||
upper.pspec[1].range[0] = value;
|
||||
upper.pspec[1].range[2] = upper.pspec[1].range[1] - value;
|
||||
}
|
||||
}
|
||||
|
||||
Patchlist::~Patchlist()
|
||||
{
|
||||
while( patch ) {
|
||||
Patch *p = patch;
|
||||
patch = patch->next;
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Patchlist::cullCheck( void )
|
||||
{
|
||||
for( Patch *p = patch; p; p = p->next )
|
||||
if( p->cullCheck() == CULL_TRIVIAL_REJECT )
|
||||
return CULL_TRIVIAL_REJECT;
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
|
||||
void
|
||||
Patchlist::getRanges(REAL ranges[4])
|
||||
{
|
||||
ranges[0] = pspec[0].range[0];
|
||||
ranges[1] = pspec[0].range[1];
|
||||
ranges[2] = pspec[1].range[0];
|
||||
ranges[3] = pspec[1].range[1];
|
||||
}
|
||||
|
||||
void
|
||||
Patchlist::getstepsize( void )
|
||||
{
|
||||
pspec[0].stepsize = pspec[0].range[2];
|
||||
pspec[0].sidestep[0] = pspec[0].range[2];
|
||||
pspec[0].sidestep[1] = pspec[0].range[2];
|
||||
|
||||
pspec[1].stepsize = pspec[1].range[2];
|
||||
pspec[1].sidestep[0] = pspec[1].range[2];
|
||||
pspec[1].sidestep[1] = pspec[1].range[2];
|
||||
|
||||
for( Patch *p = patch; p; p = p->next ) {
|
||||
p->getstepsize();
|
||||
p->clamp();
|
||||
pspec[0].stepsize = ((p->pspec[0].stepsize < pspec[0].stepsize) ? p->pspec[0].stepsize : pspec[0].stepsize);
|
||||
pspec[0].sidestep[0] = ((p->pspec[0].sidestep[0] < pspec[0].sidestep[0]) ? p->pspec[0].sidestep[0] : pspec[0].sidestep[0]);
|
||||
pspec[0].sidestep[1] = ((p->pspec[0].sidestep[1] < pspec[0].sidestep[1]) ? p->pspec[0].sidestep[1] : pspec[0].sidestep[1]);
|
||||
pspec[1].stepsize = ((p->pspec[1].stepsize < pspec[1].stepsize) ? p->pspec[1].stepsize : pspec[1].stepsize);
|
||||
pspec[1].sidestep[0] = ((p->pspec[1].sidestep[0] < pspec[1].sidestep[0]) ? p->pspec[1].sidestep[0] : pspec[1].sidestep[0]);
|
||||
pspec[1].sidestep[1] = ((p->pspec[1].sidestep[1] < pspec[1].sidestep[1]) ? p->pspec[1].sidestep[1] : pspec[1].sidestep[1]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Patchlist::bbox( void )
|
||||
{
|
||||
for( Patch *p = patch; p; p = p->next )
|
||||
p->bbox();
|
||||
}
|
||||
|
||||
int
|
||||
Patchlist::needsNonSamplingSubdivision( void )
|
||||
{
|
||||
notInBbox = 0;
|
||||
for( Patch *p = patch; p; p = p->next )
|
||||
notInBbox |= p->needsNonSamplingSubdivision();
|
||||
return notInBbox;
|
||||
}
|
||||
|
||||
int
|
||||
Patchlist::needsSamplingSubdivision( void )
|
||||
{
|
||||
pspec[0].needsSubdivision = 0;
|
||||
pspec[1].needsSubdivision = 0;
|
||||
|
||||
for( Patch *p = patch; p; p = p->next ) {
|
||||
pspec[0].needsSubdivision |= p->pspec[0].needsSubdivision;
|
||||
pspec[1].needsSubdivision |= p->pspec[0].needsSubdivision;
|
||||
}
|
||||
return (pspec[0].needsSubdivision || pspec[1].needsSubdivision) ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
Patchlist::needsSubdivision( int param )
|
||||
{
|
||||
return pspec[param].needsSubdivision;
|
||||
}
|
||||
98
src/glu/sgi/libnurbs/internals/patchlist.h
Normal file
98
src/glu/sgi/libnurbs/internals/patchlist.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* patchlist.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/patchlist.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glupatchlist_h_
|
||||
#define __glupatchlist_h_
|
||||
|
||||
#include "types.h"
|
||||
#include "defines.h"
|
||||
#include "patch.h"
|
||||
|
||||
class Quilt;
|
||||
|
||||
class Patchlist {
|
||||
friend class Subdivider;
|
||||
public:
|
||||
Patchlist( Quilt *, REAL *, REAL * );
|
||||
Patchlist( Patchlist &, int , REAL );
|
||||
~Patchlist();
|
||||
void bbox();
|
||||
int cullCheck( void );
|
||||
void getstepsize( void );
|
||||
int needsNonSamplingSubdivision( void );
|
||||
int needsSamplingSubdivision( void );
|
||||
int needsSubdivision( int );
|
||||
REAL getStepsize( int );
|
||||
void getRanges(REAL ranges[4]);
|
||||
|
||||
int get_uorder();
|
||||
int get_vorder();
|
||||
private:
|
||||
Patch *patch;
|
||||
int notInBbox;
|
||||
int needsSampling;
|
||||
Pspec pspec[2];
|
||||
};
|
||||
|
||||
inline REAL
|
||||
Patchlist::getStepsize( int param )
|
||||
{
|
||||
return pspec[param].stepsize;
|
||||
}
|
||||
|
||||
inline int
|
||||
Patchlist::get_uorder()
|
||||
{
|
||||
return patch->get_uorder();
|
||||
|
||||
}
|
||||
|
||||
inline int
|
||||
Patchlist::get_vorder()
|
||||
{
|
||||
return patch->get_vorder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* __glupatchlist_h_ */
|
||||
84
src/glu/sgi/libnurbs/internals/pwlarc.h
Normal file
84
src/glu/sgi/libnurbs/internals/pwlarc.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* pwlarc.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/pwlarc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glupwlarc_h_
|
||||
#define __glupwlarc_h_
|
||||
|
||||
#include "myassert.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
class TrimVertex;
|
||||
|
||||
class PwlArc : public PooledObj { /* a piecewise-linear arc */
|
||||
public:
|
||||
TrimVertex * pts; /* sample points */
|
||||
int npts; /* number of sample points */
|
||||
long type; /* curve type */
|
||||
inline PwlArc( void );
|
||||
inline PwlArc( int, TrimVertex * );
|
||||
inline PwlArc( int, TrimVertex *, long );
|
||||
};
|
||||
|
||||
inline
|
||||
PwlArc::PwlArc( void )
|
||||
{
|
||||
type = N_P2D;
|
||||
pts = 0;
|
||||
npts = -1;
|
||||
}
|
||||
|
||||
inline
|
||||
PwlArc::PwlArc( int _npts, TrimVertex *_pts )
|
||||
{
|
||||
pts = _pts;
|
||||
npts = _npts;
|
||||
type = N_P2D;
|
||||
}
|
||||
|
||||
inline
|
||||
PwlArc::PwlArc( int _npts, TrimVertex *_pts, long _type )
|
||||
{
|
||||
pts = _pts;
|
||||
npts = _npts;
|
||||
type = _type;
|
||||
}
|
||||
|
||||
#endif /* __glupwlarc_h_ */
|
||||
278
src/glu/sgi/libnurbs/internals/quilt.cc
Normal file
278
src/glu/sgi/libnurbs/internals/quilt.cc
Normal file
|
|
@ -0,0 +1,278 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* quilt.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/quilt.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "myassert.h"
|
||||
#include "quilt.h"
|
||||
#include "backend.h"
|
||||
#include "mapdesc.h"
|
||||
#include "flist.h"
|
||||
#include "knotvector.h"
|
||||
#include "patchlist.h"
|
||||
#include "math.h" //fabs()
|
||||
#include "simplemath.h" //min()
|
||||
|
||||
/* local preprocessor definitions */
|
||||
#define DEF_PATCH_STEPSIZE .4
|
||||
#define fsizeof(x) (sizeof(x)/sizeof(REAL))
|
||||
|
||||
|
||||
Quilt::Quilt( Mapdesc *_mapdesc )
|
||||
{
|
||||
mapdesc = _mapdesc;
|
||||
}
|
||||
|
||||
void
|
||||
Quilt::deleteMe( Pool& p )
|
||||
{
|
||||
for( Quiltspec *q=qspec; q != eqspec; q++ ) {
|
||||
#if 1
|
||||
if( q->breakpoints) delete[] q->breakpoints; q->breakpoints = 0;
|
||||
#else
|
||||
if( q->breakpoints) {
|
||||
delete[] q->breakpoints;
|
||||
q->breakpoints = 0;
|
||||
printf("in here\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if( cpts ) delete[] cpts;
|
||||
cpts = 0;
|
||||
PooledObj::deleteMe( p );
|
||||
}
|
||||
|
||||
void
|
||||
Quilt::show( void )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
int nc = mapdesc->getNcoords();
|
||||
REAL *ps = cpts;
|
||||
ps += qspec[0].offset;
|
||||
ps += qspec[1].offset;
|
||||
for( int i=0; i!= qspec[0].order * qspec[0].width; i++ ) {
|
||||
for( int j = 0; j!= qspec[1].order * qspec[1].width; j++ ) {
|
||||
for( int k=0; k < nc; k++ )
|
||||
dprintf( "%g ", ps[i*qspec[0].stride + j*qspec[1].stride + k] );
|
||||
dprintf( "\n" );
|
||||
}
|
||||
dprintf( "\n" );
|
||||
}
|
||||
dprintf( "\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Quilt::select - find which map in each quilt contains the points
|
||||
* pta and ptb with pta[i] < ptb[i]
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Quilt::select( REAL *pta, REAL *ptb )
|
||||
{
|
||||
int dim = eqspec - qspec;
|
||||
int i, j;
|
||||
for( i=0; i<dim; i++) {
|
||||
for( j=qspec[i].width-1; j>=0; j-- )
|
||||
if( (qspec[i].breakpoints[j] <= pta[i] ) &&
|
||||
(ptb[i] <= qspec[i].breakpoints[j+1] ) )
|
||||
break;
|
||||
assert( j != -1 );
|
||||
qspec[i].index = j;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Quilt::download( Backend &backend )
|
||||
{
|
||||
if( getDimension() == 2 ) {
|
||||
REAL *ps = cpts;
|
||||
ps += qspec[0].offset;
|
||||
ps += qspec[1].offset;
|
||||
ps += qspec[0].index * qspec[0].order * qspec[0].stride;
|
||||
ps += qspec[1].index * qspec[1].order * qspec[1].stride;
|
||||
backend.surfpts( mapdesc->getType(), ps,
|
||||
qspec[0].stride,
|
||||
qspec[1].stride,
|
||||
qspec[0].order,
|
||||
qspec[1].order,
|
||||
qspec[0].breakpoints[qspec[0].index],
|
||||
qspec[0].breakpoints[qspec[0].index+1],
|
||||
qspec[1].breakpoints[qspec[1].index],
|
||||
qspec[1].breakpoints[qspec[1].index+1] );
|
||||
} else {
|
||||
REAL *ps = cpts;
|
||||
ps += qspec[0].offset;
|
||||
ps += qspec[0].index * qspec[0].order * qspec[0].stride;
|
||||
backend.curvpts( mapdesc->getType(), ps,
|
||||
qspec[0].stride,
|
||||
qspec[0].order,
|
||||
qspec[0].breakpoints[qspec[0].index],
|
||||
qspec[0].breakpoints[qspec[0].index+1] );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Quilt::downloadAll - download each map that contains the current patch
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Quilt::downloadAll( REAL *pta, REAL *ptb, Backend &backend )
|
||||
{
|
||||
for( Quilt *m = this; m; m=m->next ) {
|
||||
m->select( pta, ptb );
|
||||
m->download( backend );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Quilt::isCulled - determine if an entire quilt is trivially rejected.
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
Quilt::isCulled( void )
|
||||
{
|
||||
if( mapdesc->isCulling() )
|
||||
return mapdesc->xformAndCullCheck( cpts + qspec[0].offset + qspec[1].offset,
|
||||
qspec[0].order * qspec[0].width, qspec[0].stride,
|
||||
qspec[1].order * qspec[1].width, qspec[1].stride );
|
||||
else
|
||||
return CULL_ACCEPT;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Quilt::getRange - retrieve the valid paramater range of a set of quilts
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Quilt::getRange( REAL *from, REAL *to, Flist& slist, Flist &tlist )
|
||||
{
|
||||
getRange( from, to, 0, slist );
|
||||
getRange( from, to, 1, tlist );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Quilt::getRange - retrieve the valid paramater range of a set of quilts
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Quilt::getRange( REAL *from, REAL *to, int i, Flist &list )
|
||||
{
|
||||
Quilt *maps = this;
|
||||
from[i] = maps->qspec[i].breakpoints[0];
|
||||
to[i] = maps->qspec[i].breakpoints[maps->qspec[i].width];
|
||||
int maxpts = 0;
|
||||
Quilt_ptr m;
|
||||
for( m=maps; m; m=m->next ) {
|
||||
if( m->qspec[i].breakpoints[0] > from[i] )
|
||||
from[i] = m->qspec[i].breakpoints[0];
|
||||
if( m->qspec[i].breakpoints[m->qspec[i].width] < to[i] )
|
||||
to[i] = m->qspec[i].breakpoints[m->qspec[i].width];
|
||||
maxpts += m->qspec[i].width + 1;
|
||||
}
|
||||
|
||||
list.grow( maxpts );
|
||||
|
||||
for( m=maps; m; m=m->next )
|
||||
for( int j=0; j<=m->qspec[i].width; j++ ) {
|
||||
list.add( m->qspec[i].breakpoints[j] );
|
||||
}
|
||||
|
||||
list.filter( );
|
||||
list.taper( from[i], to[i] );
|
||||
}
|
||||
|
||||
void
|
||||
Quilt::getRange( REAL *from, REAL *to, Flist& slist )
|
||||
{
|
||||
getRange( from, to, 0, slist );
|
||||
}
|
||||
|
||||
void
|
||||
Quilt::findRates( Flist& slist, Flist& tlist, REAL rate[2] )
|
||||
{
|
||||
findSampleRates( slist, tlist );
|
||||
rate[0] = qspec[0].step_size;
|
||||
rate[1] = qspec[1].step_size;
|
||||
|
||||
for( Quilt *q = next; q; q = q->next ) {
|
||||
q->findSampleRates( slist, tlist );
|
||||
if( q->qspec[0].step_size < rate[0] )
|
||||
rate[0] = q->qspec[0].step_size;
|
||||
if( q->qspec[1].step_size < rate[1] )
|
||||
rate[1] = q->qspec[1].step_size;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Quilt::findSampleRates( Flist& slist, Flist& tlist )
|
||||
{
|
||||
qspec[0].step_size = DEF_PATCH_STEPSIZE *
|
||||
(qspec[0].breakpoints[qspec[0].width] - qspec[0].breakpoints[0]);
|
||||
qspec[1].step_size = DEF_PATCH_STEPSIZE *
|
||||
(qspec[1].breakpoints[qspec[1].width] - qspec[1].breakpoints[0]);
|
||||
|
||||
for( int i = slist.start; i < slist.end-1; i++ ) {
|
||||
for( int j = tlist.start; j < tlist.end-1; j++ ) {
|
||||
|
||||
REAL pta[2], ptb[2];
|
||||
pta[0] = slist.pts[i];
|
||||
ptb[0] = slist.pts[i+1];
|
||||
pta[1] = tlist.pts[j];
|
||||
ptb[1] = tlist.pts[j+1];
|
||||
Patchlist patchlist( this, pta, ptb );
|
||||
patchlist.getstepsize();
|
||||
|
||||
{
|
||||
float edge_len_s = min(fabs(ptb[0]-pta[0]),1.0);
|
||||
float edge_len_t = min(fabs(ptb[1]-pta[1]),1.0);
|
||||
|
||||
if( patchlist.getStepsize(0)/edge_len_s < qspec[0].step_size )
|
||||
qspec[0].step_size = patchlist.getStepsize(0)/edge_len_s;
|
||||
if( patchlist.getStepsize(1)/edge_len_t < qspec[1].step_size )
|
||||
qspec[1].step_size = patchlist.getStepsize(1)/edge_len_t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
98
src/glu/sgi/libnurbs/internals/quilt.h
Normal file
98
src/glu/sgi/libnurbs/internals/quilt.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* quilt.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/quilt.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluquilt_h_
|
||||
#define __gluquilt_h_
|
||||
|
||||
#include "defines.h"
|
||||
#include "bufpool.h"
|
||||
#include "types.h"
|
||||
|
||||
class Backend;
|
||||
class Mapdesc;
|
||||
class Flist;
|
||||
class Knotvector;
|
||||
|
||||
/* constants for memory allocation of NURBS to Bezier conversion */
|
||||
#define MAXDIM 2
|
||||
|
||||
struct Quiltspec { /* a specification for a dimension of a quilt */
|
||||
int stride; /* words between points */
|
||||
int width; /* number of segments */
|
||||
int offset; /* words to first point */
|
||||
int order; /* order */
|
||||
int index; /* current segment number */
|
||||
int bdry[2]; /* boundary edge flag */
|
||||
REAL step_size;
|
||||
Knot * breakpoints;
|
||||
};
|
||||
|
||||
typedef Quiltspec *Quiltspec_ptr;
|
||||
|
||||
class Quilt : public PooledObj { /* an array of bezier patches */
|
||||
public:
|
||||
Quilt( Mapdesc * );
|
||||
Mapdesc * mapdesc; /* map descriptor */
|
||||
REAL * cpts; /* control points */
|
||||
Quiltspec qspec[MAXDIM]; /* the dimensional data */
|
||||
Quiltspec_ptr eqspec; /* qspec trailer */
|
||||
Quilt *next; /* next quilt in linked list */
|
||||
|
||||
public:
|
||||
void deleteMe( Pool& );
|
||||
void toBezier( Knotvector &, INREAL *, long );
|
||||
void toBezier( Knotvector &, Knotvector &, INREAL *, long );
|
||||
void select( REAL *, REAL * );
|
||||
int getDimension( void ) { return eqspec - qspec; }
|
||||
void download( Backend & );
|
||||
void downloadAll( REAL *, REAL *, Backend & );
|
||||
int isCulled( void );
|
||||
void getRange( REAL *, REAL *, Flist&, Flist & );
|
||||
void getRange( REAL *, REAL *, int, Flist & );
|
||||
void getRange( REAL *, REAL *, Flist& );
|
||||
void findRates( Flist& slist, Flist& tlist, REAL[2] );
|
||||
void findSampleRates( Flist& slist, Flist& tlist );
|
||||
void show();
|
||||
};
|
||||
|
||||
typedef class Quilt *Quilt_ptr;
|
||||
|
||||
#endif /* __gluquilt_h_ */
|
||||
148
src/glu/sgi/libnurbs/internals/reader.cc
Normal file
148
src/glu/sgi/libnurbs/internals/reader.cc
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* reader.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/reader.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glimports.h"
|
||||
#include "nurbsconsts.h"
|
||||
#include "reader.h"
|
||||
#include "trimvertex.h"
|
||||
#include "simplemath.h"
|
||||
|
||||
//when read a pwlCurve, if two consecutive points are the same, then
|
||||
//eliminate one of them. This makes the tessellator more robust. The spec
|
||||
//assumes the application makes sure there are no redundant points.
|
||||
//but in Inspector, the trim curves seem to have redundant points a lot.
|
||||
//I guess other similar users may have the same problem.
|
||||
|
||||
#define ELIMINATE_REDUNDANT_POINTS
|
||||
|
||||
#ifdef ELIMINATE_REDUNDANT_POINTS
|
||||
#define equal(x,y) ( abs(x-y) <= 0.00001)
|
||||
#endif
|
||||
|
||||
#ifdef ELIMINATE_REDUNDANT_POINTS
|
||||
O_pwlcurve::O_pwlcurve( long _type, long count, INREAL *array, long byte_stride, TrimVertex *trimpts )
|
||||
{
|
||||
next = 0;
|
||||
used = 0;
|
||||
owner = 0;
|
||||
pts = trimpts;
|
||||
npts = (int) count;
|
||||
int i;
|
||||
|
||||
/* copy user data into internal trimming data structures */
|
||||
switch( _type ) {
|
||||
case N_P2D: {
|
||||
TrimVertex *v = pts;
|
||||
TrimVertex *prev = NULL;
|
||||
int num = 0;
|
||||
int doit;
|
||||
for(i=0; i<count; i++) {
|
||||
doit = 1;
|
||||
if(prev != NULL)
|
||||
{
|
||||
if(equal(prev->param[0], array[0]) && equal(prev->param[1], array[1]))
|
||||
{
|
||||
doit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(doit)
|
||||
{
|
||||
v->param[0] = (REAL) array[0];
|
||||
v->param[1] = (REAL) array[1];
|
||||
prev = v;
|
||||
v++;
|
||||
num++;
|
||||
}
|
||||
array = (INREAL *) (((char *) array) + byte_stride);
|
||||
}
|
||||
npts = num;
|
||||
break;
|
||||
}
|
||||
case N_P2DR: {
|
||||
TrimVertex *v = pts;
|
||||
for( TrimVertex *lastv = v + count; v != lastv; v++ ) {
|
||||
v->param[0] = (REAL) array[0] / (REAL) array[2];
|
||||
v->param[1] = (REAL) array[1] / (REAL) array[2];
|
||||
array = (INREAL *) (((char *) array) + byte_stride);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
O_pwlcurve::O_pwlcurve( long _type, long count, INREAL *array, long byte_stride, TrimVertex *trimpts )
|
||||
{
|
||||
next = 0;
|
||||
used = 0;
|
||||
owner = 0;
|
||||
pts = trimpts;
|
||||
npts = (int) count;
|
||||
|
||||
/* copy user data into internal trimming data structures */
|
||||
switch( _type ) {
|
||||
case N_P2D: {
|
||||
TrimVertex *v = pts;
|
||||
for( TrimVertex *lastv = v + count; v != lastv; v++ ) {
|
||||
v->param[0] = (REAL) array[0];
|
||||
v->param[1] = (REAL) array[1];
|
||||
array = (INREAL *) (((char *) array) + byte_stride);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case N_P2DR: {
|
||||
TrimVertex *v = pts;
|
||||
for( TrimVertex *lastv = v + count; v != lastv; v++ ) {
|
||||
v->param[0] = (REAL) array[0] / (REAL) array[2];
|
||||
v->param[1] = (REAL) array[1] / (REAL) array[2];
|
||||
array = (INREAL *) (((char *) array) + byte_stride);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
138
src/glu/sgi/libnurbs/internals/reader.h
Normal file
138
src/glu/sgi/libnurbs/internals/reader.h
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* reader.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/reader.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glureader_h_
|
||||
#define __glureader_h_
|
||||
|
||||
#include "bufpool.h"
|
||||
#include "types.h"
|
||||
|
||||
enum Curvetype { ct_nurbscurve, ct_pwlcurve, ct_none };
|
||||
|
||||
struct Property;
|
||||
struct O_surface;
|
||||
struct O_nurbssurface;
|
||||
struct O_trim;
|
||||
struct O_pwlcurve;
|
||||
struct O_nurbscurve;
|
||||
struct O_curve;
|
||||
class Quilt;
|
||||
class TrimVertex;
|
||||
|
||||
|
||||
struct O_curve : public PooledObj {
|
||||
union {
|
||||
O_nurbscurve *o_nurbscurve;
|
||||
O_pwlcurve *o_pwlcurve;
|
||||
} curve;
|
||||
Curvetype curvetype; /* arc type: pwl or nurbs */
|
||||
O_curve * next; /* next arc in loop */
|
||||
O_surface * owner; /* owning surface */
|
||||
int used; /* curve called in cur surf */
|
||||
int save; /* 1 if in display list */
|
||||
long nuid;
|
||||
O_curve() { next = 0; used = 0; owner = 0;
|
||||
curve.o_pwlcurve = 0; }
|
||||
};
|
||||
|
||||
struct O_nurbscurve : public PooledObj {
|
||||
Quilt *bezier_curves; /* array of bezier curves */
|
||||
long type; /* range descriptor */
|
||||
REAL tesselation; /* tesselation tolerance */
|
||||
int method; /* tesselation method */
|
||||
O_nurbscurve * next; /* next curve in list */
|
||||
int used; /* curve called in cur surf */
|
||||
int save; /* 1 if in display list */
|
||||
O_curve * owner; /* owning curve */
|
||||
O_nurbscurve( long _type )
|
||||
{ type = _type; owner = 0; next = 0; used = 0; }
|
||||
};
|
||||
|
||||
class O_pwlcurve : public PooledObj {
|
||||
public:
|
||||
TrimVertex *pts; /* array of trim vertices */
|
||||
int npts; /* number of trim vertices */
|
||||
O_pwlcurve * next; /* next curve in list */
|
||||
int used; /* curve called in cur surf */
|
||||
int save; /* 1 if in display list */
|
||||
O_curve * owner; /* owning curve */
|
||||
O_pwlcurve( long, long, INREAL *, long, TrimVertex * );
|
||||
};
|
||||
|
||||
struct O_trim : public PooledObj {
|
||||
O_curve *o_curve; /* closed trim loop */
|
||||
O_trim * next; /* next loop along trim */
|
||||
int save; /* 1 if in display list */
|
||||
O_trim() { next = 0; o_curve = 0; }
|
||||
};
|
||||
|
||||
struct O_nurbssurface : public PooledObj {
|
||||
Quilt * bezier_patches;/* array of bezier patches */
|
||||
long type; /* range descriptor */
|
||||
O_surface * owner; /* owning surface */
|
||||
O_nurbssurface * next; /* next surface in chain */
|
||||
int save; /* 1 if in display list */
|
||||
int used; /* 1 if prev called in block */
|
||||
O_nurbssurface( long _type )
|
||||
{ type = _type; owner = 0; next = 0; used = 0; }
|
||||
};
|
||||
|
||||
struct O_surface : public PooledObj {
|
||||
O_nurbssurface * o_nurbssurface; /* linked list of surfaces */
|
||||
O_trim * o_trim; /* list of trim loops */
|
||||
int save; /* 1 if in display list */
|
||||
long nuid;
|
||||
O_surface() { o_trim = 0; o_nurbssurface = 0; }
|
||||
};
|
||||
|
||||
struct Property : public PooledObj {
|
||||
long type;
|
||||
long tag;
|
||||
REAL value;
|
||||
int save; /* 1 if in display list */
|
||||
Property( long _type, long _tag, INREAL _value )
|
||||
{ type = _type; tag = _tag; value = (REAL) _value; }
|
||||
Property( long _tag, INREAL _value )
|
||||
{ type = 0; tag = _tag; value = (REAL) _value; }
|
||||
};
|
||||
|
||||
class NurbsTessellator;
|
||||
#endif /* __glureader_h_ */
|
||||
135
src/glu/sgi/libnurbs/internals/renderhints.cc
Normal file
135
src/glu/sgi/libnurbs/internals/renderhints.cc
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* renderhints.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/renderhints.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "mystdio.h"
|
||||
#include "renderhints.h"
|
||||
#include "defines.h"
|
||||
#include "nurbsconsts.h"
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Renderhints::Renderhints - set all window specific options
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
Renderhints::Renderhints()
|
||||
{
|
||||
display_method = N_FILL;
|
||||
errorchecking = N_MSG;
|
||||
subdivisions = 6.0;
|
||||
tmp1 = 0.0;
|
||||
}
|
||||
|
||||
void
|
||||
Renderhints::init( void )
|
||||
{
|
||||
maxsubdivisions = (int) subdivisions;
|
||||
if( maxsubdivisions < 0 ) maxsubdivisions = 0;
|
||||
|
||||
|
||||
if( display_method == N_FILL ) {
|
||||
wiretris = 0;
|
||||
wirequads = 0;
|
||||
} else if( display_method == N_OUTLINE_TRI ) {
|
||||
wiretris = 1;
|
||||
wirequads = 0;
|
||||
} else if( display_method == N_OUTLINE_QUAD ) {
|
||||
wiretris = 0;
|
||||
wirequads = 1;
|
||||
} else {
|
||||
wiretris = 1;
|
||||
wirequads = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Renderhints::isProperty( long property )
|
||||
{
|
||||
switch ( property ) {
|
||||
case N_DISPLAY:
|
||||
case N_ERRORCHECKING:
|
||||
case N_SUBDIVISIONS:
|
||||
case N_TMP1:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
REAL
|
||||
Renderhints::getProperty( long property )
|
||||
{
|
||||
switch ( property ) {
|
||||
case N_DISPLAY:
|
||||
return display_method;
|
||||
case N_ERRORCHECKING:
|
||||
return errorchecking;
|
||||
case N_SUBDIVISIONS:
|
||||
return subdivisions;
|
||||
case N_TMP1:
|
||||
return tmp1;
|
||||
default:
|
||||
abort();
|
||||
return -1; //not necessary, needed to shut up compiler
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Renderhints::setProperty( long property, REAL value )
|
||||
{
|
||||
switch ( property ) {
|
||||
case N_DISPLAY:
|
||||
display_method = value;
|
||||
break;
|
||||
case N_ERRORCHECKING:
|
||||
errorchecking = value;
|
||||
break;
|
||||
case N_SUBDIVISIONS:
|
||||
subdivisions = value;
|
||||
break;
|
||||
case N_TMP1: /* unused */
|
||||
tmp1 = value;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
66
src/glu/sgi/libnurbs/internals/renderhints.h
Normal file
66
src/glu/sgi/libnurbs/internals/renderhints.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* renderhints.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/renderhints.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glurenderhints_h_
|
||||
#define __glurenderhints_h_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class Renderhints {
|
||||
public:
|
||||
Renderhints( void );
|
||||
void init( void );
|
||||
int isProperty( long );
|
||||
REAL getProperty( long );
|
||||
void setProperty( long, REAL );
|
||||
|
||||
REAL display_method; /* display mode */
|
||||
REAL errorchecking; /* activate error checking */
|
||||
REAL subdivisions; /* maximum number of subdivisions per patch */
|
||||
REAL tmp1; /* unused */
|
||||
|
||||
int displaydomain;
|
||||
int maxsubdivisions;
|
||||
int wiretris;
|
||||
int wirequads;
|
||||
};
|
||||
|
||||
#endif /* __glurenderhints_h_ */
|
||||
56
src/glu/sgi/libnurbs/internals/simplemath.h
Normal file
56
src/glu/sgi/libnurbs/internals/simplemath.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* simplemath.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/simplemath.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __glusimplemath_h_
|
||||
#define __glusimplemath_h_
|
||||
|
||||
/* simple inline routines */
|
||||
|
||||
inline int
|
||||
max( int x, int y ) { return ( x < y ) ? y : x; }
|
||||
|
||||
inline REAL
|
||||
min( REAL x, REAL y ) { return ( x > y ) ? y : x; }
|
||||
|
||||
inline REAL
|
||||
abs( REAL x ) { return ( x < 0.0 ) ? -x : x; }
|
||||
|
||||
#endif /* __glusimplemath_h_ */
|
||||
1287
src/glu/sgi/libnurbs/internals/slicer.cc
Normal file
1287
src/glu/sgi/libnurbs/internals/slicer.cc
Normal file
File diff suppressed because it is too large
Load diff
90
src/glu/sgi/libnurbs/internals/slicer.h
Normal file
90
src/glu/sgi/libnurbs/internals/slicer.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* slicer.h
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/slicer.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#ifndef __gluslicer_h_
|
||||
#define __gluslicer_h_
|
||||
|
||||
#include "trimregion.h"
|
||||
#include "mesher.h"
|
||||
#include "coveandtiler.h"
|
||||
#include "primitiveStream.h"
|
||||
#include "rectBlock.h"
|
||||
|
||||
class Backend;
|
||||
class Arc;
|
||||
class TrimVertex;
|
||||
|
||||
class Slicer : public CoveAndTiler, public Mesher {
|
||||
public:
|
||||
Slicer( Backend & );
|
||||
~Slicer( void );
|
||||
void slice( Arc_ptr );
|
||||
void slice_old( Arc_ptr);
|
||||
void slice_new( Arc_ptr );
|
||||
void evalStream(primStream* );
|
||||
void evalRBArray(rectBlockArray* rbArray, gridWrap* grid);
|
||||
|
||||
void outline( Arc_ptr );
|
||||
void setstriptessellation( REAL, REAL );
|
||||
void setisolines( int );
|
||||
|
||||
void set_ulinear(int ulinear_flag)
|
||||
{
|
||||
ulinear = ulinear_flag;
|
||||
}
|
||||
void set_vlinear(int vlinear_flag)
|
||||
{
|
||||
vlinear = vlinear_flag;
|
||||
}
|
||||
private:
|
||||
Backend& backend;
|
||||
REAL oneOverDu;
|
||||
REAL du, dv;
|
||||
int isolines;
|
||||
|
||||
void outline( void );
|
||||
void initGridlines( void );
|
||||
void advanceGridlines( long );
|
||||
|
||||
int ulinear; //indicate whether uorder is 2 or not
|
||||
int vlinear; //indicate whether vorder is 2 or not
|
||||
};
|
||||
#endif /* __gluslicer_h_ */
|
||||
141
src/glu/sgi/libnurbs/internals/sorter.cc
Normal file
141
src/glu/sgi/libnurbs/internals/sorter.cc
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.1 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
/*
|
||||
* sorter.c++
|
||||
*
|
||||
* $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
|
||||
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/sorter.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
|
||||
*/
|
||||
|
||||
#include "glimports.h"
|
||||
#include "sorter.h"
|
||||
#include "mystdio.h"
|
||||
|
||||
Sorter::Sorter( int _es )
|
||||
{
|
||||
es = _es;
|
||||
}
|
||||
|
||||
void
|
||||
Sorter::qsort( void *a, int n )
|
||||
{
|
||||
qs1( (char *)a, ((char *)a)+n*es);
|
||||
}
|
||||
|
||||
int
|
||||
Sorter::qscmp( char *, char * )
|
||||
{
|
||||
dprintf( "Sorter::qscmp: pure virtual called\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sorter::qsexc( char *, char * )
|
||||
{
|
||||
dprintf( "Sorter::qsexc: pure virtual called\n" );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sorter::qstexc( char *, char *, char * )
|
||||
{
|
||||
dprintf( "Sorter::qstexc: pure virtual called\n" );
|
||||
}
|
||||
|
||||
void
|
||||
Sorter::qs1( char *a, char *l )
|
||||
{
|
||||
char *i, *j;
|
||||
char *lp, *hp;
|
||||
int c;
|
||||
unsigned int n;
|
||||
|
||||
start:
|
||||
if((n=l-a) <= es)
|
||||
return;
|
||||
n = es * (n / (2*es));
|
||||
hp = lp = a+n;
|
||||
i = a;
|
||||
j = l-es;
|
||||
while(1) {
|
||||
if(i < lp) {
|
||||
if((c = qscmp(i, lp)) == 0) {
|
||||
qsexc(i, lp -= es);
|
||||
continue;
|
||||
}
|
||||
if(c < 0) {
|
||||
i += es;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
loop:
|
||||
if(j > hp) {
|
||||
if((c = qscmp(hp, j)) == 0) {
|
||||
qsexc(hp += es, j);
|
||||
goto loop;
|
||||
}
|
||||
if(c > 0) {
|
||||
if(i == lp) {
|
||||
qstexc(i, hp += es, j);
|
||||
i = lp += es;
|
||||
goto loop;
|
||||
}
|
||||
qsexc(i, j);
|
||||
j -= es;
|
||||
i += es;
|
||||
continue;
|
||||
}
|
||||
j -= es;
|
||||
goto loop;
|
||||
}
|
||||
|
||||
if(i == lp) {
|
||||
if(lp-a >= l-hp) {
|
||||
qs1(hp+es, l);
|
||||
l = lp;
|
||||
} else {
|
||||
qs1(a, lp);
|
||||
a = hp+es;
|
||||
}
|
||||
goto start;
|
||||
}
|
||||
|
||||
qstexc(j, lp -= es, i);
|
||||
j = hp -= es;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue