static void StringsToNum( const AcStringArray& strDatas, doubleVector& doubleDatas) { for(int i = 0; i < strDatas.length(); i++) { double temp = _tstof(strDatas[i].kACharPtr()); doubleDatas.push_back(temp); } }
void Dyna3DFile::GetMaterials(intVector &matnos, stringVector &matnames, doubleVector &matdens) { for(int i = 0; i < materialCards.size(); ++i) { matnos.push_back(materialCards[i].materialNumber); matnames.push_back(materialCards[i].materialName); matdens.push_back(materialCards[i].density); } }
void avtMinMaxQuery::CreateMessage(const int nMsg, const MinMaxInfo &info1, const MinMaxInfo &info2, string &msg, doubleVector &vals) { if (nMsg == 0) return; string var = queryAtts.GetVariables()[0]; if (nMsg == 1) { msg = var + " -- " + info1.GetType() + " = "; msg += InfoToString(info1); vals.push_back(info1.GetValue()); } else { if (nodeCentered) { msg = var + " -- " + info1.GetType() + " " + nodeMsg1; msg += "\n = "; msg += InfoToString(info1); msg = msg + "\n" + var + " -- " + info2.GetType() + " " + nodeMsg2; msg += "\n = "; msg += InfoToString(info2); vals.push_back(info1.GetValue()); } else { msg = var + " -- " + info1.GetType() + " " + zoneMsg1; msg += "\n = "; msg += InfoToString(info1); msg = msg + "\n" + var + " -- " + info2.GetType() + " " + zoneMsg2; msg += "\n = "; msg += InfoToString(info2); vals.push_back(info2.GetValue()); } } }
bool QvisXRayImageQueryWidget::GetDoubleValues(int whichWidget, doubleVector &pt) { QString temp; if (whichWidget == 0) // Background intensities { temp = backgroundIntensities->displayText().simplified(); } bool okay = !temp.isEmpty(); if(okay) { QStringList s = temp.split(" ", QString::SkipEmptyParts); for (int i = 0; okay && i < s.size(); ++i) { double val = s[i].toDouble(&okay); if (okay) pt.push_back(val); } } return okay; }
void QvisWindowBase::StringToDoubleList(const char *str, doubleVector &dv, int max) { size_t length, offset = 0; // Clear the vector. dv.clear(); // Get out if the input string is nothing. if(str == NULL || ((length = strlen(str)) == 0)) { return; } do { // Skip any preceding spaces, stop at end of string too. for(; str[offset] == ' ' || str[offset] == '\0'; ++offset); if(offset < length) { char buf[30]; sscanf(str + offset, "%s", buf); offset += strlen(buf); // Only add if the token was something. if(strlen(buf) > 0) { double dtemp = (double)atof(buf); if(dv.size() < (size_t)max) dv.push_back(dtemp); else offset = length * 2; } } } while(offset < length); }
void avtFVCOMParticleFileFormat::GetTimes(doubleVector &t) { const char *mName = "avtFVCOMParticleFileObject::GetTimes: "; debug4 << mName << endl; int ncid; ncid=fileObject->GetFileHandle(); if (ncid == -1) { std::string msg("Could not get file handle in avtParticleFileFormat::GetTimes"); EXCEPTION1(ImproperUseException, msg); } char varname[NC_MAX_NAME+1]; nc_type vartype; int ndims; int dims[NC_MAX_VAR_DIMS]; int varnatts; int time_id; int status = nc_inq_varid (ncid, "time", &time_id); if (status != NC_NOERR) { fileObject-> HandleError(status); debug4 << "Could not find variable: time" << endl; return; } // Now get variable type! status = nc_inq_var(ncid, time_id, varname, &vartype, &ndims, dims, &varnatts); if (status != NC_NOERR) fileObject-> HandleError(status); std::string timeunits; if(fileObject->ReadStringAttribute("time", "units", timeunits)) { debug4<< "timeunits: " << timeunits << endl; } else debug4<< "timeunits+++ could not get" << endl; double convert=1; if (strncmp(timeunits.c_str(), "seconds",7)==0) convert=convert/double(60*60*24); size_t ntimesteps; int ntime_id; status = nc_inq_dimid(ncid, "time", &ntime_id); if (status != NC_NOERR) fileObject-> HandleError(status); status = nc_inq_dimlen(ncid, ntime_id, &ntimesteps); if (status != NC_NOERR) fileObject-> HandleError(status); if (ndims==1 && vartype == NC_FLOAT) { float *tf = new float[ntimesteps+1]; fileObject->ReadVariableInto("time",FLOATARRAY_TYPE , tf); for(int n=0; n<ntimesteps; ++n) { t.push_back(convert * double(tf[n])); } delete [] tf; } else { debug4 << mName << "Wrong dimension for variable Time" << endl; } }