Changeset 22380


Ignore:
Timestamp:
01/29/18 14:39:39 (7 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing bug if initial mesh is not generated by bamg

Location:
issm/trunk-jpl/src/c/bamg
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/bamg/Geometry.cpp

    r22269 r22380  
    438438                return c - curves;
    439439        }/*}}}*/
    440         void Geometry::PostRead(){/*{{{*/
     440        void Geometry::PostRead(bool checkcurve){/*{{{*/
    441441                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/AfterRead)*/
    442442
     
    606606                        }
    607607
    608                         //all vertices provided in geometry are corners (ord = number of edges holding i)
    609                         vertices[i].SetCorner() ;
    610                         if(ord==2){
    611                                 long  n1 = head_v[i];
    612                                 long  n2 = next_p[n1];
    613                                 long  i1 = n1/2, i2 = n2/2; // edge number
    614                                 long  j1 = n1%2, j2 = n2%2; // vertex in the edge
    615                                 /* if the edge type/referencenumber a changing then is SetRequired();*/
    616                                 if (edges[i1].type != edges[i2].type || edges[i1].Required()){
    617                                         vertices[i].SetRequired();
    618                                 }
    619                                 if (edges[i1].ReferenceNumber != edges[i2].ReferenceNumber) {
    620                                         vertices[i].SetRequired();
     608                        /*Do we want to check for curve? Default is no, but if we are reconstructing, it's better to turn it on with a small threshold*/
     609                        if(checkcurve){
     610                                /*angular test on current vertex to guess whether it is a corner (ord = number of edges holding i) */
     611                                if(ord==2){
     612                                        IssmDouble MaxCornerAngle = 1*Pi/180; /*default is 1 degree*/
     613                                        long  n1 = head_v[i];
     614                                        long  n2 = next_p[n1];
     615                                        long  i1 = n1/2, i2 = n2/2; // edge number
     616                                        long  j1 = n1%2, j2 = n2%2; // vertex in the edge
     617                                        float angle1=  j1 ? OppositeAngle(eangle[i1]) : eangle[i1];
     618                                        float angle2= !j2 ? OppositeAngle(eangle[i2]) : eangle[i2];
     619                                        float da12 = Abs(angle2-angle1);
     620                                        if (( da12 >= MaxCornerAngle ) && (da12 <= 2*Pi -MaxCornerAngle)) {
     621                                                vertices[i].SetCorner() ;
     622                                        }
     623                                        /* if the edge type/referencenumber a changing then is SetRequired();*/
     624                                        if(edges[i1].type != edges[i2].type || edges[i1].Required()){
     625                                                vertices[i].SetRequired();
     626                                        }
     627                                        if(edges[i1].ReferenceNumber != edges[i2].ReferenceNumber) {
     628                                                vertices[i].SetRequired();
     629                                        }
     630                                }
     631                                if(ord!=2) vertices[i].SetCorner();
     632                        }
     633                        else{
     634                                /*all vertices provided in geometry are corners (ord = number of edges holding i)*/
     635                                vertices[i].SetCorner() ;
     636                                if(ord==2){
     637                                        long  n1 = head_v[i];
     638                                        long  n2 = next_p[n1];
     639                                        long  i1 = n1/2, i2 = n2/2; // edge number
     640                                        long  j1 = n1%2, j2 = n2%2; // vertex in the edge
     641                                        /* if the edge type/referencenumber a changing then is SetRequired();*/
     642                                        if (edges[i1].type != edges[i2].type || edges[i1].Required()){
     643                                                vertices[i].SetRequired();
     644                                        }
     645                                        if (edges[i1].ReferenceNumber != edges[i2].ReferenceNumber) {
     646                                                vertices[i].SetRequired();
     647                                        }
    621648                                }
    622649                        }
  • issm/trunk-jpl/src/c/bamg/Geometry.h

    r21864 r22380  
    5252                        void             ReadGeometry(BamgGeom *bamggeom, BamgOpts*bamgopts);
    5353                        void             Init(void);
    54                         void             PostRead();
     54                        void             PostRead(bool checkcurve=false);
    5555                        long             GetId(const GeomVertex &t) const;
    5656                        long             GetId(const GeomVertex *t) const;
  • issm/trunk-jpl/src/c/bamg/Mesh.cpp

    r22253 r22380  
    3030                        _printf_("WARNING: mesh present but no geometry found. Reconstructing...\n");
    3131                        BuildGeometryFromMesh(bamgopts);
    32                         Gh.PostRead();
     32                        Gh.PostRead(true);
    3333                }
    3434
     
    12151215                /*Construction of the edges*/
    12161216
    1217                 //initialize st and edge4
     1217                /*initialize st and edge4*/
    12181218                SetOfEdges4* edge4= new SetOfEdges4(nbt*3,nbv);
    12191219                long*        st   = new long[nbt*3];
    12201220
    1221                 //initialize st as -1 (chaining algorithm)
     1221                /*initialize st as -1 (chaining algorithm)*/
    12221222                for (i=0;i<nbt*3;i++) st[i]=-1;
    12231223
    1224                 //build edge4 (chain)
     1224                /*build edge4 (chain)*/
    12251225                for (i=0;i<nbe;i++){
    12261226                        edge4->SortAndAdd(GetId(edges[i][0]),GetId(edges[i][1]));
    12271227                }
    1228                 //check that there is no double edge
     1228                /*check that there is no double edge*/
    12291229                if (nbe !=  edge4->nb()){
    12301230                        delete [] st;
     
    12341234                long nbeold = nbe;
    12351235
    1236                 //Go through the triangles and ass the edges in edge4 if they are not there yet
     1236                //Go through the triangles and add the edges in edge4 if they are not there yet
    12371237                for (i=0;i<nbt;i++){
    12381238                        //3 edges per triangle
     
    12511251                                                _error_("problem in Geometry reconstruction: an edge on boundary is duplicated (double element?)");
    12521252                                        }
    1253                                         //OK, the element is not on boundary, is belongs to 2 triangles -> build Adjacent triangles list
     1253                                        /*OK, the element is not on boundary, is belongs to 2 triangles -> build Adjacent triangles list*/
    12541254                                        triangles[i].SetAdj2(j,triangles + st[k] / 3,(int) (st[k]%3));
    12551255                                        if (invisible)  triangles[i].SetHidden(j);
    1256                                         // if k < nbe mark the edge as on Boundary (Locked)
     1256                                        /* if k < nbe mark the edge as on Boundary (Locked)*/
    12571257                                        if (k<nbe) {
    12581258                                                triangles[i].SetLocked(j);
    12591259                                        }
    1260                                         //set st[k] as negative so that the edge should not be called again
     1260                                        /*set st[k] as negative so that the edge should not be called again*/
    12611261                                        st[k]=-2-st[k];
    12621262                                }
    1263                                 //else (see 3 lines above), the edge has been called more than twice: return error
    12641263                                else {
     1264                                        /*else (see 3 lines above), the edge has been called more than twice: return error*/
    12651265                                        _printf_("The edge (" << GetId(triangles[i][VerticesOfTriangularEdge[j][0]]) << "," << GetId(triangles[i][VerticesOfTriangularEdge[j][1]]) << ") belongs to more than 2 triangles (" << k << ")\n");
    12661266                                        _printf_("Edge " << j << " of triangle " << i << "\n");
     
    12861286                }
    12871287
    1288                 // check consistency of edge[].adj and geometrical required  vertices
     1288                /*check consistency of edge[].adj and geometrical required  vertices*/
    12891289                k=0; kk=0;
    12901290                for (i=0;i<nbedges;i++){
     
    13041304
    13051305                /*Constructions of edges*/
    1306 
    13071306                k += kk;
    13081307                kk=0;
Note: See TracChangeset for help on using the changeset viewer.