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