Changeset 5400 for issm/trunk/src/c/objects/Bamg/Geometry.cpp
- Timestamp:
- 08/19/10 09:28:10 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Bamg/Geometry.cpp
r5397 r5400 400 400 401 401 /*Methods*/ 402 /*FUNCTION Geometry::Echo {{{1*/ 403 void Geometry::Echo(void){ 404 405 printf("Geometry:\n"); 406 printf(" nbv (number of vertices) : %i\n",nbv); 407 printf(" nbe (number of edges) : %i\n",nbe); 408 printf(" nbsubdomains: %i\n",nbsubdomains); 409 printf(" nbcurves: %i\n",nbcurves); 410 printf(" vertices: %p\n",vertices); 411 printf(" edges: %p\n",edges); 412 printf(" quadtree: %p\n",quadtree); 413 printf(" subdomains: %p\n",subdomains); 414 printf(" curves: %p\n",curves); 415 printf(" pmin (x,y): (%g %g)\n",pmin.x,pmin.y); 416 printf(" pmax (x,y): (%g %g)\n",pmax.x,pmax.y); 417 printf(" coefIcoor: %g\n",coefIcoor); 418 printf(" MaxCornerAngle: %g\n",MaxCornerAngle); 419 420 return; 421 } 422 /*}}}*/ 423 /*FUNCTION Geometry::Init{{{1*/ 424 void Geometry::Init(void){ 425 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/EmptyGeometry)*/ 426 427 NbRef=0; 428 nbv=0; 429 nbe=0; 430 quadtree=NULL; 431 curves=NULL; 432 edges=NULL; 433 vertices=NULL; 434 nbsubdomains=0; 435 nbcurves=0; 436 subdomains=NULL; 437 MaxCornerAngle = 10*Pi/180; //default is 10 degres 438 } 439 /*}}}1*/ 440 /*FUNCTION Geometry::MinimalHmin{{{1*/ 441 double Geometry::MinimalHmin() { 442 /* coeffIcoor = (2^30-1)/D 443 * We cannot go beyond hmin = D/2^30 because of the quadtree 444 * hmin is therefore approximately 2/coeffIcoor */ 445 return 2.0/coefIcoor; 446 }/*}}}*/ 447 /*FUNCTION Geometry::MaximalHmax{{{1*/ 448 double Geometry::MaximalHmax() { 449 return Max(pmax.x-pmin.x,pmax.y-pmin.y); 450 }/*}}}*/ 451 /*FUNCTION Geometry::GetId(const GeometricalVertex &t){{{1*/ 452 long Geometry::GetId(const GeometricalVertex & t) const { 453 return &t - vertices; 454 }/*}}}*/ 455 /*FUNCTION Geometry::GetId(const GeometricalVertex * t){{{1*/ 456 long Geometry::GetId(const GeometricalVertex * t) const { 457 return t - vertices; 458 }/*}}}*/ 459 /*FUNCTION Geometry::GetId(const GeometricalEdge & t){{{1*/ 460 long Geometry::GetId(const GeometricalEdge & t) const { 461 return &t - edges; 462 }/*}}}*/ 463 /*FUNCTION Geometry::GetId(const GeometricalEdge * t){{{1*/ 464 long Geometry::GetId(const GeometricalEdge * t) const { 465 return t - edges; 466 }/*}}}*/ 467 /*FUNCTION Geometry::GetId(const Curve * c){{{1*/ 468 long Geometry::GetId(const Curve * c) const { 469 return c - curves; 470 }/*}}}*/ 471 /*FUNCTION Geometry::Containing{{{1*/ 472 GeometricalEdge* Geometry::Containing(const R2 P, GeometricalEdge * start) const { 473 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/Contening)*/ 474 475 GeometricalEdge* on =start,* pon=0; 476 // walk with the cos on geometry 477 int counter=0; 478 while(pon != on){ 479 counter++; 480 ISSMASSERT(counter<100); 481 pon = on; 482 R2 A= (*on)[0]; 483 R2 B= (*on)[1]; 484 R2 AB = B-A; 485 R2 AP = P-A; 486 R2 BP = P-B; 487 if ( (AB,AP) < 0) 488 on = on->Adj[0]; 489 else if ( (AB,BP) > 0) 490 on = on->Adj[1]; 491 else 492 return on; 493 } 494 return on; 495 } 496 /*}}}1*/ 402 497 /*FUNCTION Geometry::PostRead{{{1*/ 403 498 void Geometry::PostRead(){ … … 420 515 421 516 /*build integer coordinates (non unique) 422 these coordinates are used by the quadtree to group423 the vertices by groups of 5:424 All the coordinates are transformed to ]0,1[^2425 then, the integer coordinates are computed using426 the transformation ]0,1[^2 -> [0 2^30-1[^2 for a quadtree of depth 30*/517 these coordinates are used by the quadtree to group 518 the vertices by groups of 5: 519 All the coordinates are transformed to ]0,1[^2 520 then, the integer coordinates are computed using 521 the transformation ]0,1[^2 -> [0 2^30-1[^2 for a quadtree of depth 30*/ 427 522 vertices[i].i=R2ToI2(vertices[i].r); 428 523 … … 669 764 GeometricalVertex *a=(*e)(k0); // begin 670 765 if(curves){ 671 curves[nbcurves]. be=e;672 curves[nbcurves]. kb=k0;766 curves[nbcurves].FirstEdge=e; 767 curves[nbcurves].FirstVertexIndex=k0; 673 768 } 674 769 int nee=0; … … 679 774 nb_marked_edges++; 680 775 e->CurveNumber=nbcurves; 681 if(curves){682 curves[nbcurves].ee=e;683 curves[nbcurves].ke=k1;684 }685 686 776 GeometricalVertex *b=(*e)(k1); 687 777 688 778 //break if we have reached the other end of the curve 689 779 if (a==b || b->Required()){ 780 if(curves){ 781 curves[nbcurves].LastEdge=e; 782 curves[nbcurves].LastVertexIndex=k1; 783 } 690 784 break; 691 785 } … … 706 800 if(step==0) curves=new Curve[nbcurves]; 707 801 } 708 for(int i=0;i<nbcurves ;i++){709 GeometricalEdge * be=curves[i].be, *eqbe=be;710 //GeometricalEdge * ee=curves[i].ee, *eqee=be;711 }712 802 713 803 /*clean up*/ … … 716 806 delete [] eangle; 717 807 718 }719 /*}}}1*/720 /*FUNCTION Geometry::Echo {{{1*/721 void Geometry::Echo(void){722 723 printf("Geometry:\n");724 printf(" nbv (number of vertices) : %i\n",nbv);725 printf(" nbe (number of edges) : %i\n",nbe);726 printf(" nbsubdomains: %i\n",nbsubdomains);727 printf(" nbcurves: %i\n",nbcurves);728 printf(" vertices: %p\n",vertices);729 printf(" edges: %p\n",edges);730 printf(" quadtree: %p\n",quadtree);731 printf(" subdomains: %p\n",subdomains);732 printf(" curves: %p\n",curves);733 printf(" pmin (x,y): (%g %g)\n",pmin.x,pmin.y);734 printf(" pmax (x,y): (%g %g)\n",pmax.x,pmax.y);735 printf(" coefIcoor: %g\n",coefIcoor);736 printf(" MaxCornerAngle: %g\n",MaxCornerAngle);737 738 return;739 }740 /*}}}*/741 /*FUNCTION Geometry::Init{{{1*/742 void Geometry::Init(void){743 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/EmptyGeometry)*/744 745 NbRef=0;746 nbv=0;747 nbe=0;748 quadtree=NULL;749 curves=NULL;750 edges=NULL;751 vertices=NULL;752 nbsubdomains=0;753 nbcurves=0;754 subdomains=NULL;755 MaxCornerAngle = 10*Pi/180; //default is 10 degres756 }757 /*}}}1*/758 /*FUNCTION Geometry::MinimalHmin{{{1*/759 double Geometry::MinimalHmin() {760 /* coeffIcoor = (2^30-1)/D761 * We cannot go beyond hmin = D/2^30 because of the quadtree762 * hmin is therefore approximately 2/coeffIcoor */763 return 2.0/coefIcoor;764 }/*}}}*/765 /*FUNCTION Geometry::MaximalHmax{{{1*/766 double Geometry::MaximalHmax() {767 return Max(pmax.x-pmin.x,pmax.y-pmin.y);768 }/*}}}*/769 /*FUNCTION Geometry::GetId(const GeometricalVertex &t){{{1*/770 long Geometry::GetId(const GeometricalVertex & t) const {771 return &t - vertices;772 }/*}}}*/773 /*FUNCTION Geometry::GetId(const GeometricalVertex * t){{{1*/774 long Geometry::GetId(const GeometricalVertex * t) const {775 return t - vertices;776 }/*}}}*/777 /*FUNCTION Geometry::GetId(const GeometricalEdge & t){{{1*/778 long Geometry::GetId(const GeometricalEdge & t) const {779 return &t - edges;780 }/*}}}*/781 /*FUNCTION Geometry::GetId(const GeometricalEdge * t){{{1*/782 long Geometry::GetId(const GeometricalEdge * t) const {783 return t - edges;784 }/*}}}*/785 /*FUNCTION Geometry::GetId(const Curve * c){{{1*/786 long Geometry::GetId(const Curve * c) const {787 return c - curves;788 }/*}}}*/789 /*FUNCTION Geometry::Containing{{{1*/790 GeometricalEdge* Geometry::Containing(const R2 P, GeometricalEdge * start) const {791 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/Contening)*/792 793 GeometricalEdge* on =start,* pon=0;794 // walk with the cos on geometry795 int counter=0;796 while(pon != on){797 counter++;798 ISSMASSERT(counter<100);799 pon = on;800 R2 A= (*on)[0];801 R2 B= (*on)[1];802 R2 AB = B-A;803 R2 AP = P-A;804 R2 BP = P-B;805 if ( (AB,AP) < 0)806 on = on->Adj[0];807 else if ( (AB,BP) > 0)808 on = on->Adj[1];809 else810 return on;811 }812 return on;813 808 } 814 809 /*}}}1*/
Note:
See TracChangeset
for help on using the changeset viewer.