H3D API  2.4.1
H3DFunctionNode.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __H3DFUNCTIONNODE_H__
30 #define __H3DFUNCTIONNODE_H__
31 
32 #include <H3D/X3DNode.h>
33 #include <H3D/MFDouble.h>
34 #include <H3D/SFDouble.h>
35 
36 #include <HAPI/HAPIFunctionObject.h>
37 
38 namespace H3D {
39 
45  class H3DAPI_API H3DFunctionNode : public X3DNode {
46  public:
47 
50  class H3DAPI_API Value: public TypedField< SFDouble, MFDouble > {
51  protected:
52  virtual void update();
53  };
54 
56  H3DFunctionNode( Inst< SFNode > _metadata = 0,
57  Inst< MFDouble > _input = 0,
58  Inst< Value > _output = 0 );
59 
61  virtual H3DDouble evaluate( H3DDouble *input ) = 0;
62 
64  inline H3DDouble evaluate( H3DDouble _input ) {
65  return evaluate( &_input );
66  }
67 
69  inline H3DDouble get( H3DDouble _input ) {
70  return evaluate( &_input );
71  }
72 
74  virtual unsigned int nrInputValues() = 0;
75 
81  virtual HAPI::HAPIFunctionObject *getAsHAPIFunctionObject() { return NULL;}
82 
83  virtual string defaultXMLContainerField() {
84  return "function";
85  }
86 
88  H3DUniquePtr< MFDouble > input;
89 
92  H3DUniquePtr< Value > output;
93 
98  H3DUniquePtr< Field > functionChanged;
99  };
100 }
101 
102 #endif
Contains the MFDouble field class.
Contains the SFDouble field class.
Header file for X3DNode, X3D scene-graph node.
Field class that calculates the function value for the given input.
Definition: H3DFunctionNode.h:50
Base class for nodes evaluating function.
Definition: H3DFunctionNode.h:45
H3DDouble get(H3DDouble _input)
Same as evaluate(). For backwards compatability.
Definition: H3DFunctionNode.h:69
H3DDouble evaluate(H3DDouble _input)
Shortcut for functions just taking one input.
Definition: H3DFunctionNode.h:64
virtual H3DDouble evaluate(H3DDouble *input)=0
Evaluate the function for the given input.
H3DUniquePtr< Field > functionChanged
Field that indicated whether the function has changed.
Definition: H3DFunctionNode.h:98
virtual unsigned int nrInputValues()=0
Returns the number of input values the function takes.
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: H3DFunctionNode.h:83
H3DUniquePtr< Value > output
Output value from the function when evaluated for the input values given in the input field.
Definition: H3DFunctionNode.h:92
virtual HAPI::HAPIFunctionObject * getAsHAPIFunctionObject()
Returns the function as a HAPIFunctionObject.
Definition: H3DFunctionNode.h:81
H3DUniquePtr< MFDouble > input
Input value to the function to evaluate.
Definition: H3DFunctionNode.h:88
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
This abstract node type is the base type for all nodes in the X3D system.
Definition: X3DNode.h:65
double H3DDouble
H3D API namespace.
Definition: Anchor.h:38