OSGBaseFunctions.inl

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  *                                                                           *
00016  * This library is free software; you can redistribute it and/or modify it   *
00017  * under the terms of the GNU Library General Public License as published    *
00018  * by the Free Software Foundation, version 2.                               *
00019  *                                                                           *
00020  * This library is distributed in the hope that it will be useful, but       *
00021  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00023  * Library General Public License for more details.                          *
00024  *                                                                           *
00025  * You should have received a copy of the GNU Library General Public         *
00026  * License along with this library; if not, write to the Free Software       *
00027  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00028  *                                                                           *
00029  *                                                                           *
00030 \*---------------------------------------------------------------------------*/
00031 /*---------------------------------------------------------------------------*\
00032  *                                Changes                                    *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037  *                                                                           *
00038  *                                                                           *
00039 \*---------------------------------------------------------------------------*/
00040
00041 OSG_BEGIN_NAMESPACE
00042
00043 //---------------------------------------------------------------------------
00044 //   Base Math Functions
00045 //---------------------------------------------------------------------------
00046
00047 //#define OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00048
00049 /*---------------------------------------------------------------------*/
00063 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00064 
00066 template <class FloatTypeT> inline
00067 typename TypeTraits<FloatTypeT>::RealReturnType
00068     osgSqrt(const FloatTypeT rValue)
00069 {
00070     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00071
00072     return  osgSqrt(RealType(rValue));
00073 }
00074 #endif
00075 
00078 inline
00079 OSG::Real32 osgSqrt(const OSG::Real32 rValue)
00080 {
00081 #ifdef OSG_USE_STDMATH
00082     return std::sqrt(rValue);
00083 #elif defined(OSG_HAS_FLOATMATH)
00084     return sqrtf(rValue);
00085 #else
00086     return static_cast<Real32>(sqrt(static_cast<Real32>(rValue)));
00087 #endif
00088 }
00089
00092 inline
00093 OSG::Real64 osgSqrt(const OSG::Real64 rValue)
00094 {
00095 #ifdef OSG_USE_STDMATH
00096     return std::sqrt(rValue);
00097 #else
00098     return sqrt(rValue);
00099 #endif
00100 }
00101
00104 inline
00105 OSG::Real128 osgSqrt(const OSG::Real128 rValue)
00106 {
00107 #ifdef OSG_USE_STDMATH
00108     return std::sqrt(rValue);
00109 #else
00110     return sqrtl(rValue);
00111 #endif
00112 }
00113
00114
00117 inline
00118 OSG::Fixed32 osgSqrt(const OSG::Fixed32 rValue)
00119 {
00120     return Fixed32::sqrt(rValue);
00121 }
00122
00123 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00124 
00126 template <class FloatTypeT> inline
00127 typename TypeTraits<FloatTypeT>::RealReturnType
00128     osgSqrt(const FloatTypeT rValue)
00129 {
00130     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00131
00132     return  osgSqrt(RealType(rValue));
00133 }
00134 #endif
00135 
00136 #ifdef OSG_1_COMPAT
00137 
00150 template <class FloatTypeT> inline
00151 typename TypeTraits<FloatTypeT>::RealReturnType
00152 osgsqrt(const FloatTypeT rValue)
00153 {
00154     return OSG::osgSqrt(rValue);
00155 }
00156
00159 inline
00160 OSG::Real32 osgsqrt(const OSG::Real32 rValue)
00161 {
00162     return OSG::osgSqrt(rValue);
00163 }
00164
00167 inline
00168 OSG::Real64 osgsqrt(const OSG::Real64 rValue)
00169 {
00170     return OSG::osgSqrt(rValue);
00171 }
00172
00175 inline
00176 OSG::Real128 osgsqrt(const OSG::Real128 rValue)
00177 {
00178     return OSG::osgSqrt(rValue);
00179 }
00180
00183 inline
00184 OSG::Fixed32 osgsqrt(const OSG::Fixed32 rValue)
00185 {
00186     return OSG::osgSqrt(rValue);
00187 }
00188 #endif  // OSG_1_COMPAT
00189 
00191 /*---------------------------------------------------------------------*/
00204 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00205 
00207 template <class FloatTypeT> inline
00208 typename TypeTraits<FloatTypeT>::RealReturnType
00209     osgCos(const FloatTypeT rValue)
00210 {
00211     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00212
00213     return  osgCos(RealType(rValue));
00214 }
00215 #endif
00216 
00219 inline
00220 OSG::Real32 osgCos(const OSG::Real32 rValue)
00221 {
00222 #ifdef OSG_USE_STDMATH
00223     return std::cos(rValue);
00224 #elif defined(OSG_HAS_FLOATMATH)
00225     return cosf(rValue);
00226 #else
00227     return static_cast<Real32>(cos(static_cast<Real32>(rValue)));
00228 #endif
00229 }
00230
00233 inline
00234 OSG::Real64 osgCos(const OSG::Real64 rValue)
00235 {
00236 #ifdef OSG_USE_STDMATH
00237     return std::cos(rValue);
00238 #else
00239     return cos(rValue);
00240 #endif
00241 }
00242
00245 inline
00246 OSG::Real128 osgCos(const OSG::Real128 rValue)
00247 {
00248 #ifdef OSG_USE_STDMATH
00249     return std::cos(rValue);
00250 #else
00251     return cosl(rValue);
00252 #endif
00253 }
00254
00257 inline
00258 OSG::Fixed32 osgCos(const OSG::Fixed32 rValue)
00259 {
00260     return Fixed32::cos(rValue);
00261 }
00262
00263 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00264 
00266 template <class FloatTypeT> inline
00267 typename TypeTraits<FloatTypeT>::RealReturnType
00268     osgCos(const FloatTypeT rValue)
00269 {
00270     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00271
00272     return  osgCos(RealType(rValue));
00273 }
00274 #endif
00275 
00276 #ifdef OSG_1_COMPAT
00277 
00289 template <class FloatTypeT> inline
00290 typename TypeTraits<FloatTypeT>::RealReturnType
00291     osgcos(const FloatTypeT rValue)
00292 {
00293     return OSG::osgCos(rValue);
00294 }
00295
00298 inline
00299 OSG::Real32 osgcos(const OSG::Real32 rValue)
00300 {
00301     return OSG::osgCos(rValue);
00302 }
00303
00306 inline
00307 OSG::Real64 osgcos(const OSG::Real64 rValue)
00308 {
00309     return OSG::osgCos(rValue);
00310 }
00311
00314 inline
00315 OSG::Real128 osgcos(const OSG::Real128 rValue)
00316 {
00317     return OSG::osgCos(rValue);
00318 }
00319
00322 inline
00323 OSG::Fixed32 osgcos(const OSG::Fixed32 rValue)
00324 {
00325     return OSG::osgCos(rValue);
00326 }
00327 #endif // OSG_1_COMPAT
00328 
00330 /*---------------------------------------------------------------------*/
00343 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00344 
00346 template <class FloatTypeT> inline
00347 typename TypeTraits<FloatTypeT>::RealReturnType
00348     osgSin(const FloatTypeT rValue)
00349 {
00350     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00351
00352     return  osgSin(RealType(rValue));
00353 }
00354 #endif
00355 
00358 inline
00359 OSG::Real32 osgSin(const OSG::Real32 rValue)
00360 {
00361 #ifdef OSG_USE_STDMATH
00362     return std::sin(rValue);
00363 #elif defined(OSG_HAS_FLOATMATH)
00364     return sinf(rValue);
00365 #else
00366     return static_cast<Real32>(sin(static_cast<Real32>(rValue)));
00367 #endif
00368 }
00369
00372 inline
00373 OSG::Real64 osgSin(const OSG::Real64 rValue)
00374 {
00375 #ifdef OSG_USE_STDMATH
00376     return std::sin(rValue);
00377 #else
00378     return sin(rValue);
00379 #endif
00380 }
00381
00384 inline
00385 OSG::Real128 osgSin(const OSG::Real128 rValue)
00386 {
00387 #ifdef OSG_USE_STDMATH
00388     return std::sin(rValue);
00389 #else
00390     return sinl(rValue);
00391 #endif
00392 }
00393
00396 inline
00397 OSG::Fixed32 osgSin(const OSG::Fixed32 rValue)
00398 {
00399     return Fixed32::sin(rValue);
00400 }
00401
00402 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00403 
00405 template <class FloatTypeT> inline
00406 typename TypeTraits<FloatTypeT>::RealReturnType
00407     osgSin(const FloatTypeT rValue)
00408 {
00409     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00410
00411     return  osgSin(RealType(rValue));
00412 }
00413 #endif
00414 
00415 #ifdef OSG_1_COMPAT
00416 
00428 template <class FloatTypeT> inline
00429 typename TypeTraits<FloatTypeT>::RealReturnType
00430     osgsin(const FloatTypeT rValue)
00431 {
00432     return OSG::osgSin(rValue);
00433 }
00434
00437 inline
00438 OSG::Real32 osgsin(const OSG::Real32 rValue)
00439 {
00440     return OSG::osgSin(rValue);
00441 }
00442
00445 inline
00446 OSG::Real64 osgsin(const OSG::Real64 rValue)
00447 {
00448     return OSG::osgSin(rValue);
00449 }
00450
00453 inline
00454 OSG::Real128 osgsin(const OSG::Real128 rValue)
00455 {
00456     return OSG::osgSin(rValue);
00457 }
00458
00461 inline
00462 OSG::Fixed32 osgsin(const OSG::Fixed32 rValue)
00463 {
00464     return OSG::osgSin(rValue);
00465 }
00466 #endif // OSG_1_COMPAT
00467 
00469 /*---------------------------------------------------------------------*/
00484 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00485 
00487 template <class FloatTypeT> inline
00488 typename TypeTraits<FloatTypeT>::RealReturnType
00489     osgTan(const FloatTypeT rValue)
00490 {
00491     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00492
00493     return  osgTan(RealType(rValue));
00494 }
00495 #endif
00496 
00499 inline
00500 OSG::Real32 osgTan(const OSG::Real32 rValue)
00501 {
00502 #ifdef OSG_USE_STDMATH
00503     return std::tan(rValue);
00504 #elif defined(OSG_HAS_FLOATMATH)
00505     return tanf(rValue);
00506 #else
00507     return static_cast<Real32>(tan(static_cast<Real32>(rValue)));
00508 #endif
00509 }
00510
00513 inline
00514 OSG::Real64 osgTan(const OSG::Real64 rValue)
00515 {
00516 #ifdef OSG_USE_STDMATH
00517     return std::tan(rValue);
00518 #else
00519     return tan(rValue);
00520 #endif
00521 }
00522
00525 inline
00526 OSG::Real128 osgTan(const OSG::Real128 rValue)
00527 {
00528 #ifdef OSG_USE_STDMATH
00529     return std::tan(rValue);
00530 #else
00531     return tanl(rValue);
00532 #endif
00533 }
00534
00537 inline
00538 OSG::Fixed32 osgTan(const OSG::Fixed32 rValue)
00539 {
00540     return Fixed32::tan(rValue);
00541 }
00542
00543 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00544 
00546 template <class FloatTypeT> inline
00547 typename TypeTraits<FloatTypeT>::RealReturnType
00548     osgTan(const FloatTypeT rValue)
00549 {
00550     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00551
00552     return  osgTan(RealType(rValue));
00553 }
00554 #endif
00555 
00556 #ifdef OSG_1_COMPAT
00557 
00571 template <class FloatTypeT> inline
00572 typename TypeTraits<FloatTypeT>::RealReturnType
00573     osgtan(const FloatTypeT rValue)
00574 {
00575     return OSG::osgTan(rValue);
00576 }
00577
00580 inline
00581 OSG::Real32 osgtan(const OSG::Real32 rValue)
00582 {
00583     return OSG::osgTan(rValue);
00584 }
00585
00588 inline
00589 OSG::Real64 osgtan(const OSG::Real64 rValue)
00590 {
00591     return OSG::osgTan(rValue);
00592 }
00593
00596 inline
00597 OSG::Real128 osgtan(const OSG::Real128 rValue)
00598 {
00599     return OSG::osgTan(rValue);
00600 }
00601
00604 inline
00605 OSG::Fixed32 osgtan(const OSG::Fixed32 rValue)
00606 {
00607     return OSG::osgTan(rValue);
00608 }
00609 #endif // OSG_1_COMPAT
00610 
00612 /*---------------------------------------------------------------------*/
00627 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00628 
00630 template <class FloatTypeT> inline
00631 typename TypeTraits<FloatTypeT>::RealReturnType
00632     osgACos(const FloatTypeT rValue)
00633 {
00634     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00635
00636     return  osgACos(RealType(rValue));
00637 }
00638 #endif
00639 
00642 inline
00643 OSG::Real32 osgACos(const OSG::Real32 rValue)
00644 {
00645 #ifdef OSG_USE_STDMATH
00646     return std::acos(rValue);
00647 #elif defined(OSG_HAS_FLOATMATH)
00648     return acosf(rValue);
00649 #else
00650     return static_cast<Real32>(acos(static_cast<Real32>(rValue)));
00651 #endif
00652 }
00653
00656 inline
00657 OSG::Real64 osgACos(const OSG::Real64 rValue)
00658 {
00659 #ifdef OSG_USE_STDMATH
00660     return std::acos(rValue);
00661 #else
00662     return acos(rValue);
00663 #endif
00664 }
00665
00668 inline
00669 OSG::Real128 osgACos(const OSG::Real128 rValue)
00670 {
00671 #ifdef OSG_USE_STDMATH
00672     return std::acos(rValue);
00673 #else
00674     return acosl(rValue);
00675 #endif
00676 }
00677
00678 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00679 
00681 template <class FloatTypeT> inline
00682 typename TypeTraits<FloatTypeT>::RealReturnType
00683     osgACos(const FloatTypeT rValue)
00684 {
00685     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00686
00687     return  osgACos(RealType(rValue));
00688 }
00689 #endif
00690 
00691 #ifdef OSG_1_COMPAT
00692 
00706 template <class FloatTypeT> inline
00707 typename TypeTraits<FloatTypeT>::RealReturnType
00708     osgacos(const FloatTypeT rValue)
00709 {
00710     return OSG::osgACos(rValue);
00711 }
00712
00715 inline
00716 OSG::Real32 osgacos(const OSG::Real32 rValue)
00717 {
00718     return OSG::osgACos(rValue);
00719 }
00720
00723 inline
00724 OSG::Real64 osgacos(const OSG::Real64 rValue)
00725 {
00726     return OSG::osgACos(rValue);
00727 }
00728
00731 inline
00732 OSG::Real128 osgacos(const OSG::Real128 rValue)
00733 {
00734     return OSG::osgACos(rValue);
00735 }
00736 #endif // OSG_1_COMPAT
00737 
00739 /*---------------------------------------------------------------------*/
00754 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00755 
00757 template <class FloatTypeT> inline
00758 typename TypeTraits<FloatTypeT>::RealReturnType
00759     osgASin(const FloatTypeT rValue)
00760 {
00761     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00762
00763     return  osgASin(RealType(rValue));
00764 }
00765 #endif
00766 
00769 inline
00770 OSG::Real32 osgASin(const OSG::Real32 rValue)
00771 {
00772 #ifdef OSG_USE_STDMATH
00773     return std::asin(rValue);
00774 #elif defined(OSG_HAS_FLOATMATH)
00775     return asinf(rValue);
00776 #else
00777     return static_cast<Real32>(asin(static_cast<Real32>(rValue)));
00778 #endif
00779 }
00780
00781
00784 inline
00785 OSG::Real64 osgASin(const OSG::Real64 rValue)
00786 {
00787 #ifdef OSG_USE_STDMATH
00788     return std::asin(rValue);
00789 #else
00790     return asin(rValue);
00791 #endif
00792 }
00793
00796 inline
00797 OSG::Real128 osgASin(const OSG::Real128 rValue)
00798 {
00799 #ifdef OSG_USE_STDMATH
00800     return std::asin(rValue);
00801 #else
00802     return asinl(rValue);
00803 #endif
00804 }
00805
00806 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00807 
00809 template <class FloatTypeT> inline
00810 typename TypeTraits<FloatTypeT>::RealReturnType
00811     osgASin(const FloatTypeT rValue)
00812 {
00813     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00814
00815     return  osgASin(RealType(rValue));
00816 }
00817 #endif
00818 
00819 #ifdef OSG_1_COMPAT
00820 
00834 template <class FloatTypeT> inline
00835 typename TypeTraits<FloatTypeT>::RealReturnType
00836     osgasin(const FloatTypeT rValue)
00837 {
00838     return OSG::osgASin(rValue);
00839 }
00840
00843 inline
00844 OSG::Real32 osgasin(const OSG::Real32 rValue)
00845 {
00846     return OSG::osgASin(rValue);
00847 }
00848
00849
00852 inline
00853 OSG::Real64 osgasin(const OSG::Real64 rValue)
00854 {
00855     return OSG::osgASin(rValue);
00856 }
00857
00860 inline
00861 OSG::Real128 osgasin(const OSG::Real128 rValue)
00862 {
00863     return OSG::osgASin(rValue);
00864 }
00865 #endif // OSG_1_COMPAT
00866 
00868 /*---------------------------------------------------------------------*/
00884 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00885 
00887 template <class FloatTypeT> inline
00888 typename TypeTraits<FloatTypeT>::RealReturnType
00889     osgATan(const FloatTypeT rValue)
00890 {
00891     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00892
00893     return  osgATan(RealType(rValue));
00894 }
00895 #endif
00896 
00899 inline
00900 OSG::Real32 osgATan(const OSG::Real32 rValue)
00901 {
00902 #ifdef OSG_USE_STDMATH
00903     return std::atan(rValue);
00904 #elif defined(OSG_HAS_FLOATMATH)
00905     return atanf(rValue);
00906 #else
00907     return static_cast<Real32>(atan(static_cast<Real32>(rValue)));
00908 #endif
00909 }
00910
00913 inline
00914 OSG::Real64 osgATan(const OSG::Real64 rValue)
00915 {
00916 #ifdef OSG_USE_STDMATH
00917     return std::atan(rValue);
00918 #else
00919     return atan(rValue);
00920 #endif
00921 }
00922
00925 inline
00926 OSG::Real128 osgATan(const OSG::Real128 rValue)
00927 {
00928 #ifdef OSG_USE_STDMATH
00929     return std::atan(rValue);
00930 #else
00931     return atanl(rValue);
00932 #endif
00933 }
00934
00935 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
00936 
00938 template <class FloatTypeT> inline
00939 typename TypeTraits<FloatTypeT>::RealReturnType
00940     osgATan(const FloatTypeT rValue)
00941 {
00942     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
00943
00944     return  osgATan(RealType(rValue));
00945 }
00946 #endif
00947 
00948 #ifdef OSG_1_COMPAT
00949 
00964 template <class FloatTypeT> inline
00965 typename TypeTraits<FloatTypeT>::RealReturnType
00966     osgatan(const FloatTypeT rValue)
00967 {
00968     return OSG::osgATan(rValue);
00969 }
00970
00973 inline
00974 OSG::Real32 osgatan(const OSG::Real32 rValue)
00975 {
00976     return OSG::osgATan(rValue);
00977 }
00978
00981 inline
00982 OSG::Real64 osgatan(const OSG::Real64 rValue)
00983 {
00984     return OSG::osgATan(rValue);
00985 }
00986
00989 inline
00990 OSG::Real128 osgatan(const OSG::Real128 rValue)
00991 {
00992     return OSG::osgATan(rValue);
00993 }
00994 #endif // OSG_1_COMPAT
00995 
00997 /*---------------------------------------------------------------------*/
01015 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01016 
01018 template <class FloatTypeT> inline
01019 typename TypeTraits<FloatTypeT>::RealReturnType
01020     osgATan2(const FloatTypeT rValue1,
01021              const FloatTypeT rValue2)
01022 {
01023     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01024
01025     return  osgATan2(RealType(rValue1), RealType(rValue2));
01026 }
01027 #endif
01028 
01031 inline
01032 OSG::Real32 osgATan2(const OSG::Real32 rValue1, const OSG::Real32 rValue2)
01033 {
01034 #ifdef OSG_USE_STDMATH
01035     return std::atan2(rValue1, rValue2);
01036 #elif defined(OSG_HAS_FLOATMATH)
01037 #ifndef _OSG_HAS_ATANF2__
01038     return atan2f(rValue1, rValue2);
01039 #else
01040     return static_cast<Real32>(atan2(static_cast<Real32>(rValue1),
01041                                      static_cast<Real32>(rValue2) ));
01042 #endif
01043 #else
01044     return static_cast<Real32>(atan2(static_cast<Real32>(rValue1),
01045                                      static_cast<Real32>(rValue2) ));
01046 #endif
01047 }
01048
01051 inline
01052 OSG::Real64 osgATan2(const OSG::Real64 rValue1, const OSG::Real64 rValue2)
01053 {
01054 #ifdef OSG_USE_STDMATH
01055     return std::atan2(rValue1, rValue2);
01056 #else
01057     return atan2(rValue1, rValue2);
01058 #endif
01059 }
01060
01063 inline
01064 OSG::Real128 osgATan2(const OSG::Real128 rValue1, const OSG::Real128 rValue2)
01065 {
01066 #ifdef OSG_USE_STDMATH
01067     return std::atan2(rValue1, rValue2);
01068 #else
01069     return atan2l(rValue1, rValue2);
01070 #endif
01071 }
01072
01073 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01074 
01076 template <class FloatTypeT> inline
01077 typename TypeTraits<FloatTypeT>::RealReturnType
01078     osgATan2(const FloatTypeT rValue1,
01079              const FloatTypeT rValue2)
01080 {
01081     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01082
01083     return  osgATan2(RealType(rValue1), RealType(rValue2));
01084 }
01085 #endif
01086 
01087 #ifdef OSG_1_COMPAT
01088 
01105 template <class FloatTypeT> inline
01106 typename TypeTraits<FloatTypeT>::RealReturnType
01107     osgatan2(const FloatTypeT rValue1,
01108              const FloatTypeT rValue2)
01109 {
01110     return OSG::osgATan2(rValue1, rValue2);
01111 }
01112
01115 inline
01116 OSG::Real32 osgatan2(const OSG::Real32 rValue1, const OSG::Real32 rValue2)
01117 {
01118     return OSG::osgATan2(rValue1, rValue2);
01119 }
01120
01123 inline
01124 OSG::Real64 osgatan2(const OSG::Real64 rValue1, const OSG::Real64 rValue2)
01125 {
01126     return OSG::osgATan2(rValue1, rValue2);
01127 }
01128
01131 inline
01132 OSG::Real128 osgatan2(const OSG::Real128 rValue1, const OSG::Real128 rValue2)
01133 {
01134     return OSG::osgATan2(rValue1, rValue2);
01135 }
01136 #endif // OSG_1_COMPAT
01137 
01139 /*---------------------------------------------------------------------*/
01153 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01154 
01156 template <class TypeT> inline
01157 TypeT osgAbs(const TypeT rValue)
01158 {
01159     return (rValue > 0) ? rValue : -rValue;
01160 }
01161 #endif
01162 
01165 inline
01166 OSG::Real32 osgAbs(const OSG::Real32 rValue)
01167 {
01168 #ifdef OSG_USE_STDMATH
01169     return std::abs(rValue);
01170 #elif defined(OSG_HAS_FLOATMATH) && !defined(OSG_NO_FABSF)
01171     return fabsf(rValue);
01172 #else
01173     return static_cast<Real32>(fabs(static_cast<Real32>(rValue)));
01174 #endif
01175 }
01176
01179 inline
01180 OSG::Real64 osgAbs(const OSG::Real64 rValue)
01181 {
01182 #ifdef OSG_USE_STDMATH
01183     return std::abs(rValue);
01184 #else
01185     return fabs(rValue);
01186 #endif
01187 }
01188
01191 inline
01192 OSG::Fixed32 osgAbs(const OSG::Fixed32 rValue)
01193 {
01194     return Fixed32::abs(rValue);
01195 }
01196
01199 inline
01200 OSG::Real128 osgAbs(const OSG::Real128 rValue)
01201 {
01202 #ifdef OSG_USE_STDMATH
01203     return std::abs(rValue);
01204 #else
01205     return fabsl(rValue);
01206 #endif
01207 }
01208
01209 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01210 
01212 template <class TypeT> inline
01213 TypeT osgAbs(const TypeT rValue)
01214 {
01215     return (rValue > 0) ? rValue : -rValue;
01216 }
01217 #endif
01218 
01219 #ifdef OSG_1_COMPAT
01220 
01233 template <class TypeT> inline
01234 TypeT osgabs(const TypeT rValue)
01235 {
01236     return OSG::osgAbs(rValue);
01237 }
01238
01241 inline
01242 OSG::Real32 osgabs(const OSG::Real32 rValue)
01243 {
01244     return OSG::osgAbs(rValue);
01245 }
01246
01249 inline
01250 OSG::Real64 osgabs(const OSG::Real64 rValue)
01251 {
01252     return OSG::osgAbs(rValue);
01253 }
01254
01257 inline
01258 OSG::Fixed32 osgabs(const OSG::Fixed32 rValue)
01259 {
01260     return OSG::osgAbs(rValue);
01261 }
01262
01265 inline
01266 OSG::Real128 osgabs(const OSG::Real128 rValue)
01267 {
01268     return OSG::osgAbs(rValue);
01269 }
01270 #endif // OSG_1_COMPAT
01271 
01273 /*---------------------------------------------------------------------*/
01286 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01287 
01289 template <class FloatTypeT> inline
01290 typename TypeTraits<FloatTypeT>::RealReturnType
01291     osgPow(const FloatTypeT rValue,
01292            const FloatTypeT rExp)
01293 {
01294     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01295
01296     return  osgPow(RealType(rValue), RealType(rExp));
01297 }
01298 #endif
01299 
01302 inline
01303 OSG::Real32 osgPow(const OSG::Real32 rValue, const OSG::Real32 rExp)
01304 {
01305 #ifdef OSG_USE_STDMATH
01306     return std::pow(rValue, rExp);
01307 #elif defined(OSG_HAS_FLOATMATH)
01308     return powf(rValue, rExp);
01309 #else
01310     return static_cast<Real32>(pow(static_cast<Real32>(rValue),
01311                                    static_cast<Real32>(rExp)   ));
01312 #endif
01313 }
01314
01317 inline
01318 OSG::Real64 osgPow(const OSG::Real64 rValue, const OSG::Real64 rExp)
01319 {
01320 #ifdef OSG_USE_STDMATH
01321     return std::pow(rValue, rExp);
01322 #else
01323     return pow(rValue, rExp);
01324 #endif
01325 }
01326
01329 inline
01330 OSG::Real128 osgPow(const OSG::Real128 rValue, const OSG::Real128 rExp)
01331 {
01332 #ifdef OSG_USE_STDMATH
01333     return std::pow(rValue, rExp);
01334 #else
01335     return powl(rValue, rExp);
01336 #endif
01337 }
01338
01339 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01340 
01342 template <class FloatTypeT> inline
01343 typename TypeTraits<FloatTypeT>::RealReturnType
01344     osgPow(const FloatTypeT rValue,
01345            const FloatTypeT rExp)
01346 {
01347     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01348
01349     return  osgPow(RealType(rValue), RealType(rExp));
01350 }
01351 #endif
01352 
01353 #ifdef OSG_1_COMPAT
01354 
01366 template <class FloatTypeT> inline
01367 typename TypeTraits<FloatTypeT>::RealReturnType
01368     osgpow(const FloatTypeT rValue,
01369            const FloatTypeT rExp)
01370 {
01371     return OSG::osgPow(rValue, rExp);
01372 }
01373
01376 inline
01377 OSG::Real32 osgpow(const OSG::Real32 rValue, const OSG::Real32 rExp)
01378 {
01379     return OSG::osgPow(rValue, rExp);
01380 }
01381
01384 inline
01385 OSG::Real64 osgpow(const OSG::Real64 rValue, const OSG::Real64 rExp)
01386 {
01387     return OSG::osgPow(rValue, rExp);
01388 }
01389
01392 inline
01393 OSG::Real128 osgpow(const OSG::Real128 rValue, const OSG::Real128 rExp)
01394 {
01395     return OSG::osgPow(rValue, rExp);
01396 }
01397 #endif // OSG_1_COMPAT
01398 
01400 /*---------------------------------------------------------------------*/
01415 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01416 
01418 template <class FloatTypeT> inline
01419 typename TypeTraits<FloatTypeT>::RealReturnType
01420     osgLog(const FloatTypeT rValue)
01421 {
01422     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01423
01424     return  osgLog(RealType(rValue));
01425 }
01426 #endif
01427 
01430 inline
01431 OSG::Real32 osgLog(const OSG::Real32 rValue)
01432 {
01433 #ifdef OSG_USE_STDMATH
01434     return std::log(rValue);
01435 #elif defined(OSG_HAS_FLOATMATH)
01436     return logf(rValue);
01437 #else
01438     return static_cast<Real32>(log(static_cast<Real32>(rValue)));
01439 #endif
01440 }
01441
01444 inline
01445 OSG::Real64 osgLog(const OSG::Real64 rValue)
01446 {
01447 #ifdef OSG_USE_STDMATH
01448     return std::log(rValue);
01449 #else
01450     return log(rValue);
01451 #endif
01452 }
01453
01456 inline
01457 OSG::Real128 osgLog(const OSG::Real128 rValue)
01458 {
01459 #ifdef OSG_USE_STDMATH
01460     return std::log(rValue);
01461 #else
01462     return logl(rValue);
01463 #endif
01464 }
01465
01466 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01467 
01469 template <class FloatTypeT> inline
01470 typename TypeTraits<FloatTypeT>::RealReturnType
01471     osgLog(const FloatTypeT rValue)
01472 {
01473     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01474
01475     return  osgLog(RealType(rValue));
01476 }
01477 #endif
01478 
01479 #ifdef OSG_1_COMPAT
01480 
01494 template <class FloatTypeT> inline
01495 typename TypeTraits<FloatTypeT>::RealReturnType
01496     osglog(const FloatTypeT rValue)
01497 {
01498     return OSG::osgLog(rValue);
01499 }
01500
01503 inline
01504 OSG::Real32 osglog(const OSG::Real32 rValue)
01505 {
01506     return OSG::osgLog(rValue);
01507 }
01508
01511 inline
01512 OSG::Real64 osglog(const OSG::Real64 rValue)
01513 {
01514     return OSG::osgLog(rValue);
01515 }
01516
01519 inline
01520 OSG::Real128 osglog(const OSG::Real128 rValue)
01521 {
01522     return OSG::osgLog(rValue);
01523 }
01524 #endif // OSG_1_COMPAT
01525 
01527 /*---------------------------------------------------------------------*/
01541 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01542 
01544 template <class FloatTypeT> inline
01545 typename TypeTraits<FloatTypeT>::RealReturnType
01546     osgExp(const FloatTypeT rValue)
01547 {
01548     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01549
01550     return  osgExp(RealType(rValue));
01551 }
01552 #endif
01553 
01556 inline
01557 OSG::Real32 osgExp(const OSG::Real32 rValue)
01558 {
01559 #ifdef OSG_USE_STDMATH
01560     return std::exp(rValue);
01561 #elif defined(OSG_HAS_FLOATMATH)
01562     return expf(rValue);
01563 #else
01564     return static_cast<Real32>(exp(static_cast<Real32>(rValue)));
01565 #endif
01566 }
01567
01570 inline
01571 OSG::Real64 osgExp(const OSG::Real64 rValue)
01572 {
01573 #ifdef OSG_USE_STDMATH
01574     return std::exp(rValue);
01575 #else
01576     return exp(rValue);
01577 #endif
01578 }
01579
01582 inline
01583 OSG::Real128 osgExp(const OSG::Real128 rValue)
01584 {
01585 #ifdef OSG_USE_STDMATH
01586     return std::exp(rValue);
01587 #else
01588     return expl(rValue);
01589 #endif
01590 }
01591
01592 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01593 
01595 template <class FloatTypeT> inline
01596 typename TypeTraits<FloatTypeT>::RealReturnType
01597     osgExp(const FloatTypeT rValue)
01598 {
01599     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01600
01601     return  osgExp(RealType(rValue));
01602 }
01603 #endif
01604 
01605 #ifdef OSG_1_COMPAT
01606 
01619 template <class FloatTypeT> inline
01620 typename TypeTraits<FloatTypeT>::RealReturnType
01621     osgexp(const FloatTypeT rValue)
01622 {
01623     return OSG::osgExp(rValue);
01624 }
01625
01628 inline
01629 OSG::Real32 osgexp(const OSG::Real32 rValue)
01630 {
01631     return OSG::osgExp(rValue);
01632 }
01633
01636 inline
01637 OSG::Real64 osgexp(const OSG::Real64 rValue)
01638 {
01639     return OSG::osgExp(rValue);
01640 }
01641
01644 inline
01645 OSG::Real128 osgexp(const OSG::Real128 rValue)
01646 {
01647     return OSG::osgExp(rValue);
01648 }
01649 #endif // OSG_1_COMPAT
01650 
01652 /*---------------------------------------------------------------------*/
01672 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01673 
01675 template <class FloatTypeT> inline
01676 typename TypeTraits<FloatTypeT>::RealReturnType
01677     osgFloor(const FloatTypeT rValue)
01678 {
01679     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01680
01681     return  osgFloor(RealType(rValue));
01682 }
01683 #endif
01684 
01687 inline
01688 OSG::Real32 osgFloor(const OSG::Real32 rValue)
01689 {
01690 #ifdef OSG_USE_STDMATH
01691     return std::floor(rValue);
01692 #elif defined(OSG_HAS_FLOATMATH)
01693 # ifdef OSG_HPUX_ACC
01694     return static_cast<Real32>(floor(static_cast<Real32>(rValue)));
01695 # else
01696     return floorf(rValue);
01697 # endif
01698 #else
01699     return static_cast<Real32>(floor(static_cast<Real32>(rValue)));
01700 #endif
01701 }
01702
01705 inline
01706 OSG::Real64 osgFloor(const OSG::Real64 rValue)
01707 {
01708 #ifdef OSG_USE_STDMATH
01709     return std::floor(rValue);
01710 #else
01711     return floor(rValue);
01712 #endif
01713 }
01714
01717 inline
01718 OSG::Real128 osgFloor(const OSG::Real128 rValue)
01719 {
01720 #ifdef OSG_USE_STDMATH
01721     return std::floor(rValue);
01722 #else
01723     return floorl(rValue);
01724 #endif
01725 }
01726
01727 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01728 
01730 template <class FloatTypeT> inline
01731 typename TypeTraits<FloatTypeT>::RealReturnType
01732     osgFloor(const FloatTypeT rValue)
01733 {
01734     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01735
01736     return  osgFloor(RealType(rValue));
01737 }
01738 #endif
01739 
01740 #ifdef OSG_1_COMPAT
01741 
01760 template <class FloatTypeT> inline
01761 typename TypeTraits<FloatTypeT>::RealReturnType
01762     osgfloor(const FloatTypeT rValue)
01763 {
01764     return OSG::osgFloor(rValue);
01765 }
01766
01769 inline
01770 OSG::Real32 osgfloor(const OSG::Real32 rValue)
01771 {
01772     return OSG::osgFloor(rValue);
01773 }
01774
01777 inline
01778 OSG::Real64 osgfloor(const OSG::Real64 rValue)
01779 {
01780     return OSG::osgFloor(rValue);
01781 }
01782
01785 inline
01786 OSG::Real128 osgfloor(const OSG::Real128 rValue)
01787 {
01788     return OSG::osgFloor(rValue);
01789 }
01790 #endif // OSG_1_COMPAT
01791 
01793 /*---------------------------------------------------------------------*/
01813 #ifdef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01814 
01816 template <class FloatTypeT> inline
01817 typename TypeTraits<FloatTypeT>::RealReturnType
01818     osgCeil(const FloatTypeT rValue)
01819 {
01820     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01821
01822     return  OSG::osgCeil(RealType(rValue));
01823 }
01824 #endif
01825 
01828 inline
01829 OSG::Real32 osgCeil(const OSG::Real32 rValue)
01830 {
01831 #ifdef OSG_USE_STDMATH
01832     return std::ceil(rValue);
01833 #elif defined(OSG_HAS_FLOATMATH)
01834 # ifdef OSG_HPUX_ACC
01835     return static_cast<Real32>(ceil(static_cast<Real32>(rValue)));
01836 # else
01837     return ceilf(rValue);
01838 # endif
01839 #else
01840     return static_cast<Real32>(ceil(static_cast<Real32>(rValue)));
01841 #endif
01842 }
01843
01846 inline
01847 OSG::Real64 osgCeil(const OSG::Real64 rValue)
01848 {
01849 #ifdef OSG_USE_STDMATH
01850     return std::ceil(rValue);
01851 #else
01852     return ceil(rValue);
01853 #endif
01854 }
01855
01858 inline
01859 OSG::Real128 osgCeil(const OSG::Real128 rValue)
01860 {
01861 #ifdef OSG_USE_STDMATH
01862     return std::ceil(rValue);
01863 #else
01864     return ceill(rValue);
01865 #endif
01866 }
01867
01868 #ifndef OSG_GENERAL_TEMPLATE_BEFORE_SPEZ
01869 
01871 template <class FloatTypeT> inline
01872 typename TypeTraits<FloatTypeT>::RealReturnType
01873     osgCeil(const FloatTypeT rValue)
01874 {
01875     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01876
01877     return  OSG::osgCeil(RealType(rValue));
01878 }
01879 #endif
01880 
01881 #ifdef OSG_1_COMPAT
01882 
01901 template <class FloatTypeT> inline
01902 typename TypeTraits<FloatTypeT>::RealReturnType
01903     osgceil(const FloatTypeT rValue)
01904 {
01905     return OSG::osgCeil(rValue);
01906 }
01907
01910 inline
01911 OSG::Real32 osgceil(const OSG::Real32 rValue)
01912 {
01913     return OSG::osgCeil(rValue);
01914 }
01915
01918 inline
01919 OSG::Real64 osgceil(const OSG::Real64 rValue)
01920 {
01921     return OSG::osgCeil(rValue);
01922 }
01923
01926 inline
01927 OSG::Real128 osgceil(const OSG::Real128 rValue)
01928 {
01929     return OSG::osgCeil(rValue);
01930 }
01931 #endif // OSG_1_COMPAT
01932 
01933
01935 /*---------------------------------------------------------------------*/
01949 template <class FloatTypeT> inline
01950 typename TypeTraits<FloatTypeT>::RealReturnType
01951     osgMod(const FloatTypeT lValue, const FloatTypeT rValue)
01952 {
01953     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
01954
01955     return  OSG::osgMod(RealType(lValue), RealType(rValue));
01956 }
01957
01960 inline
01961 OSG::Real32 osgMod(const OSG::Real32 lValue, const OSG::Real32 rValue)
01962 {
01963 #ifdef OSG_USE_STDMATH
01964     return std::fmod(lValue, rValue);
01965 #else
01966     return fmodf(lValue, rValue);
01967 #endif
01968 }
01969
01972 inline
01973 OSG::Real64 osgMod(const OSG::Real64 lValue, const OSG::Real64 rValue)
01974 {
01975 #ifdef OSG_USE_STDMATH
01976     return std::fmod(lValue, rValue);
01977 #else
01978     return fmod(lValue, rValue);
01979 #endif
01980 }
01981
01983 /*---------------------------------------------------------------------*/
01998 template <class FloatTypeT> inline
01999 OSG::UInt32 osgFinite(const FloatTypeT rValue)
02000 {
02001 #ifdef WIN32
02002     return _finite(rValue);
02003 #else
02004 # ifdef __hpux
02005     return  isfinite(rValue);
02006 # else
02007 #  ifdef __APPLE__
02008     return  std::isfinite(rValue);
02009 #  else
02010     return  finite(rValue);
02011 #  endif
02012 # endif
02013 #endif
02014 }
02015
02016 #ifdef OSG_1_COMPAT
02017 
02030 template <class FloatTypeT> inline
02031 OSG::UInt32 osgfinite(const FloatTypeT rValue)
02032 {
02033     return OSG::osgFinite(rValue);
02034 }
02035 #endif // OSG_1_COMPAT
02036 
02038 /*---------------------------------------------------------------------*/
02050 template <class TypeT> inline
02051 TypeT osgMin(const TypeT lValue, const TypeT rValue)
02052 {
02053     return ((lValue < rValue) ? lValue : rValue);
02054 }
02055
02064 template <class TypeT> inline
02065 TypeT osgMax(const TypeT lValue, const TypeT rValue)
02066 {
02067     return ((lValue > rValue) ? lValue : rValue);
02068 }
02069
02079 template <class TypeT> inline
02080 TypeT osgClamp(const TypeT minVal, const TypeT val, const TypeT maxVal)
02081 {
02082     OSG_ASSERT(minVal < maxVal);
02083
02084     return ((val > minVal) ? ((val < maxVal) ? val : maxVal) : minVal);
02085 }
02086
02088 /*---------------------------------------------------------------------*/
02092 template <class TypeT> inline
02093 bool osgIsEqual(const TypeT lValue, const TypeT rValue, const TypeT tol)
02094 {
02095     return osgAbs(lValue - rValue) < tol;
02096 }
02097
02099 /*---------------------------------------------------------------------*/
02111 template <class TypeT> inline
02112 Int8 osgSgn(TypeT val)
02113 {
02114     if(val < 0)
02115         return -1;
02116
02117     if(val > 0)
02118         return  1;
02119
02120     return 0;
02121 }
02122
02124 /*---------------------------------------------------------------------*/
02140 template <class TypeT> inline
02141 void osgSwap(TypeT & lValue, TypeT & rValue)
02142 {
02143     TypeT val(lValue);
02144
02145     lValue = rValue;
02146     rValue = val;
02147 }
02148
02150 /*---------------------------------------------------------------------*/
02161 inline
02162 OSG::Real32 osgDegree2Rad(const OSG::Real32 rValue)
02163 {
02164    return (rValue/360.f) * 2.f * 3.1415926535f;
02165 }
02166
02169 inline
02170 OSG::Real64 osgDegree2Rad(const OSG::Real64 rValue)
02171 {
02172    return (rValue/360) * 2 * 3.1415926535;
02173 }
02174
02177 inline
02178 OSG::Fixed32 osgDegree2Rad(const OSG::Fixed32 rValue)
02179 {
02180    return (rValue/360.f) * 2.f * 3.1415926535f;
02181 }
02182
02186 template <class FloatTypeT> inline
02187 typename TypeTraits<FloatTypeT>::RealReturnType
02188     osgDegree2Rad(const FloatTypeT rValue)
02189 {
02190     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
02191
02192     return  OSG::osgDegree2Rad(RealType(rValue));
02193 }
02194
02195 #ifdef OSG_1_COMPAT
02196 
02205 inline
02206 OSG::Real32 osgdegree2rad(const OSG::Real32 rValue)
02207 {
02208     return OSG::osgDegree2Rad(rValue);
02209 }
02210
02213 inline
02214 OSG::Real64 osgdegree2rad(const OSG::Real64 rValue)
02215 {
02216     return OSG::osgDegree2Rad(rValue);
02217 }
02218
02221 inline
02222 OSG::Fixed32 osgdegree2rad(const OSG::Fixed32 rValue)
02223 {
02224     return OSG::osgDegree2Rad(rValue);
02225 }
02226
02230 template <class FloatTypeT> inline
02231 typename TypeTraits<FloatTypeT>::RealReturnType
02232     osgdegree2rad(const FloatTypeT rValue)
02233 {
02234     return OSG::osgDegree2Rad(rValue);
02235 }
02236 #endif // OSG_1_COMPAT
02237 
02238
02240 /*---------------------------------------------------------------------*/
02251 inline
02252 OSG::Real32 osgRad2Degree(const OSG::Real32 rValue)
02253 {
02254     return (rValue/(2.f * 3.1415926535f)) * 360.f;
02255 }
02256
02259 inline
02260 OSG::Real64 osgRad2Degree(const OSG::Real64 rValue)
02261 {
02262     return (rValue/(2 * 3.1415926535)) * 360;
02263 }
02264
02267 inline
02268 OSG::Fixed32 osgRad2Degree(const OSG::Fixed32 rValue)
02269 {
02270     return (rValue/(2.f * 3.1415926535f)) * 360.f;
02271 }
02272
02275 template <class FloatTypeT> inline
02276 typename TypeTraits<FloatTypeT>::RealReturnType
02277     osgRad2Degree(const FloatTypeT rValue)
02278 {
02279     typedef typename TypeTraits<FloatTypeT>::RealReturnType RealType;
02280
02281     return  OSG::osgRad2Degree(RealType(rValue));
02282 }
02283
02284 #ifdef OSG_1_COMPAT
02285 
02294 inline
02295 OSG::Real32 osgrad2degree(const OSG::Real32 rValue)
02296 {
02297     return OSG::osgRad2Degree(rValue);
02298 }
02299
02302 inline
02303 OSG::Real64 osgrad2degree(const OSG::Real64 rValue)
02304 {
02305     return OSG::osgRad2Degree(rValue);
02306 }
02307
02310 inline
02311 OSG::Fixed32 osgrad2degree(const OSG::Fixed32 rValue)
02312 {
02313     return OSG::osgRad2Degree(rValue);
02314 }
02315
02318 template <class FloatTypeT> inline
02319 typename TypeTraits<FloatTypeT>::RealReturnType
02320     osgrad2degree(const FloatTypeT rValue)
02321 {
02322     return OSG::osgRad2Degree(rValue);
02323 }
02324 #endif // OSG_1_COMPAT
02325 
02326 #ifdef OSG_1_COMPAT
02327 
02328 /*---------------------------------------------------------------------*/
02341 template <class FloatTypeT> inline
02342 typename TypeTraits<FloatTypeT>::RealReturnType
02343     deg2rad(const FloatTypeT rValue)
02344 {
02345     return OSG::osgDegree2Rad(rValue);
02346 }
02347
02357 template <class FloatTypeT> inline
02358 typename TypeTraits<FloatTypeT>::RealReturnType
02359     rad2deg(const FloatTypeT rValue)
02360 {
02361     return OSG::osgRad2Degree(rValue);
02362 }
02363 #endif // OSG_1_COMPAT
02364 
02366 /*---------------------------------------------------------------------*/
02377 template <> inline
02378 bool osgIsPower2<UInt32>(const OSG::UInt32 rValue)
02379 {
02380     return !(rValue & (rValue - 1));
02381 }
02382
02383 template <> inline
02384 bool osgIsPower2<Int32>(const OSG::Int32 rValue)
02385 {
02386     return (rValue >= 0) && !(rValue & (rValue - 1));
02387 }
02388
02389 template <> inline
02390 bool osgIsPower2<UInt64>(const OSG::UInt64 rValue)
02391 {
02392     return !(rValue & (rValue - 1));
02393 }
02394
02395 template <> inline
02396 bool osgIsPower2<Int64>(const OSG::Int64 rValue)
02397 {
02398     return (rValue >= 0) && !(rValue & (rValue - 1));
02399 }
02400
02401 #ifdef OSG_1_COMPAT
02402 
02411 template <> inline
02412 bool osgispower2<UInt32>(const OSG::UInt32 rValue)
02413 {
02414     return OSG::osgIsPower2(rValue);
02415 }
02416
02417 template <> inline
02418 bool osgispower2<Int32>(const OSG::Int32 rValue)
02419 {
02420     return OSG::osgIsPower2(rValue);
02421 }
02422
02423 template <> inline
02424 bool osgispower2<UInt64>(const OSG::UInt64 rValue)
02425 {
02426     return OSG::osgIsPower2(rValue);
02427 }
02428
02429 template <> inline
02430 bool osgispower2<Int64>(const OSG::Int64 rValue)
02431 {
02432     return OSG::osgIsPower2(rValue);
02433 }
02434 #endif // OSG_1_COMPAT
02435 
02437 /*---------------------------------------------------------------------*/
02450 template <> inline
02451 OSG::UInt32 osgNextPower2<UInt32>(OSG::UInt32 rValue)
02452 {
02453     if(rValue == 0)
02454         return TypeTraits<UInt32>::getOneElement();
02455
02456     --rValue;
02457     rValue |= rValue >> 1;
02458     rValue |= rValue >> 2;
02459     rValue |= rValue >> 4;
02460     rValue |= rValue >> 8;
02461     rValue |= rValue >> 16;
02462     ++rValue;
02463
02464     return rValue;
02465 }
02466
02469 template <> inline
02470 OSG::Int32 osgNextPower2<Int32>(OSG::Int32 rValue)
02471 {
02472     const Int32 maxPower2 = TypeTraits<Int32>::getOneElement() << 30;
02473
02474     if(rValue <= 0)
02475         return TypeTraits<Int32>::getOneElement();
02476
02477     // signed overflow invokes undefined behavior, avoid it.
02478     if(rValue > maxPower2)
02479         return TypeTraits<Int32>::getZeroElement();
02480
02481     --rValue;
02482     rValue |= rValue >> 1;
02483     rValue |= rValue >> 2;
02484     rValue |= rValue >> 4;
02485     rValue |= rValue >> 8;
02486     rValue |= rValue >> 16;
02487     ++rValue;
02488
02489     return rValue;
02490 }
02491
02494 template <> inline
02495 OSG::UInt64 osgNextPower2<UInt64>(OSG::UInt64 rValue)
02496 {
02497     if(rValue == 0)
02498         return TypeTraits<UInt64>::getOneElement();
02499
02500     --rValue;
02501     rValue |= rValue >> 1;
02502     rValue |= rValue >> 2;
02503     rValue |= rValue >> 4;
02504     rValue |= rValue >> 8;
02505     rValue |= rValue >> 16;
02506     rValue |= rValue >> 32;
02507     ++rValue;
02508
02509     return rValue;
02510 }
02511
02514 template <> inline
02515 OSG::Int64 osgNextPower2<Int64>(OSG::Int64 rValue)
02516 {
02517     const Int64 maxPower2 = TypeTraits<Int64>::getOneElement() << 62;
02518
02519     if(rValue <= 0)
02520         return TypeTraits<Int64>::getOneElement();
02521
02522     // signed overflow invokes undefined behavior, avoid it.
02523     if(rValue > maxPower2)
02524         return TypeTraits<Int64>::getZeroElement();
02525
02526     --rValue;
02527     rValue |= rValue >> 1;
02528     rValue |= rValue >> 2;
02529     rValue |= rValue >> 4;
02530     rValue |= rValue >> 8;
02531     rValue |= rValue >> 16;
02532     rValue |= rValue >> 32;
02533     ++rValue;
02534
02535     return rValue;
02536 }
02537
02538 #ifdef SIZE_T_NEQ_UINT32
02539 
02542 template <> inline
02543 size_t osgNextPower2<size_t>(size_t rValue)
02544 {
02545     if(rValue == 0)
02546         return TypeTraits<size_t>::getOneElement();
02547
02548     --rValue;
02549     rValue |= rValue >> 1;
02550     rValue |= rValue >> 2;
02551     rValue |= rValue >> 4;
02552     rValue |= rValue >> 8;
02553     rValue |= rValue >> 16;
02554 #if defined(SIZE_T_64BIT)
02555     rValue |= rValue >> 32;
02556 #endif
02557     ++rValue;
02558
02559     return rValue;
02560 }
02561 #endif
02562 
02563 #ifdef OSG_1_COMPAT
02564 
02575 template <> inline
02576 OSG::UInt32 osgnextpower2<UInt32>(OSG::UInt32 rValue)
02577 {
02578     return OSG::osgNextPower2(rValue);
02579 }
02580
02583 template <> inline
02584 OSG::Int32 osgnextpower2<Int32>(OSG::Int32 rValue)
02585 {
02586     return OSG::osgNextPower2(rValue);
02587 }
02588
02591 template <> inline
02592 OSG::UInt64 osgnextpower2<UInt64>(OSG::UInt64 rValue)
02593 {
02594     return OSG::osgNextPower2(rValue);
02595 }
02596
02599 template <> inline
02600 OSG::Int64 osgnextpower2<Int64>(OSG::Int64 rValue)
02601 {
02602     return OSG::osgNextPower2(rValue);
02603 }
02604
02605 #ifdef SIZE_T_NEQ_UINT32
02606 
02609 template <> inline
02610 size_t osgnextpower2<size_t>(size_t rValue)
02611 {
02612     return OSG::osgNextPower2(rValue);
02613 }
02614 #endif
02615 #endif // OSG_1_COMPAT
02616 
02617
02619 /*---------------------------------------------------------------------*/
02623 inline
02624 int osgLog2Int(OSG::Real32 v)
02625 {
02626     return ((*reinterpret_cast<Int32 *>(&v)) >> 23) - 127;
02627 }
02628
02629 inline
02630 OSG::Int32 osgRound2Int(OSG::Real64 val)
02631 {
02632 #ifdef OSG_FAST_INT
02633     val     = val + OSG_DOUBLEMAGIC;
02634     return (reinterpret_cast<long*>(&val))[0];
02635 #else
02636     return int (val + OSG_DOUBLEMAGICROUNDEPS);
02637 #endif
02638 }
02639
02648 template<class VecPntT> inline
02649 OSG::UInt32 getMaxIndexAbs3(const VecPntT &v)
02650 {
02651     return
02652         osgAbs(v[0]) > osgAbs(v[1]) ?
02653             (osgAbs(v[0]) > osgAbs(v[2]) ? 0 : 2) :
02654             (osgAbs(v[1]) > osgAbs(v[2]) ? 1 : 2);
02655 }
02656
02657 #if defined(OSG_EMBEDDED) && !defined(__linux)
02658 
02674 inline
02675 OSG::Int32 putenv(Char8 *string)
02676 {
02677 #if !defined(WIN32) || defined(BCC)
02678     return ::putenv(string);
02679 #else
02680     return ::_putenv(string);
02681 #endif
02682 }
02683 inline
02684 Char8 *getenv(const Char8 *string)
02685 {
02686     return NULL;
02687 }
02688 #else
02689 #endif
02690 
02697 inline
02698 void osgSleep(OSG::UInt32 millisecs)
02699 {
02700 #ifdef WIN32
02701     Sleep(millisecs);
02702 #else
02703 
02704 #if 0 // replaced by nanosleep to work around IRIX problems
02705     // Rough aproximation, have to find a better way soon (GV)
02706
02707     if( (millisecs * 1000) > 1000000)
02708     {
02709         ::sleep(millisecs / 1000);
02710     }
02711     else
02712     {
02713         ::usleep(millisecs * 1000);
02714     }
02715
02716 #else
02717 
02718     struct timespec req;
02719     int ns;
02720
02721     req.tv_sec  = static_cast<long> (millisecs / 1000);
02722     req.tv_nsec = static_cast<long>((millisecs % 1000) * 1000 * 1000);
02723
02724     while((req.tv_sec > 0 || req.tv_nsec > 0) &&
02725           (ns = nanosleep(&req, &req)) < 0)
02726     {
02727         if(ns < 0 && errno != EINTR)
02728         {
02729             break;
02730         }
02731     }
02732
02733 #endif
02734 #endif
02735 }
02736
02737 #ifdef OSG_1_COMPAT
02738 
02746 inline
02747 void osgsleep(OSG::UInt32 millisecs)
02748 {
02749     OSG::osgSleep(millisecs);
02750 }
02751 #endif // OSG_1_COMPAT
02752 
02759 inline
02760 OSG::Real32 osgRand(void)
02761 {
02762     return rand() / static_cast<Real32>(RAND_MAX);
02763 }
02764
02765 #ifdef OSG_1_COMPAT
02766 
02774 inline
02775 OSG::Real32 osgrand(void)
02776 {
02777     return OSG::osgRand();
02778 }
02779 #endif // OSG_1_COMPAT
02780 
02781 #if defined(WIN32) && defined(_MSC_VER)
02782 #if _MSC_VER <= 1200  // VC6
02783 
02791 inline
02792 std::ostream &operator<<(std::ostream &os, OSG::UInt64 v)
02793 {
02794     char buf[30];
02795     sprintf(buf, "%I64u", v);
02796     return os << buf;
02797 }
02798
02807 inline
02808 std::ostream &operator<<(std::ostream &os, OSG::Int64 v)
02809 {
02810     char buf[30];
02811     sprintf(buf, "%I64d", v);
02812     return os << buf;
02813 }
02814 #endif
02815 #endif
02816 
02818 /*---------------------------------------------------------------------*/
02828 inline
02829 bool osgIsBigEndian(void)
02830 {
02831     return (BYTE_ORDER) == (BIG_ENDIAN);
02832 }
02833
02834 #ifdef OSG_LONGLONG_HAS_LL
02835 
02836 #define OSG_UINT64_LITERAL(value) value##ULL
02837 
02838 #define OSG_INT64_LITERAL(value) value##LL
02839 
02840 #else
02841 
02842 #define OSG_UINT64_LITERAL(value) value##U
02843 
02844 #define OSG_INT64_LITERAL(value) value
02845 
02846 #endif
02847 
02856 template <> inline
02857 OSG::UInt16 osgSwapBytes<UInt16>(OSG::UInt16 src)
02858 {
02859     return (((src & 0x00ff) << 8) |
02860             ((src & 0xff00) >> 8)  );
02861 }
02862
02865 template <> inline
02866 OSG::Int16 osgSwapBytes<Int16>(OSG::Int16 src)
02867 {
02868     return static_cast<Int16>(osgSwapBytes<UInt16>(static_cast<UInt16>(src)));
02869 }
02870
02873 template <> inline
02874 OSG::UInt32 osgSwapBytes<UInt32>(OSG::UInt32 src)
02875 {
02876     return (((src & 0x000000ff) << 24) |
02877             ((src & 0x0000ff00) <<  8) |
02878             ((src & 0x00ff0000) >>  8) |
02879             ((src & 0xff000000) >> 24)  );
02880 }
02881
02884 template <> inline
02885 OSG::Int32 osgSwapBytes<Int32>(OSG::Int32 src)
02886 {
02887     return static_cast<Int32>(osgSwapBytes<UInt32>(static_cast<UInt32>(src)));
02888 }
02889
02890 #ifdef OSG_GLENUM_NEQ_UINT32
02891 
02893 template <> inline
02894 GLenum osgSwapBytes<GLenum>(GLenum src)
02895 {
02896     return static_cast<GLenum>(osgSwapBytes<UInt32>(static_cast<UInt32>(src)));
02897 }
02898 #endif // OSG_GLENUM_NEQ_UINT32
02899 
02902 template <> inline
02903 OSG::UInt64 osgSwapBytes<UInt64>(OSG::UInt64 src)
02904 {
02905     return (((src & OSG_UINT64_LITERAL(0x00000000000000ff)) << 56) |
02906             ((src & OSG_UINT64_LITERAL(0x000000000000ff00)) << 40) |
02907             ((src & OSG_UINT64_LITERAL(0x0000000000ff0000)) << 24) |
02908             ((src & OSG_UINT64_LITERAL(0x00000000ff000000)) <<  8) |
02909             ((src & OSG_UINT64_LITERAL(0x000000ff00000000)) >>  8) |
02910             ((src & OSG_UINT64_LITERAL(0x0000ff0000000000)) >> 24) |
02911             ((src & OSG_UINT64_LITERAL(0x00ff000000000000)) >> 40) |
02912             ((src & OSG_UINT64_LITERAL(0xff00000000000000)) >> 56)  );
02913 }
02914
02917 template <> inline
02918 OSG::Int64 osgSwapBytes<Int64>(OSG::Int64 src)
02919 {
02920     return static_cast<Int64>(osgSwapBytes<UInt64>(static_cast<UInt64>(src)));
02921 }
02922
02925 template <> inline
02926 OSG::Real32 osgSwapBytes<Real32>(OSG::Real32 src)
02927 {
02928     UInt8* pStart = reinterpret_cast<UInt8*>(&src);
02929     UInt8* pEnd   = reinterpret_cast<UInt8*>(&src) + sizeof(Real32);
02930
02931     std::reverse(pStart, pEnd);
02932
02933     return src;
02934 }
02935
02938 template <> inline
02939 OSG::Real64 osgSwapBytes<Real64>(OSG::Real64 src)
02940 {
02941     UInt8* pStart = reinterpret_cast<UInt8*>(&src);
02942     UInt8* pEnd   = reinterpret_cast<UInt8*>(&src) + sizeof(Real64);
02943
02944     std::reverse(pStart, pEnd);
02945
02946     return src;
02947 }
02948
02958 template <class TypeT> inline
02959 TypeT osgHostToBigEndian(TypeT src)
02960 {
02961 #if BYTE_ORDER == LITTLE_ENDIAN
02962     return osgSwapBytes(src);
02963 #else
02964     return src;
02965 #endif
02966 }
02967
02970 template <> inline
02971 OSG::Real128 osgHostToBigEndian<Real128>(OSG::Real128 src)
02972 {
02973 #if BYTE_ORDER == LITTLE_ENDIAN
02974     char *p = reinterpret_cast<char*>(&src);
02975
02976     std::swap(p[0], p[15]);
02977     std::swap(p[1], p[14]);
02978     std::swap(p[2], p[13]);
02979     std::swap(p[3], p[12]);
02980     std::swap(p[4], p[11]);
02981     std::swap(p[5], p[10]);
02982     std::swap(p[6], p[9]);
02983     std::swap(p[7], p[8]);
02984
02985     return src;
02986 #else
02987     return src;
02988 #endif
02989 }
02990
03000 template <class TypeT> inline
03001 TypeT osgHostToLittleEndian(TypeT src)
03002 {
03003 #if BYTE_ORDER == LITTLE_ENDIAN
03004     return src;
03005 #else
03006     return osgSwapBytes(src);
03007 #endif
03008 }
03009
03012 template <> inline
03013 OSG::Real128 osgHostToLittleEndian<Real128>(OSG::Real128 src)
03014 {
03015 #if BYTE_ORDER == LITTLE_ENDIAN
03016     return src;
03017 #else
03018     char *p = reinterpret_cast<char*>(&src);
03019
03020     std::swap(p[0], p[15]);
03021     std::swap(p[1], p[14]);
03022     std::swap(p[2], p[13]);
03023     std::swap(p[3], p[12]);
03024     std::swap(p[4], p[11]);
03025     std::swap(p[5], p[10]);
03026     std::swap(p[6], p[9]);
03027     std::swap(p[7], p[8]);
03028
03029     return src;
03030 #endif
03031 }
03032
03042 template <class TypeT> inline
03043 TypeT osgBigEndianToHost(TypeT src)
03044 {
03045 #if BYTE_ORDER == LITTLE_ENDIAN
03046     return osgSwapBytes(src);
03047 #else
03048     return src;
03049 #endif
03050 }
03051
03054 template <> inline
03055 OSG::Real128 osgBigEndianToHost<Real128>(OSG::Real128 src)
03056 {
03057 #if BYTE_ORDER == LITTLE_ENDIAN
03058     char *p = reinterpret_cast<char*>(&src);
03059
03060     std::swap(p[0], p[15]);
03061     std::swap(p[1], p[14]);
03062     std::swap(p[2], p[13]);
03063     std::swap(p[3], p[12]);
03064     std::swap(p[4], p[11]);
03065     std::swap(p[5], p[10]);
03066     std::swap(p[6], p[9]);
03067     std::swap(p[7], p[8]);
03068
03069     return src;
03070 #else
03071     return src;
03072 #endif
03073 }
03074
03084 template <class TypeT> inline
03085 TypeT osgLittleEndianToHost(TypeT src)
03086 {
03087 #if BYTE_ORDER == LITTLE_ENDIAN
03088     return src;
03089 #else
03090     return osgSwapBytes(src);
03091 #endif
03092 }
03093
03096 template <> inline
03097 OSG::Real128 osgLittleEndianToHost<Real128>(OSG::Real128 src)
03098 {
03099 #if BYTE_ORDER == LITTLE_ENDIAN
03100     return src;
03101 #else
03102     char *p = reinterpret_cast<char*>(&src);
03103
03104     std::swap(p[0], p[15]);
03105     std::swap(p[1], p[14]);
03106     std::swap(p[2], p[13]);
03107     std::swap(p[3], p[12]);
03108     std::swap(p[4], p[11]);
03109     std::swap(p[5], p[10]);
03110     std::swap(p[6], p[9]);
03111     std::swap(p[7], p[8]);
03112
03113     return src;
03114 #endif
03115 }
03116
03127 template <class TypeT> inline
03128 TypeT osgHostToNet(const TypeT src)
03129 {
03130     return OSG::osgHostToBigEndian(src);
03131 }
03132
03143 template <class TypeT> inline
03144 TypeT osgNetToHost(const TypeT src)
03145 {
03146     return OSG::osgBigEndianToHost(src);
03147 }
03148
03149 // host to network
03150
03163 inline
03164 OSG::UInt16 osghtons(OSG::UInt16 src)
03165 {
03166     return OSG::osgHostToNet<UInt16>(src);
03167 }
03168
03181 inline
03182 OSG::UInt32 osghtonl(OSG::UInt32 src)
03183 {
03184     return OSG::osgHostToNet<UInt32>(src);
03185 }
03186
03199 inline
03200 OSG::UInt64 osghtonll(OSG::UInt64 src)
03201 {
03202     return OSG::osgHostToNet<UInt64>(src);
03203 }
03204
03217 inline
03218 OSG::Real32 osghtonf(OSG::Real32 src)
03219 {
03220     return OSG::osgHostToNet<Real32>(src);
03221 }
03222
03235 inline
03236 OSG::Real64 osghtond(OSG::Real64 src)
03237 {
03238     return OSG::osgHostToNet<Real64>(src);
03239 }
03240
03253 inline
03254 OSG::Real128 osghtondd(OSG::Real128 src)
03255 {
03256     return OSG::osgHostToNet<Real128>(src);
03257 }
03258
03259 // network to host
03260
03273 inline
03274 UInt16 osgntohs(UInt16 src)
03275 {
03276     return OSG::osgNetToHost<UInt16>(src);
03277 }
03278
03291 inline
03292 OSG::UInt32 osgntohl(OSG::UInt32 src)
03293 {
03294     return OSG::osgNetToHost<UInt32>(src);
03295 }
03296
03309 inline
03310 OSG::UInt64 osgntohll(OSG::UInt64 src)
03311 {
03312     return OSG::osgNetToHost<UInt64>(src);
03313 }
03314
03327 inline
03328 OSG::Real32 osgntohf(OSG::Real32 src)
03329 {
03330     return OSG::osgNetToHost<Real32>(src);
03331 }
03332
03345 inline
03346 OSG::Real64 osgntohd(OSG::Real64 src)
03347 {
03348     return OSG::osgNetToHost<Real64>(src);
03349 }
03350
03363 inline
03364 OSG::Real128 osgntohdd(OSG::Real128 src)
03365 {
03366     return OSG::osgNetToHost<Real128>(src);
03367 }
03368
03369
03371 /*---------------------------------------------------------------------*/
03385 inline
03386 void osgStringDup(const OSG::TChar *szInput, OSG::TChar *&szOutput)
03387 {
03388     delete [] szOutput;
03389
03390     szOutput = NULL;
03391
03392     if(szInput != NULL)
03393     {
03394 #if defined(WIN32)
03395         szOutput = new TChar[::_tcslen(szInput) + 1];
03396         ::_tcscpy(szOutput, szInput);
03397 #else
03398         szOutput = new TChar[::strlen(szInput) + 1];
03399         ::strcpy(szOutput, szInput);
03400 #endif
03401     }
03402 }
03403
03404 #ifdef OSG_1_COMPAT
03405 
03417 inline
03418 void stringDup(const OSG::TChar *szInput, OSG::TChar *&szOutput)
03419 {
03420     OSG::osgStringDup(szInput, szOutput);
03421 }
03422 #endif // OSG_1_COMPAT
03423 
03436 inline
03437 void  osgStringCopy(const OSG::Char8 *szInput, OSG::Char8 *szOutput)
03438 {
03439     if(szInput != NULL && szOutput != NULL)
03440     {
03441         ::strcpy(szOutput, szInput);
03442     }
03443 }
03444
03445 #ifdef OSG_1_COMPAT
03446 
03460 inline
03461 void  stringcpy(const OSG::Char8 *szInput, OSG::Char8 *szOutput)
03462 {
03463     OSG::osgStringCopy(szInput, szOutput);
03464 }
03465 #endif // OSG_1_COMPAT
03466 
03479 inline
03480 OSG::Int32 osgStringNCmp(const OSG::Char8 *string1,
03481                          const OSG::Char8 *string2,
03482                                size_t      count)
03483 {
03484     return ::strncmp(string1, string2, count);
03485 }
03486
03487 #ifdef OSG_1_COMPAT
03488 
03502 inline
03503 OSG::Int32 stringncmp(const OSG::Char8  *string1,
03504                       const OSG::Char8  *string2,
03505                             size_t       count  )
03506 {
03507     return OSG::osgStringNCmp(string1, string2, count);
03508 }
03509 #endif // OSG_1_COMPAT
03510 
03519 inline
03520 OSG::Int32 osgStringLen(const OSG::Char8 *string1)
03521 {
03522     return ::strlen(string1);
03523 }
03524
03525 #ifdef OSG_1_COMPAT
03526 
03536 inline
03537 OSG::Int32 stringlen(const OSG::Char8 *string1)
03538 {
03539     return OSG::osgStringLen(string1);
03540 }
03541 #endif // OSG_1_COMPAT
03542 
03553 inline
03554 OSG::Int32 osgStringCmp(const OSG::Char8 *string1, const OSG::Char8 *string2)
03555 {
03556     return ::strcmp(string1, string2);
03557 }
03558
03559 #ifdef OSG_1_COMPAT
03560 
03572 inline
03573 OSG::Int32 stringcmp(const OSG::Char8 *string1, const OSG::Char8 *string2)
03574 {
03575     return OSG::osgStringCmp(string1, string2);
03576 }
03577 #endif // OSG_1_COMPAT
03578 
03589 inline
03590 OSG::Int32 osgStringCaseCmp(const OSG::Char8 *string1,
03591                             const OSG::Char8 *string2)
03592 {
03593 #if !defined(WIN32)
03594     return ::strcasecmp(string1, string2);
03595 #else
03596     return _stricmp  (string1, string2);
03597 #endif
03598 }
03599
03612 inline
03613 OSG::Int32 osgStringNCaseCmp(const OSG::Char8  *string1,
03614                              const OSG::Char8  *string2,
03615                                    size_t       count)
03616 {
03617 #if !defined(WIN32)
03618     return ::strncasecmp(string1, string2, count);
03619 #else
03620     return _strnicmp  (string1, string2, count);
03621 #endif
03622 }
03623
03624 #ifdef OSG_1_COMPAT
03625 
03637 inline
03638 OSG::Int32 stringcasecmp(const OSG::Char8 *string1,
03639                          const OSG::Char8 *string2)
03640 {
03641     return OSG::osgStringCaseCmp(string1, string2);
03642 }
03643 #endif // OSG_1_COMPAT
03644 
03645
03646 // Indirector
03647
03648 template <class ContentT, class IndexT> inline
03649 indirector<ContentT, IndexT>::indirector(ContentT cont) : _cont(cont)
03650 {
03651 }
03652
03653 template <class ContentT, class IndexT> inline
03654 bool indirector<ContentT, IndexT>::operator()(IndexT a, IndexT b)
03655 {
03656     if(_cont[a] < _cont[b])
03657         return true;
03658
03659     return false;
03660 }
03661
03663 /*---------------------------------------------------------------------*/
03664
03665 #undef OSG_UINT64_LITERAL
03666 #undef OSG_INT64_LITERAL
03667 
03668 OSG_END_NAMESPACE
03669