foreach (const MeshPointer& mesh, meshes) { meshNormalStartOffset.append(currentNormalStartOffset); const gpu::BufferView& normalsBufferView = mesh->getAttributeBuffer(gpu::Stream::InputSlot::NORMAL); gpu::BufferView::Index numNormals = (gpu::BufferView::Index)normalsBufferView.getNumElements(); for (gpu::BufferView::Index i = 0; i < numNormals; i++) { glm::vec3 normal = normalsBufferView.get<glm::vec3>(i); out << "vn "; out << formatFloat(normal[0]) << " "; out << formatFloat(normal[1]) << " "; out << formatFloat(normal[2]) << "\n"; } currentNormalStartOffset += numNormals; }
void Functions::printFloat(Aurora::NWScript::FunctionContext &ctx) { const float value = ctx.getParams()[0].getFloat(); const int width = ctx.getParams()[1].getInt(); const int decimals = ctx.getParams()[2].getInt(); status("NWN2: %s", formatFloat(value, width, decimals).c_str()); }
void Functions::floatToString(Aurora::NWScript::FunctionContext &ctx) { const float value = ctx.getParams()[0].getFloat(); const int width = ctx.getParams()[1].getInt(); const int decimals = ctx.getParams()[2].getInt(); ctx.getReturn() = formatFloat(value, width, decimals); }
void DialogEditSIMDRegister::updateFloatEntries(const std::array<NumberEdit*,numBytes/sizeof(T)>& entries,NumberEdit* notUpdated) { for(std::size_t i=0;i<entries.size();++i) { if(entries[i]==notUpdated) continue; T value; std::memcpy(&value,&value_[i*sizeof(value)],sizeof(value)); entries[i]->setText(formatFloat(value)); } }
char *getData(){ int totmem = totalMemory(); char *TOTAL_MEMORY = formatInt(totmem); float freemem = freeMemory(); float usedmem = usedMemory(); char *FREE_MEMORY = formatFloat(freemem); char *USED_MEMORY = formatFloat(usedmem); double loadavg[1]; getloadavg(loadavg, 1); char *CPU_LOAD_AVG = formatDouble(loadavg[0] * 10); double cpuLoad = getCpuReading(); char *CPU_LOAD_CURR = formatDouble(cpuLoad); double cpuTemp = getCpuTemp(); char *CPU_TEMP = formatDouble(cpuTemp); char host[40];//cuts username off if more than 40 characters. gethostname(host, sizeof(host)); char HOSTNAME[40] ="|"; strcat(HOSTNAME,host); int hostlen = strlen(HOSTNAME); for (int s = hostlen; s <40; s++){//fill excess space to prevent overflows. strcpy(&HOSTNAME[s], " "); } char *data = new char[75]; //original 35 strcpy(data,HOSTNAME); strcat(data,TOTAL_MEMORY); strcat(data,FREE_MEMORY); strcat(data,USED_MEMORY); strcat(data,CPU_LOAD_AVG); strcat(data,CPU_LOAD_CURR); strcat(data,CPU_TEMP); return data; }
void formatLabels() { const wxString unit = wxT( "Hz" ); wxString suffix; int power; for( auto &l : TickLabels() ) { getSISuffix( l.pos, unit, power, suffix ); double sf = pow( 10.0, power ); int k = countDecimalDigits( l.pos / sf, 3 ); l.label = formatFloat( l.pos / sf, k ) + suffix; l.visible = true; } }
static void formatSILabels( mpScaleBase* scale, const wxString& aUnit, int nDigits ) { double maxVis = scale->AbsVisibleMaxValue(); wxString suffix; int power, digits = 0; getSISuffix( maxVis, aUnit, power, suffix ); double sf = pow( 10.0, power ); for( auto &l : scale->TickLabels() ) { int k = countDecimalDigits( l.pos / sf, nDigits ); digits = std::max( digits, k ); } for( auto &l : scale->TickLabels() ) { l.label = formatFloat ( l.pos / sf, digits ) + suffix; l.visible = true; } }
bool writeOBJToTextStream(QTextStream& out, QList<MeshPointer> meshes) { // each mesh's vertices are numbered from zero. We're combining all their vertices into one list here, // so keep track of the start index for each mesh. QList<int> meshVertexStartOffset; QList<int> meshNormalStartOffset; int currentVertexStartOffset = 0; int currentNormalStartOffset = 0; // write out vertices (and maybe colors) foreach (const MeshPointer& mesh, meshes) { meshVertexStartOffset.append(currentVertexStartOffset); const gpu::BufferView& vertexBuffer = mesh->getVertexBuffer(); const gpu::BufferView& colorsBufferView = mesh->getAttributeBuffer(gpu::Stream::COLOR); gpu::BufferView::Index numColors = (gpu::BufferView::Index)colorsBufferView.getNumElements(); gpu::BufferView::Index colorIndex = 0; int vertexCount = 0; gpu::BufferView::Iterator<const glm::vec3> vertexItr = vertexBuffer.cbegin<const glm::vec3>(); while (vertexItr != vertexBuffer.cend<const glm::vec3>()) { glm::vec3 v = *vertexItr; out << "v "; out << formatFloat(v[0]) << " "; out << formatFloat(v[1]) << " "; out << formatFloat(v[2]); if (colorIndex < numColors) { glm::vec3 color = colorsBufferView.get<glm::vec3>(colorIndex); out << " " << formatFloat(color[0]); out << " " << formatFloat(color[1]); out << " " << formatFloat(color[2]); colorIndex++; } out << "\n"; vertexItr++; vertexCount++; } currentVertexStartOffset += vertexCount; }
String FieldVisitorToString::operator() (const Float64 & x) const { return formatFloat(x); }
bool MicroRateCalculator::testMicroRateCoeffs(Reaction* pReact, PersistPtr ppbase) const { vector<Molecule *> unimolecularspecies; pReact->get_unimolecularspecies(unimolecularspecies); if (!unimolecularspecies.size()){ ctest << "\nNo microcanonical rate coefficients for " << pReact->getName() << endl; return true; } string comment("Canonical rate coefficients (calculated from microcanonical rate coefficients)"); PersistPtr ppList = ppbase->XmlWriteMainElement("me:canonicalRateList", comment); ctest << "\nCanonical (high pressure) rate coefficients for " << pReact->getName() << ", calculated from microcanonical rates\n{\n"; //Number of reactants and products to set kf,kb and Keq units vector<Molecule*> vec; int nr = pReact->get_reactants(vec); int np = pReact->get_products(vec); ctest << right << setw(7) << "T/K" << setw(20) << (nr == 2 ? "kf/cm3molecule-1s-1" : "kf/s-1") << setw(20) << (np == 2 ? "kb/cm3molecule-1s-1" : "kb/s-1") << setw(18) << ((np - nr) == 0 ? "Keq " : ((np - nr) > 0 ? "Keq/moleculecm-3" : "Keq/cm3molecule-1")) << endl; // Save the current value of excess concentration and set it to unity // to prevent division by zero for assocaiation type reactions. const double current_conc = pReact->get_concExcessReactant(); pReact->set_concExcessReactant(1.0); // Save current value of beta. const double current_beta = pReact->getEnv().beta; // Calculate Canonical rate coefficients up to the max. temperature givn by MesmerEnv. MesmerEnv &env = const_cast<MesmerEnv&>(pReact->getEnv()); double dTemp(100.0); // 100 K intervals. double Temp(0.0); vector<double> Coeffs; size_t nTemp(size_t(pReact->getEnv().MaximumTemperature / dTemp) + 1); for (size_t j(0); j < nTemp; j++) { Temp += dTemp; env.beta = 1.0 / (boltzmann_RCpK*Temp); Coeffs.clear(); pReact->HighPresRateCoeffs(&Coeffs); formatFloat(ctest, Temp, 6, 7); formatFloat(ctest, Coeffs[0], 6, 20); if (Coeffs.size()>1) //output only forward rate if no ZPE has been provided { formatFloat(ctest, Coeffs[1], 6, 20); formatFloat(ctest, Coeffs[2], 6, 18); } ctest << endl; // Add to XML document. vector<Molecule*> vec; int nr = pReact->get_reactants(vec); int np = pReact->get_products(vec); PersistPtr ppItem = ppList->XmlWriteElement("me:kinf"); PersistPtr pp = ppItem->XmlWriteValueElement("me:T", Temp, 6); if (j == 0) pp->XmlWriteAttribute("units", "K"); pp = ppItem->XmlWriteValueElement("me:val", Coeffs[0], 6); if (j == 0) pp->XmlWriteAttribute("units", nr == 2 ? "cm3molecule-1s-1" : "s-1"); if (Coeffs.size() > 1) { pp = ppItem->XmlWriteValueElement("me:rev", Coeffs[1], 6); if (j == 0) pp->XmlWriteAttribute("units", np == 2 ? "cm3molecule-1s-1" : "s-1"); pp = ppItem->XmlWriteValueElement("me:Keq", Coeffs[2], 6); if (j == 0) pp->XmlWriteAttribute("units", ((np - nr) == 0 ? "" : ((np - nr) > 0 ? "moleculecm-3" : "cm3molecule-1"))); } } ctest << "}\n"; // Restore excess concentration value. pReact->set_concExcessReactant(current_conc); // Restore current value of beta. env.beta = current_beta; return true; }