Skip to content
Snippets Groups Projects
Commit 287ffcb0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

don't crash if #points in tree is < 2

parent af4fc861
No related branches found
No related tags found
No related merge requests found
...@@ -556,6 +556,7 @@ double backgroundMesh::operator() (double u, double v, double w) const ...@@ -556,6 +556,7 @@ double backgroundMesh::operator() (double u, double v, double w) const
if (!e) { if (!e) {
#if defined(HAVE_ANN) #if defined(HAVE_ANN)
//printf("BGM octree not found --> find in kdtree \n"); //printf("BGM octree not found --> find in kdtree \n");
if(uv_kdtree->nPoints() < 2) return -1000.;
double pt[3] = {u, v, 0.0}; double pt[3] = {u, v, 0.0};
uv_kdtree->annkSearch(pt, 2, index, dist); uv_kdtree->annkSearch(pt, 2, index, dist);
SPoint3 p1(nodes[index[0]][0], nodes[index[0]][1], nodes[index[0]][2]); SPoint3 p1(nodes[index[0]][0], nodes[index[0]][1], nodes[index[0]][2]);
...@@ -584,6 +585,8 @@ double backgroundMesh::getAngle(double u, double v, double w) const ...@@ -584,6 +585,8 @@ double backgroundMesh::getAngle(double u, double v, double w) const
// generate a spurious mesh and solve a PDE // generate a spurious mesh and solve a PDE
if (!_octree){ if (!_octree){
#if defined(HAVE_ANN) #if defined(HAVE_ANN)
double angle = 0.;
if(angle_kdtree->nPoints() >= _NBANN){
double pt[3] = {u,v,0.0}; double pt[3] = {u,v,0.0};
angle_kdtree->annkSearch(pt, _NBANN, index, dist); angle_kdtree->annkSearch(pt, _NBANN, index, dist);
double SINE = 0.0 , COSINE = 0.0; double SINE = 0.0 , COSINE = 0.0;
...@@ -592,7 +595,8 @@ double backgroundMesh::getAngle(double u, double v, double w) const ...@@ -592,7 +595,8 @@ double backgroundMesh::getAngle(double u, double v, double w) const
COSINE += _cos[index[i]]; COSINE += _cos[index[i]];
// printf("%2d %2d %12.5E %12.5E\n",i,index[i],_sin[index[i]],_cos[index[i]]); // printf("%2d %2d %12.5E %12.5E\n",i,index[i],_sin[index[i]],_cos[index[i]]);
} }
double angle = atan2(SINE,COSINE)/4.0; angle = atan2(SINE,COSINE)/4.0;
}
crossField2d::normalizeAngle (angle); crossField2d::normalizeAngle (angle);
return angle; return angle;
#endif #endif
...@@ -614,6 +618,7 @@ double backgroundMesh::getAngle(double u, double v, double w) const ...@@ -614,6 +618,7 @@ double backgroundMesh::getAngle(double u, double v, double w) const
if (!e) { if (!e) {
#if defined(HAVE_ANN) #if defined(HAVE_ANN)
//printf("BGM octree not found --> find in kdtree \n"); //printf("BGM octree not found --> find in kdtree \n");
if(uv_kdtree->nPoints() < 2) return -1000.0;
double pt[3] = {u,v,0.0}; double pt[3] = {u,v,0.0};
uv_kdtree->annkSearch(pt, 2, index, dist); uv_kdtree->annkSearch(pt, 2, index, dist);
SPoint3 p1(nodes[index[0]][0], nodes[index[0]][1], nodes[index[0]][2]); SPoint3 p1(nodes[index[0]][0], nodes[index[0]][1], nodes[index[0]][2]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment