Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CubicSplineEngine.h
Go to the documentation of this file.
1 #ifndef CUBICSPLINEENGINE_H
2 #define CUBICSPLINEENGINE_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/engines/SoSubEngine.h>
37 #include <Inventor/engines/SoEngineOutput.h>
38 #include <Inventor/fields/SoMFVec3f.h>
39 #include <Inventor/fields/SoSFBool.h>
40 #include <Inventor/fields/SoSFTime.h>
41 #include <Inventor/fields/SoSFFloat.h>
42 #include <Inventor/fields/SoMFFloat.h>
43 #include <Inventor/fields/SoSFEnum.h>
44 #include <Inventor/fields/SoSFMatrix.h>
45 #include <Inventor/fields/SoMFRotation.h>
46 #include <Inventor/fields/SoSFVec3d.h>
47 #include <Inventor/lists/SbList.h>
48 #include <Inventor/lists/SoCallbackList.h>
49 #include <Inventor/SbMatrix.h>
50 #include <Inventor/lists/SbList.h>
52 
53 #include <SmallChange/basic.h>
54 
55 
56 class SMALLCHANGE_DLL_API CubicSplineEngine : public SoEngine {
57  typedef SoEngine inherited;
58 
59  SO_ENGINE_HEADER(CubicSplineEngine);
60 
61 public:
62 
63  enum Type {
64  CATMULL_ROM = 0,
67  GENERIC
68  };
69 
70  void setVerifyCallback(void (*cb)(SbVec3d &));
71  void setLinear(const SbBool onoff) {
72  this->linear = onoff;
73  }
74 
76 
80  SoSFMatrix basisMatrix; // only valid when type == GENERIC
86 
87  SoEngineOutput pointOut; // SoSFVec3d
88  SoEngineOutput tangentOut; // SoSFVec3f
89  SoEngineOutput orientationOut; // SoSFRotation
90  SoEngineOutput syncOut; // SoSFTrigger
91 
92  static void initClass(void);
93  CubicSplineEngine(void);
94 
95  void addEvaluateCallback(void (*callback)(void *, CubicSplineEngine *), void * userdata);
96  void removeEvaluateCallback(void (*callback)(void *, CubicSplineEngine *), void * userdata);
97  void clearEvaluateCallbacks(void);
98 
99 protected:
100 
101  virtual ~CubicSplineEngine();
102 
103 private:
104 
105  virtual void evaluate();
106  virtual void inputChanged(SoField * which);
107 
108  void activate(const SbBool onoff);
109  SbCubicSpline currspline;
110  double currtime;
111  double currduration;
112  double starttime;
113  SoCallbackList cblist;
114  SbList <SbVec3f> currpt;
115  SbBool first;
116  SbBool linear;
117 
118  void (*verifycb)(SbVec3d & pos);
119 };
120 
121 
122 #endif // CUBICSPLINEENGINE_H
SoEngineOutput pointOut
Definition: CubicSplineEngine.h:87
void setLinear(const SbBool onoff)
Definition: CubicSplineEngine.h:71
SoSFVec3d offset
Definition: CubicSplineEngine.h:85
SoSFBool loop
Definition: CubicSplineEngine.h:83
SoMFFloat orientationTime
Definition: CubicSplineEngine.h:79
SoMFVec3f controlpoint
Definition: CubicSplineEngine.h:77
Definition: CubicSplineEngine.h:65
SoSFMatrix basisMatrix
Definition: CubicSplineEngine.h:80
virtual void inputChanged(SoField *which)
SoEngineOutput syncOut
Definition: CubicSplineEngine.h:90
SoSFEnum type
Definition: CubicSplineEngine.h:84
Definition: CubicSplineEngine.h:66
static void initClass(void)
Definition: SbCubicSpline.h:44
SoEngineOutput tangentOut
Definition: CubicSplineEngine.h:88
Definition: CubicSplineEngine.h:56
SoSFBool on
Definition: CubicSplineEngine.h:82
SoMFRotation orientation
Definition: CubicSplineEngine.h:78
Type
Definition: CubicSplineEngine.h:63
virtual void evaluate(void)=0
SoSFTime timeIn
Definition: CubicSplineEngine.h:75
SoEngineOutput orientationOut
Definition: CubicSplineEngine.h:89
SoSFFloat duration
Definition: CubicSplineEngine.h:81