TuttleOFX  1
SeExprAlgorithm.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_SEEXPR_ALGORITHM_HPP_
00002 #define _TUTTLE_PLUGIN_SEEXPR_ALGORITHM_HPP_
00003 
00004 namespace tuttle {
00005 namespace plugin {
00006 namespace seExpr {
00007 
00008 class ImageSynthExpr : public SeExpression
00009 {
00010 public:
00011         //! Constructor that takes the expression to parse
00012         ImageSynthExpr( const std::string& expr )
00013                 :SeExpression( expr )
00014         {}
00015 
00016         //! Simple variable that just returns its internal value
00017         struct Var:public SeExprScalarVarRef
00018         {
00019                 Var( const double val )
00020                         :val(val)
00021                 {}
00022 
00023                 Var(){}
00024 
00025                 double val; // independent variable
00026                 void eval( const SeExprVarNode* /*node*/,SeVec3d& result )
00027                 { result[0] = val; }
00028         };
00029 
00030         //! variable map
00031         mutable std::map<std::string,Var> vars;
00032 
00033         //! resolve function that only supports one external variable 'x'
00034         SeExprVarRef* resolveVar( const std::string& name ) const
00035         {
00036                 std::map< std::string, Var >::iterator i = vars.find( name );
00037 
00038                 if( i != vars.end() )
00039                         return &i->second;
00040 
00041                 return 0;
00042         }
00043 };
00044 
00045 }
00046 }
00047 }
00048 
00049 #endif