Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 3 4 #ifndef tools_box_3f 5 #define tools_box_3f 6 7 #include "../mnmx" 8 9 #include <cfloat> // FLT_MAX 10 11 namespace tools { 12 13 // optimization (used in exlib/sg/text_hershey) : 14 15 inline void box_3f_make_empty(float& a_mn_x,float& a_mn_y,float& a_mn_z, 16 float& a_mx_x,float& a_mx_y,float& a_mx_z){ 17 a_mn_x = FLT_MAX; 18 a_mn_y = FLT_MAX; 19 a_mn_z = FLT_MAX; 20 a_mx_x = -FLT_MAX; 21 a_mx_y = -FLT_MAX; 22 a_mx_z = -FLT_MAX; 23 } 24 inline void box_3f_extend_by(float& a_mn_x,float& a_mn_y,float& a_mn_z, 25 float& a_mx_x,float& a_mx_y,float& a_mx_z, 26 float a_x,float a_y,float a_z){ 27 if(a_mx_x<a_mn_x){ //is empty. 28 a_mn_x = a_x; 29 a_mn_y = a_y; 30 a_mn_z = a_z; 31 32 a_mx_x = a_x; 33 a_mx_y = a_y; 34 a_mx_z = a_z; 35 } else { 36 a_mn_x = mn<float>(a_x,a_mn_x); 37 a_mn_y = mn<float>(a_y,a_mn_y); 38 a_mn_z = mn<float>(a_z,a_mn_z); 39 40 a_mx_x = mx<float>(a_x,a_mx_x); 41 a_mx_y = mx<float>(a_y,a_mx_y); 42 a_mx_z = mx<float>(a_z,a_mx_z); 43 } 44 } 45 inline bool box_3f_is_empty(float a_mn_x,float a_mx_x) { 46 return a_mx_x < a_mn_x; 47 } 48 49 } 50 51 #endif