patch niche rcb issue

This commit is contained in:
Adrian-Diaz 2019-07-19 17:13:44 -06:00
parent 981b9a1f7a
commit 9239c9dedb
1 changed files with 32 additions and 0 deletions

View File

@ -467,6 +467,38 @@ void RCB::compute(int dimension, int n, double **x, double *wt,
}
}
//check if zero box width is the result due to dots being on box vertices
//select half of the box in this case along the best dim
//the best dim is chosen according to the optimum volume (to minimize surface area)
if(largest==0.0){
double best_volume=0;
double current_volume;
int dim1o,dim2o;
for (dim = 0; dim < dimension; dim++){
if(dim==0){
dim1o=1;
dim2o=2;
}
if(dim==1){
dim1o=0;
dim2o=2;
}
if(dim==2){
dim1o=0;
dim2o=1;
}
valuehalf = 0.5*(lo[dim] + hi[dim]);
current_volume = (hi[dim1o]-lo[dim1o])
*(hi[dim2o]-lo[dim2o])*(valuehalf-lo[dim]);
//chose cut that minimizes surface area by maximizing volume;
if(current_volume>best_volume){ best_volume = current_volume;
valuehalf_select = valuehalf;
dim_select = dim;
}
}
}
// copy results for best dim cut into dim,valuehalf,dotmark
dim = dim_select;