H3D API  2.4.1
GeneralFunction.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 __GENERALFUNCTION_H__
30 #define __GENERALFUNCTION_H__
31 
32 // H3D API includes
33 #include <H3D/H3DFunctionNode.h>
34 #include <H3D/SFString.h>
35 
36 #ifdef HAVE_FPARSER
37 
38 namespace HAPI {
39  // Forward declaration.
40  class ParsedFunction;
41 }
42 
43 namespace H3D {
144  class H3DAPI_API GeneralFunction : public H3DFunctionNode {
145  public:
150  class H3DAPI_API SFFunctionObject:
151  public TypedField< SField< HAPI::ParsedFunction * >,
152  Types< SFString, SFString > > {
153  public:
156 
157  ~SFFunctionObject();
158 
159  protected:
160  virtual void update();
161  };
162 
164  GeneralFunction( Inst< SFNode > _metadata = 0,
165  Inst< SFString > _function = 0,
166  Inst< SFString > _params = 0,
167  Inst< SFFunctionObject > _functionObject = 0 );
168 
169 
171  virtual unsigned int nrInputValues();
172 
178  virtual HAPI::HAPIFunctionObject *getAsHAPIFunctionObject();
179 
181  H3DDouble evaluate(H3DDouble *x );
182 
192  H3DUniquePtr< SFString > function;
193 
204  H3DUniquePtr< SFString > params;
205 
208 
209  protected:
211  H3DUniquePtr< SFFunctionObject > functionObject;
212  };
213 }
214 
215 #endif
216 #endif
Header file for H3DFunctionNode.
Contains the SFString field class.
Class for updating an HAPI::ParsedFunction depending on field input value.
Definition: GeneralFunction.h:152
The function node implements a general function R^n -> R by specifying it by a string.
Definition: GeneralFunction.h:144
H3DUniquePtr< SFFunctionObject > functionObject
Field with the function object to use to evaluate the function.
Definition: GeneralFunction.h:211
H3DUniquePtr< SFString > params
The function parameter string.
Definition: GeneralFunction.h:204
static H3DNodeDatabase database
The H3DNodeDatabase for this object.
Definition: GeneralFunction.h:207
Base class for nodes evaluating function.
Definition: H3DFunctionNode.h:45
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
H3DDouble x
double H3DDouble
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194