Files Classes Functions Hierarchy
00001 00002 00003 #include <cassert> 00004 #include <iostream> 00005 #include <fstream> 00006 #include <sstream> 00007 #include <string> 00008 00009 using namespace std; 00010 00011 #include <GL/glut.h> 00012 #include <GL/gl.h> 00013 00014 #include <zpr.h> 00015 #include <graphmisc.h> 00016 #include <print.h> 00017 #include <commandline.h> 00018 00019 00020 00021 #include <gobj.h> 00022 00023 #include <halfspaceD2.h> 00024 #include <halfspaceD2draw.h> 00025 00026 #include <d3tess.h> 00027 00028 #include <d3clipping.h> 00029 00030 #include <d3circlepartition.h> 00031 #include <d3circlepartitiondraw.h> 00032 00033 #include <d2partitiondraw.h> 00034 00035 #include <d3meshiterrecursive.h> 00036 00037 #include <d3meshpartition.h> 00038 #include <d3meshpartitiondraw.h> 00039 00040 #include <test01obj.h> 00041 00042 00043 typedef unsigned int uint; 00044 typedef unsigned int const uintc; 00045 00046 typedef point2<double> pt2; 00047 typedef point3<double> pt3; 00048 00049 void tessinitgeneral 00050 ( 00051 d3tess & tess, 00052 double const * d, 00053 uintc dsz, 00054 uintc * ti, 00055 uintc tisz 00056 ) 00057 { 00058 tess.reset(); 00059 00060 for (uint i=0; i<dsz; ++i) 00061 tess.pt.push_back( pt3(d[i*2],d[i*2+1],0.0) ); 00062 00063 uint k; 00064 for (uint i=0; i<tisz; ++i) 00065 { 00066 k=i*6; 00067 tess.viadd( ti[k], ti[k+1], ti[k+2], ti[k+3], ti[k+4], ti[k+5] ); 00068 } 00069 00070 tess.debugcheck(); 00071 } 00072 00073 00074 00075 void tessinit03 00076 (d3tess & tess) 00077 { 00078 uintc dsz=4; 00079 double const d[] = 00080 { 00081 0.0, 0.0, 00082 2.0, 0.0, 00083 2.0, 2.0, 00084 0.0, 6.0 00085 }; 00086 00087 uintc tisz=2; 00088 uint ti[] = 00089 { 00090 1,2,3, 0,2,0, 00091 1,3,4, 0,0,1 00092 }; 00093 00094 tessinitgeneral(tess,d,dsz,ti,tisz); 00095 } 00096 00097 // Writes a non-convex tessellation 00098 void tessinit01(d3tess & tess) 00099 { 00100 tess.reset(); 00101 00102 uintc dsz=16; 00103 double const d[dsz*2] = 00104 { 00105 0.0, 0.0, // The tessellation starts from index 1. 00106 2.0, 0.0, 00107 2.0, 2.0, 00108 4.0, 2.0, 00109 4.0, 0.0, 00110 00111 6.0, 0.0, 00112 6.0, 6.0, 00113 2.0, 5.0, 00114 4.0, 5.0, 00115 4.0, 4.0, 00116 00117 2.0, 4.0, 00118 0.0, 6.0, 00119 1.0, 0.0, 00120 2.0, 6.0, 00121 3.0, 4.0, 00122 00123 2.0, 3.0 00124 00125 }; 00126 00127 for (uint i=0; i<dsz; ++i) 00128 tess.pt.push_back( pt3(d[i*2],d[i*2+1],0.0) ); 00129 00130 uintc tisz=12; 00131 uint ti[] = 00132 { 00133 1,2,3, 0,2,0, 00134 1,3,12, 3,0,1, 00135 3,11,12, 12,2,4, 00136 3,4,11, 5,3,0, 00137 4,10,11, 0,4,6, 00138 00139 10,4,6, 7,8,5, 00140 5,6,4, 6,0,0, 00141 6,7,10, 9,6,0, 00142 10,7,9, 10,0,8, 00143 7,8,9, 0,9,11, 00144 00145 8,7,12, 0,12,10, 00146 12,11,8, 0,11,3 00147 00148 }; 00149 00150 uint k; 00151 for (uint i=0; i<tisz; ++i) 00152 { 00153 k=i*6; 00154 tess.viadd( ti[k], ti[k+1], ti[k+2], ti[k+3], ti[k+4], ti[k+5] ); 00155 } 00156 00157 tess.debugcheck(); 00158 00159 } 00160 00161 void tessinit02(d3tess & tess) 00162 { 00163 tess.reset(); 00164 00165 uintc dsz=6; 00166 double const d[dsz*2] = 00167 { 00168 1.0, 0.0, 00169 3.0, 0.5, 00170 0.5, 1.0, 00171 -0.5, 2.0, 00172 0.0, 0.5 00173 00174 }; 00175 00176 for (uint i=0; i<dsz; ++i) 00177 tess.pt.push_back( pt3(d[i*2],d[i*2+1],0.0) ); 00178 00179 uintc tisz=3; 00180 uint ti[] = 00181 { 00182 1,2,3, 0,2,0, 00183 5,1,3, 1,3,0, 00184 5,3,4, 0,0,2 00185 }; 00186 00187 uint k; 00188 for (uint i=0; i<tisz; ++i) 00189 { 00190 k=i*6; 00191 tess.viadd( ti[k], ti[k+1], ti[k+2], ti[k+3], ti[k+4], ti[k+5] ); 00192 } 00193 00194 tess.debugcheck(); 00195 } 00196 00197 00198 00199 void test01(d3tess & tess) 00200 { 00201 tessinit01(tess); 00202 00203 cout << endl << endl << "Split on boundary" << endl << endl; 00204 //cout << "No neighbors" << endl; 00205 //tess.splitonboundary(1,2,13); 00206 00207 //tess.splitonboundary(1,3,13); 00208 //splitmidpoint(tess,1,3); 00209 00210 tess.debugcheck(); 00211 /* 00212 tess.splitonboundary(11,0,14); 00213 tess.debugcheck(); 00214 00215 tess.splitonboundary(3,2,16); 00216 tess.debugcheck(); 00217 00218 */ 00219 00220 00221 } 00222 00223 00224 00225 int main(int argc, char** argv) 00226 { 00227 commandline cmd(argc,argv); 00228 uint prog(0); 00229 cmd.mapvar(prog,"prog"); 00230 00231 switch (prog) 00232 { 00233 case 0: 00234 cout << "Test programs for clipping workspace" << endl << endl; 00235 cout << "$./main prog=3 - clipping A with another mesh" << endl; 00236 cout << "$./main prog=2 - clipping A with circle partition" << endl; 00237 cout << "$/.main prog=1 - clipping A with halfspace" << endl; 00238 break; 00239 00240 case 1: 00241 { 00242 test01obj<halfspaceD2< pt3, double >,halfspaceD2draw> x 00243 ( 00244 tessinit01, 00245 new halfspaceD2< pt3, double >( pt3(2.5,-2.0,0.0), pt3(8.0,7.5,0.0) ), 00246 argc,argv,GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH,800,600,"" 00247 ); 00248 00249 x.eval(); 00250 glutMainLoop(); 00251 break; 00252 } 00253 00254 case 2: 00255 { 00256 test01obj<d3circlepartition,d3circlepartitiondraw> x 00257 ( 00258 tessinit01, 00259 new d3circlepartition( pt2(2.0,2.0), 1.5), 00260 argc,argv,GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH,800,600,"" 00261 ); 00262 00263 x.eval(); 00264 glutMainLoop(); 00265 00266 break; 00267 } 00268 00269 case 3: 00270 { 00271 unsigned int const N(100); 00272 d3tess * meshB = new d3tess(N); 00273 tessinit02(*meshB); 00274 00275 test01obj<d3meshpartition,d3meshpartitiondraw> x 00276 ( 00277 tessinit03, 00278 new d3meshpartition(*meshB), 00279 argc,argv,GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH,800,600,"" 00280 ); 00281 00282 x.eval(); 00283 glutMainLoop(); 00284 00285 break; 00286 } 00287 00288 default: cout << "error: No case handled." << endl; return 1; 00289 } 00290 00291 return 0; 00292 } 00293 00294
1.5.8