Files Classes Functions Hierarchy
#include <cassert>#include <iostream>#include <GL/glut.h>#include <GL/gl.h>#include <zpr.h>#include <graphmisc.h>#include <cmdln.h>#include <gobj.h>#include <displaypoints.h>#include <rand.h>#include <d3halfspace.h>#include <print.h>#include <aclock.h>#include <d4tri.h>#include <d4tess.h>#include <d4tessdraw.h>#include <d4minboundary.h>#include <d4meshpointreader.h>#include <d3func.h>#include <d3sphere.h>
Go to the source code of this file.
Defines | |
| #define | SHOW(x) #x << '=' << (x) |
Typedefs | |
| typedef point4< double > | pt4 |
| typedef point3< double > | pt3 |
Functions | |
| Message | error ("error.txt", true) |
| void | init01 () |
| void | init02 () |
| void | init03 () |
| void | setface (uintc face) |
| void | timmingexperiment02 () |
| void | timmingexperiment03 () |
| void | keyboard (unsigned char key, int x, int y) |
| void | display () |
| void | help () |
| int | main (int argc, char **argv) |
Variables | |
| d4tess * | mesh |
| d4tessdraw * | meshdraw |
| d3func * | p3dfunc = new d3sphere(point3<double>(),0.6) |
| gobjContainer | xGraphics |
| random11< double > | fr |
| trianglefacedraw * | tfd |
| void display | ( | ) |
Definition at line 590 of file main.cpp.
References d4tessdraw::draw(), gobjContainer::draw(), and glerrordisplay().
00591 { 00592 glMatrix temp; 00593 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00594 00595 //axes(0.5); 00596 //f3().draw(); 00597 00598 xGraphics.draw(); 00599 00600 meshdraw->draw(); 00601 00602 glerrordisplay(); 00603 00604 { 00605 glPushMatrix(); 00606 00607 glPushAttrib(GL_CURRENT_BIT); 00608 glPushAttrib(GL_LIGHTING_BIT); 00609 00610 glColor3f(1.0,1.0,0.0); 00611 glEnable(GL_LIGHTING); 00612 00613 //glutWireSphere(0.6,10,10); 00614 00615 glPopAttrib(); 00616 glPopAttrib(); 00617 00618 glPopMatrix(); 00619 } 00620 glerrordisplay(); 00621 00622 glutSwapBuffers(); 00623 }
| Message error | ( | "error.txt" | , | |
| true | ||||
| ) |
| void help | ( | ) |
Definition at line 626 of file main.cpp.
00627 { 00628 cout << "Command Line Options" << endl; 00629 cout << "For boolean values true and 1, false and 0 are equivalent" << endl; 00630 cout << "cp=true - current pointer" << endl; 00631 cout << "winding=true - display tetrahedrons triangle windings" << endl; 00632 cout << "base=true - display each triangles base" << endl; 00633 cout << "surface=true - draw the surface" << endl; 00634 cout << "grid=true - draw the tetrahedrons as blue grid" << endl; 00635 cout << "points=true - label each point with its integer index" << endl; 00636 cout << "tets=1 - label each tetrahedron with its integer index" << endl; 00637 00638 00639 cout << endl; 00640 cout << "Keyboard Commands" << endl; 00641 cout << "'a' 'A' - rotate anticlockwise or clockwise the base triangle on the current tetrahedron" << endl; 00642 cout << "'j' 'k' - move left, right and down on current tetrahedron surface" << endl; 00643 cout << " 'm'" << endl; 00644 cout << "'d' 'f' - move left, right and down through the mesh(tetmove)" << endl; 00645 cout << " 'c' relative to the current tetredrons base" << endl; 00646 cout << "'b' - orient the current tetrahedron to the boundary if possible" << endl; 00647 cout << "'w' 'e' First orient the cp to the boundary with 'b'. Then move" << endl; 00648 cout << " 's' on the surface left, right, and down respectively." << endl; 00649 cout << "z and Z 2->3 and 3->2" << endl; 00650 00651 cout << endl; 00652 cout << "Minimizers" << endl; 00653 cout << " Explore mesh balancing." << endl; 00654 cout << "greedy=true - very bad mesh generated." << endl; 00655 cout << "greedy2=true - very experimental, do I know what I am doing?" << endl; 00656 00657 }
| void init01 | ( | ) |
Definition at line 93 of file main.cpp.
References d4tess::debugcheck(), d3func::eval(), d4tess::pt, d4tess::viadd(), point4< T >::x, point4< T >::y, and point4< T >::z.
00094 { 00095 mesh->pt.push_back( pt4(0.0,1.0,0.0,0.0) ); 00096 mesh->pt.push_back( pt4(0.0,-1.0,0.0,0.0) ); 00097 mesh->pt.push_back( pt4(1.0,0.0,0.0,0.0) ); 00098 mesh->pt.push_back( pt4(-0.2,0.0,-0.7,0.0) ); 00099 mesh->pt.push_back( pt4(-0.5,0.1,0.1,0.0) ); 00100 mesh->pt.push_back( pt4(0.0,0.0,1.0,0.0) ); 00101 00102 mesh->viadd(1,6,2,5,0,2,0,4); 00103 mesh->viadd(1,5,2,4,0,3,0,1); 00104 mesh->viadd(4,2,1,3,4,0,0,2); 00105 mesh->viadd(3,2,1,6,1,0,0,3); 00106 00107 for (uint i=1; i<mesh->pt.size(); ++i) 00108 { 00109 pt4 & x(mesh->pt[i]); 00110 pt3 y(x.x,x.y,x.z); 00111 x[3] = p3dfunc->eval(y); 00112 } 00113 00114 assert( mesh->debugcheck() ); 00115 }
| void init02 | ( | ) |
Definition at line 117 of file main.cpp.
References d4tess::debugcheck(), d3func::eval(), d3tess::initialize(), d2func::make(), d4tess::pt, d3tess::pt, r, d4tess::viadd(), point4< T >::x, point4< T >::y, and point4< T >::z.
Referenced by main(), mainmenu(), searchStats(), and timmingexperiment01().
00118 { 00119 mesh->pt.push_back( pt4(0.0,1.0,0.0,0.0) ); 00120 mesh->pt.push_back( pt4(0.0,-1.0,0.0,0.0) ); 00121 mesh->pt.push_back( pt4(1.0,0.0,0.0,0.0) ); 00122 mesh->pt.push_back( pt4(-0.2,0.0,-0.7,0.0) ); 00123 mesh->pt.push_back( pt4(-0.5,0.1,0.7,0.0) ); 00124 00125 mesh->viadd(4,3,5,1, 0,0,0,2); 00126 mesh->viadd(5,3,4,2, 0,0,0,1); 00127 00128 for (uint i=1; i<mesh->pt.size(); ++i) 00129 { 00130 pt4 & x(mesh->pt[i]); 00131 pt3 y(x.x,x.y,x.z); 00132 x[3] = p3dfunc->eval(y); 00133 } 00134 00135 assert( mesh->debugcheck() ); 00136 }
| void init03 | ( | ) |
Definition at line 138 of file main.cpp.
References d3func::eval(), d4tess::initialize(), d4tess::pt, point4< T >::x, point4< T >::y, and point4< T >::z.
Referenced by main().
00139 { 00140 mesh->pt.push_back( pt4(0.0,1.0,0.0,0.0) ); 00141 mesh->pt.push_back( pt4(0.0,-1.0,0.0,0.0) ); 00142 mesh->pt.push_back( pt4(1.0,0.0,0.0,0.0) ); 00143 mesh->pt.push_back( pt4(-0.2,0.0,-0.7,0.0) ); 00144 00145 for (uint i=1; i<mesh->pt.size(); ++i) 00146 { 00147 pt4 & x(mesh->pt[i]); 00148 pt3 y(x.x,x.y,x.z); 00149 x[3] = p3dfunc->eval(y); 00150 } 00151 00152 mesh->initialize(); 00153 }
| void keyboard | ( | unsigned char | key, | |
| int | x, | |||
| int | y | |||
| ) |
Definition at line 221 of file main.cpp.
References d4tess::addpoint(), virtualtetrahedron::anticlockwise(), d4tess::boundaryorient(), virtualtetrahedron::clockwise(), virtualtetrahedron::down(), d3func::eval(), virtualtetrahedron::left(), d4tessdraw::meshupdate(), d4tess::pt, r, gobjQuadric::radius, virtualtetrahedron::right(), d4tess::rotateaboutaxis(), d4tess::searchinsidemesh(), setface(), SHOW, d4tess::surfacedown(), d4tess::surfaceleft(), d4tess::surfaceright(), d4tess::tet2to3(), d4tess::tet2to3Inverse(), d4tess::tetmovedown(), d4tess::tetmoveleft(), d4tess::tetmoveright(), timmingexperiment02(), timmingexperiment03(), d4tess::vs, point3< T >::x, point3< T >::y, and point3< T >::z.
00222 { 00223 switch (key) 00224 { 00225 case 27: 00226 exit(0); 00227 break; 00228 00229 case 'a': 00230 mesh->vs.anticlockwise(); 00231 break; 00232 00233 case 'A': 00234 mesh->vs.clockwise(); 00235 break; 00236 00237 case 'j': 00238 mesh->vs.left(); 00239 break; 00240 00241 case 'k': 00242 mesh->vs.right(); 00243 break; 00244 00245 case 'm': 00246 mesh->vs.down(); 00247 break; 00248 00249 // aim: d f Move left, right and down. 00250 // c 00251 case 'd': 00252 mesh->tetmoveleft(); 00253 break; 00254 00255 case 'f': 00256 mesh->tetmoveright(); 00257 break; 00258 00259 case 'c': 00260 mesh->tetmovedown(); 00261 break; 00262 00263 case 'b': 00264 mesh->boundaryorient(); 00265 break; 00266 00267 case 'w': 00268 mesh->surfaceleft(); 00269 break; 00270 case 'e': 00271 mesh->surfaceright(); 00272 break; 00273 00274 case 's': 00275 mesh->surfacedown(); 00276 break; 00277 00278 00279 00280 case 'T': 00281 { 00282 cout << " 1: Read points from file." << endl; 00283 00284 cout << " 2: Create a new data set by writing 3D random data points to a file." << endl; 00285 /* 00286 cout << " 3: Create a new data set by writing 4D random data points to a file." << endl; 00287 00288 */ 00289 cout << " q: quit" << endl; 00290 cout << " Enter a choice "; 00291 char ch; 00292 cin >> ch; 00293 switch (ch) 00294 { 00295 case '1': 00296 timmingexperiment02(); 00297 break; 00298 case '2': 00299 timmingexperiment03(); 00300 meshdraw->meshupdate(); 00301 break; 00302 } 00303 } 00304 break; 00305 00306 00307 case 'r': 00308 { 00309 random11<double> r; 00310 00311 static gobjQuadric q3; 00312 q3.radius=0.005; 00313 00314 xGraphics.push_back( new gobjglColor3f(1.0,0.0,0.0) ); 00315 00316 uint k= mesh->pt.size(); 00317 00318 pt3 x(-1.0+2.0*r(),-1.0+2.0*r(),-1.0+2.0*r()); 00319 mesh->pt.push_back(pt4(x.x,x.y,x.z,p3dfunc->eval(x))); 00320 xGraphics.push_back( new gobjMySphereDraw( x, &q3 ) ); 00321 00322 mesh->addpoint(k); 00323 /* 00324 uint face; 00325 if (mesh->searchinsidemesh(face,k)) 00326 mesh->addpoint(k); 00327 else 00328 setface(face); 00329 */ 00330 00331 meshdraw->meshupdate(); 00332 } 00333 break; 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 /* 00353 00354 00355 case 'r': 00356 { 00357 random11<double> r; 00358 bool found,status; 00359 uint face; 00360 00361 static gobjQuadric q3; 00362 q3.radius=0.005; 00363 00364 xGraphics.push_back( new gobjglColor3f(1.0,0.0,0.0) ); 00365 00366 uint k; 00367 00368 // Only add points in existing mesh. 00369 00370 for (found=false; !found; ) 00371 { 00372 k = mesh->pt.size(); 00373 00374 pt3 x(-1.0+2.0*r(),-1.0+2.0*r(),-1.0+2.0*r()); 00375 mesh->pt.push_back(pt4(x.x,x.y,x.z,0.0)); 00376 xGraphics.push_back( new gobjMySphereDraw( x, &q3 ) ); 00377 00378 // mesh->pt.push_back(pt4(-1.0+2.0*r(),-1.0+2.0*r(),-1.0+2.0*r(),0.0)); 00379 found = mesh->search(status,face,k); 00380 } 00381 00382 mesh->addpoint(k); 00383 meshdraw->meshupdate(); 00384 } 00385 break; 00386 00387 00388 */ 00389 00390 // Writing out state to file. 00391 case '1': 00392 { 00393 Message e1("e1.txt",true); 00394 e1() << *mesh << endl; 00395 } 00396 break; 00397 00398 // Writing out state to file. 00399 case '2': 00400 { 00401 Message e2("e2.txt",true); 00402 e2() << *mesh << endl; 00403 } 00404 break; 00405 00406 00407 00408 00409 00410 case 'R': 00411 { 00412 static gobjQuadric q2; 00413 q2.radius=0.00625; 00414 00415 uint k; 00416 uint face; 00417 bool found; 00418 00419 random11<double> r; 00420 for (uint i=0; i<100; ++i) 00421 { 00422 pt3 x(-1.0+2.0*r(),-1.0+2.0*r(),-1.0+2.0*r()); 00423 00424 k = mesh->pt.size(); 00425 mesh->pt.push_back(pt4(x.x,x.y,x.z,0.0)); 00426 00427 // addpoint also uses the search function, 00428 // so its called before addpoint. 00429 // Else a search occures where the very point is already 00430 // in the mesh. 00431 found = mesh->searchinsidemesh(face,k); 00432 00433 mesh->addpoint(k); 00434 meshdraw->meshupdate(); 00435 00436 00437 if (found) 00438 xGraphics.push_back( new gobjglColor3f(0.0,sqrt(r()),0.0) ); 00439 else 00440 continue; 00441 //xGraphics.push_back( new gobjglColor3f(sqrt(r()),0.0,0.0) ); 00442 00443 xGraphics.push_back( new gobjMySphereDraw( x, &q2 ) ); 00444 } 00445 00446 } 00447 break; 00448 00449 case 'i': 00450 { 00451 static gobjQuadric q; 00452 q.radius=0.0125; 00453 00454 cout << "Input a point" << endl; 00455 pt3 x; 00456 cin >> x.x >> x.y >> x.z; 00457 00458 uint k = mesh->pt.size(); 00459 mesh->pt.push_back(pt4(x.x,x.y,x.z,0.0)); 00460 00461 random11<double> r; 00462 uint face; 00463 bool found = mesh->searchinsidemesh(face,k); 00464 00465 if (found) 00466 { 00467 xGraphics.push_back( new gobjglColor3f(0.0,sqrt(r()),0.0) ); 00468 xGraphics.push_back( new gobjMySphereDraw( x, &q ) ); 00469 tfd->on=false; 00470 } 00471 else 00472 { 00473 setface(face); 00474 00475 /* 00476 00477 d4tri t(mesh->cptri()); 00478 uint a,b,c; 00479 t.getanticlockwiseface(a,b,c,face); 00480 pt3 A(mesh->pt[t.pi[a]]); 00481 pt3 B(mesh->pt[t.pi[b]]); 00482 pt3 C(mesh->pt[t.pi[c]]); 00483 00484 tfd->set(A,B,C); 00485 */ 00486 00487 xGraphics.push_back( new gobjglColor3f(sqrt(r()),0.0,0.0) ); 00488 xGraphics.push_back( new gobjMySphereDraw( x, &q ) ); 00489 } 00490 00491 } 00492 break; 00493 00494 00495 case 'I': 00496 { 00497 static gobjQuadric q3; 00498 q3.radius=0.0125; 00499 00500 cout << "Input a new mesh point" << endl; 00501 pt3 x; 00502 cin >> x.x >> x.y >> x.z; 00503 // x.x=.2; 00504 // x.y=.3; 00505 // x.z=.4; 00506 00507 uint k = mesh->pt.size(); 00508 mesh->pt.push_back(pt4(x.x,x.y,x.z,0.0)); 00509 00510 mesh->addpoint(k); 00511 00512 meshdraw->meshupdate(); 00513 00514 // Draw a green point if its inside the existing mesh, 00515 // a red point if outside the mesh. 00516 00517 /* 00518 uint face; 00519 bool found = mesh->search(face,k); 00520 00521 random11<double> r; 00522 00523 if (found) 00524 xGraphics.push_back( new gobjglColor3f(0.0,sqrt(r()),0.0) ); 00525 else 00526 xGraphics.push_back( new gobjglColor3f(sqrt(r()),0.0,0.0) ); 00527 00528 xGraphics.push_back( new gobjMySphereDraw( x, &q3 ) ); 00529 */ 00530 } 00531 break; 00532 00533 00534 00535 00536 00537 case 'p': 00538 cout << endl; 00539 cout << *mesh << endl; 00540 break; 00541 /* 00542 case 'd': 00543 cout << "d: debug check" << endl; 00544 mesh->debugcheck(); 00545 break; 00546 */ 00547 00548 /* 00549 case 'r': 00550 { 00551 random11<double> r; 00552 double x = r()*10.0; 00553 double y = r()*8.0; 00554 double z = r()*8.0; 00555 cout << SHOW(x) << " " << SHOW(y) << " "; 00556 cout << SHOW(z) << endl; 00557 mesh->eval(x,y,z); 00558 glutPostRedisplay(); 00559 } 00560 break; 00561 */ 00562 00563 case 'z': 00564 mesh->tet2to3(); 00565 meshdraw->meshupdate(); 00566 break; 00567 00568 case 'Z': 00569 mesh->tet2to3Inverse(); 00570 meshdraw->meshupdate(); 00571 break; 00572 00573 case 't': 00574 { 00575 uint steps; 00576 bool res = mesh->rotateaboutaxis(steps); 00577 cout << SHOW(res) << " "; 00578 cout << SHOW(steps) << endl; 00579 } 00580 break; 00581 00582 } 00583 00584 00585 glutPostRedisplay(); 00586 }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 660 of file main.cpp.
References display(), error, d4tessdraw::graphicsDeffered, d4tessdraw::graphicsImmediate, help(), init03(), keyboard(), commandline::mapvar(), d4tessdraw::meshupdate(), d4tess::minimizerSet(), gobjContainer::set(), and SHOW.
00661 { 00662 glutInit(&argc,argv); 00663 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00664 unsigned int const wx=800; 00665 unsigned int const wy=800; 00666 00667 glutInitWindowSize(wx,wy); 00668 00669 glutCreateWindow(""); 00670 00671 glutDisplayFunc(display); 00672 glutKeyboardFunc(keyboard); 00673 00674 OpenGLinitialisation(); 00675 00676 glEnable(GL_DEPTH_TEST); 00677 00678 //glDisable(GL_CULL_FACE); 00679 glEnable(GL_CULL_FACE); 00680 00681 glEnable(GL_NORMALIZE); 00682 00683 xGraphics.set(); 00684 00685 error.setMessageGlobal(); 00686 00687 00688 commandline cmd(argc,argv); 00689 00690 bool greedy(false); 00691 cmd.mapvar(greedy,"greedy"); 00692 bool greedy2(false); 00693 cmd.mapvar(greedy2,"greedy2"); 00694 00695 tfd = new trianglefacedraw(); 00696 xGraphics.push_back(tfd); 00697 00698 00699 00700 00701 unsigned int N(1000); 00702 cmd.mapvar(N,"N"); 00703 00704 mesh = new d4tess(N); 00705 00706 init03(); 00707 00708 meshdraw = new d4tessdraw(*mesh); 00709 00710 00711 cmd.mapvar(meshdraw->graphicsDeffered.v[0]->isdrawn,"points"); 00712 cmd.mapvar(meshdraw->graphicsDeffered.v[1]->isdrawn,"tets"); 00713 cmd.mapvar(meshdraw->graphicsDeffered.v[2]->isdrawn,"winding"); 00714 cmd.mapvar(meshdraw->graphicsDeffered.v[3]->isdrawn,"grid",true); 00715 cmd.mapvar(meshdraw->graphicsDeffered.v[4]->isdrawn,"base"); 00716 cmd.mapvar(meshdraw->graphicsDeffered.v[5]->isdrawn,"surface"); 00717 00718 00719 cmd.mapvar(meshdraw->graphicsImmediate.v[0]->isdrawn,"cp",true); 00720 00721 00722 meshdraw->meshupdate(); 00723 00724 00725 00726 // *mesh,enablegrid,enablewinding,enablepoints,enablebase,enabletets); 00727 00728 cout << SHOW(greedy) << endl; 00729 00730 if (greedy) 00731 mesh->minimizerSet( new d4mingreedy(*mesh) ); 00732 //mesh->minimizerSet( new d4minboundary(*mesh) ); 00733 00734 if (greedy2) 00735 mesh->minimizerSet( new d4mingreedy2(*mesh) ); 00736 00737 00738 zprInit(); 00739 00740 help(); 00741 glutMainLoop(); 00742 00743 return 0; 00744 }
| void setface | ( | uintc | face | ) |
Definition at line 155 of file main.cpp.
References d4tess::cpsimplex(), and d4tess::pt.
Referenced by keyboard().
00156 { 00157 d4tri t(mesh->cpsimplex()); 00158 uint a,b,c; 00159 t.getanticlockwiseface(a,b,c,face); 00160 pt3 A(mesh->pt[t.pi[a]]); 00161 pt3 B(mesh->pt[t.pi[b]]); 00162 pt3 C(mesh->pt[t.pi[c]]); 00163 00164 tfd->set(A,B,C); 00165 }
| void timmingexperiment02 | ( | ) |
Definition at line 167 of file main.cpp.
References aclock::diff_s(), d4meshpointreader::eval(), and aclock::measure().
00168 { 00169 cout << "Reading Points from a File" << endl; 00170 cout << "Expecting the file to have 3 or 4 columns of numbers." << endl; 00171 cout << endl; 00172 cout << " Enter the filename: "; 00173 string fname; 00174 00175 //fname = "dataset2D08.txt"; 00176 //cout << fname << endl; 00177 cin >> fname; 00178 00179 bool res; 00180 d4meshpointreader mr(res,*mesh,fname); 00181 00182 if (res==false) 00183 return; 00184 00185 cout << "Finished reading file: " << fname << endl << endl; 00186 00187 cout << "Starting insertion of points into the mesh" << endl; 00188 00189 aclock c; 00190 c.measure(); 00191 mr.eval(); 00192 c.measure(); 00193 00194 cout << "Finished insertion of points into the mesh" << endl << endl; 00195 cout << "Time without graphics: "; 00196 cout << c.diff_s() << "s" << endl; 00197 00198 }
| void timmingexperiment03 | ( | ) |
Definition at line 200 of file main.cpp.
References fr.
00201 { 00202 cout << "Creating a 3D Data Set" << endl; 00203 cout << "Writing Points to a File" << endl; 00204 cout << " Enter the filename: "; 00205 string fname; 00206 cin >> fname; 00207 cout << " Enter the number of points: "; 00208 uint n; 00209 cin >> n; 00210 00211 ofstream targ(fname.c_str()); 00212 00213 for (uint i=0; i<n; ++i) 00214 targ << -1.0+2.0*fr() << " " << -1.0+2.0*fr() << " " << -1.0+2.0*fr() << endl; 00215 00216 cout << "Finished writing file: " << fname << endl << endl; 00217 }
1.5.8