Changeset 3272
- Timestamp:
- 03/12/10 11:37:01 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/objects/GeometricalEdge.h
r3263 r3272 35 35 36 36 //Methods 37 R2 F(double theta) const ; // parametrization of the curve edge37 R2 F(double theta) const ; // parametrization of the curve edge 38 38 double R1tg(double theta,R2 &t) const ; // 1/radius of curvature + tangente 39 int Cracked() const {return flag & 1;}40 int Dup() const { return flag & 32;}41 int Equi()const {return flag & 2;}42 int ReverseEqui()const {return flag & 128;}43 int TgA()const {return flag &4;}44 int TgB()const {return flag &8;}45 int Tg(int i) const{return i==0 ? TgA() : TgB();}46 int Mark()const {return flag &16;}47 int Required() { return flag & 64;}48 void SetCracked() { flag |= 1;}49 void SetDup() { flag |= 32;} // not a real edge50 void SetEqui() { flag |= 2;}51 void SetTgA() { flag|=4;}52 void SetTgB() { flag|=8;}53 void SetMark() { flag|=16;}54 void SetUnMark(){ flag &= 1007 /* 1023-16*/;}55 void SetRequired() { flag |= 64;}56 void SetReverseEqui() {flag |= 128;}57 void Set(const GeometricalEdge & rec,const Geometry & Th ,Geometry & ThNew);39 int Tg(int i) const{return i==0 ? TgA() : TgB();} 40 int Cracked() const {return flag & 1; } 41 int Dup() const {return flag & 32; } 42 int Equi()const {return flag & 2; } 43 int ReverseEqui()const {return flag & 128;} 44 int TgA()const {return flag & 4; } 45 int TgB()const {return flag & 8; } 46 int Mark()const {return flag & 16; } 47 int Required() {return flag & 64; } 48 void SetCracked() { flag |= 1; } 49 void SetDup() { flag |= 32; } // not a real edge 50 void SetEqui() { flag |= 2; } 51 void SetTgA() { flag |=4; } 52 void SetTgB() { flag |=8; } 53 void SetMark() { flag |=16; } 54 void SetUnMark() { flag &= 1007 /* 1023-16*/;} 55 void SetRequired() { flag |= 64; } 56 void SetReverseEqui() { flag |= 128;} 57 void Set(const GeometricalEdge & rec,const Geometry & Th ,Geometry & ThNew); 58 58 }; 59 59 -
issm/trunk/src/c/Bamgx/objects/SetOfE4.cpp
r3263 r3272 1 1 2 #include <assert.h> 2 3 #include "BamgObjects.h" 3 4 … … 18 19 //initialize fields 19 20 nx =nnx; //number of vertices 20 nbax =mmx; // 3 * number of triangles21 nbax =mmx; // 3 * number of triangles 21 22 NbOfEdges=0; 22 23 head = new long [nx]; … … 25 26 //initialize head (-1 everywhere) 26 27 i=nx; 27 while 28 while(i--) head[i]=-1; 28 29 } 29 30 /*}}}1*/ … … 66 67 int h,n; 67 68 68 //check that head is not empty69 if (head==NULL) {70 throw ErrorException(__FUNCT__,exprintf("SetOfEdges4::add no head is NULL (How come?)"));71 }72 73 69 //get n from h (usually h=ii) 70 assert(head); 74 71 n=head[h=Abs(ii)%nx]; 75 72 -
issm/trunk/src/c/Bamgx/objects/SetOfE4.h
r3245 r3272 21 21 22 22 public: 23 24 // Constructors 23 25 SetOfEdges4(long ,long);// nb Edges mx , nb de sommet 24 26 ~SetOfEdges4() {delete [] head; delete [] Edges;} 27 28 //operators 29 IntEdge & operator[](long k){return Edges[k];} 30 31 //Methods 25 32 long add (long ii,long jj); 26 33 long SortAndAdd (long ii,long jj) {return ii <=jj ? add (ii,jj) : add (jj,ii) ;} 27 long 34 long nb(){return NbOfEdges;} 28 35 long find (long ii,long jj); 29 36 long SortAndFind (long ii,long jj) {return ii <=jj ? find (ii,jj) : find (jj,ii) ;} … … 31 38 long j(long k){return Edges[k].j;} 32 39 long newarete(long k){return NbOfEdges == k+1;} 33 34 //operators35 IntEdge & operator[](long k){return Edges[k];}36 40 }; 37 41 } -
issm/trunk/src/c/Bamgx/objects/Triangle.h
r3263 r3272 79 79 } 80 80 void SetAdj2(short a,Triangle *t,short aat){ 81 TriaAdjTriangles[a]=t; //the adjacent triangle to the edge a is t81 TriaAdjTriangles[a]=t; //the adjacent triangle to the edge a is t 82 82 TriaAdjSharedEdge[a]=aat; //position of the edge in the adjacent triangle 83 83 if(t) { //if t!=NULL add adjacent triangle to t (this) -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r3267 r3272 23 23 PreInit(0); 24 24 25 /*Read Geometry if provided*/ 26 if(bamggeom->NumEdges>0) { 27 Gh.ReadGeometry(bamggeom,bamgopts); 28 Gh.AfterRead(); 29 } 30 25 31 /*Read background mesh*/ 26 32 ReadMesh(bamgmesh,bamgopts); 27 33 28 /* Read Geometry*/34 /*Build Geometry if not provided*/ 29 35 if(bamggeom->NumEdges==0) { 30 36 /*Recreate geometry if needed*/ 31 37 printf("WARNING: mesh present but no geometry found. Reconstructing...\n"); 32 38 BuildGeometryFromMesh(bamgopts); 33 Gh.AfterRead();34 }35 else{36 Gh.ReadGeometry(bamggeom,bamgopts);37 39 Gh.AfterRead(); 38 40 } … … 511 513 i2=bamgmesh->NumEdgesOnGeometricEdge; 512 514 for (i1=0;i1<i2;i1++) { 513 i=(int)bamgmesh->EdgesOnGeometricEdge[i*2+0]; 514 j=(int)bamgmesh->EdgesOnGeometricEdge[i*2+1]; 515 printf("%i %i\n",(int)bamgmesh->EdgesOnGeometricEdge[i1*2+0],(int)bamgmesh->EdgesOnGeometricEdge[i1*2+1]); 516 } 517 for (i1=0;i1<i2;i1++) { 518 i=(int)bamgmesh->EdgesOnGeometricEdge[i1*2+0]; 519 j=(int)bamgmesh->EdgesOnGeometricEdge[i1*2+1]; 515 520 if(!(i>0 && j >0 && i <= nbe && j <= Gh.nbe)) { 516 throw ErrorException(__FUNCT__,exprintf(" EdgesOnGeometricEdge error: We must have : (i>0 && j >0 && i <= nbe && j <= Gh.nbe)"));521 throw ErrorException(__FUNCT__,exprintf("ReadMesh error: EdgesOnGeometricEdge edge provided (line %i: [%i %i]) is incorrect (must be positive, [0<i<nbe=%i 0<j<Gh.nbe=%i]",i1+1,i,j,nbe,Gh.nbe)); 517 522 } 518 523 edges[i-1].onGeometry = Gh.edges + j-1; … … 2628 2633 */ 2629 2634 2635 /*Intermediary*/ 2630 2636 int verbosity=0; 2631 2637 … … 2634 2640 // find extrema coordinates of vertices pmin,pmax 2635 2641 long i; 2636 if(verbosity>2) printf(" Completing Triangles structure for amesh of %i vertices\n",nbv);2642 if(verbosity>2) printf(" Reconstruct mesh of %i vertices\n",nbv); 2637 2643 2638 2644 //initialize ordre … … 2640 2646 for (i=0;i<nbv;i++) ordre[i]=0; 2641 2647 2648 //Initialize NbSubDomains 2642 2649 NbSubDomains =0; 2643 2650 2644 /* generation of the adjacence of the triangles*/ 2645 2651 /* generation of triangles adjacency*/ 2652 2653 //First add existing edges 2654 long kk =0; 2646 2655 SetOfEdges4* edge4= new SetOfEdges4(nbt*3,nbv); 2647 2648 //initialize st 2656 for (i=0;i<nbe;i++){ 2657 kk=kk+(i==edge4->SortAndAdd(Number(edges[i][0]),Number(edges[i][1]))); 2658 } 2659 if (kk != nbe){ 2660 throw ErrorException(__FUNCT__,exprintf("There are %i double edges in the mesh",kk-nbe)); 2661 } 2662 2663 //Add edges of all triangles in existing mesh 2649 2664 long* st = new long[nbt*3]; 2650 2665 for (i=0;i<nbt*3;i++) st[i]=-1; 2651 2652 //check number of edges2653 long kk =0;2654 for (i=0;i<nbe;i++){2655 kk=kk+(i == edge4->SortAndAdd(Number(edges[i][0]),Number(edges[i][1])));2656 }2657 if (kk != nbe) {2658 throw ErrorException(__FUNCT__,exprintf("Some Double edge in the mesh, the number is %i",kk-nbe));2659 }2660 2661 //2662 2666 for (i=0;i<nbt;i++){ 2663 for (int j=0;j<3;j++) { 2664 long k =edge4->SortAndAdd(Number(triangles[i][VerticesOfTriangularEdge[j][0]]), 2665 Number(triangles[i][VerticesOfTriangularEdge[j][1]])); 2666 long invisible = triangles[i].Hidden(j); 2667 if(st[k]==-1){ 2668 st[k]=3*i+j; 2669 } 2667 for (int j=0;j<3;j++){ 2668 2669 //Add current triangle edge to edge4 2670 long k =edge4->SortAndAdd(Number(triangles[i][VerticesOfTriangularEdge[j][0]]),Number(triangles[i][VerticesOfTriangularEdge[j][1]])); 2671 2672 long invisible=triangles[i].Hidden(j); 2673 2674 //If the edge has not been added to st, add it 2675 if(st[k]==-1) st[k]=3*i+j; 2676 2677 //If the edge already exists, add adjacency 2670 2678 else if(st[k]>=0) { 2671 2679 assert(!triangles[i].TriangleAdj(j)); 2672 2680 assert(!triangles[st[k]/3].TriangleAdj((int) (st[k]%3))); 2673 2681 2674 triangles[i].SetAdj2(j,triangles + st[k] / 3,(int)(st[k]%3));2675 if (invisible) 2676 if (k<nbe) {2677 triangles[i].SetLocked(j); 2678 }2682 triangles[i].SetAdj2(j,triangles+st[k]/3,(int)(st[k]%3)); 2683 if (invisible) triangles[i].SetHidden(j); 2684 if (k<nbe) triangles[i].SetLocked(j); 2685 2686 //Make st[k] negative so that it will throw an error message if it is found again 2679 2687 st[k]=-2-st[k]; 2680 2688 } 2689 2690 //An edge belongs to 2 triangles 2681 2691 else { 2682 2692 throw ErrorException(__FUNCT__,exprintf("The edge (%i , %i) belongs to more than 2 triangles", … … 2685 2695 } 2686 2696 } 2697 2698 //Display info if required 2687 2699 if(verbosity>5) { 2688 printf(" info o nMesh:\n");2700 printf(" info of Mesh:\n"); 2689 2701 printf(" - number of vertices = %i \n",nbv); 2690 2702 printf(" - number of triangles = %i \n",nbt); … … 2694 2706 } 2695 2707 2696 // 2708 //check the consistant of edge[].adj and the geometrical required vertex 2697 2709 long k=0; 2698 2710 for (i=0;i<edge4->nb();i++){ 2699 if (st[i] 2711 if (st[i]>=0){ // edge alone 2700 2712 if (i<nbe){ 2701 2713 long i0=edge4->i(i); … … 2721 2733 2722 2734 /* mesh generation with boundary points*/ 2723 long nbvb =0;2735 long nbvb=0; 2724 2736 for (i=0;i<nbv;i++){ 2725 2737 vertices[i].t=0; 2726 2738 vertices[i].vint=0; 2727 if (ordre[i]){ 2728 ordre[nbvb++]=ordre[i]; 2729 } 2739 if (ordre[i]) ordre[nbvb++]=ordre[i]; 2730 2740 } 2731 2741 … … 2736 2746 subdomains=0; 2737 2747 2738 long Nbtriafillhole =2*nbvb;2739 Triangle* triafillhole 2740 triangles = 2748 long Nbtriafillhole=2*nbvb; 2749 Triangle* triafillhole=new Triangle[Nbtriafillhole]; 2750 triangles = triafillhole; 2741 2751 2742 2752 nbt=2; 2743 2753 nbtx= Nbtriafillhole; 2744 2754 2745 for (i=2 ; det( ordre[0]->i, ordre[1]->i, ordre[i]->i ) == 0;) 2755 //Find a vertex that is not aligned with vertices 0 and 1 2756 for (i=2;det(ordre[0]->i,ordre[1]->i,ordre[i]->i)==0;) 2746 2757 if (++i>=nbvb) { 2747 2758 throw ErrorException(__FUNCT__,exprintf("ReconstructExistingMesh: All the vertices are aligned")); 2748 2759 } 2760 //Move this vertex (i) to the 2d position in ordre 2749 2761 Exchange(ordre[2], ordre[i]); 2750 2762 2763 /*Reconstruct mesh beginning with 2 triangles*/ 2751 2764 Vertex * v0=ordre[0], *v1=ordre[1]; 2752 2765 … … 2774 2787 triangles[1].link=&triangles[0]; 2775 2788 2776 if (!quadtree ) 2777 delete quadtree; // ->ReInitialise(); 2778 2789 if (!quadtree) delete quadtree; //ReInitialise; 2779 2790 quadtree = new QuadTree(this,0); 2780 2791 quadtree->Add(*v0); 2781 2792 quadtree->Add(*v1); 2782 2793 2783 // We add the verticesone by one2794 // vertices are added one by one 2784 2795 long NbSwap=0; 2785 2796 for (int icount=2; icount<nbvb; icount++) { … … 2792 2803 } 2793 2804 2794 // inforce the boundary2805 //enforce the boundary 2795 2806 TriangleAdjacent ta(0,0); 2796 2807 long nbloss = 0,knbe=0; 2797 2808 for ( i = 0; i < nbe; i++){ 2798 if (st[i] >=0){ // edge alone => on border ... FH oct 2009 2799 Vertex & a=edges[i][0], & b = edges[i][1]; 2800 if (a.t && b.t) // le bug est la si maillage avec des bod non raffine 1. 2801 { 2809 if (st[i] >=0){ //edge alone => on border 2810 Vertex &a=edges[i][0], &b=edges[i][1]; 2811 if (a.t && b.t){ 2802 2812 knbe++; 2803 if (ForceEdge(a,b,ta)<0) 2804 nbloss++; 2805 } 2813 if (ForceEdge(a,b,ta)<0) nbloss++; 2814 } 2806 2815 } 2807 2816 } 2808 2817 if(nbloss) { 2809 throw ErrorException(__FUNCT__,exprintf("we lost (?) %iedges other %i",nbloss,knbe));2818 throw ErrorException(__FUNCT__,exprintf("we lost %i existing edges other %i",nbloss,knbe)); 2810 2819 } 2811 2820 … … 2817 2826 if (triangles[i].link){ // remove triangles 2818 2827 krm++; 2819 for (int j=0;j<3;j++) 2820 { 2828 for (int j=0;j<3;j++){ 2821 2829 TriangleAdjacent ta = triangles[i].Adj(j); 2822 Triangle & tta = * (Triangle *) ta; 2823 if(! tta.link) // edge between remove and not remove 2824 { // change the link of ta; 2830 Triangle &tta = *(Triangle*)ta; 2831 //if edge between remove and not remove 2832 if(! tta.link){ 2833 // change the link of ta; 2825 2834 int ja = ta; 2826 2835 Vertex *v0= ta.EdgeVertex(0); 2827 2836 Vertex *v1= ta.EdgeVertex(1); 2828 2837 long k =edge4->SortAndAdd(v0?Number(v0):nbv,v1? Number(v1):nbv); 2829 if (st[k]<0){ 2830 throw ErrorException(__FUNCT__,exprintf("st[k]<0")); 2831 } 2838 2839 assert(st[k]>=0); 2832 2840 tta.SetAdj2(ja,savetriangles + st[k] / 3,(int) (st[k]%3)); 2833 2841 ta.SetLock(); 2834 2842 st[k]=-2-st[k]; 2835 2836 2843 } 2844 } 2837 2845 } 2838 2846 } … … 2843 2851 triangles[i].color=-1; 2844 2852 } 2845 else 2846 { 2853 else{ 2847 2854 triangles[i].color= savenbt+ NbTfillHoll++; 2848 } 2849 } 2850 if (savenbt+NbTfillHoll>savenbtx ){ 2851 throw ErrorException(__FUNCT__,exprintf("savenbt+NbTfillHoll>savenbtx")); 2852 } 2855 } 2856 } 2857 assert(savenbt+NbTfillHoll<=savenbtx); 2858 2853 2859 // copy of the outside triangles in saveTriangles 2854 2860 for (i=0;i<nbt;i++){ … … 2862 2868 k =0; 2863 2869 Triangle * tmax = triangles + nbt; 2864 for (i=0;i<savenbt;i++) 2865 { 2870 for (i=0;i<savenbt;i++) { 2866 2871 Triangle & ti = savetriangles[i]; 2867 for (int j=0;j<3;j++) 2868 { 2872 for (int j=0;j<3;j++){ 2869 2873 Triangle * ta = ti.TriangleAdj(j); 2870 2874 int aa = ti.NuEdgeTriangleAdj(j); 2871 2875 int lck = ti.Locked(j); 2872 2876 if (!ta) k++; // bug 2873 else if ( ta >= triangles && ta < tmax) 2874 { 2877 else if ( ta >= triangles && ta < tmax){ 2875 2878 ta= savetriangles + ta->color; 2876 2879 ti.SetAdj2(j,ta,aa); 2877 2880 if(lck) ti.SetLocked(j); 2878 } 2879 } 2880 } 2881 // OutSidesTriangles = triangles; 2882 // long NbOutSidesTriangles = nbt; 2881 } 2882 } 2883 } 2883 2884 2884 2885 // restore triangles; … … 2896 2897 delete edge4; 2897 2898 delete [] st; 2898 for (i=0;i<nbv;i++) 2899 quadtree->Add(vertices[i]); 2899 for (i=0;i<nbv;i++) quadtree->Add(vertices[i]); 2900 2900 2901 2901 SetVertexFieldOn(); … … 2906 2906 if(edges[i].onGeometry){ 2907 2907 for(int j=0;j<2;j++){ 2908 /*Go through the edges adjacent to current edge (if on the same curve)*/ 2908 2909 if (!edges[i].adj[j]){ 2909 if(!edges[i][j].onGeometry->IsRequiredVertex()) { 2910 printf("Error: adj and vertex requires edges [%i %i]=%i on = %i\n",i,j,Number(edges[i][j]),Gh.Number(edges[i].onGeometry)); 2910 /*The edge is on Geometry and does not have 2 adjacent edges... (not on a closed curve)*/ 2911 /*Check that the 2 vertices are on geometry AND required*/ 2912 if(!edges[i][j].onGeometry->IsRequiredVertex()){ 2913 printf("ReconstructExistingMesh error message: problem with the edge %i: [%i][%i]\n",Number(edges[i][j])+1,i,j); 2914 printf(" This edge is on geometry (Edge of geometry %i)",Gh.Number(edges[i].onGeometry)); 2911 2915 if (edges[i][j].onGeometry->OnGeomVertex()) 2912 2916 printf(" Vertex %i\n",Gh.Number(edges[i][j].onGeometry->gv)); 2913 2917 else if (edges[i][j].onGeometry->OnGeomEdge()) 2914 printf(" Edges %i 2918 printf(" Edges %i\n",Gh.Number(edges[i][j].onGeometry->ge)); 2915 2919 else 2916 2920 printf(" = %p\n",edges[i][j].onGeometry); -
issm/trunk/src/c/Bamgx/objects/Vertex.h
r3263 r3272 30 30 union { 31 31 Triangle* t; // one triangle which is containing the vertex 32 long color;33 Vertex* to; // use in geometry Vertex to now the Mesh Vertex associed34 VertexOnGeom* onGeometry; // if vint == 8; // set with Triangles::SetVertexFieldOn()35 Vertex* onBackgroundVertex;// if vint == 16 on Background vertex Triangles::SetVertexFieldOnBTh()36 VertexOnEdge* onBackgroundEdge; // if vint == 32 on Background edge32 long color; 33 Vertex* to; // use in geometry Vertex to now the Mesh Vertex associed 34 VertexOnGeom* onGeometry; // if vint == 8; // set with Triangles::SetVertexFieldOn() 35 Vertex* onBackgroundVertex;// if vint == 16 on Background vertex Triangles::SetVertexFieldOnBTh() 36 VertexOnEdge* onBackgroundEdge; // if vint == 32 on Background edge 37 37 }; 38 38 39 39 //Operators 40 operator 41 operator 42 operator Metric () const {return m;} 40 operator I2() const {return i;} // Cast operator 41 operator const R2 & () const {return r;} // Cast operator 42 operator Metric () const {return m;} // Cast operator 43 43 double operator()(R2 x) const { return m(x);} // Get x in the metric m 44 44 45 45 //methods (No constructor and no destructors...) 46 46 double Smoothing(Triangles & ,const Triangles & ,Triangle * & ,double =1); 47 void MetricFromHessian(const double Hxx,const double Hyx, const double Hyy, const double smin,const double smax,const double s,const double err,BamgOpts* bamgopts);48 void Echo();49 int ref() const { return ReferenceNumber;}50 long Optim(int =1,int =0);47 void MetricFromHessian(const double Hxx,const double Hyx, const double Hyy, const double smin,const double smax,const double s,const double err,BamgOpts* bamgopts); 48 void Echo(); 49 int ref() const { return ReferenceNumber;} 50 long Optim(int =1,int =0); 51 51 52 52 //inline functions … … 54 54 }; 55 55 56 // FOR NOW (WARNING)56 //Intermediary 57 57 double QuadQuality(const Vertex &,const Vertex &,const Vertex &,const Vertex &); 58 58 } -
issm/trunk/src/c/Bamgx/objects/VertexOnGeom.h
r3267 r3272 40 40 41 41 //Methods 42 int OnGeomVertex()const 42 int OnGeomVertex()const{return this? abscisse <0 :0;} 43 43 int OnGeomEdge() const {return this? abscisse >=0 :0;} 44 int IsRequiredVertex() { return this? ((abscisse<0 ? (gv?gv->Required():0):0 )) : 0;}44 int IsRequiredVertex() {return this? ((abscisse<0 ? (gv?gv->Required():0):0 )) : 0;} 45 45 void SetOn(){mv->onGeometry=this;mv->vint=IsVertexOnGeom;} 46 46 -
issm/trunk/src/m/classes/public/bamg.m
r3268 r3272 139 139 %Get position of the two nodes of the edge in domain 140 140 i1=j; 141 i2=mod(j+1,domain(1).nods -1);141 i2=mod(j+1,domain(1).nods); 142 142 143 143 %rift is crossing edge [i1 i2] of the domain … … 168 168 count=count+nods; 169 169 170 disp(' done');break;170 break; 171 171 end 172 172 end … … 187 187 end 188 188 189 %update other fields of bamg_geometry 190 bamg_geometry.NumVertices=size(bamg_geometry.Vertices,1); 191 bamg_geometry.NumEdges=size(bamg_geometry.Edges,1); 192 bamg_geometry.NumSubDomains=size(bamg_geometry.SubDomains,1); 189 else 190 191 %Use segments as the geometry 192 %bamg_geometry.Vertices=[md.x md.y ones(md.numberofgrids,1)]; 193 %bamg_geometry.Edges=[md.segments(:,1:2) md.segmentmarkers]; 194 %bamg_geometry.Edges 195 193 196 end 197 198 %update other fields of bamg_geometry 199 bamg_geometry.NumVertices=size(bamg_geometry.Vertices,1); 200 bamg_geometry.NumEdges=size(bamg_geometry.Edges,1); 201 bamg_geometry.NumSubDomains=size(bamg_geometry.SubDomains,1); 194 202 %}}} 195 203 … … 201 209 bamg_mesh.NumEdges=0; 202 210 bamg_mesh.Edges=zeros(0,3); 211 bamg_mesh.NumEdgesOnGeometricEdge=0; 212 bamg_mesh.EdgesOnGeometricEdge=zeros(0,2); 213 bamg_mesh.NumVerticesOnGeometricEdge=0; 214 bamg_mesh.VerticesOnGeometricEdge=zeros(0,2); 203 215 bamg_mesh.hVertices=[]; 204 216 bamg_mesh.NumCrackedEdges=0; … … 215 227 end 216 228 end 229 217 230 if isstruct(md.rifts) 218 for i=1:length(md.rifts) 219 bamg_mesh.Edges=[bamg_mesh.Edges;md.rifts(i).segments]; 220 end 221 bamg_mesh.NumEdges=size(bamg_mesh.Edges,1); 222 bamg_mesh.NumCrackedEdges=bamg_mesh.NumEdges; 223 bamg_mesh.CrackedEdges=[1 2;3 4]; 231 error('bamg error message: rifts not supported yet. Do meshprocessrift AFTER bamg'); 224 232 end 225 233 end … … 265 273 266 274 %call Bamg 267 [ triangles vertices segments segmentsmarkers metric]=Bamg(bamg_mesh,bamg_geometry,bamg_options);275 [bamgmesh_out bamggeom_out]=Bamg(bamg_mesh,bamg_geometry,bamg_options); 268 276 269 277 % plug results onto model 270 md.x=vertices(:,1); 271 md.y=vertices(:,2); 272 md.elements=triangles(:,1:3); 273 md.segments=segments; 274 md.segmentmarkers=segmentsmarkers; 275 md.dummy=metric; 278 md.x=bamgmesh_out.Vertices(:,1); 279 md.y=bamgmesh_out.Vertices(:,2); 280 md.elements=bamgmesh_out.Triangles(:,1:3); 281 md.segments=bamgmesh_out.Segments; 282 md.segmentmarkers=bamgmesh_out.SegmentsMarkers; 276 283 277 284 %Fill in rest of fields: -
issm/trunk/src/mex/Bamg/Bamg.cpp
r3271 r3272 42 42 FetchData(&bamgmesh_in.NumCrackedEdges,mxGetField(BAMGMESH,0,"NumCrackedEdges")); 43 43 FetchData(&bamgmesh_in.CrackedEdges,NULL,NULL,mxGetField(BAMGMESH,0,"CrackedEdges")); 44 FetchData(&bamgmesh_in.NumEdges,mxGetField(BAMGMESH,0,"NumEdges")); 45 FetchData(&bamgmesh_in.Edges,NULL,NULL,mxGetField(BAMGMESH,0,"Edges")); 46 FetchData(&bamgmesh_in.NumEdgesOnGeometricEdge,mxGetField(BAMGMESH,0,"NumEdgesOnGeometricEdge")); 47 FetchData(&bamgmesh_in.EdgesOnGeometricEdge,NULL,NULL,mxGetField(BAMGMESH,0,"EdgesOnGeometricEdge")); 48 FetchData(&bamgmesh_in.NumVerticesOnGeometricEdge,mxGetField(BAMGMESH,0,"NumVerticesOnGeometricEdge")); 49 FetchData(&bamgmesh_in.VerticesOnGeometricEdge,NULL,NULL,mxGetField(BAMGMESH,0,"VerticesOnGeometricEdge")); 44 50 if (bamgmesh_in.hVertices && (cols!=1 || lines!=bamgmesh_in.NumVertices)){throw ErrorException(__FUNCT__,exprintf("the size of 'hVertices' should be [%i %i]",bamgmesh_in.NumVertices,1));} 45 51 … … 77 83 Bamgx(&bamgmesh_out,&bamggeom_out,&bamgmesh_in,&bamggeom_in,&bamgopts); 78 84 79 printf("ok0\n");80 81 85 /*Variables*/ 82 86 mxArray* bamgmesh_mat=NULL; … … 114 118 bamgmesh_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames); 115 119 116 printf("ok2\n");117 118 120 mxSetField(bamgmesh_mat,0,"NumTriangles",mxCreateDoubleScalar(bamgmesh_out.NumTriangles)); 119 121 … … 222 224 mxSetField(bamgmesh_mat,0,"SubDomainsFromGeom",pfield2); 223 225 224 printf("ok3\n");225 226 227 226 /*assign output datasets: */ 228 printf("ok4\n");229 227 *BAMGMESHOUT=bamgmesh_mat; 230 printf("ok5\n");231 228 232 229 /*Variables*/ … … 270 267 mxSetField(bamggeom_mat,0,"Edges",pfield2); 271 268 272 273 269 mxSetField(bamggeom_mat,0,"NumTangentAtEdges",mxCreateDoubleScalar(bamggeom_out.NumTangentAtEdges)); 274 270 … … 317 313 318 314 /*assign output datasets: */ 319 printf("ok4\n");320 315 *BAMGGEOMOUT=bamggeom_mat; 321 printf("ok5\n");322 316 323 317 /*Free ressources: */
Note:
See TracChangeset
for help on using the changeset viewer.