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