| 1 | /* $Id: subdivider.h,v 1.1 2000-02-09 08:49:56 jeroen Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | ** License Applicability. Except to the extent portions of this file are
|
|---|
| 4 | ** made subject to an alternative license as permitted in the SGI Free
|
|---|
| 5 | ** Software License B, Version 1.0 (the "License"), the contents of this
|
|---|
| 6 | ** file are subject only to the provisions of the License. You may not use
|
|---|
| 7 | ** this file except in compliance with the License. You may obtain a copy
|
|---|
| 8 | ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
|---|
| 9 | ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
|---|
| 10 | **
|
|---|
| 11 | ** http://oss.sgi.com/projects/FreeB
|
|---|
| 12 | **
|
|---|
| 13 | ** Note that, as provided in the License, the Software is distributed on an
|
|---|
| 14 | ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
|---|
| 15 | ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
|---|
| 16 | ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
|---|
| 17 | ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|---|
| 18 | **
|
|---|
| 19 | ** Original Code. The Original Code is: OpenGL Sample Implementation,
|
|---|
| 20 | ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
|---|
| 21 | ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
|---|
| 22 | ** Copyright in any portions created by third parties is as indicated
|
|---|
| 23 | ** elsewhere herein. All Rights Reserved.
|
|---|
| 24 | **
|
|---|
| 25 | ** Additional Notice Provisions: The application programming interfaces
|
|---|
| 26 | ** established by SGI in conjunction with the Original Code are The
|
|---|
| 27 | ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
|---|
| 28 | ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
|---|
| 29 | ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
|---|
| 30 | ** Window System(R) (Version 1.3), released October 19, 1998. This software
|
|---|
| 31 | ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
|---|
| 32 | ** published by SGI, but has not been independently verified as being
|
|---|
| 33 | ** compliant with the OpenGL(R) version 1.2.1 Specification.
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | * subdivider.h
|
|---|
| 38 | *
|
|---|
| 39 | * $Date: 2000-02-09 08:49:56 $ $Revision: 1.1 $
|
|---|
| 40 | * $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glu/nurbs/internals/subdivider.h,v 1.1 2000-02-09 08:49:56 jeroen Exp $
|
|---|
| 41 | */
|
|---|
| 42 |
|
|---|
| 43 | #ifndef __glusubdivider_h_
|
|---|
| 44 | #define __glusubdivider_h_
|
|---|
| 45 |
|
|---|
| 46 | #include "mysetjmp.h"
|
|---|
| 47 | #include "bin.h"
|
|---|
| 48 | #include "flist.h"
|
|---|
| 49 | #include "slicer.h"
|
|---|
| 50 | #include "arctess.h"
|
|---|
| 51 | #include "trimvertex.h"
|
|---|
| 52 | #include "trimvertpool.h"
|
|---|
| 53 |
|
|---|
| 54 | class Arc;
|
|---|
| 55 | class Pool;
|
|---|
| 56 | class Renderhints;
|
|---|
| 57 | class Quilt;
|
|---|
| 58 | class Patchlist;
|
|---|
| 59 | class Curvelist;
|
|---|
| 60 | class JumpBuffer;
|
|---|
| 61 |
|
|---|
| 62 | class Subdivider {
|
|---|
| 63 | public:
|
|---|
| 64 | Subdivider( Renderhints&, Backend& );
|
|---|
| 65 | ~Subdivider( void );
|
|---|
| 66 | void clear( void );
|
|---|
| 67 |
|
|---|
| 68 | void beginTrims( void ) {}
|
|---|
| 69 | void beginLoop( void );
|
|---|
| 70 | void addArc( REAL *, Quilt *, long );
|
|---|
| 71 | void addArc( int, TrimVertex *, long );
|
|---|
| 72 | void endLoop( void ) {}
|
|---|
| 73 | void endTrims( void ) {}
|
|---|
| 74 |
|
|---|
| 75 | void beginQuilts( void );
|
|---|
| 76 | void addQuilt( Quilt * );
|
|---|
| 77 | void endQuilts( void ) {}
|
|---|
| 78 |
|
|---|
| 79 | void drawCurves( void );
|
|---|
| 80 | void drawSurfaces( long );
|
|---|
| 81 |
|
|---|
| 82 | int ccwTurn_sl( Arc_ptr, Arc_ptr );
|
|---|
| 83 | int ccwTurn_sr( Arc_ptr , Arc_ptr );
|
|---|
| 84 | int ccwTurn_tl( Arc_ptr , Arc_ptr );
|
|---|
| 85 | int ccwTurn_tr( Arc_ptr , Arc_ptr );
|
|---|
| 86 |
|
|---|
| 87 | void setJumpbuffer( JumpBuffer * );
|
|---|
| 88 |
|
|---|
| 89 | void set_domain_distance_u_rate(REAL u_rate)
|
|---|
| 90 | {
|
|---|
| 91 | domain_distance_u_rate = u_rate;
|
|---|
| 92 | }
|
|---|
| 93 | void set_domain_distance_v_rate(REAL v_rate)
|
|---|
| 94 | {
|
|---|
| 95 | domain_distance_v_rate = v_rate;
|
|---|
| 96 | }
|
|---|
| 97 | void set_is_domain_distance_sampling(int flag)
|
|---|
| 98 | {
|
|---|
| 99 | is_domain_distance_sampling = flag;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | private:
|
|---|
| 103 | void classify_headonleft_s( Bin &, Bin &, Bin &, REAL );
|
|---|
| 104 | void classify_tailonleft_s( Bin &, Bin &, Bin &, REAL );
|
|---|
| 105 | void classify_headonright_s( Bin &, Bin &, Bin &, REAL );
|
|---|
| 106 | void classify_tailonright_s( Bin &, Bin &, Bin &, REAL );
|
|---|
| 107 | void classify_headonleft_t( Bin &, Bin &, Bin &, REAL );
|
|---|
| 108 | void classify_tailonleft_t( Bin &, Bin &, Bin &, REAL );
|
|---|
| 109 | void classify_headonright_t( Bin &, Bin &, Bin &, REAL );
|
|---|
| 110 | void classify_tailonright_t( Bin &, Bin &, Bin &, REAL );
|
|---|
| 111 |
|
|---|
| 112 | enum dir { down, same, up, none };
|
|---|
| 113 | void tessellate( Arc_ptr, REAL );
|
|---|
| 114 | void monotonize( Arc_ptr , Bin & );
|
|---|
| 115 | int isMonotone( Arc_ptr );
|
|---|
| 116 | int decompose( Bin &, REAL );
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | Slicer slicer;
|
|---|
| 120 | ArcTessellator arctessellator;
|
|---|
| 121 | Pool arcpool;
|
|---|
| 122 | Pool bezierarcpool;
|
|---|
| 123 | Pool pwlarcpool;
|
|---|
| 124 | TrimVertexPool trimvertexpool;
|
|---|
| 125 |
|
|---|
| 126 | JumpBuffer* jumpbuffer;
|
|---|
| 127 | Renderhints& renderhints;
|
|---|
| 128 | Backend& backend;
|
|---|
| 129 |
|
|---|
| 130 | Bin initialbin;
|
|---|
| 131 | Arc_ptr pjarc;
|
|---|
| 132 | int s_index;
|
|---|
| 133 | int t_index;
|
|---|
| 134 | Quilt * qlist;
|
|---|
| 135 | Flist spbrkpts;
|
|---|
| 136 | Flist tpbrkpts;
|
|---|
| 137 | Flist smbrkpts;
|
|---|
| 138 | Flist tmbrkpts;
|
|---|
| 139 | REAL stepsizes[4];
|
|---|
| 140 | int showDegenerate;
|
|---|
| 141 | int isArcTypeBezier;
|
|---|
| 142 |
|
|---|
| 143 | void samplingSplit( Curvelist&, int );
|
|---|
| 144 |
|
|---|
| 145 | void subdivideInS( Bin& );
|
|---|
| 146 | void splitInS( Bin&, int, int );
|
|---|
| 147 | void splitInT( Bin&, int, int );
|
|---|
| 148 | void samplingSplit( Bin&, Patchlist&, int, int );
|
|---|
| 149 | void nonSamplingSplit( Bin&, Patchlist&, int, int );
|
|---|
| 150 | void tessellation( Bin&, Patchlist& );
|
|---|
| 151 | void monosplitInS( Bin&, int, int );
|
|---|
| 152 | void monosplitInT( Bin&, int, int );
|
|---|
| 153 |
|
|---|
| 154 | void outline( Bin & );
|
|---|
| 155 | void freejarcs( Bin & );
|
|---|
| 156 | void render( Bin & );
|
|---|
| 157 | void split( Bin &, Bin &, Bin &, int, REAL );
|
|---|
| 158 | void tessellate( Bin &, REAL, REAL, REAL, REAL );
|
|---|
| 159 |
|
|---|
| 160 | inline void setDegenerate( void ) { showDegenerate = 1; }
|
|---|
| 161 | inline void setNonDegenerate( void ) { showDegenerate = 0; }
|
|---|
| 162 | inline int showingDegenerate( void ) { return showDegenerate; }
|
|---|
| 163 | inline void setArcTypeBezier( void ) { isArcTypeBezier = 1; }
|
|---|
| 164 | inline void setArcTypePwl( void ) { isArcTypeBezier = 0; }
|
|---|
| 165 | inline int isBezierArcType( void ) { return isArcTypeBezier; }
|
|---|
| 166 |
|
|---|
| 167 | void makeBorderTrim( const REAL *, const REAL * );
|
|---|
| 168 | void split( Bin &, int, const REAL *, int, int );
|
|---|
| 169 | void partition( Bin &, Bin &, Bin &, Bin &, Bin &, int, REAL );
|
|---|
| 170 | void findIrregularS( Bin & );
|
|---|
| 171 | void findIrregularT( Bin & );
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 | inline int bbox( TrimVertex *, TrimVertex *, TrimVertex *, int );
|
|---|
| 175 | static int bbox( REAL, REAL, REAL, REAL, REAL, REAL );
|
|---|
| 176 | static int ccw( TrimVertex *, TrimVertex *, TrimVertex * );
|
|---|
| 177 | void join_s( Bin &, Bin &, Arc_ptr, Arc_ptr );
|
|---|
| 178 | void join_t( Bin &, Bin &, Arc_ptr , Arc_ptr );
|
|---|
| 179 | int arc_split( Arc_ptr , int, REAL, int );
|
|---|
| 180 | void check_s( Arc_ptr , Arc_ptr );
|
|---|
| 181 | void check_t( Arc_ptr , Arc_ptr );
|
|---|
| 182 | inline void link( Arc_ptr , Arc_ptr , Arc_ptr , Arc_ptr );
|
|---|
| 183 | inline void simple_link( Arc_ptr , Arc_ptr );
|
|---|
| 184 |
|
|---|
| 185 | Bin* makePatchBoundary( const REAL *from, const REAL *to );
|
|---|
| 186 |
|
|---|
| 187 | /*in domain distance method, the tessellation is controled by two numbers:
|
|---|
| 188 | *GLU_U_STEP: number of u-segments per unit u length of domain
|
|---|
| 189 | *GLU_V_STEP: number of v-segments per unit v length of domain
|
|---|
| 190 | *These two numbers are normally stored in mapdesc->maxs(t)rate.
|
|---|
| 191 | *I (ZL) put these two numbers here so that I can optimize the untrimmed
|
|---|
| 192 | *case in the case of domain distance sampling.
|
|---|
| 193 | *These two numbers are set by set_domain_distance_u_rate() and ..._v_..().
|
|---|
| 194 | */
|
|---|
| 195 | REAL domain_distance_u_rate;
|
|---|
| 196 | REAL domain_distance_v_rate;
|
|---|
| 197 | int is_domain_distance_sampling;
|
|---|
| 198 | };
|
|---|
| 199 |
|
|---|
| 200 | inline void
|
|---|
| 201 | Subdivider::beginLoop( void )
|
|---|
| 202 | {
|
|---|
| 203 | pjarc = 0;
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 | #endif /* __glusubdivider_h_ */
|
|---|