00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "DataSource/ACLVISPtclAttribDataSource.h"
00028 #include "DataSource/ACLVISOperations.h"
00029 #include "Particle/ParticleAttrib.h"
00030 #include "Particle/ParticleLayout.h"
00031 #include "Message/Message.h"
00032 #include "Utility/IpplInfo.h"
00033 #include "Utility/Pstring.h"
00034 #include "Profile/Profiler.h"
00035
00036
00038
00039 template<class T>
00040 ACLVISParticleAttribDataSource<T>::ACLVISParticleAttribDataSource(const
00041 char *nm,
00042 DataConnect *dc, int tm, ParticleAttrib<T>& pa)
00043 : ParticleAttribDataSource(nm, dc, tm, &pa, &pa), MyParticles(pa) {
00044
00045 TAU_TYPE_STRING(taustr, "void (char *, DataConnect *, int, " +
00046 CT(pa));
00047 TAU_PROFILE(
00048 "ACLVISParticleAttribDataSource::ACLVISParticleAttribDataSource()",
00049 taustr, TAU_VIZ);
00050
00051
00052 LocalData = 0;
00053 string filestring = "aclvis";
00054 if (string(dc->ID()) != filestring) {
00055 ERRORMSG("Illegal DataConnect object for ACLVIS Data Object." << endl);
00056 Connection = 0;
00057 } else if (tm != DataSource::OUTPUT) {
00058 ERRORMSG("ACLVIS data connections may only be of type OUTPUT." << endl);
00059 Connection = 0;
00060 } else {
00061
00062 if (PBase != 0) {
00063
00064
00065
00066
00067 if (getConnection()->onConnectNode())
00068 LocalData = new ReadParticleTool;
00069
00070
00071
00072 PBase->connect_attrib(this);
00073
00074 } else {
00075
00076 Connection = 0;
00077 }
00078 }
00079 }
00080
00081
00083
00084 template<class T>
00085 ACLVISParticleAttribDataSource<T>::~ACLVISParticleAttribDataSource() {
00086
00087 TAU_TYPE_STRING(taustr, CT(*this) + " void ()");
00088 TAU_PROFILE("ACLVISParticleAttribDataSource::~ACLVISParticleAttribDataSource()",
00089 taustr, TAU_VIZ);
00090
00091
00092 if (PBase != 0)
00093 PBase->disconnect_attrib(this);
00094
00095
00096 if (LocalData != 0)
00097 delete LocalData;
00098 }
00099
00100
00102
00103
00104
00105
00106
00107
00108 template<class T>
00109 bool ACLVISParticleAttribDataSource<T>::update() {
00110 TAU_TYPE_STRING(taustr, CT(*this) + " bool ()");
00111 TAU_PROFILE("ACLVISParticleAttribDataSource::update()", taustr, TAU_VIZ);
00112
00113
00114 return true;
00115 }
00116
00117
00119
00120
00121
00122 template<class T>
00123 void ACLVISParticleAttribDataSource<T>::interact(const char *str) {
00124 TAU_TYPE_STRING(taustr, CT(*this) + " void ()");
00125 TAU_PROFILE("ACLVISParticleAttribDataSource::interact()", taustr, TAU_VIZ);
00126
00127
00128 if (PBase != 0)
00129 PBase->interact(str);
00130 }
00131
00132
00134
00135 template<class T>
00136 void ACLVISParticleAttribDataSource<T>::putMessage(Message *msg) {
00137
00138 TAU_TYPE_STRING(taustr, CT(*this) + " void (Message *)");
00139 TAU_PROFILE("ACLVISParticleAttribDataSource::putMessage()", taustr, TAU_VIZ);
00140
00141 unsigned N = MyParticles.size();
00142
00143
00144
00145
00146
00147 if (N > 0) {
00148
00149
00150 MyParticles.putMessage(*msg, N, 0);
00151
00152 }
00153 }
00154
00155
00157
00158
00159
00160
00161 template<class T>
00162 void ACLVISParticleAttribDataSource<T>::prepare_data(bool start, unsigned N) {
00163 TAU_TYPE_STRING(taustr, CT(*this) + " void (bool, unsigned)");
00164 TAU_PROFILE("ACLVISParticleAttribDataSource::prepare_data()", taustr, TAU_VIZ);
00165
00166 if (start) {
00167
00168 LocalData->GetVizData()->InitData(N,
00169 ACLVISTraits<ReadParticleTool,T>::getType(), 1);
00170 } else {
00171
00172 LocalData->PrepareFinishedData();
00173 }
00174 }
00175
00176
00178
00179
00180
00181
00182
00183 template<class T>
00184 void ACLVISParticleAttribDataSource<T>::insert_data(unsigned N,unsigned sIndx,
00185 Message* msg) {
00186 TAU_TYPE_STRING(taustr, CT(*this) + " void (unsigned, unsigned, Message *)");
00187 TAU_PROFILE("ACLVISParticleAttribDataSource::insert_data()", taustr, TAU_VIZ);
00188
00189
00190 unsigned maxIndx = sIndx + N;
00191
00192 if (msg != 0) {
00193
00194 T* msgdata = (T *)(msg->remove());
00195 if (msgdata != 0) {
00196 T *data = msgdata;
00197 for ( ; sIndx < maxIndx; ++sIndx, ++data)
00198 ACLVISTraits<ReadParticleTool,T>::setPoint(LocalData, sIndx, *data);
00199
00200
00201 free(static_cast<void *>(msgdata));
00202 }
00203
00204 } else {
00205
00206 typename ParticleAttrib<T>::iterator msgdata = MyParticles.begin();
00207 for ( ; sIndx < maxIndx; ++sIndx, ++msgdata)
00208 ACLVISTraits<ReadParticleTool,T>::setPoint(LocalData, sIndx, *msgdata);
00209 }
00210 }
00211
00212
00213
00214
00215
00216
00217