diff --git a/hurricane/src/hurricane/hurricane/Commons.h b/hurricane/src/hurricane/hurricane/Commons.h index 9b3b3a11..3024c8ab 100644 --- a/hurricane/src/hurricane/hurricane/Commons.h +++ b/hurricane/src/hurricane/hurricane/Commons.h @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -132,6 +133,33 @@ namespace Hurricane { inline string demangle ( const type_info& info ) { return demangle(info.name()); } +// For a complete explanation of this function, please look at : +// http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm + + inline int floatCompare ( float a, float b ) + { + assert ( sizeof(float) == sizeof(int) ); + + if ( a == b ) return 0; + return *(int*)&a - *(int*)&b; + } + + inline int floatDifference ( float a, float b, int threshold ) + { + int difference = floatCompare(a,b); + if ( abs(difference) < threshold ) return 0; + + return (difference<0) ? -1 : 1; + } + + + inline void floatRound ( float& value, float precision ) + { + float rounded = roundf ( value*precision ); + value = rounded / precision; + } + + } // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/hurricane/Net.h b/hurricane/src/hurricane/hurricane/Net.h index 0122ce7e..3503d155 100644 --- a/hurricane/src/hurricane/hurricane/Net.h +++ b/hurricane/src/hurricane/hurricane/Net.h @@ -296,6 +296,10 @@ INSPECTOR_P_SUPPORT(Hurricane::Net::ComponentSet); INSPECTOR_P_SUPPORT(Hurricane::Net::RubberSet); INSPECTOR_PV_SUPPORT(Hurricane::Net::Type); INSPECTOR_PV_SUPPORT(Hurricane::Net::Direction); +IOSTREAM_POINTER_SUPPORT(Hurricane::Net::Type::Code); +IOSTREAM_VALUE_SUPPORT(Hurricane::Net::Type::Code); +IOSTREAM_POINTER_SUPPORT(Hurricane::Net::Direction::Code); +IOSTREAM_VALUE_SUPPORT(Hurricane::Net::Direction::Code); #endif // HURRICANE_NET