00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GUNU_INTERSECT_H
00021 #define GUNU_INTERSECT_H
00022
00023 namespace gunu {
00024
00025 using gul::Ptr;
00026 using gul::point;
00027 using gul::hpoint;
00028 using gul::line2;
00029 using gul::cross_product;
00030 using gul::euclid;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 template< class T >
00058 class IntersectionLineInfo : public gul::pool_object
00059 {
00060 public:
00061 gul::point2<T> Suv[2];
00062 int Sflag[2];
00063 };
00064
00065 template< class T >
00066 class IntersectInfo : public gul::pool_object
00067 {
00068 public:
00069 T minx,miny,minz,scalei;
00070
00071 gul::List<gul::ListNode<IntersectionLineInfo<T> > > IA,IB;
00072
00073 gul::List<gul::ListNode<gul::line<T> > > IS;
00074 };
00075
00076 template< class T, class HP >
00077 struct SurfaceInfo
00078 {
00079 int nu;
00080 int pu;
00081 Ptr< T > U;
00082 int nv;
00083 int pv;
00084 Ptr< T > V;
00085 Ptr< Ptr< HP > > Pw;
00086 void *reserved[2];
00087
00088 point<T> P00;
00089 point<T> P01;
00090 point<T> P10;
00091 point<T> P11;
00092
00093 void *operator new( size_t s )
00094 {
00095 size_t dummy;
00096
00097 void *p = gust::PoolAlloc( s, &dummy );
00098 if( p == NULL ) throw gul::PoolAllocError();
00099 return(p);
00100 }
00101 void operator delete( void *p, size_t s )
00102 {
00103 gust::PoolFree( p, s );
00104 }
00105 };
00106
00107 template< class T, class HP >
00108 class TessInfo
00109 {
00110 public:
00111 T x1;
00112 T x2;
00113 T y1;
00114 T y2;
00115 T z1;
00116 T z2;
00117
00118 T u1;
00119 T u2;
00120 T v1;
00121 T v2;
00122
00123 unsigned int linearized : 1;
00124 unsigned int divided : 1;
00125
00126 SurfaceInfo<T,HP> *org;
00127 TessInfo *sub[4];
00128
00129 void operator delete( void *p, size_t s )
00130 {
00131 gust::PoolFree( p, s );
00132 }
00133 void *operator new( size_t s )
00134 {
00135 size_t dummy;
00136 void *p = gust::PoolAlloc( s, &dummy );
00137 if( p == NULL ) throw gul::PoolAllocError();
00138 return(p);
00139 }
00140
00141 TessInfo()
00142 {
00143 linearized = divided = 0;
00144 org = new SurfaceInfo<T,HP>();
00145 for( int i = 0; i < 4; i++ ) sub[i] = 0;
00146 }
00147 ~TessInfo()
00148 {
00149 int i;
00150
00151
00152
00153 for( i = 0; i < 4; i++ )
00154 {
00155 delete sub[i];
00156 sub[i] = 0;
00157 }
00158
00159
00160
00161 delete org;
00162 org = 0;
00163
00164 }
00165 };
00166
00167
00168
00169
00170
00171
00172 template< class T, class HP >
00173 void LinearizeOrDivide( TessInfo<T,HP> *A, const T tol,
00174 bool need_bbox = false );
00175
00176
00177
00178
00179 template< class T, class HP >
00180 void DoLinearizeSurface(
00181 int current_iter, int max_iter,
00182 TessInfo<T,HP> *A,
00183 const T tol,
00184 void outfunc( TessInfo<T,HP> *, void * ),
00185 void *outfunc_data );
00186
00187
00188
00189
00190
00191 template< class T, class HP >
00192 void DoIntersectSurfaces(
00193 TessInfo<T,HP> *A, TessInfo<T,HP> *B,
00194 T tol,
00195 IntersectInfo<T> *II );
00196
00197
00198
00199
00200 template< class T, class HP >
00201 GULAPI void IntersectSurfaces(
00202 int nu1, int pu1, const Ptr< T >& U1,
00203 int nv1, int pv1, const Ptr< T >& V1,
00204 const Ptr< Ptr < HP > >& Pw1,
00205 int nu2, int pu2, const Ptr< T >& U2,
00206 int nv2, int pv2, const Ptr< T >& V2,
00207 const Ptr< Ptr < HP > >& Pw2,
00208 T tol,
00209 gul::List<gul::ListNode<IntersectionLineInfo<T> > >& S1,
00210 gul::List<gul::ListNode<IntersectionLineInfo<T> > >& S2,
00211 gul::List<gul::ListNode<gul::line<T> > >& S );
00212
00213
00214 }
00215
00216 #endif