11 pnt closest_pnt = pSource->
get_point( rClosestPointNumber );
15 vector<int> grid_points;
17 grid_points.push_back(-1);
18 grid_points.push_back(-1);
19 grid_points.push_back(-1);
20 grid_points.push_back(-1);
26 std::list<int*> tri_str;
29 for(
int j=0;
j<near_pts.size();
j++){
30 for(
int k=
j;
k<near_pts.size();
k++){
41 int *t_add =
new int[2];
42 t_add[0] = near_pts[
j];
43 t_add[1] = near_pts[
k];
45 tri_str.push_back(t_add);
55 for(list<int*>::iterator it = tri_str.begin(); it != tri_str.end(); it++){
64 for(
int j=0;
j<near_pts_x.size();
j++){
65 for(
int k=0;
k<near_pts_y.size();
k++){
67 if( near_pts_x[
j] == near_pts_y[
k] ){
69 mp_str[matched_pts] = near_pts_x[
j];
77 && mp_str[0] != mp_str[1]
78 && mp_str[0] != (*it)[0]
79 && mp_str[0] != (*it)[1]
80 && mp_str[1] != (*it)[0]
81 && mp_str[1] != (*it)[1] ){
83 grid_points[0] = (*it)[0];
84 grid_points[1] = (*it)[1];
85 grid_points[2] = mp_str[0];
86 grid_points[3] = mp_str[1];
92 for(list<int*>::iterator it = tri_str.begin(); it != tri_str.end(); it++){
105 vector< int > sorted_points;
108 if(pSource == NULL || rGridPoints.size() != 4)
109 return sorted_points;
112 while( rGridPoints.size() > 0 ){
115 int curr_point = rGridPoints.back();
116 rGridPoints.pop_back();
120 vector<int>::iterator it;
122 for(it = sorted_points.begin(); it < sorted_points.end(); it++){
125 if(to_insert.
vals[0] < curr_sorted.
vals[0]){
126 sorted_points.insert(it, curr_point);
132 if(it == sorted_points.end())
133 sorted_points.push_back(curr_point);
139 int zero = sorted_points[0];
140 sorted_points[0] = sorted_points[1];
141 sorted_points[1] = zero;
145 int two = sorted_points[2];
146 sorted_points[2] = sorted_points[3];
147 sorted_points[3] = two;
150 return sorted_points;
159 if( pTarget == NULL || pSource == NULL )
176 int dropped_points = 0;
186 coord[m] = tgt_pnt.
vals[m];
197 vector<int> grid_points =
getCell( pTarget, pSource,
i, closest );
202 if( grid_points[0] < 0 || grid_points[1] < 0 ||
203 grid_points[2] < 0 || grid_points[3] < 0 ){
212 vector<int> sorted_points =
sortPoints(pSource, grid_points);
214 long double bot_right_0 = pSource->
get_point(sorted_points[3]).
vals[0];
215 long double bot_left_0 = pSource->
get_point(sorted_points[0]).
vals[0];
216 long double top_left_1 = pSource->
get_point(sorted_points[1]).
vals[1];
217 long double bot_left_1 = pSource->
get_point(sorted_points[0]).
vals[1];
219 long double source_vals[4];
226 for(
int sp_num = 0; sp_num < sorted_points.size(); sp_num++){
227 source_vals[sp_num] = pSource->
get_point(sorted_points[sp_num]).
vals[rSourceVariable];
231 long double dist_0 = bot_right_0 - bot_left_0;
232 long double dist_1 = top_left_1 - bot_left_1;
235 long double tgt_0 = tgt_pnt.
vals[0];
236 long double tgt_1 = tgt_pnt.
vals[1];
238 long double t = (tgt_0 - bot_left_0) / dist_0;
239 long double u = (tgt_1 - bot_left_1) / dist_1;
241 long double interp_val = (1-t)*(1-u)*source_vals[0] + t*(1-u)*source_vals[1];
242 interp_val += t*u*source_vals[2] + (1-t)*u*source_vals[3];
virtual std::vector< int > get_connected_points(int point_num)
static vector< int > sortPoints(points *pSource, vector< int > rGridPoints)
Sort points (rGridPoints) from pSouce into a vector where 0 - Bottom Left 1 - Top Left 2 - Top Right ...
int coord[NPANE][NROW *NCOL][3]
void set_point_val(int point_number, int var, long double val)
Point object that represents a single point.
static points * bilinear(points *pTarget, points *pSource, int rTargetVariable, int rSourceVariable)
Performs bilinear interpolation to find values from source mesh at the target points.
virtual int get_closest(long double *coord)
bool pnt_in_tri(pnt test, pnt p1, pnt p2, pnt p3)
static vector< int > getCell(points *pTarget, points *pSource, int rTargetPointNumber, int rClosestPointNumber)
Get a points surrounding a target point in a mesh.