Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/DataSource/ACLVISOperations.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  *
00007  * Visit http://people.web.psi.ch/adelmann/ for more details
00008  *
00009  ***************************************************************************/
00010 
00011 #ifndef ACLVIS_OPERATIONS_H
00012 #define ACLVIS_OPERATIONS_H
00013 
00014 /***********************************************************************
00015  * 
00016  * This file contains various ACLVIS-specific helper classes and templated
00017  * functions, which are used to convert templated objects into type-specific
00018  * ACLVIS structures.
00019  *
00020  ***********************************************************************/
00021 
00022 // include files
00023 #ifdef IPPL_LUX
00024 # include "luxvis.h"
00025 #else
00026 # include "aclvis/aclvis.h"
00027 #endif
00028 #include "AppTypes/Vektor.h"
00029 #include "AppTypes/dcomplex.h"
00030 
00031 
00033 // simple templated class with specializations to convert data to float
00034 // if possible, or else to just return 0
00035 struct ACLVISToFloat {
00036   template<class T>
00037   float operator()(const T&)            { return 0.0; }
00038 
00039   float operator()(const char& val)     { return static_cast<float>(val); }
00040   float operator()(const short& val)    { return static_cast<float>(val); }
00041   float operator()(const int& val)      { return static_cast<float>(val); }
00042   float operator()(const long& val)     { return static_cast<float>(val); }
00043   float operator()(const float& val)    { return static_cast<float>(val); }
00044   float operator()(const double& val)   { return static_cast<float>(val); }
00045   float operator()(const dcomplex& val) {
00046     return static_cast<float>(norm(val));
00047   }
00048 };
00049 
00050 
00052 // a templated traits class which is used to determine what type of data is
00053 // being displayed, and to convert the data into the format needed by the
00054 // ACLVIS tools.  By default, it works for scalar data.
00055 template<class V, class T>
00056 struct ACLVISTraits {
00057   // return what type of data this is
00058 #ifdef IPPL_LUX
00059   static int getType() { return vizStructuredFieldDataType::LUXVIS_SCALAR; }
00060 #else
00061   static int getType() { return vizStructuredFieldDataType::ACLVIS_SCALAR; }
00062 #endif
00063 
00064   // set the value of the Nth point
00065   static void setPoint(V *vizdata, int indx, const T &val) {
00066     vizdata->GetVizData()->AddScalar(indx, ACLVISToFloat()(val));
00067   }
00068 
00069   // set the value of the Nth ID ... this should only be defined in this
00070   // version of the traits class
00071   static void setID(V *vizdata, int indx, int id) {
00072     vizdata->GetVizData()->AddIdInfoVal(indx, id);
00073   }
00074 };
00075 
00076 
00078 // a version of the Traits class for Vektors
00079 template<class V, class T, unsigned int D>
00080 struct ACLVISTraits<V, Vektor<T,D> > {
00081   // return what type of data this is
00082 #ifdef IPPL_LUX
00083   static int getType() { return vizStructuredFieldDataType::LUXVIS_VECTOR; }
00084 #else
00085   static int getType() { return vizStructuredFieldDataType::ACLVIS_VECTOR; }
00086 #endif
00087 
00088   // set the value of the Nth point
00089   static void setPoint(V *vizdata, int indx, const Vektor<T,D> &val) {
00090     float vect[3];
00091     for (unsigned int d=0; d < 3; ++d)
00092       vect[d] = (d < D ? ACLVISToFloat()(val[d]) : 0.0);
00093     vizdata->GetVizData()->AddVector(indx, vect);
00094   }
00095 
00096   // set the value of the Nth particle coordinate ... this should only
00097   // be defined in this version of the traits class
00098   static void setCoord(V *vizdata, int indx, const Vektor<T,D> &pos) {
00099     float vect[3];
00100     for (unsigned int d=0; d < 3; ++d)
00101       vect[d] = (d < D ? ACLVISToFloat()(pos[d]) : 0.0);
00102     vizdata->GetVizData()->AddPoint(indx, vect);
00103   }
00104 };
00105 
00106 
00107 #endif // ACLVIS_OPERATIONS_H
00108 
00109 /***************************************************************************
00110  * $RCSfile: ACLVISOperations.h,v $   $Author: adelmann $
00111  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:24 $
00112  * IPPL_VERSION_ID: $Id: ACLVISOperations.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $ 
00113  ***************************************************************************/

Generated on Fri Nov 2 01:25:55 2007 for IPPL by doxygen 1.3.5