Ice Sheet System Model  4.18
Code documentation
Functions
MeshProfileIntersection.cpp File Reference

: takes a .exp file (made of several profiles), and figures out its intersection with a mesh. More...

#include "./MeshProfileIntersection.h"

Go to the source code of this file.

Functions

void MeshProfileIntersectionUsage (void)
 
 WRAPPER (MeshProfileIntersection_python)
 

Detailed Description

: takes a .exp file (made of several profiles), and figures out its intersection with a mesh.

usage: [segments]=MeshProfileIntersection(index,x,y,filename);

where: input: index,x,y is a triangulation filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments) output: segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremities for a segment belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the mesh.

Definition in file MeshProfileIntersection.cpp.

Function Documentation

◆ MeshProfileIntersectionUsage()

void MeshProfileIntersectionUsage ( void  )

Definition at line 20 of file MeshProfileIntersection.cpp.

20  {/*{{{*/
21  _printf_(" usage:\n");
22  _printf_(" [segments]=MeshProfileIntersection(index,x,y,filename);\n");
23  _printf_(" where:\n");
24  _printf_(" input:\n");
25  _printf_(" index,x,y is a triangulation\n");
26  _printf_(" filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)\n");
27  _printf_(" output:\n");
28  _printf_(" segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremities for a segment \n");
29  _printf_(" belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the \n");
30  _printf_(" mesh.\n");
31 }/*}}}*/

◆ WRAPPER()

WRAPPER ( MeshProfileIntersection_python  )

Definition at line 32 of file MeshProfileIntersection.cpp.

32  {
33 
34  int i,j;
35 
36  /* required input: */
37  //mesh
38  double *double_index = NULL;
39  int *index = NULL;
40  int nel;
41  double *x = NULL;
42  double *y = NULL;
43  int nods;
44  int dummy;
45 
46  //contours
47  Contours *domain = NULL;
48  Contour<double> **contours=NULL;
49  int numcontours;
50  Contour<double> *contouri=NULL;
51 
52  /* output: */
53  double* segments=NULL;
54  int numsegs;
55 
56  /*Boot module: */
57  MODULEBOOT();
58 
59  /*checks on arguments: */
60  CHECKARGUMENTS(NLHS,NRHS,&MeshProfileIntersectionUsage);
61 
62  /*Fetch inputs: */
63  //index
64  FetchData(&double_index,&nel,&dummy,INDEX);
65  if(dummy!=3 && dummy!=6)_error_("element triangulation should be of 3 or 6 column width!");
66  index=xNew<int>(nel*3);
67  for(i=0;i<nel;i++){
68  for(j=0;j<3;j++){
69  *(index+3*i+j)=(int)*(double_index+dummy*i+j)-1; //"C" style indexing
70  }
71  }
72  //x and y
73  FetchData(&x,&nods,X);
74  FetchData(&y,&dummy,Y);
75 
76  //contours
77  FetchData(&domain,FILENAME);
78  // MeshProfileIntersectionx should be modified to take DataSet directly (and perhaps IssmDenseMat and IssmSeqVec).
79  numcontours=domain->Size();
80  contours=xNew<Contour<double>*>(numcontours);
81  for(i=0;i<numcontours;i++)
82  *(contours+i)=(Contour<double>*)domain->GetObjectByOffset(i);
83 
84  /*Run interpolation routine: */
85  MeshProfileIntersectionx(&segments,&numsegs,index,x,y,nel,nods,contours,numcontours);
86 
87  /* output: */
88  WriteData(SEGMENTS,segments,numsegs,5);
89 
90  /*end module: */
91  xDelete<double>(double_index);
92  xDelete<int>(index);
93  xDelete<double>(x);
94  xDelete<double>(y);
95  delete domain;
96  delete contouri;
97  xDelete<double>(segments);
98  MODULEEND();
99 
100 }
DataSet::Size
int Size()
Definition: DataSet.cpp:399
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
Contours
Declaration of Contours class.
Definition: Contours.h:10
Contour
Definition: Contour.h:15
MeshProfileIntersectionUsage
void MeshProfileIntersectionUsage(void)
Definition: MeshProfileIntersection.cpp:20
FetchData
void FetchData(char **pstring, char *stringin)
Definition: FetchJavascriptData.cpp:16
MeshProfileIntersectionx
void MeshProfileIntersectionx(double **psegments, int *pnumsegs, int *index, double *x, double *y, int nel, int nods, Contour< IssmPDouble > **contours, int numcontours)
Definition: MeshProfileIntersectionx.cpp:6
NLHS
#define NLHS
Definition: BamgConvertMesh.h:50
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334