//DEBTRACE("triangle node 0: " << v[0][0] << " " << v[0][1] << " " << v[0][2]);
//DEBTRACE("triangle node 1: " << v[1][0] << " " << v[1][1] << " " << v[1][2]);
//DEBTRACE("triangle node 2: " << v[2][0] << " " << v[2][1] << " " << v[2][2]);
+
// compute barycentric coordinates (https://en.wikipedia.org/wiki/Barycentric_coordinate_system)
// det = (y2-y3)(x1-x3)+(x3-x2)(y1-y3)
double det = (v[1][1]-v[2][1])*(v[0][0]-v[2][0]) + (v[2][0]-v[1][0])*(v[0][1]-v[2][1]);
DEBTRACE("adjust precision to: " << aQuadtree->getPrecision());
aQuadtree->NodesAround(thePoint, dist2nodes, aQuadtree->getPrecision());
}
- //aQuadtree->NodesAround(thePoint, dist2nodes, 5.0);
std::map<double, const gpi_XYZ*>::const_iterator it = dist2nodes.begin();
aResAltitude = it->second->Z();
int nodeIndex = it->second->getIndex();
cells->Allocate(64);
vtkIdList* points= vtkIdList::New();
points->Allocate(64);
- DEBTRACE("---");
aDelaunay2D->GetPointCells(nodeIndex, cells);
vtkIdType nbCells = cells->GetNumberOfIds();
- DEBTRACE(nbCells);
+ DEBTRACE(" triangles on nearest point: " << nbCells);
+ bool isInside = false;
for (int i=0; i<nbCells; i++)
{
aDelaunay2D->GetCellPoints(cells->GetId(i), points);
double z = 0;
- if (interpolZtriangle(thePoint, aDelaunay2D, points, z))
+ isInside = interpolZtriangle(thePoint, aDelaunay2D, points, z);
+ if (isInside)
{
aResAltitude = z;
- DEBTRACE("interpolated z: " << z);
+ DEBTRACE(" interpolated z: " << z);
break;
}
- else
- {
- DEBTRACE("point outside triangles, nearest z kept");
- }
}
+ if (!isInside) DEBTRACE(" point outside triangles, nearest z kept");
}
return aResAltitude;
}