Ice Sheet System Model  4.18
Code documentation
ContourToMesh.cpp
Go to the documentation of this file.
1 
6 #include "./ContourToMesh.h"
7 
8 void ContourToMeshUsage(void){/*{{{*/
9  _printf_("CONTOURTOMESH - Flag the elements or nodes inside a contour\n");
10  _printf_("\n");
11  _printf_(" Usage: \n");
12  _printf_(" [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n");
13  _printf_("\n");
14  _printf_(" index,x,y: mesh triangulation.\n");
15  _printf_(" contourname: name of .exp file containing the contours.\n");
16  _printf_(" interptype: string definining type of interpolation ('element', or 'node').\n");
17  _printf_(" edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
18  _printf_(" in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', \n");
19  _printf_(" or of size 0 otherwise.\n");
20  _printf_(" in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', \n");
21  _printf_(" or of size 0 otherwise.\n");
22  _printf_("\n");
23  _printf_(" Example: \n");
24  _printf_(" in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)\n");
25  _printf_(" in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)\n");
26  _printf_(" [in_nodes,in_elements]=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0)\n");
27  _printf_("\n");
28 }/*}}}*/
29 WRAPPER(ContourToMesh_python){
30 
31  /* required input: */
32  int edgevalue;
33  int nel,nods;
34  double *index = NULL;
35  double *x = NULL;
36  double *y = NULL;
37  char *interptype = NULL;
38  Contours *contours = NULL;
39 
40  /* output: */
41  double *in_nod = NULL;
42  double *in_elem = NULL;
43 
44  /*Boot module: */
45  MODULEBOOT();
46 
47  /*checks on output arguments on the matlab side: */
48  #ifdef _HAVE_MATLAB_MODULES_
49  if(nlhs!=1 && nlhs!=2){
51  _error_("usage. See above");
52  }
53  #endif
54  /*check on input arguments: */
55  if(nrhs!=NRHS){
57  _error_("usage. See above");
58  }
59 
60  /*Fetch inputs: */
61  FetchData(&index,&nel,NULL,INDEX);
62  FetchData(&x,&nods,NULL,X);
63  FetchData(&y,NULL,NULL,Y);
64  FetchData(&edgevalue,EDGEVALUE);
65  FetchData(&contours,CONTOUR);
66  FetchData(&interptype,INTERPTYPE);
67 
68  /*Run interpolation routine: */
69  ContourToMeshx( &in_nod,&in_elem,index,x,y,contours,interptype,nel,nods,edgevalue);
70 
71  /* output: */
72  WriteData(PLHS0,in_nod,nods);
73  WriteData(PLHS1,in_elem,nel);
74 
75  /*Clean up*/
76  xDelete<double>(index);
77  xDelete<double>(x);
78  xDelete<double>(y);
79  xDelete<char>(interptype);
80  delete contours;
81  xDelete<double>(in_nod);
82  xDelete<double>(in_elem);
83  /*end module: */
84  MODULEEND();
85 }
ContourToMesh.h
WriteData
void WriteData(IssmPDouble **pmatrix, int *pnel, int *matrix, int M, int N)
Definition: WriteJavascriptData.cpp:16
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
NRHS
#define NRHS
Definition: BamgConvertMesh.h:52
ContourToMeshx
int ContourToMeshx(double **pin_nod, double **pin_elem, double *index, double *x, double *y, Contours *contours, char *interptype, int nel, int nods, int edgevalue)
Definition: ContourToMeshx.cpp:12
Contours
Declaration of Contours class.
Definition: Contours.h:10
ContourToMeshUsage
void ContourToMeshUsage(void)
Definition: ContourToMesh.cpp:8
FetchData
void FetchData(char **pstring, char *stringin)
Definition: FetchJavascriptData.cpp:16
WRAPPER
WRAPPER(ContourToMesh_python)
Definition: ContourToMesh.cpp:29
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49