source: issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.cpp@ 13216

Last change on this file since 13216 was 13216, checked in by Eric.Larour, 13 years ago

NEW: large change to the code, to adapt to ADOLC requirements.

This change relates to the introduction of template classes and functions for the
Option.h abstract class. This is needed, because we want to make the Matlab
API independent from the libCore objects, which are dependent on the IssmDouble*
ADOLC type (adouble), when the Matlab API is dependent on the IssmPDouble* type (double).

To make them independent, we need to be able to specify at run time Options, Matrix and
Vector objects that hold either IssmDouble or IssmPDouble objects. The only way to do
that is through the use of templated classes for Option.h, Matrix and Vector.

The change gets rid of a lot of useless code (especially in the classes/objects/Options
directory), by introducing template versions of the same code.

The bulk of the changes to src/modules and src/mex modules is to adapt to this
new runtime declaration of templated Matrix, Vector and Option objects.

File size: 1.4 KB
RevLine 
[1105]1/*! \file ContourToNodesx.c
2 */
3
4#include "./ContourToNodesx.h"
5
[13216]6int ContourToNodesx( Vector<IssmDouble>** pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue){
[1105]7
8 int i;
9 int m,n;
10
11 /*Contour:*/
12 Contour* contouri=NULL;
[8303]13 int numnodes;
[1105]14 double* xc=NULL;
15 double* yc=NULL;
16 double value;
17
18 /*output: */
[13216]19 Vector<IssmDouble>* flags=NULL;
[1105]20
[13216]21 flags=new Vector<IssmDouble>(nods);
[1105]22
23 /*Loop through all contours: */
24 for (i=0;i<numcontours;i++){
25 contouri=*(contours+i);
[8303]26 numnodes=contouri->nods;
[1105]27 xc=contouri->x;
28 yc=contouri->y;
[8303]29 IsInPoly(flags,xc,yc,numnodes,x,y,0,nods,edgevalue);
[1105]30 }
31
32 /*Assemble vector: */
[11695]33 flags->Assemble();
[1105]34
35 /*Assign output pointers: */
36 *pflags=flags;
[11401]37
38 return 1;
[1105]39}
[12121]40
[13216]41int ContourToNodesx( Vector<IssmDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){
[12121]42
43 int i;
44 int m,n;
45
46 /*Contour:*/
47 Contour* contouri=NULL;
48 int numnodes;
49 double* xc=NULL;
50 double* yc=NULL;
51 double value;
52
53 /*output: */
[13216]54 Vector<IssmDouble>* flags=NULL;
[12121]55
[13216]56 flags=new Vector<IssmDouble>(nods);
[12121]57
58 /*Loop through all contours: */
59 if(contours){
60 for (i=0;i<contours->Size();i++){
61 Contour* contour=(Contour*)contours->GetObjectByOffset(i);
62 IsInPoly(flags,contour->x,contour->y,contour->nods,x,y,0,nods,edgevalue);
63 }
64 }
65
66 /*Assemble vector: */
67 flags->Assemble();
68
69 /*Assign output pointers: */
70 *pflags=flags;
71
72 return 1;
73}
Note: See TracBrowser for help on using the repository browser.