Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoInterpolate.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Ronen Barzel (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2019 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_INTERPOLATE_
51#define _SO_INTERPOLATE_
52
53#include <Inventor/SoDB.h>
63
65//
66// Class: SoInterpolate
67//
68// Abstract base class for all interpolater engines. An interpolater
69// engine interpolates linearly between two values, based on "alpha"
70// between 0 and 1.
71//
73
100class SoInterpolate : public SoEngine {
101
103
104 public:
114
115 private:
116 static void initClass();
117 static void exitClass();
118 static void initClasses(); // init all builtin derived classes
119 static void exitClasses();
120
121 private:
123
124 static int findMax(int a, int b) { return (a > b) ? a : b; }
125 static int clamp(int i, int n) { return (i < n) ? i : n-1; }
126
128};
129
131//
132// These macros can be used to easily define interpolater engine
133// headers and source.
134//
136
137//
138// This macro is to be used within the class definition header. It
139// declares variables and methods that all interpolaters support
140//
141
142#define SO_INTERPOLATE_HEADER(className) \
143 \
144 SO_ENGINE_HEADER(className); \
145 \
146 private: \
147 ~className(); \
148 \
151 virtual void evaluate(); \
152 \
153 private:\
154 static void initClass(); \
155 static void exitClass(); \
156 \
157 public: \
158 \
159 className()
160
161//
162// This macro is to be used within the class source. It defines the
163// variables and methods declared in SO_INTERPOLATE_HEADER().
164// The "interpVal" argument should be an expression that returns
165// the interpolation between local variables "v0" and "v1" of type
166// "valType", based on local variable "a" which is a float.
168
169#define SO_INTERPOLATE_SOURCE(className, type, \
170 valType, defaultVal0, defaultVal1, interpVal) \
171 \
172SO_ENGINE_SOURCE(className)/*;*/ \
173 \
174className::className() \
175{ \
176 SO_ENGINE_CONSTRUCTOR(className); \
177 SO_ENGINE_ADD_INPUT(alpha, (0.0)); \
178 SO_ENGINE_ADD_INPUT(input0, defaultVal0); \
179 SO_ENGINE_ADD_INPUT(input1, defaultVal1); \
180 SO_ENGINE_ADD_OUTPUT(output, type); \
181 isBuiltIn = TRUE; \
182} \
183 \
184className::~className() \
185{ \
186} \
187 \
188void \
189className::evaluate() \
190{ \
191 int n0 = input0.getNum(); \
192 int n1 = input1.getNum(); \
193 float a = alpha.getValue(); \
194 for (int i=findMax(n0,n1)-1; i>=0; i--) { \
195 valType v0 = input0[clamp(i,n0)]; \
196 valType v1 = input1[clamp(i,n1)]; \
197 SO_ENGINE_OUTPUT(output, type, set1Value(i, interpVal)); \
198 } \
199}
200
202//
203// This macro defines the initClass method for Interpolators. It is
204// separate from the _SOURCE macro so that we can put all of the
205// engine's initClass methods near each other to reduce the number of
206// pages touched on startup (decreasing startup time and the amount of
207// memory used).
209
210#define SO_INTERPOLATE_INITCLASS(className, classPrintName) \
211 \
212void \
213className::initClass() \
214{ \
215 SO__ENGINE_INIT_CLASS(className, classPrintName, SoInterpolate); \
217
218#define SO_INTERPOLATE_EXITCLASS(className) \
219 \
220void \
221className::exitClass() \
222{ \
223 SO_ENGINE_EXIT_CLASS(className); \
224}
225
227//
228// Interpolaters for the builtin field types.
229//
231
265class SoInterpolateFloat : public SoInterpolate {
267 public:
272
277
278
280 //
281 // #unfound SoInterpolateFloat()
282 //
284};
285
321 public:
326
331
332
334 //
335 // #unfound SoInterpolateRotation()
336 //
338};
339
373class SoInterpolateVec2f : public SoInterpolate {
375 public:
380
385
386
388 //
389 // #unfound SoInterpolateVec2f()
390 //
392};
393
427class SoInterpolateVec3f : public SoInterpolate {
429 public:
434
439
440
442 //
443 // #unfound SoInterpolateVec3f()
444 //
446};
447
481class SoInterpolateVec4f : public SoInterpolate {
483 public:
488
493
494
496 //
497 // #unfound SoInterpolateVec4f()
498 //
500};
501
502#endif /* _SO_INTERPOLATE_ */
503
504
505
506
507
508
#define SO_INTERPOLATE_HEADER(className)
#define SO_ENGINE_ABSTRACT_HEADER(className)
Base class for all engines.
Definition SoEngine.h:133
Class for all engine outputs.
Definition SoEngine.h:282
Interpolates floating-point values.
SoMFFloat input1
The engine linearly interpolates from input0 to input1.
SoMFFloat input0
The engine linearly interpolates from input0 to input1.
Base class for all interpolator engines.
SoEngineOutput output
( SoMFFloat ) Interpolated value.
SoSFFloat alpha
Interpolation control value.
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.
Multiple-value field containing any number of floating point values.
Definition SoMFFloat.h:90
Multiple-value field containing any number of SbRotations.
Multiple-value field containing any number of two-dimensional vectors.
Definition SoMFVec2f.h:89
Multiple-value field containing any number of three-dimensional vectors.
Definition SoMFVec3f.h:181
Multiple-value field containing any number of four-dimensional vectors.
Definition SoMFVec4f.h:90
Field containing a floating-point value.
Definition SoSFFloat.h:78