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_PARTICLE_BASE_DATA_SOURCE_H 00012 #define ACLVIS_PARTICLE_BASE_DATA_SOURCE_H 00013 00014 /*********************************************************************** 00015 * 00016 * class ACLVISParticleBaseDataSource 00017 * 00018 * ACLVISParticleBaseDataSource is a specific version of ParticleBaseDataSource 00019 * which takes position and attribute data for a given ParticleBase and 00020 * provides it to an external agency. This is done by collecting data on 00021 * node 0, and formatting it for VTK use. 00022 * 00023 * ACLVISParticleBaseDataSource will take the position data, and all connected 00024 * attributes for the ParticleBase, and update their values. 00025 * 00026 ***********************************************************************/ 00027 00028 // include files 00029 #include "DataSource/PtclBaseDataSource.h" 00030 #include "Utility/vmap.h" 00031 00032 00033 // forward declarations 00034 template<class PLayout> class ParticleBase; 00035 class ACLVISDataConnect; 00036 00037 00038 // class definition 00039 template<class PLayout> 00040 class ACLVISParticleBaseDataSource : public ParticleBaseDataSource { 00041 00042 public: 00043 // constructor: name, connection method, transfer method, pbase 00044 ACLVISParticleBaseDataSource(const char *, DataConnect *, int, 00045 ParticleBase<PLayout>&); 00046 00047 // destructor 00048 virtual ~ACLVISParticleBaseDataSource(); 00049 00050 // 00051 // DataSourceObject virtual function interface. 00052 // 00053 00054 // Update the object, that is, make sure the receiver of the data has a 00055 // current and consistent snapshot of the current state. Return success. 00056 virtual bool update(); 00057 00058 // Indicate to the receiver that we're allowing them time to manipulate the 00059 // data (e.g., for a viz program, to rotate it, change representation, etc.) 00060 // This should only return when the manipulation is done. 00061 virtual void interact(const char * = 0); 00062 00063 // 00064 // ParticleBaseDataSource virtual function interface 00065 // 00066 00067 // make a connection using the given attribute. Return success. 00068 virtual bool connect_attrib(ParticleAttribDataSource *); 00069 00070 // disconnect from the external agency the connection involving this 00071 // particle base and the given attribute. Return success. 00072 virtual bool disconnect_attrib(ParticleAttribDataSource *); 00073 00074 // check to see if the given ParticleAttribBase is in this ParticleBase's 00075 // list of registered attributes. Return true if this is so. 00076 virtual bool has_attrib(ParticleAttribBase *); 00077 00078 private: 00079 // the set of particles to connect 00080 ParticleBase<PLayout>& MyParticleBase; 00081 00082 // recast of DataConnect to ACL-specific object 00083 ACLVISDataConnect *ACLVISConnection; 00084 00085 // a map from particle ID's to their serialized index (0 ... totalnum-1). 00086 // This is updated at the end of each update, so that the following update 00087 // can tell where a particle moved to. We actually keep two maps, one with 00088 // the current values, and the one used to store new values until an update 00089 // is complete. 00090 typedef vmap<typename PLayout::Index_t, unsigned int> IDMap_t; 00091 IDMap_t IDMapA; 00092 IDMap_t IDMapB; 00093 IDMap_t *IDMap; 00094 IDMap_t *NewIDMap; 00095 00096 // copy data out of the given coordinates iterator into the data structure 00097 // for the given ParticleAttribDataSource which represents the agency- 00098 // specific storage. Arguments = number of particles, starting index, 00099 // pointer to value, pointer to ID's, and ParticleAttribDataSource 00100 void insert_pos(unsigned, unsigned, typename PLayout::SingleParticlePos_t *, 00101 typename PLayout::Index_t *, 00102 ParticleAttribDataSource *); 00103 }; 00104 00105 #include "DataSource/ACLVISPtclBaseDataSource.cpp" 00106 00107 #endif // ACLVIS_PARTICLE_BASE_DATA_SOURCE_H 00108 00109 /*************************************************************************** 00110 * $RCSfile: ACLVISPtclBaseDataSource.h,v $ $Author: adelmann $ 00111 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $ 00112 * IPPL_VERSION_ID: $Id: ACLVISPtclBaseDataSource.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $ 00113 ***************************************************************************/