| 1 | /*\file BamgTriangulate.c
|
|---|
| 2 | *\brief: bamg module.
|
|---|
| 3 | */
|
|---|
| 4 | #include "./BamgTriangulate.h"
|
|---|
| 5 |
|
|---|
| 6 | void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
|
|---|
| 7 |
|
|---|
| 8 | /*input: */
|
|---|
| 9 | double* x=NULL;
|
|---|
| 10 | double* y=NULL;
|
|---|
| 11 | int x_cols;
|
|---|
| 12 | int y_rows,y_cols;
|
|---|
| 13 | int nods;
|
|---|
| 14 |
|
|---|
| 15 | /*Output*/
|
|---|
| 16 | int* index=NULL;
|
|---|
| 17 | int nels;
|
|---|
| 18 |
|
|---|
| 19 | /*Intermediary*/
|
|---|
| 20 | int verbose=0;
|
|---|
| 21 |
|
|---|
| 22 | /*Boot module: */
|
|---|
| 23 | MODULEBOOT();
|
|---|
| 24 |
|
|---|
| 25 | /*checks on arguments on the matlab side: */
|
|---|
| 26 | CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&BamgTriangulateUsage);
|
|---|
| 27 |
|
|---|
| 28 | /*Input datasets: */
|
|---|
| 29 | if (verbose) _printLine_("Fetching inputs");
|
|---|
| 30 | FetchData(&x,&nods,&x_cols,XHANDLE);
|
|---|
| 31 | FetchData(&y,&y_rows,&y_cols,YHANDLE);
|
|---|
| 32 |
|
|---|
| 33 | /*Check inputs*/
|
|---|
| 34 | if(y_rows!=nods) _error2_("x and y do not have the same length");
|
|---|
| 35 | if(x_cols>1 || y_cols>1) _error2_("x and y should have only one column");
|
|---|
| 36 | if(nods<3) _error2_("At least 3 points are required");
|
|---|
| 37 |
|
|---|
| 38 | /* Run core computations: */
|
|---|
| 39 | if (verbose) _printLine_("Call core");
|
|---|
| 40 | BamgTriangulatex(&index,&nels,x,y,nods);
|
|---|
| 41 |
|
|---|
| 42 | /*Write output*/
|
|---|
| 43 | WriteData(INDEX,index,nels,3);
|
|---|
| 44 |
|
|---|
| 45 | /*end module: */
|
|---|
| 46 | MODULEEND();
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | void BamgTriangulateUsage(void)
|
|---|
| 50 | {
|
|---|
| 51 | _pprintString_("BAMGTRIANGULATE - Delaunay Triangulation of a list of points");
|
|---|
| 52 | _pprintLine_("");
|
|---|
| 53 | _pprintLine_(" Usage:");
|
|---|
| 54 | _pprintLine_(" index=BamgTriangulate(x,y);");
|
|---|
| 55 | _pprintLine_(" index: index of the triangulation");
|
|---|
| 56 | _pprintLine_(" x,y: coordinates of the nodes");
|
|---|
| 57 | _pprintLine_("");
|
|---|
| 58 | }
|
|---|