Open Inventor Reference
SoInterpolate.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | This file defines the abstract SoInterpolate class and
48  | macros used to derive classes from it, as well as the
49  | derived classes themselves.
50  |
51  | Macros:
52  | SO_INTERPOLATE_HEADER
53  | SO_INTERPOLATE_SOURCE
54  | SO_INTERPOLATE_INITCLASS
55  |
56  | Classes:
57  |
58  | SoInterpolate (abstract base class)
59  | SoInterpolateFloat
60  | SoInterpolateRotation
61  | SoInterpolateVec2f
62  | SoInterpolateVec3f
63  | SoInterpolateVec4f
64  |
65  | Author(s) : Ronen Barzel
66  |
67  ______________ S I L I C O N G R A P H I C S I N C . ____________
68  _______________________________________________________________________
69  */
70 
71 #ifndef _SO_INTERPOLATE_
72 #define _SO_INTERPOLATE_
73 
75 #include <Inventor/SoDB.h>
83 
84 
87 
102 
104 
106 
107  public:
109 
110 
113 
115 
117 
118 
123 
125 
126  SoINTERNAL public:
127  static void initClass();
128  static void initClasses();
129 
130  protected:
132  static int max(int a, int b) { return (a > b) ? a : b; }
133  static int clamp(int i, int n) { return (i < n) ? i : n-1; }
134 
136 };
137 
144 
149 
150 #define SO_INTERPOLATE_HEADER(className) \
151  \
152  SO_ENGINE_HEADER(className); \
153  \
154  private: \
155  ~className(); \
156  virtual void evaluate(); \
157  \
158  SoINTERNAL public: \
159  static void initClass(); \
160  \
161  public: \
162  className()
163 
171 
172 #define SO_INTERPOLATE_SOURCE(className, type, \
173  valType, defaultVal0, defaultVal1, interpVal) \
174  \
175 SO_ENGINE_SOURCE(className); \
176  \
177 className::className() \
178 { \
179  SO_ENGINE_CONSTRUCTOR(className); \
180  SO_ENGINE_ADD_INPUT(alpha, (0.0)); \
181  SO_ENGINE_ADD_INPUT(input0, defaultVal0); \
182  SO_ENGINE_ADD_INPUT(input1, defaultVal1); \
183  SO_ENGINE_ADD_OUTPUT(output, type); \
184  isBuiltIn = TRUE; \
185 } \
186  \
187 className::~className() \
188 { \
189 } \
190  \
191 void \
192 className::evaluate() \
193 { \
194  int n0 = input0.getNum(); \
195  int n1 = input1.getNum(); \
196  float a = alpha.getValue(); \
197  for (int i=max(n0,n1)-1; i>=0; i--) { \
198  valType v0 = input0[clamp(i,n0)]; \
199  valType v1 = input1[clamp(i,n1)]; \
200  SO_ENGINE_OUTPUT(output, type, set1Value(i, interpVal)); \
201  } \
202 }
203 
212 
213 #define SO_INTERPOLATE_INITCLASS(className, classPrintName) \
214  \
215 void \
216 className::initClass() \
217 { \
218  SO__ENGINE_INIT_CLASS(className, classPrintName, SoInterpolate); \
219 }
225 
228 
256 
259 public:
261 
262 
266 
270 
272 
273 };
274 
277 
305 
308 public:
310 
311 
315 
319 
321 
322 };
323 
326 
354 
357 public:
359 
360 
364 
368 
370 
371 };
372 
375 
403 
406 public:
408 
409 
413 
417 
419 
420 };
421 
424 
452 
455 public:
457 
458 
462 
466 
468 
469 };
470 
471 #endif /* _SO_INTERPOLATE_ */
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
#define SO_INTERPOLATE_HEADER(className)
These macros can be used to easily define interpolater engine headers and source.
#define SO_ENGINE_ABSTRACT_HEADER(className)
Macros to be called within the class definition header:
Definition: SoSubEngine.h:146
Class for all engine outputs.
Definition: SoEngine.h:228
Base class for all engines.
Definition: SoEngine.h:102
Interpolaters for the builtin field types.
SoMFFloat input1
The engine linearly interpolates from input0 to input1 .
SoMFFloat input0
The engine linearly interpolates from input0 to input1 .
Interpolates rotation values.
SoMFRotation input1
The engine linearly interpolates from input0 to input1 .
SoMFRotation input0
The engine linearly interpolates from input0 to input1 .
Interpolates 2D floating-point vectors.
SoMFVec2f input1
The engine linearly interpolates from input0 to input1 .
SoMFVec2f input0
The engine linearly interpolates from input0 to input1 .
Interpolates 3D floating-point vectors.
SoMFVec3f input0
The engine linearly interpolates from input0 to input1 .
SoMFVec3f input1
The engine linearly interpolates from input0 to input1 .
Interpolates 4D floating-point vectors.
SoMFVec4f input0
The engine linearly interpolates from input0 to input1 .
SoMFVec4f input1
The engine linearly interpolates from input0 to input1 .
Base class for all interpolator engines.
SoEngineOutput output
Interpolated value.
static int clamp(int i, int n)
static int max(int a, int b)
static void initClasses()
init all builtin derived classes
SoSFFloat alpha
Interpolation control value.
static void initClass()
Multiple-value field containing any number of floating point values.
Definition: SoMFFloat.h:82
Multiple-value field containing any number of SbRotations.
Definition: SoMFRotation.h:89
Multiple-value field containing any number of two-dimensional vectors.
Definition: SoMFVec2f.h:83
Multiple-value field containing any number of three-dimensional vectors.
Definition: SoMFVec3f.h:85
Multiple-value field containing any number of four-dimensional vectors.
Definition: SoMFVec4f.h:85
Field containing a floating-point value.
Definition: SoSFFloat.h:77