Ignore:
Timestamp:
08/12/10 09:43:45 (15 years ago)
Author:
Mathieu Morlighem
Message:

As usual (Added object constructor from matlab structure

File:
1 edited

Legend:

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

    r5154 r5177  
    111111                         * where D is the longest side of the domain (direction x or y)
    112112                         * so that (x-pmin.x)/D is in ]0 1[
     113                         *
     114                         * coefIcoor = (2^30 -1)/D
    113115                         */
    114116                        coefIcoor=(MaxICoor)/(Max(pmax.x-pmin.x,pmax.y-pmin.y));
     
    398400
    399401        /*Methods*/
    400         /*FUNCTION Geometry::AfterRead(){{{1*/
     402        /*FUNCTION Geometry::AfterRead{{{1*/
    401403        void Geometry::AfterRead(){
    402404                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/AfterRead)*/
    403405
    404                 long int verbose=0;
    405 
    406                 long i,j,k;
    407                 int jj;
    408                 long* head_v=new long[nbv];
    409                 long* next_p=new long[2*nbe];
    410                 float* eangle=new float[nbe];
    411                 double eps=1e-20;
    412                 QuadTree quadtree; // build quadtree to find duplicates
    413                 BamgVertex* v0=vertices;
    414                 GeometricalVertex* v0g=(GeometricalVertex*) (void*)v0;   
     406                long               i,j,k;
     407                int                jj;
     408                long              *head_v   = new long[nbv];
     409                long              *next_p   = new long[2*nbe];
     410                float             *eangle   = new float[nbe];
     411                double             eps      = 1e-20;
     412                QuadTree           quadtree; // build quadtree to find duplicates
     413                BamgVertex        *v0       = vertices;
     414                GeometricalVertex *v0g      = (GeometricalVertex*) (void*)v0;
    415415
    416416                k=0;
     
    424424                        All the coordinates are transformed to ]0,1[^2
    425425                        then, the integer coordinates are computed using
    426                         the transformation ]0,1[^2 -> [0 2^(30-1)[^2 for a quadtree of depth 30*/
     426                        the transformation ]0,1[^2 -> [0 2^30-1[^2 for a quadtree of depth 30*/
    427427                        vertices[i].i=toI2(vertices[i].r);
    428428
    429                         //find nearest vertex already present in the quadtree (NULL if empty)
     429                        /*find nearest vertex already present in the quadtree (NULL if empty)*/
    430430                        BamgVertex* v=quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y);
    431431
    432                         //if there is a vertex found that is to close to vertices[i] -> error
    433                         if( v && Norme1(v->r - vertices[i]) < eps ){
    434                                 printf("WARNING: two points of the geometry are very closed to each other\n");
    435                         }
    436 
    437                         //Add vertices[i] to the quadtree
     432                        /*if there is a vertex found that is to close to vertices[i] -> error*/
     433                        if( v && Norme1(v->r - vertices[i].r) < eps ){
     434                                ISSMERROR("two points of the geometry are very closed to each other");
     435                        }
     436
     437                        /*Add vertices[i] to the quadtree*/
    438438                        quadtree.Add(vertices[i]);
    439                 }
    440 
    441                 //if k>0, there are some duplicate vertices -> error
    442                 if (k) {
    443                         printf("number of distinct vertices= %i, over %i\n",nbv - k,nbv);
    444                         printf("List of duplicate vertices:\n");
    445                         ISSMERROR("See above");
    446439                }
    447440
     
    767760                nbv=0;
    768761                nbe=0;
    769                 quadtree=0;
    770                 curves=0;
    771                 edges=0;
    772                 vertices=0;
     762                quadtree=NULL;
     763                curves=NULL;
     764                edges=NULL;
     765                vertices=NULL;
    773766                nbsubdomains=0;
    774767                nbcurves=0;
    775                 subdomains=0;
     768                subdomains=NULL;
    776769                MaxCornerAngle = 10*Pi/180; //default is 10 degres
    777770        }
     
    941934        /*FUNCTION Geometry::toI2{{{1*/
    942935        I2 Geometry::toI2(const R2 & P) const {
    943                 return  I2( (Icoor1) (coefIcoor*(P.x-pmin.x))
    944                                         ,(Icoor1) (coefIcoor*(P.y-pmin.y)) );
     936                /*coefIcoor is the coefficient used for integer coordinates:
     937                 *                       (x-pmin.x)
     938                 * Icoor x = (2^30 -1) ------------
     939                 *                          D
     940                 * where D is the longest side of the domain (direction x or y)
     941                 * so that (x-pmin.x)/D is in ]0 1[
     942                 *
     943                 * coefIcoor = (2^30 -1)/D
     944                 */
     945                return  I2( (Icoor1) (coefIcoor*(P.x-pmin.x)) ,(Icoor1) (coefIcoor*(P.y-pmin.y)) );
    945946        }/*}}}*/
    946947        /*FUNCTION Geometry::UnMarkEdges{{{1*/
Note: See TracChangeset for help on using the changeset viewer.