Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoInterpolate.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2002 by Systems in Motion. All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public License
00008  *  version 2.1 as published by the Free Software Foundation. See the
00009  *  file LICENSE.LGPL at the root directory of the distribution for
00010  *  more details.
00011  *
00012  *  If you want to use Coin for applications not compatible with the
00013  *  LGPL, please contact SIM to acquire a Professional Edition license.
00014  *
00015  *  Systems in Motion, Prof Brochs gate 6, 7030 Trondheim, NORWAY
00016  *  http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097
00017  *
00018 \**************************************************************************/
00019 
00020 #ifndef COIN_SOINTERPOLATE_H
00021 #define COIN_SOINTERPOLATE_H
00022 
00023 
00024 #include <Inventor/engines/SoSubEngine.h>
00025 #include <Inventor/engines/SoEngineOutput.h>
00026 #include <Inventor/fields/SoSFFloat.h>
00027 
00028 class COIN_DLL_API SoInterpolate : public SoEngine {
00029   typedef SoEngine inherited;
00030   SO_ENGINE_ABSTRACT_HEADER(SoInterpolate);
00031 
00032 public:
00033   static void initClass(void);
00034   static void initClasses(void);
00035 
00036   SoSFFloat alpha;
00037   SoEngineOutput output; // type varies for subclasses
00038 
00039 protected:
00040   SoInterpolate();
00041   virtual ~SoInterpolate();
00042 };
00043 
00044 
00045 
00047 
00048 
00049 #define SO_INTERPOLATE_HEADER(_class_) \
00050   SO_ENGINE_HEADER(_class_); \
00051   public: \
00052     _class_(); \
00053     static void initClass(); \
00054   protected: \
00055     virtual ~_class_(); \
00056   private: \
00057     virtual void evaluate()
00058 
00059 
00060 #define PRIVATE_SO_INTERPOLATE_CONSTRUCTOR(_class_, _type_, _valtype_, _default0_, _default1_) \
00061   SO_ENGINE_CONSTRUCTOR(_class_); \
00062   SO_ENGINE_ADD_INPUT(alpha, (0.0f)); \
00063   SO_ENGINE_ADD_INPUT(input0, _default0_); \
00064   SO_ENGINE_ADD_INPUT(input1, _default1_); \
00065   SO_ENGINE_ADD_OUTPUT(output, _type_)
00066 
00067 #define PRIVATE_SO_INTERPOLATE_DESTRUCTOR(_class_) \
00068 _class_::~_class_() \
00069 { \
00070 }
00071 
00072 #define PRIVATE_SO_INTERPOLATE_EVALUATE(_class_, _type_, _valtype_, _interpexp_) \
00073 void \
00074 _class_::evaluate(void) \
00075 { \
00076   int n0 = this->input0.getNum(); \
00077   int n1 = this->input1.getNum(); \
00078   float a = this->alpha.getValue(); \
00079   for (int i = SbMax(n0, n1) - 1; i >= 0; i--) { \
00080     _valtype_ v0 = this->input0[SbMin(i, n0-1)]; \
00081     _valtype_ v1 = this->input1[SbMin(i, n1-1)]; \
00082     SO_ENGINE_OUTPUT(output, _type_, set1Value(i, _interpexp_)); \
00083   } \
00084 }
00085 
00086 
00087 // Considering the number of lines of code needed to implement
00088 // the evaluate() method in each class, I'm amazed it is defined in
00089 // a macro and not simply implemented for each class. But, I guess
00090 // we'll have to supply this macro to keep the OIV compatibility,
00091 // so here it is. Check the interpolator classes for examples on
00092 // how to use it.
00093 //                                               pederb, 20000309
00094 //
00095 // There's another version of this macro for internal use in the
00096 // SoSubEngineP.h file, so match any changes you do here with that
00097 // macro also -- if applicable.
00098 //
00099 //                                               mortene, 20000505
00100 
00101 #define SO_INTERPOLATE_SOURCE(_class_, _type_, _valtype_, _default0_, _default1_, _interpexp_) \
00102  \
00103 SO_ENGINE_SOURCE(_class_); \
00104  \
00105 _class_::_class_(void) \
00106 { \
00107   PRIVATE_SO_INTERPOLATE_CONSTRUCTOR(_class_, _type_, _valtype_, _default0_, _default1_); \
00108   this->isBuiltIn = FALSE; \
00109 } \
00110  \
00111 PRIVATE_SO_INTERPOLATE_DESTRUCTOR(_class_) \
00112 PRIVATE_SO_INTERPOLATE_EVALUATE(_class_, _type_, _valtype_, _interpexp_)
00113 
00114 
00115 #define SO_INTERPOLATE_INITCLASS(_class_, _classname_) \
00116  \
00117 void \
00118 _class_::initClass(void) \
00119 { \
00120   SO_ENGINE_INIT_CLASS(_class_, SoInterpolate, "SoInterpolate"); \
00121 }
00122 
00123 
00125 
00126 
00127 #ifndef COIN_INTERNAL
00128 // Include these header files for better Open Inventor compatibility.
00129 #include <Inventor/engines/SoInterpolateFloat.h>
00130 #include <Inventor/engines/SoInterpolateVec2f.h>
00131 #include <Inventor/engines/SoInterpolateVec3f.h>
00132 #include <Inventor/engines/SoInterpolateVec4f.h>
00133 #include <Inventor/engines/SoInterpolateRotation.h>
00134 #endif // !COIN_INTERNAL
00135 
00136 
00137 #endif // !COIN_SOINTERPOLATE_H

Generated at Tue Mar 5 03:31:14 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001