VedaLibMath/EquationList.h

Go to the documentation of this file.
00001 /*! \file 
00002     \author victorien ferry & www.m4nkind.com
00003     \brief This file applies the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 , read file COPYING.
00004 */
00005 #ifndef COM_M4NKIND_EquationList_H
00006 #define COM_M4NKIND_EquationList_H
00007 
00008 #include "VirtualEquation.h"
00009 #include "PackFloat.h"
00010 #include "PackStruct.h"
00011 #include "PackULong_Enums.h"
00012 #include "PackULong_Flags.h"
00013 #include "PackDynamicFloat.h"
00014 #include "PackList.h"
00015 
00016 /*!
00017     \class  EquationList
00018     \ingroup BaseObjectInherited_VedaLibMath BaseObjectInheritedDocGroup
00019     \brief  Able to compute an equation according to a list of operators.
00020 */
00021 class EquationList : public VirtualEquation
00022 {
00023 /*==================================================================
00024                                 PUBLIC
00025 ==================================================================*/
00026 public:
00027     /*!
00028         \brief  Constructor. There should only be members initialisation there.
00029     */
00030     EquationList(void);
00031 
00032     /*!
00033         \brief  Class Inheritance Descriptors. Also forces a destructor. See BASEOBJECT_DECLARE_... in .cpp
00034     */
00035     BASEOBJECT_DEFINE_CLASS(EquationList);
00036 
00037     /*!
00038         \brief   Compute a scalar value according to a parameter list (X,Y,Z,D).
00039         \param  _OutgoingParameterTable result table. elements are writen or not according to the equation.
00040         \param _IncomingParameterTable. float table, the (X,Y,Z,D) parameters.
00041     */
00042     virtual void Compute( float _OutgoingParameterTable[4] , const float _IncomingParameterTable[4] );
00043 
00044 /*==================================================================
00045                                 PROTECTED
00046 ==================================================================*/
00047 protected:
00048 
00049     //! the equation line list:
00050     PackList    mSer_EquationList;
00051     /*!
00052         \brief  just use CreateInternal() to return an error in some case...
00053         no use in other cases...
00054     */
00055     //virtual bool CreateInternal(void);
00056     /*!
00057         \brief   enum of the available Variables    
00058     */
00059     typedef enum  {
00060         eEqu_Var_Input=0,
00061         eEqu_Var_Result,
00062         eEqu_Var_A,
00063         eEqu_Var_B,
00064         eEqu_Var_C,
00065         eEqu_Var_D,
00066         eEqu_Var_E,
00067         eEqu_Var_F,
00068         eEqu_Var_G,
00069         eEqu_Var_H,
00070         eEqu_Var_NumberOfVar
00071     };
00072     /*!
00073         \brief   enum of the available operators    
00074     */
00075     typedef enum  {
00076         eEquOp_Equal=0,
00077         eEquOp_Add,
00078         eEquOp_Sub,
00079         eEquOp_Mul,
00080         eEquOp_Div,
00081         eEquOp_Ceiling,
00082         eEquOp_Floor,
00083         eEquOp_Sin,
00084         eEquOp_Cos,
00085         eEquOp_MulSin,
00086         eEquOp_MulCos,
00087         eEquOp_AddSin,
00088         eEquOp_AddCos,
00089         eEquOp_Sqrt
00090     };
00091     /*!
00092         \brief   Nested class used for operand combo,patching PackDynamicFloat.
00093     */
00094     class OperandType  : public PackDynamicType
00095     { public:
00096         //! constructor, add member:
00097         OperandType();
00098         PackULong_Enums     mSer_Variables;
00099         PackDynamicFloat    mSer_Vector;
00100     };
00101     /*!
00102         \brief   Nested class that describes a reference to an object3D, used as element in the list.
00103     */
00104     class EquationLine : public PackStruct
00105     {
00106     public:
00107         //! \brief constructor . It registers the members:
00108         EquationLine(void);
00109         //! the variable touch:
00110         PackULong_Enums mSer_AffectedVarEnum;
00111         //! which XYZT is affected
00112         PackULong_Enums mSer_AffectedDimension;
00113         //! type of affectation, =,+=,-=,*=,/=
00114         //PackULong_Enums   mSer_DoOperator;
00115         //! the operator identifier:
00116         PackULong_Enums mSer_OperatorEnum;
00117         //! which XYZT is used in operand
00118         PackULong_Enums mSer_OperandDimension;
00119         //! operand:
00120         OperandType mSer_Operand;
00121         //! precalculation:
00122         //char m_AffectedToOperandIndex[4];
00123     };
00124     
00125     /*!
00126         \brief  static method passed to the list to create new elements.
00127         \return a new MathOperator object.
00128     */
00129     static BaseType *NewEquationLine();
00130     
00131     static  void    Op_Equal(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00132     static  void    Op_Add(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00133     static  void    Op_Sub(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00134     static  void    Op_Mul(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00135     static  void    Op_Div(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00136     static  void    Op_Ceiling(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00137     static  void    Op_Floor(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00138     static  void    Op_CosSin(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00139     static  void    Op_AddCosSin(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00140     static  void    Op_MulCosSin(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00141     static  void    Op_Random(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00142     static  void    Op_Norm(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00143 
00144     //static    void    Op_Sqrt(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00145 
00146     //! function table to execute the operators by index.
00147     static void (*m_Op_FunctionTable[])(float *_pAffect,unsigned int _nbAffect,float *_pOperand,unsigned int _nbOp);
00148 
00149 
00150 };
00151 #endif

      /\/\        4         N         k         !         N         D
                      _______  _ __ ___  _____            ___ _ _  ____
     ___________  __//___   /________  |/    / ___________\_______/    \
    /   _   _   \/   _     /    _   /      _/_/____/    _       __     /
   /    /   /       /     /    /    \      \/     /    /    \   \     /
  \\___/___/___/    ¯    _____/_____/       ______\___/_____/\________\\
               \________/_ ___ __ l____\      /elD!  
                 http://www.m4nkind.com \____/