Coin Logo http://www.sim.no/
http://www.coin3d.org/

SoInterpolate.h
1 /**************************************************************************\
2  *
3  * This file is part of the Coin 3D visualization library.
4  * Copyright (C) by Kongsberg Oil & Gas Technologies.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.GPL at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using Coin with software that can not be combined with the GNU
13  * GPL, and for taking advantage of the additional benefits of our
14  * support services, please contact Kongsberg Oil & Gas Technologies
15  * about acquiring a Coin Professional Edition License.
16  *
17  * See http://www.coin3d.org/ for more information.
18  *
19  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
20  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
21  *
22 \**************************************************************************/
23 
24 #ifndef COIN_SOINTERPOLATE_H
25 #define COIN_SOINTERPOLATE_H
26 
27 
28 #include <Inventor/engines/SoSubEngine.h>
29 #include <Inventor/engines/SoEngineOutput.h>
30 #include <Inventor/fields/SoSFFloat.h>
31 
32 class COIN_DLL_API SoInterpolate : public SoEngine {
33  typedef SoEngine inherited;
34  SO_ENGINE_ABSTRACT_HEADER(SoInterpolate);
35 
36 public:
37  static void initClass(void);
38  static void initClasses(void);
39 
41  SoEngineOutput output; // type varies for subclasses
42 
43 protected:
44  SoInterpolate();
45  virtual ~SoInterpolate(void);
46 };
47 
48 
49 
51 
52 
53 #define SO_INTERPOLATE_HEADER(_class_) \
54  SO_ENGINE_HEADER(_class_); \
55  public: \
56  _class_(); \
57  static void initClass(); \
58  protected: \
59  virtual ~_class_(); \
60  private: \
61  virtual void evaluate()
62 
63 
64 #define PRIVATE_SO_INTERPOLATE_CONSTRUCTOR(_class_, _type_, _valtype_, _default0_, _default1_) \
65  SO_ENGINE_CONSTRUCTOR(_class_); \
66  SO_ENGINE_ADD_INPUT(alpha, (0.0f)); \
67  SO_ENGINE_ADD_INPUT(input0, _default0_); \
68  SO_ENGINE_ADD_INPUT(input1, _default1_); \
69  SO_ENGINE_ADD_OUTPUT(output, _type_)
70 
71 #define PRIVATE_SO_INTERPOLATE_DESTRUCTOR(_class_) \
72 _class_::~_class_() \
73 { \
74 }
75 
76 #define PRIVATE_SO_INTERPOLATE_EVALUATE(_class_, _type_, _valtype_, _interpexp_) \
77 void \
78 _class_::evaluate(void) \
79 { \
80  int n0 = this->input0.getNum(); \
81  int n1 = this->input1.getNum(); \
82  float a = this->alpha.getValue(); \
83  for (int i = SbMax(n0, n1) - 1; i >= 0; i--) { \
84  _valtype_ v0 = this->input0[SbMin(i, n0-1)]; \
85  _valtype_ v1 = this->input1[SbMin(i, n1-1)]; \
86  SO_ENGINE_OUTPUT(output, _type_, set1Value(i, _interpexp_)); \
87  } \
88 }
89 
90 
91 // Considering the number of lines of code needed to implement
92 // the evaluate() method in each class, I'm amazed it is defined in
93 // a macro and not simply implemented for each class. But, I guess
94 // we'll have to supply this macro to keep the OIV compatibility,
95 // so here it is. Check the interpolator classes for examples on
96 // how to use it.
97 // pederb, 20000309
98 //
99 // There's another version of this macro for internal use in the
100 // SoSubEngineP.h file, so match any changes you do here with that
101 // macro also -- if applicable.
102 //
103 // mortene, 20000505
104 
105 #define SO_INTERPOLATE_SOURCE(_class_, _type_, _valtype_, _default0_, _default1_, _interpexp_) \
106  \
107 SO_ENGINE_SOURCE(_class_); \
108  \
109 _class_::_class_(void) \
110 { \
111  PRIVATE_SO_INTERPOLATE_CONSTRUCTOR(_class_, _type_, _valtype_, _default0_, _default1_); \
112  this->isBuiltIn = FALSE; \
113 } \
114  \
115 PRIVATE_SO_INTERPOLATE_DESTRUCTOR(_class_) \
116 PRIVATE_SO_INTERPOLATE_EVALUATE(_class_, _type_, _valtype_, _interpexp_)
117 
118 
119 #define SO_INTERPOLATE_INITCLASS(_class_, _classname_) \
120  \
121 void \
122 _class_::initClass(void) \
123 { \
124  SO_ENGINE_INIT_CLASS(_class_, SoInterpolate, "SoInterpolate"); \
125 }
126 
127 
129 
130 
131 #ifndef COIN_INTERNAL
132 // Include these header files for better Open Inventor compatibility.
133 #include <Inventor/engines/SoInterpolateFloat.h>
134 #include <Inventor/engines/SoInterpolateVec2f.h>
135 #include <Inventor/engines/SoInterpolateVec3f.h>
136 #include <Inventor/engines/SoInterpolateVec4f.h>
137 #include <Inventor/engines/SoInterpolateRotation.h>
138 #endif // !COIN_INTERNAL
139 
140 
141 #endif // !COIN_SOINTERPOLATE_H
The SoInterpolate class is the base class for all interpolator engines.Interpolators are used to line...
Definition: SoInterpolate.h:32
SoEngine is the base class for Coin engines.Engines enables the application programmers to make compl...
Definition: SoEngine.h:34
The SoFieldContainer class is a base class for all classes that contain fields.The classes containing...
Definition: SoFieldContainer.h:34
SoEngineOutput output
Definition: SoInterpolate.h:41
SoSFFloat alpha
Definition: SoInterpolate.h:40
static void initClasses(void)
Definition: SoEngine.cpp:163
The SoEngineOutput class is the output slots in SoEngine instances.SoEngineOutput has methods for con...
Definition: SoEngineOutput.h:36
The SoSFFloat class is a container for a floating point value.This field is used where nodes...
Definition: SoSFFloat.h:30

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Wed Feb 7 2018 for Coin by Doxygen 1.8.14.