1f220fa62Smrg/* 2f220fa62Smrg * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3f220fa62Smrg * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4f220fa62Smrg * 5f220fa62Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6f220fa62Smrg * copy of this software and associated documentation files (the "Software"), 7f220fa62Smrg * to deal in the Software without restriction, including without limitation 8f220fa62Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9f220fa62Smrg * and/or sell copies of the Software, and to permit persons to whom the 10f220fa62Smrg * Software is furnished to do so, subject to the following conditions: 11f220fa62Smrg * 12f220fa62Smrg * The above copyright notice including the dates of first publication and 13f220fa62Smrg * either this permission notice or a reference to 14f220fa62Smrg * http://oss.sgi.com/projects/FreeB/ 15f220fa62Smrg * shall be included in all copies or substantial portions of the Software. 16f220fa62Smrg * 17f220fa62Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18f220fa62Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19f220fa62Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20f220fa62Smrg * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21f220fa62Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22f220fa62Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23f220fa62Smrg * SOFTWARE. 24f220fa62Smrg * 25f220fa62Smrg * Except as contained in this notice, the name of Silicon Graphics, Inc. 26f220fa62Smrg * shall not be used in advertising or otherwise to promote the sale, use or 27f220fa62Smrg * other dealings in this Software without prior written authorization from 28f220fa62Smrg * Silicon Graphics, Inc. 29f220fa62Smrg */ 30f220fa62Smrg 31f220fa62Smrg/* 32f220fa62Smrg * mapdesc.h 33f220fa62Smrg * 34f220fa62Smrg */ 35f220fa62Smrg 36f220fa62Smrg#ifndef __glumapdesc_h_ 37f220fa62Smrg#define __glumapdesc_h_ 38f220fa62Smrg 39f220fa62Smrg#include "mystdio.h" 40f220fa62Smrg#include "types.h" 41f220fa62Smrg#include "defines.h" 42f220fa62Smrg#include "bufpool.h" 43f220fa62Smrg#include "nurbsconsts.h" 44f220fa62Smrg 45f220fa62Smrgtypedef REAL Maxmatrix[MAXCOORDS][MAXCOORDS]; 46f220fa62Smrg 47f220fa62Smrgclass Backend; 48f220fa62Smrg 49f220fa62Smrgclass Mapdesc : public PooledObj { 50f220fa62Smrg friend class Maplist; 51f220fa62Smrg 52f220fa62Smrgpublic: 53f220fa62Smrg Mapdesc( long, int, int, Backend & ); 54f220fa62Smrg int isProperty( long ); 55f220fa62Smrg REAL getProperty( long ); 56f220fa62Smrg void setProperty( long, REAL ); 57f220fa62Smrg int isConstantSampling( void ); 58f220fa62Smrg int isDomainSampling( void ); 59f220fa62Smrg int isRangeSampling( void ); 60f220fa62Smrg int isSampling( void ); 61f220fa62Smrg int isParametricDistanceSampling( void ); 62f220fa62Smrg int isObjectSpaceParaSampling( void ); 63f220fa62Smrg int isObjectSpacePathSampling( void ); 64f220fa62Smrg int isSurfaceAreaSampling( void ); 65f220fa62Smrg int isPathLengthSampling( void ); 66f220fa62Smrg int isCulling( void ); 67f220fa62Smrg int isBboxSubdividing( void ); 68f220fa62Smrg long getType( void ); 69f220fa62Smrg 70f220fa62Smrg /* curve routines */ 71f220fa62Smrg void subdivide( REAL *, REAL *, REAL, int, int ); 72f220fa62Smrg int cullCheck( REAL *, int, int ); 73f220fa62Smrg void xformBounding( REAL *, int, int, REAL *, int ); 74f220fa62Smrg void xformCulling( REAL *, int, int, REAL *, int ); 75f220fa62Smrg void xformSampling( REAL *, int, int, REAL *, int ); 76f220fa62Smrg void xformMat( Maxmatrix, REAL *, int, int, REAL *, int ); 77f220fa62Smrg REAL calcPartialVelocity ( REAL *, int, int, int, REAL ); 78f220fa62Smrg int project( REAL *, int, REAL *, int, int ); 79f220fa62Smrg REAL calcVelocityRational( REAL *, int, int ); 80f220fa62Smrg REAL calcVelocityNonrational( REAL *, int, int ); 81f220fa62Smrg 82f220fa62Smrg /* surface routines */ 83f220fa62Smrg void subdivide( REAL *, REAL *, REAL, int, int, int, int ); 84f220fa62Smrg int cullCheck( REAL *, int, int, int, int ); 85f220fa62Smrg void xformBounding( REAL *, int, int, int, int, REAL *, int, int ); 86f220fa62Smrg void xformCulling( REAL *, int, int, int, int, REAL *, int, int ); 87f220fa62Smrg void xformSampling( REAL *, int, int, int, int, REAL *, int, int ); 88f220fa62Smrg void xformMat( Maxmatrix, REAL *, int, int, int, int, REAL *, int, int ); 89f220fa62Smrg REAL calcPartialVelocity ( REAL *, REAL *, int, int, int, int, int, int, REAL, REAL, int ); 90f220fa62Smrg int project( REAL *, int, int, REAL *, int, int, int, int); 91f220fa62Smrg void surfbbox( REAL bb[2][MAXCOORDS] ); 92f220fa62Smrg 93f220fa62Smrg int bboxTooBig( REAL *, int, int, int, int, REAL [2][MAXCOORDS] ); 94f220fa62Smrg int xformAndCullCheck( REAL *, int, int, int, int ); 95f220fa62Smrg 96f220fa62Smrg void identify( REAL[MAXCOORDS][MAXCOORDS] ); 97f220fa62Smrg void setBboxsize( INREAL *); 98f220fa62Smrg inline void setBmat( INREAL*, long, long ); 99f220fa62Smrg inline void setCmat( INREAL*, long, long ); 100f220fa62Smrg inline void setSmat( INREAL*, long, long ); 101f220fa62Smrg inline int isRational( void ); 102f220fa62Smrg inline int getNcoords( void ); 103f220fa62Smrg 104f220fa62Smrg REAL pixel_tolerance; /* pathlength sampling tolerance */ 105f220fa62Smrg REAL error_tolerance; /* parametric error sampling tolerance*/ 106f220fa62Smrg REAL object_space_error_tolerance; /* object space tess*/ 107f220fa62Smrg REAL clampfactor; 108f220fa62Smrg REAL minsavings; 109f220fa62Smrg REAL maxrate; 110f220fa62Smrg REAL maxsrate; 111f220fa62Smrg REAL maxtrate; 112f220fa62Smrg REAL bboxsize[MAXCOORDS]; 113f220fa62Smrg 114f220fa62Smrgprivate: 115f220fa62Smrg long type; 116f220fa62Smrg int isrational; 117f220fa62Smrg int ncoords; 118f220fa62Smrg int hcoords; 119f220fa62Smrg int inhcoords; 120f220fa62Smrg int mask; 121f220fa62Smrg Maxmatrix bmat; 122f220fa62Smrg Maxmatrix cmat; 123f220fa62Smrg Maxmatrix smat; 124f220fa62Smrg REAL s_steps; /* max samples in s direction */ 125f220fa62Smrg REAL t_steps; /* max samples in t direction */ 126f220fa62Smrg REAL sampling_method; 127f220fa62Smrg REAL culling_method; /* check for culling */ 128f220fa62Smrg REAL bbox_subdividing; 129f220fa62Smrg Mapdesc * next; 130f220fa62Smrg Backend & backend; 131f220fa62Smrg 132f220fa62Smrg void bbox( REAL [2][MAXCOORDS], REAL *, int, int, int, int ); 133f220fa62Smrg REAL maxDifference( int, REAL *, int ); 134f220fa62Smrg static void copy( Maxmatrix, long, INREAL *, long, long ); 135f220fa62Smrg 136f220fa62Smrg /* individual control point routines */ 137f220fa62Smrg static void transform4d( float[4], float[4], float[4][4] ); 138f220fa62Smrg static void multmatrix4d ( float[4][4], const float[4][4], 139f220fa62Smrg const float[4][4] ); 140f220fa62Smrg void copyPt( REAL *, REAL * ); 141f220fa62Smrg void sumPt( REAL *, REAL *, REAL *, REAL, REAL ); 142f220fa62Smrg void xformSampling( REAL *, REAL * ); 143f220fa62Smrg void xformCulling( REAL *, REAL * ); 144f220fa62Smrg void xformRational( Maxmatrix, REAL *, REAL * ); 145f220fa62Smrg void xformNonrational( Maxmatrix, REAL *, REAL * ); 146f220fa62Smrg unsigned int clipbits( REAL * ); 147f220fa62Smrg}; 148f220fa62Smrg 149f220fa62Smrginline void 150f220fa62SmrgMapdesc::setBmat( INREAL *mat, long rstride, long cstride ) 151f220fa62Smrg{ 152f220fa62Smrg copy( bmat, hcoords, mat, rstride, cstride ); 153f220fa62Smrg} 154f220fa62Smrg 155f220fa62Smrginline void 156f220fa62SmrgMapdesc::setCmat( INREAL *mat, long rstride, long cstride ) 157f220fa62Smrg{ 158f220fa62Smrg copy( cmat, hcoords, mat, rstride, cstride ); 159f220fa62Smrg} 160f220fa62Smrg 161f220fa62Smrginline void 162f220fa62SmrgMapdesc::setSmat( INREAL *mat, long rstride, long cstride ) 163f220fa62Smrg{ 164f220fa62Smrg copy( smat, hcoords, mat, rstride, cstride ); 165f220fa62Smrg} 166f220fa62Smrg 167f220fa62Smrginline long 168f220fa62SmrgMapdesc::getType( void ) 169f220fa62Smrg{ 170f220fa62Smrg return type; 171f220fa62Smrg} 172f220fa62Smrg 173f220fa62Smrginline void 174f220fa62SmrgMapdesc::xformCulling( REAL *d, REAL *s ) 175f220fa62Smrg{ 176f220fa62Smrg if( isrational ) 177f220fa62Smrg xformRational( cmat, d, s ); 178f220fa62Smrg else 179f220fa62Smrg xformNonrational( cmat, d, s ); 180f220fa62Smrg} 181f220fa62Smrg 182f220fa62Smrginline void 183f220fa62SmrgMapdesc::xformSampling( REAL *d, REAL *s ) 184f220fa62Smrg{ 185f220fa62Smrg if( isrational ) 186f220fa62Smrg xformRational( smat, d, s ); 187f220fa62Smrg else 188f220fa62Smrg xformNonrational( smat, d, s ); 189f220fa62Smrg} 190f220fa62Smrg 191f220fa62Smrginline int 192f220fa62SmrgMapdesc::isRational( void ) 193f220fa62Smrg{ 194f220fa62Smrg return isrational ? 1 : 0; 195f220fa62Smrg} 196f220fa62Smrg 197f220fa62Smrginline int 198f220fa62SmrgMapdesc::getNcoords( void ) 199f220fa62Smrg{ 200f220fa62Smrg return ncoords; 201f220fa62Smrg} 202f220fa62Smrg 203f220fa62Smrginline int 204f220fa62SmrgMapdesc::isConstantSampling( void ) 205f220fa62Smrg{ 206f220fa62Smrg return ((sampling_method == N_FIXEDRATE) ? 1 : 0); 207f220fa62Smrg} 208f220fa62Smrg 209f220fa62Smrginline int 210f220fa62SmrgMapdesc::isDomainSampling( void ) 211f220fa62Smrg{ 212f220fa62Smrg return ((sampling_method == N_DOMAINDISTANCE) ? 1 : 0); 213f220fa62Smrg} 214f220fa62Smrg 215f220fa62Smrginline int 216f220fa62SmrgMapdesc::isParametricDistanceSampling( void ) 217f220fa62Smrg{ 218f220fa62Smrg return ((sampling_method == N_PARAMETRICDISTANCE) ? 1 : 0); 219f220fa62Smrg} 220f220fa62Smrg 221f220fa62Smrginline int 222f220fa62SmrgMapdesc::isObjectSpaceParaSampling( void ) 223f220fa62Smrg{ 224f220fa62Smrg return ((sampling_method == N_OBJECTSPACE_PARA) ? 1 : 0); 225f220fa62Smrg} 226f220fa62Smrg 227f220fa62Smrginline int 228f220fa62SmrgMapdesc::isObjectSpacePathSampling( void ) 229f220fa62Smrg{ 230f220fa62Smrg return ((sampling_method == N_OBJECTSPACE_PATH) ? 1 : 0); 231f220fa62Smrg} 232f220fa62Smrg 233f220fa62Smrginline int 234f220fa62SmrgMapdesc::isSurfaceAreaSampling( void ) 235f220fa62Smrg{ 236f220fa62Smrg return ((sampling_method == N_SURFACEAREA) ? 1 : 0); 237f220fa62Smrg} 238f220fa62Smrg 239f220fa62Smrginline int 240f220fa62SmrgMapdesc::isPathLengthSampling( void ) 241f220fa62Smrg{ 242f220fa62Smrg return ((sampling_method == N_PATHLENGTH) ? 1 : 0); 243f220fa62Smrg} 244f220fa62Smrg 245f220fa62Smrginline int 246f220fa62SmrgMapdesc::isRangeSampling( void ) 247f220fa62Smrg{ 248f220fa62Smrg return ( isParametricDistanceSampling() || isPathLengthSampling() || 249f220fa62Smrg isSurfaceAreaSampling() || 250f220fa62Smrg isObjectSpaceParaSampling() || 251f220fa62Smrg isObjectSpacePathSampling()); 252f220fa62Smrg} 253f220fa62Smrg 254f220fa62Smrginline int 255f220fa62SmrgMapdesc::isSampling( void ) 256f220fa62Smrg{ 257f220fa62Smrg return isRangeSampling() || isConstantSampling() || isDomainSampling(); 258f220fa62Smrg} 259f220fa62Smrg 260f220fa62Smrginline int 261f220fa62SmrgMapdesc::isCulling( void ) 262f220fa62Smrg{ 263f220fa62Smrg return ((culling_method != N_NOCULLING) ? 1 : 0); 264f220fa62Smrg} 265f220fa62Smrg 266f220fa62Smrginline int 267f220fa62SmrgMapdesc::isBboxSubdividing( void ) 268f220fa62Smrg{ 269f220fa62Smrg return ((bbox_subdividing != N_NOBBOXSUBDIVISION) ? 1 : 0); 270f220fa62Smrg} 271f220fa62Smrg#endif /* __glumapdesc_h_ */ 272