Changeset 3299


Ignore:
Timestamp:
03/18/10 08:54:02 (15 years ago)
Author:
Mathieu Morlighem
Message:

Bug fix from Bamg

Location:
issm/trunk/src/c/Bamgx/objects
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Bamgx/objects/Geometry.cpp

    r3279 r3299  
    141141
    142142                //RequiredEdges
    143                 if(verbose>5) printf("      writing RequiredEdges\n");
     143                if(verbose>5) printf("      writing %i RequiredEdges\n",nbreq);
    144144                bamggeom->NumRequiredEdges=nbreq;
    145145                if (nbreq){
     
    160160
    161161                //RequiredVertices
    162                 if(verbose>5) printf("      writing RequiredVertices\n");
     162                if(verbose>5) printf("      writing %i RequiredVertices\n",nbreqv);
    163163                bamggeom->NumRequiredVertices=nbreqv;
    164164                if (nbreqv){
    165165                        bamggeom->RequiredVertices=(double*)xmalloc(1*nbreqv*sizeof(double));
    166166                        count=0;
    167                         for (i=0;i<nbe;i++){
     167                        for (i=0;i<nbv;i++){
    168168                                if (vertices[i].Required()){
    169169                                        bamggeom->RequiredVertices[count]=i+1; //back to Matlab indexing
     
    296296                        for (i=0;i<nbe;i++){
    297297
     298                                //printf("%i th edge of geometry: [%i %i]\n",i+1,(int)bamggeom->Edges[i*3+0],(int)bamggeom->Edges[i*3+1]);
    298299                                i1=(int)bamggeom->Edges[i*3+0]-1; //-1 for C indexing
    299300                                i2=(int)bamggeom->Edges[i*3+1]-1; //-1 for C indexing
     
    789790                                                 GeometricalEdge *e = & ei;
    790791                                                 GeometricalVertex *a=(*e)(k0); // begin
    791                                                  if(curves) {
     792                                                 if(curves){
    792793                                                         curves[NbOfCurves].be=e;
    793794                                                         curves[NbOfCurves].kb=k0;
     
    814815                                 }
    815816                         }
    816                         if (nbgem==0 || nbe==0){
    817                                 throw ErrorException(__FUNCT__,exprintf("nbgem==0 || nbe==0"));
    818                         }
    819                         if(step==0) {
     817                        assert(nbgem && nbe);
     818                        if(step==0){
    820819                                curves = new Curve[NbOfCurves];
    821820                        }
  • issm/trunk/src/c/Bamgx/objects/Geometry.h

    r3280 r3299  
    2222namespace bamg {
    2323
    24    /*CLASS: Geometry{{{1*/
    2524        class Geometry {
    2625
     
    7574                        void WriteGeometry(BamgGeom* bamggeom, BamgOpts* bamgopts);
    7675        };
    77         /*}}}1*/
    7876       
    7977}
  • issm/trunk/src/c/Bamgx/objects/Triangles.cpp

    r3279 r3299  
    26812681                }
    26822682
    2683                 //check that edges is empty
     2683                //check that edges has been allocated
    26842684                if (edges){
    26852685                        throw ErrorException(__FUNCT__,exprintf("edges is empty"));
    26862686                }
    26872687
    2688                 // 2 step
    2689                 // step=0 to compute the number of edges + alloc at end
    2690                 // step=1 to construct the edges
     2688                /* Now we are going to create the first edges corresponding
     2689                 * to the one present in the geometry provided.
     2690                 * We proceed in 2 steps
     2691                 *  -step 1: we count all the edges
     2692                 *           we allocate the number of edges at the end of step 1
     2693                 *  -step 2: the edges are created */
    26912694                for (int step=0;step<2;step++){
    26922695
     
    26962699                        long NbVerticesOnGeomEdge0=NbVerticesOnGeomEdge;
    26972700                        Gh.UnMarkEdges();       
    2698                         NbOfCurves = 0;
     2701                        NbOfCurves=0;
    26992702
    27002703                        //go through the edges of the geometry
     
    27042707                                GeometricalEdge &ei=Gh.edges[i];   
    27052708
    2706                                 // a good curve (not dup)
     2709                                // a good curve (not a duplicate)
    27072710                                if (!ei.Dup()){
    27082711
    27092712                                        for(int j=0;j<2;j++) {
    27102713
    2711                                                 if (!ei.Mark() && ei[j].Required()) {
    2712                                                         // warning ei.Mark() can be change in loop for(j=0;j<2;j++)
    2713                                                         long nbvend=0;
     2714                                                /*The first time, no edge is marked but this might change during the loop*/
     2715                                                if (!ei.Mark() && ei[j].Required()){
     2716
     2717                                                        long  nbvend=0;
    27142718                                                        Edge* PreviousNewEdge=NULL;
    27152719
    2716                                                         //do not create points if required
    27172720                                                        lstep = -1;
     2721
     2722                                                        /*If Edge is required*/
    27182723                                                        if(ei.Required()){
     2724                                                                //do not create internal points if required (take it as is)
    27192725                                                                if (j==0){
    27202726                                                                        if(step==0) nbe++;
     
    27392745                                                        }
    27402746
    2741                                                         //if not required: on curve
     2747                                                        /*If Edge is not required: on a curve*/
    27422748                                                        else {
    2743                                                                 for ( int kstep=0;kstep<= step;kstep++){
    2744                                                                         //step=0, nohing
    2745                                                                         //step=1,
    2746                                                                         //step=2
    2747                                                                         // 1 compute the length of the curve
    2748                                                                         // 2 create the points and edge
     2749                                                                for ( int kstep=0;kstep<=step;kstep++){
     2750                                                                        //step=0, do nothing
     2751                                                                        //step=1, compute the length of the curve
     2752                                                                        //step=2  create the points and edge
    27492753                                                                        PreviousNewEdge=0;
    27502754                                                                        NbNewPoints=0;
     
    27582762                                                                        // i = edge number, j=[0;1] vertex number in edge
    27592763                                                                       
    2760                                                                         k=j;            // k = vertex number in edge
    2761                                                                         e=&ei;          // e = address of current edge
     2764                                                                        k=j;            // k = vertex number in edge (0 or 1)
     2765                                                                        e=&ei;          // e = reference of current edge
    27622766                                                                        a=ei(k)->The(); // a = pointer toward the kth vertex of the current edge
    2763                                                                         va = a->to;     // va= pointer toward vertex of ???
    2764                                                                         e->SetMark();   // Mark e
     2767                                                                        va = a->to;     // va = pointer toward vertex associated
     2768                                                                        e->SetMark();   // Mark edge
    27652769
    27662770                                                                        //if SameGeo We have go to the background geometry
     
    27682772                                                                        for(;;){
    27692773                                                                                k = 1-k;
    2770                                                                                 b = (*e)(k)->The(); // b = pointer toward the other vertex of the current edge
    2771                                                                                 AB = b->r - a->r;   // AB = vector of the current edge
     2774                                                                                b = (*e)(k)->The();// b = pointer toward the other vertex of the current edge
     2775                                                                                AB= b->r - a->r;   // AB = vector of the current edge
    27722776                                                                                Metric MA = background ? BTh.MetricAt(a->r) :a->m ;  //Get metric associated to A
    27732777                                                                                Metric MB =  background ? BTh.MetricAt(b->r) :b->m ; //Get metric associated to B
     
    28112815
    28122816                                                                                //Now, create corresponding points
    2813                                                                                 //s = lstep
    28142817                                                                                while (lcurve<=s && s <= lcurveb && nbv < nbvend){
    28152818
     
    28462849                                                                                        edges[nbe].v[0]=va;
    28472850                                                                                        edges[nbe].v[1]=vb;
    2848                                                                                         edges[nbe].ref = e->ref;
     2851                                                                                        edges[nbe].ref =e->ref;
    28492852                                                                                        edges[nbe].onGeometry = e;
    28502853                                                                                        edges[nbe].adj[0] = PreviousNewEdge;
     
    28872890                                                                else nbe += NbEdgeCurve;
    28882891                                                        } // end on  curve ---
    2889                                                 } // if (edges[i][j].Corner()) 
     2892                                                }
    28902893                                        }
    28912894                                }
     
    30233026                        Edge &ei = BTh.edges[iedge];
    30243027                        for(int je=0;je<2;je++){ // for the 2 extremities
    3025                                 if (!ei.onGeometry->Mark() && ei[je].onGeometry->IsRequiredVertex() ){
    3026                                         // a begin of curve
     3028
     3029                                // If one of the vertex is required we are in a new curve
     3030                                if (ei[je].onGeometry->IsRequiredVertex()){
     3031
     3032                                        //Get curve number
    30273033                                        int nc=ei.onGeometry->CurveNumber;
    3028                                         if(ei.onGeometry==Gh.curves[nc].be    &&
    3029                                                                 (GeometricalVertex *) *ei[je].onGeometry == &(*Gh.curves[nc].be)[Gh.curves[nc].kb] //  same extremity
     3034                                       
     3035                                        //BUG FIX from original bamg
     3036                                        if(
     3037                                                                (ei.onGeometry==Gh.curves[nc].be  || ei.onGeometry==Gh.curves[nc].ee)  &&          //Check that we are on the right edge
     3038                                                                (GeometricalVertex *) *ei[je].onGeometry == &(*Gh.curves[nc].be)[Gh.curves[nc].kb] //Check that we are on the right extremity
    30303039                                          ){
     3040                                        if( (GeometricalVertex *) *ei[je].onGeometry == &(*Gh.curves[nc].be)[Gh.curves[nc].kb]){
    30313041                                                bcurve[nc]=iedge*2+je;
    30323042                                                bfind++;       
     
    30353045                        }
    30363046                }
    3037                 assert(bfind==Gh.NbOfCurves);
     3047                if (bfind!=Gh.NbOfCurves){
     3048                        throw ErrorException(__FUNCT__,exprintf("problem generating number of curves (Gh.NbOfCurves=%i bfind=%i)",Gh.NbOfCurves,bfind));
     3049                }
    30383050
    30393051                // method in 2 + 1 step
  • issm/trunk/src/c/Bamgx/objects/Vertex.h

    r3280 r3299  
    3030                        short vint;  // the vertex number in triangle; varies between 0 and 2 in t
    3131                        union {
    32                                 Triangle* t; // one triangle which is containing the vertex
     32                                Triangle* t;   // one triangle which is containing the vertex
    3333                                long      color;
    34                                 Vertex*   to;  // use in geometry Vertex to now the Mesh Vertex associed
     34                                Vertex*   to;  // used in geometry Vertex to know the Mesh Vertex associated
    3535                                VertexOnGeom* onGeometry;        // if vint == 8; // set with Triangles::SetVertexFieldOn()
    3636                                Vertex*       onBackgroundVertex;// if vint == 16 on Background vertex Triangles::SetVertexFieldOnBTh()
Note: See TracChangeset for help on using the changeset viewer.