Changeset 3271


Ignore:
Timestamp:
03/12/10 11:13:47 (15 years ago)
Author:
seroussi
Message:

create matlab structures for bamg output

Location:
issm/trunk/src/mex/Bamg
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/mex/Bamg/Bamg.cpp

    r3218 r3271  
    7777        Bamgx(&bamgmesh_out,&bamggeom_out,&bamgmesh_in,&bamggeom_in,&bamgopts);
    7878
    79         /*write output datasets: */
    80         WriteData(TRIANGLESOUT,bamgmesh_out.Triangles,bamgmesh_out.NumTriangles,4);
    81         WriteData(VERTICESOUT,bamgmesh_out.Vertices,bamgmesh_out.NumVertices,3);
    82         WriteData(SEGMENTSOUT,bamgmesh_out.Segments,bamgmesh_out.NumSegments,3);
    83         WriteData(SEGMENTSMARKERSOUT,bamgmesh_out.SegmentsMarkers,bamgmesh_out.NumSegments,1);
    84         WriteData(METRICOUT,bamgopts.metric,bamgmesh_in.NumVertices,3);
     79        printf("ok0\n");
     80
     81        /*Variables*/
     82        mxArray*    bamgmesh_mat=NULL;
     83        mxArray*    pfield=NULL;
     84        mxArray*    pfield2=NULL;
     85        int         numfields=23;
     86        const char* fnames[numfields];
     87        mwSize      ndim=2;
     88        mwSize      dimensions[2]={1,1};
     89
     90        fnames[0] = "NumTriangles";
     91        fnames[1] = "Triangles";
     92        fnames[2] = "NumVertices";
     93        fnames[3] = "Vertices";
     94        fnames[4] = "NumEdges";
     95        fnames[5] = "Edges";
     96        fnames[6] = "NumSegments";
     97        fnames[7] = "Segments";
     98        fnames[8] = "SegmentsMarkers";
     99        fnames[9] = "NumCrackedEdges";
     100        fnames[10] = "CrackedEdges";
     101        fnames[11] = "NumQuadrilaterals";
     102        fnames[12] = "Quadrilaterals";
     103        fnames[13] = "NumVerticesOnGeometricVertex";
     104        fnames[14] = "VerticesOnGeometricVertex";
     105        fnames[15] = "NumVerticesOnGeometricEdge";
     106        fnames[16] = "VerticesOnGeometricEdge";
     107        fnames[17] = "NumEdgesOnGeometricEdge";
     108        fnames[18] = "EdgesOnGeometricEdge";
     109        fnames[19] = "NumSubDomains";
     110        fnames[20] = "SubDomains";
     111        fnames[21] = "NumSubDomainsFromGeom";
     112        fnames[22] = "SubDomainsFromGeom";
     113
     114        bamgmesh_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames);
     115
     116        printf("ok2\n");
     117         
     118        mxSetField(bamgmesh_mat,0,"NumTriangles",mxCreateDoubleScalar(bamgmesh_out.NumTriangles));
     119
     120        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     121        mxSetM(pfield,4);
     122        mxSetN(pfield,bamgmesh_out.NumTriangles);
     123        mxSetPr(pfield,bamgmesh_out.Triangles);
     124        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     125        mxSetField(bamgmesh_mat,0,"Triangles",pfield2);
     126
     127        mxSetField(bamgmesh_mat,0,"NumVertices",mxCreateDoubleScalar(bamgmesh_out.NumVertices));
     128
     129        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     130        mxSetM(pfield,3);
     131        mxSetN(pfield,bamgmesh_out.NumVertices);
     132        mxSetPr(pfield,bamgmesh_out.Vertices);
     133        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     134        mxSetField(bamgmesh_mat,0,"Vertices",pfield2);
     135
     136        mxSetField(bamgmesh_mat,0,"NumEdges",mxCreateDoubleScalar(bamgmesh_out.NumEdges));
     137
     138        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     139        mxSetM(pfield,3);
     140        mxSetN(pfield,bamgmesh_out.NumEdges);
     141        mxSetPr(pfield,bamgmesh_out.Edges);
     142        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     143        mxSetField(bamgmesh_mat,0,"Edges",pfield2);
     144
     145        mxSetField(bamgmesh_mat,0,"NumSegments",mxCreateDoubleScalar(bamgmesh_out.NumSegments));
     146
     147        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     148        mxSetM(pfield,3);
     149        mxSetN(pfield,bamgmesh_out.NumSegments);
     150        mxSetPr(pfield,bamgmesh_out.Segments);
     151        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     152        mxSetField(bamgmesh_mat,0,"Segments",pfield2);
     153
     154        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     155        mxSetM(pfield,1);
     156        mxSetN(pfield,bamgmesh_out.NumSegments);
     157        mxSetPr(pfield,bamgmesh_out.SegmentsMarkers);
     158        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     159        mxSetField(bamgmesh_mat,0,"SegmentsMarkers",pfield2);
     160
     161        mxSetField(bamgmesh_mat,0,"NumCrackedEdges",mxCreateDoubleScalar(bamgmesh_out.NumCrackedEdges));
     162
     163        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     164        mxSetM(pfield,2);
     165        mxSetN(pfield,bamgmesh_out.NumCrackedEdges);
     166        mxSetPr(pfield,bamgmesh_out.CrackedEdges);
     167        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     168        mxSetField(bamgmesh_mat,0,"CrackedEdges",pfield2);
     169
     170        mxSetField(bamgmesh_mat,0,"NumQuadrilaterals",mxCreateDoubleScalar(bamgmesh_out.NumQuadrilaterals));
     171
     172        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     173        mxSetM(pfield,5);
     174        mxSetN(pfield,bamgmesh_out.NumQuadrilaterals);
     175        mxSetPr(pfield,bamgmesh_out.Quadrilaterals);
     176        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     177        mxSetField(bamgmesh_mat,0,"Quadrilaterals",pfield2);
     178
     179        mxSetField(bamgmesh_mat,0,"NumVerticesOnGeometricVertex",mxCreateDoubleScalar(bamgmesh_out.NumVerticesOnGeometricVertex));
     180
     181        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     182        mxSetM(pfield,2);
     183        mxSetN(pfield,bamgmesh_out.NumVerticesOnGeometricVertex);
     184        mxSetPr(pfield,bamgmesh_out.VerticesOnGeometricVertex);
     185        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     186        mxSetField(bamgmesh_mat,0,"VerticesOnGeometricVertex",pfield2);
     187
     188        mxSetField(bamgmesh_mat,0,"NumVerticesOnGeometricEdge",mxCreateDoubleScalar(bamgmesh_out.NumVerticesOnGeometricEdge));
     189
     190        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     191        mxSetM(pfield,2);
     192        mxSetN(pfield,bamgmesh_out.NumVerticesOnGeometricEdge);
     193        mxSetPr(pfield,bamgmesh_out.VerticesOnGeometricEdge);
     194        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     195        mxSetField(bamgmesh_mat,0,"VerticesOnGeometricEdge",pfield2);
     196
     197        mxSetField(bamgmesh_mat,0,"NumEdgesOnGeometricEdge",mxCreateDoubleScalar(bamgmesh_out.NumEdgesOnGeometricEdge));
     198
     199        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     200        mxSetM(pfield,2);
     201        mxSetN(pfield,bamgmesh_out.NumEdgesOnGeometricEdge);
     202        mxSetPr(pfield,bamgmesh_out.EdgesOnGeometricEdge);
     203        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     204        mxSetField(bamgmesh_mat,0,"EdgesOnGeometricEdge",pfield2);
     205
     206        mxSetField(bamgmesh_mat,0,"NumSubDomains",mxCreateDoubleScalar(bamgmesh_out.NumSubDomains));
     207
     208        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     209        mxSetM(pfield,4);
     210        mxSetN(pfield,bamgmesh_out.NumSubDomains);
     211        mxSetPr(pfield,bamgmesh_out.SubDomains);
     212        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     213        mxSetField(bamgmesh_mat,0,"SubDomains",pfield2);
     214
     215        mxSetField(bamgmesh_mat,0,"NumSubDomainsFromGeom",mxCreateDoubleScalar(bamgmesh_out.NumSubDomainsFromGeom));
     216
     217        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     218        mxSetM(pfield,4);
     219        mxSetN(pfield,bamgmesh_out.NumSubDomainsFromGeom);
     220        mxSetPr(pfield,bamgmesh_out.SubDomainsFromGeom);
     221        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     222        mxSetField(bamgmesh_mat,0,"SubDomainsFromGeom",pfield2);
     223
     224        printf("ok3\n");
     225
     226
     227        /*assign output datasets: */
     228        printf("ok4\n");
     229        *BAMGMESHOUT=bamgmesh_mat;
     230        printf("ok5\n");
     231
     232        /*Variables*/
     233        mxArray*    bamggeom_mat=NULL;
     234        int         numfields2=14;
     235        const char* fnames2[numfields];
     236
     237        fnames[0] = "NumVertices";
     238        fnames[1] = "Vertices";
     239        fnames[2] = "NumEdges";
     240        fnames[3] = "Edges";
     241        fnames[4] = "NumTangentAtEdges";
     242        fnames[5] = "TangentAtEdges";
     243        fnames[6] = "NumRequiredVertices";
     244        fnames[7] = "RequiredVertices";
     245        fnames[8] = "NumRequiredEdges";
     246        fnames[9] = "RequiredEdges";
     247        fnames[10]= "NumCrackedEdges";
     248        fnames[11]= "CrackedEdges";
     249        fnames[12]= "NumEdges";
     250        fnames[13]= "SubDomains";
     251
     252        bamggeom_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames);
     253
     254        mxSetField(bamggeom_mat,0,"NumVertices",mxCreateDoubleScalar(bamggeom_out.NumVertices));
     255
     256        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     257        mxSetM(pfield,3);
     258        mxSetN(pfield,bamggeom_out.NumVertices);
     259        mxSetPr(pfield,bamggeom_out.Vertices);
     260        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     261        mxSetField(bamggeom_mat,0,"Vertices",pfield2);
     262
     263        mxSetField(bamggeom_mat,0,"NumEdges",mxCreateDoubleScalar(bamggeom_out.NumEdges));
     264
     265        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     266        mxSetM(pfield,3);
     267        mxSetN(pfield,bamggeom_out.NumEdges);
     268        mxSetPr(pfield,bamggeom_out.Edges);
     269        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     270        mxSetField(bamggeom_mat,0,"Edges",pfield2);
     271
     272
     273        mxSetField(bamggeom_mat,0,"NumTangentAtEdges",mxCreateDoubleScalar(bamggeom_out.NumTangentAtEdges));
     274
     275        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     276        mxSetM(pfield,4);
     277        mxSetN(pfield,bamggeom_out.NumTangentAtEdges);
     278        mxSetPr(pfield,bamggeom_out.TangentAtEdges);
     279        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     280        mxSetField(bamggeom_mat,0,"TangentAtEdges",pfield2);
     281
     282        mxSetField(bamggeom_mat,0,"NumRequiredVertices",mxCreateDoubleScalar(bamggeom_out.NumRequiredVertices));
     283
     284        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     285        mxSetM(pfield,1);
     286        mxSetN(pfield,bamggeom_out.NumRequiredVertices);
     287        mxSetPr(pfield,bamggeom_out.RequiredVertices);
     288        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     289        mxSetField(bamggeom_mat,0,"RequiredVertices",pfield2);
     290
     291        mxSetField(bamggeom_mat,0,"NumRequiredEdges",mxCreateDoubleScalar(bamggeom_out.NumRequiredEdges));
     292
     293        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     294        mxSetM(pfield,1);
     295        mxSetN(pfield,bamggeom_out.NumRequiredEdges);
     296        mxSetPr(pfield,bamggeom_out.RequiredEdges);
     297        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     298        mxSetField(bamggeom_mat,0,"RequiredEdges",pfield2);
     299
     300        mxSetField(bamggeom_mat,0,"NumCrackedEdges",mxCreateDoubleScalar(bamggeom_out.NumCrackedEdges));
     301
     302        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     303        mxSetM(pfield,2);
     304        mxSetN(pfield,bamggeom_out.NumCrackedEdges);
     305        mxSetPr(pfield,bamggeom_out.CrackedEdges);
     306        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     307        mxSetField(bamggeom_mat,0,"CrackedEdges",pfield2);
     308
     309        mxSetField(bamggeom_mat,0,"NumSubDomains",mxCreateDoubleScalar(bamggeom_out.NumSubDomains));
     310
     311        pfield=mxCreateDoubleMatrix(0,0,mxREAL);
     312        mxSetM(pfield,4);
     313        mxSetN(pfield,bamggeom_out.NumSubDomains);
     314        mxSetPr(pfield,bamggeom_out.SubDomains);
     315        mexCallMATLAB(1,&pfield2,1,&pfield,"'");//transpose
     316        mxSetField(bamggeom_mat,0,"SubDomains",pfield2);
     317
     318        /*assign output datasets: */
     319        printf("ok4\n");
     320        *BAMGGEOMOUT=bamggeom_mat;
     321        printf("ok5\n");
    85322
    86323        /*Free ressources: */
  • issm/trunk/src/mex/Bamg/Bamg.h

    r2977 r3271  
    2323
    2424/* serial output macros: */
    25 #define TRIANGLESOUT       (mxArray**)&plhs[0]
    26 #define VERTICESOUT        (mxArray**)&plhs[1]
    27 #define SEGMENTSOUT        (mxArray**)&plhs[2]
    28 #define SEGMENTSMARKERSOUT (mxArray**)&plhs[3]
    29 #define METRICOUT          (mxArray**)&plhs[4]
     25#define BAMGMESHOUT    (mxArray**)&plhs[0]
     26#define BAMGGEOMOUT    (mxArray**)&plhs[1]
    3027
    3128/* serial arg counts: */
    3229#undef NLHS
    33 #define NLHS  5
     30#define NLHS  2
    3431#undef NRHS
    3532#define NRHS  3
Note: See TracChangeset for help on using the changeset viewer.