Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | Related Pages

SbBasic.h

00001 /* include/Inventor/SbBasic.h.  Generated by configure.  */
00002 /**************************************************************************\
00003  *
00004  *  This file is part of the Coin 3D visualization library.
00005  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU General Public License
00009  *  ("GPL") version 2 as published by the Free Software Foundation.
00010  *  See the file LICENSE.GPL at the root directory of this source
00011  *  distribution for additional information about the GNU GPL.
00012  *
00013  *  For using Coin with software that can not be combined with the GNU
00014  *  GPL, and for taking advantage of the additional benefits of our
00015  *  support services, please contact Systems in Motion about acquiring
00016  *  a Coin Professional Edition License.
00017  *
00018  *  See <URL:http://www.coin3d.org> for  more information.
00019  *
00020  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
00021  *  <URL:http://www.sim.no>.
00022  *
00023 \**************************************************************************/
00024 
00025 #ifndef COIN_SBBASIC_H
00026 #define COIN_SBBASIC_H
00027 
00028 /* *********************************************************************** */
00029 
00030 #include <Inventor/C/basic.h>
00031 
00032 /* *********************************************************************** */
00033 /* Trap people trying to use Inventor headers while compiling C source code.
00034  * (we get support mail about this from time to time)
00035  */
00036 #ifndef __cplusplus
00037 #error You are not compiling C++ - maybe your source file is named <file>.c
00038 #endif
00039 
00040 /* *********************************************************************** */
00041 /* Include these for Open Inventor compatibility reasons (they are not
00042  * actually used in Coin.)
00043  */
00044 #define SoEXTENDER
00045 #define SoINTERNAL
00046 
00047 /* *********************************************************************** */
00048 
00049 /* Some useful inline template functions:
00050  *   SbAbs(Val)              - returns absolute value
00051  *   SbMin(Val1, Val2)       - returns minimum value
00052  *   SbMax(Val1, Val2)       - returns maximum value
00053  *   SbClamp(Val, Min, Max)  - returns clamped value
00054  *   SbSwap(Val1, Val2)      - swaps the two values (no return value)
00055  *   SbSqr(val)              - returns (val)²
00056  */
00057 
00058 template <class Type>
00059 inline Type SbAbs( Type Val ) {
00060   return (Val < 0) ? 0 - Val : Val;
00061 }
00062 
00063 template <class Type>
00064 inline Type SbMax( const Type A, const Type B ) {
00065   return (A < B) ? B : A;
00066 }
00067 
00068 template <class Type>
00069 inline Type SbMin( const Type A, const Type B ) {
00070   return (A < B) ? A : B;
00071 }
00072 
00073 template <class Type>
00074 inline Type SbClamp( const Type Val, const Type Min, const Type Max ) {
00075   return (Val < Min) ? Min : (Val > Max) ? Max : Val;
00076 }
00077 
00078 template <class Type>
00079 inline void SbSwap( Type & A, Type & B ) {
00080   Type T; T = A; A = B; B = T;
00081 }
00082 
00083 template <class Type>
00084 inline Type SbSqr(const Type val) {
00085   return val * val;
00086 }
00087 
00088 /* *********************************************************************** */
00089 
00090 #endif /* !COIN_SBBASIC_H */

Generated on Wed Dec 10 23:49:37 2003 for Coin by doxygen 1.3.3