/** * Write out the header information as text. * @param ofs The output file stream. * @param Dimensions[] The dimensions of the data. * @param Origin[] The origin. * @param Spacing[] The spacing. * @param Increment[] The increment. * @param ScalarType The scalar type. * The scalar type is defined as follows: * \code * #define VTK_VOID 0 * #define VTK_BIT 1 * #define VTK_CHAR 2 * #define VTK_SIGNED_CHAR 15 * #define VTK_UNSIGNED_CHAR 3 * #define VTK_SHORT 4 * #define VTK_UNSIGNED_SHORT 5 * #define VTK_INT 6 * #define VTK_UNSIGNED_INT 7 * #define VTK_LONG 8 * #define VTK_UNSIGNED_LONG 9 * #define VTK_FLOAT 10 * #define VTK_DOUBLE 11 * #define VTK_ID_TYPE 12 * \endcode */ void WriteHeader(std::ofstream & ofs, int Dimensions[3], double Origin[3], double Spacing[3], int Increment[3], int & ScalarType) { // ofs.seekg(0,std::ios::beg); std::ios::fmtflags flags = ofs.setf(std::ios::fmtflags()); ofs << std::fixed << std::setprecision(2); ofs << "Dimensions: "; for ( int i = 0; i < 3; ++i ) ofs << Dimensions[i] << " "; ofs << std::endl; ofs << "Origin: "; for ( int i = 0; i < 3; ++i ) ofs << Origin[i] << " "; ofs << std::endl; ofs << "Spacings: "; for ( int i = 0; i < 3; ++i ) ofs << Spacing[i] << " "; ofs << std::endl; ofs << "Increments: "; for ( int i = 0; i < 3; ++i ) ofs << Increment[i] << " "; ofs << std::endl; ofs << "Scalar type: " << ScalarType << std::endl; ofs << std::setprecision(6) << std::endl; std::ios::fmtflags newflags = ofs.setf(std::ios::fmtflags()); ofs.setf(flags,newflags); }
void DTMImage::WriteTextScalars(std::ofstream &ofs, int const & precision, bool const &DisplayI, bool const &DisplayJ, bool const DisplayK) { if ( this->scalars->size() != (std::size_t)(this->pointProduct[2]) ) { std::cerr << "Dimensions do not match." << std::endl; std::cerr << "Number of Scalars:" << this->scalars->size() << " expected: " << this->pointProduct[2] << std::endl; return; } std::ios::fmtflags flags = ofs.setf(std::ios::fmtflags()); ofs << std::fixed << std::setprecision(precision); int choice = (DisplayK << 2) + (DisplayJ << 1) + DisplayI; if ( choice & 4 ) choice = 4; if ( choice & 2 ) choice = 2; if ( choice & 1 ) choice = 1; if ( choice == 0 ) { for ( ufDTMScalarTypeBase::iterator p = this->scalars->begin(); p != this->scalars->end(); ++p ) ofs << *p << "\n"; return; } ufDTMScalarTypeBase::iterator p = this->scalars->begin(); int i = 0; int j = 0; int k = 0; for ( i = 0; i < this->dimensions[0]; ++i ) { if ( choice & 1 ) ofs << "(" << i << ",...,...) "; for ( j = 0; j < this->dimensions[1]; ++j ) { if( choice & 2 ) { ofs << "(" << i << "," << j << ",...) "; } for ( k = 0; k < this->dimensions[2]; ++k ) { if ( choice & 4 ) ofs << "(" << i << "," << j << "," << k << ") "; ofs << *p++ << " "; if ( choice & 4 ) ofs << std::endl; } if( choice & 2 ) ofs << std::endl; } if ( choice & 1 ) ofs << std::endl; } ofs << std::setprecision(6) << std::endl; std::ios::fmtflags newflags = ofs.setf(std::ios::fmtflags()); ofs.setf(flags,newflags); }
void WriteScalars(std::ofstream &ofs, std::vector<T> & Scalars, int Dimensions[3], bool const &DisplayI = false, bool const &DisplayJ = false, bool const DisplayK = false) { std::ios::fmtflags flags = ofs.setf(std::ios::fmtflags()); ofs << std::fixed << std::setprecision(2); int choice = (DisplayK << 2) + (DisplayJ << 1) + DisplayI; if ( choice & 4 ) choice = 4; if ( choice & 2 ) choice = 2; if ( choice & 1 ) choice = 1; if ( choice == 0 ) { for ( typename std::vector<T>::iterator p = Scalars.begin(); p != Scalars.end(); ++p ) ofs << *p << "\n"; return; } if ( Scalars.size() != (size_t)(Dimensions[0]*Dimensions[1]*Dimensions[2]) ) { std::cerr << "Dimensions do not match." << std::endl; return; } typename std::vector<T>::iterator p = Scalars.begin(); for ( int i = 0; i < Dimensions[0]; ++i ) { if ( choice & 1 ) ofs << "(" << i << ",...,...) "; for ( int j = 0; j < Dimensions[1]; ++j ) { if( choice & 2 ) { ofs << "(" << i << "," << j << ",...) "; } for ( int k = 0; k < Dimensions[2]; ++k ) { if ( choice & 4 ) ofs << "(" << i << "," << j << "," << k << ") "; ofs << *p++ << " "; if ( choice & 4 ) ofs << std::endl; } if( choice & 2 ) ofs << std::endl; } if ( choice & 1 ) ofs << std::endl; } ofs << std::setprecision(6) << std::endl; std::ios::fmtflags newflags = ofs.setf(std::ios::fmtflags()); ofs.setf(flags,newflags); }
void pluginLoad() { if (notifyFrequency > 0) { // number of cells on the current CPU for each direction const DataSpace<simDim> nrOfGpuCells = Environment<simDim>::get().SubGrid().getLocalDomain().size; // create as much storage as cells in the direction we are interested in: // on gpu und host sliceDataField = new GridBuffer<float3_X, DIM1 > (DataSpace<DIM1 > (nrOfGpuCells.y())); Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyFrequency); const int rank = Environment<simDim>::get().GridController().getGlobalRank(); // open output file std::stringstream oFileName; oFileName << "lineSliceFields_" << rank << ".txt"; outfile.open(oFileName.str().c_str(), std::ofstream::out | std::ostream::trunc); outfile.precision(8); outfile.setf(std::ios::scientific); } }
int main(int argc, CHAR *argv[]) { PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } TRACE_AddInstrumentFunction(Trace, 0); PIN_AddFiniFunction(Fini, 0); IMG_AddUnloadFunction(ImageUnload, 0); out.open(KnobOutputFile.Value().c_str()); out.setf(ios::showbase); out << hex; // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { // Initialize pin & symbol manager PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } // Write to a file since cout and cerr maybe closed by the application TraceFile.open(KnobOutputFile.Value().c_str()); TraceFile << hex; TraceFile.setf(ios::showbase); // Register Image to be called to instrument functions. IMG_AddInstrumentFunction(Image, 0); // RTN_AddInstrumentFunction(Routine, 0); // Register ImageUnload to be called when an image is unloaded // IMG_AddUnloadFunction(ImageUnload, 0); // Register Fini to be called when the application exits PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { // Initialize pin & symbol manager PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } pinplay_engine.Activate(argc, argv, KnobPinPlayLogger, KnobPinPlayReplayer); // Write to a file since cout and cerr maybe closed by the application TraceFile.open(KnobOutputFile.Value().c_str()); TraceFile << hex; TraceFile.setf(ios::showbase); cout << hex; cout.setf(ios::showbase); // Register Image to be called to instrument functions. IMG_AddInstrumentFunction(Image, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { string trace_header = string("#\n" "# Memory Access Trace Generated By Pin\n" "#\n"); if( PIN_Init(argc,argv) ) { return Usage(); } TraceFile.open(KnobOutputFile.Value().c_str()); TraceFile.write(trace_header.c_str(),trace_header.size()); TraceFile.setf(ios::showbase); INS_AddInstrumentFunction(Instruction, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); RecordMemWrite(0); RecordWriteAddrSize(0, 0); return 0; }
int main(int argc, char *argv[]) { PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } TraceFile.open(KnobOutputFile.Value().c_str()); TraceFile << hex; TraceFile.setf(ios::showbase); string trace_header = string("#\n" "# Call Trace Generated By Pin\n" "#\n"); TraceFile.write(trace_header.c_str(),trace_header.size()); TRACE_AddInstrumentFunction(Trace, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { // Initialize pin & symbol manager PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } // Write to a file since cout and cerr maybe closed by the application outFile.open(KnobOutputFile.Value().c_str()); outFile << hex; outFile.setf(ios::showbase); // Register Image to be called to instrument functions. IMG_AddInstrumentFunction(Image, 0); INS_AddInstrumentFunction(Instruction, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { // Initialize pin & symbol manager PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } thread_init(); PIN_AddFollowChildProcessFunction(FollowChild, 0); // Write to a file since cout and cerr maybe closed by the application TraceFile.open(KnobOutputFile.Value().c_str()); TraceFile << hex; TraceFile.setf(ios::showbase); // Register Image to be called to instrument functions. IMG_AddInstrumentFunction(ImageLoad, 0); IMG_AddUnloadFunction(ImageUnLoad, 0); TRACE_AddInstrumentFunction(trace_instrument, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } TraceFile.open(KnobOutputFile.Value().c_str()); TraceFile << hex; TraceFile.setf(ios::showbase); cout << hex; cout.setf(ios::showbase); IMG_AddInstrumentFunction(Image, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
void LasWell::WriteLasLine(std::ofstream & file, const std::string & mnemonic, const std::string & units, double data, const std::string & description) { file.precision(3); file.setf(std::ios_base::fixed); file << mnemonic << " ." << units << " " << data << " : " << description << "\n"; }
void DiskFromCFD::PrepareOutputFile(const boost::filesystem::path file_name, std::ofstream& fOutput) { fOutput.open(file_name.c_str(), std::ios::out); fOutput.setf(std::ios::scientific); unsigned int count = 1; OpenSMOKE::PrintTagOnASCIILabel(22, fOutput, "x[mm]", count); OpenSMOKE::PrintTagOnASCIILabel(22, fOutput, "T[K]", count); for (unsigned int j = 0; j < thermodynamicsMap_.NumberOfSpecies(); j++) OpenSMOKE::PrintTagOnASCIILabel(22, fOutput, thermodynamicsMap_.NamesOfSpecies()[j] + "_w", count); fOutput << std::endl; }
void write_cams(std::ofstream &file, CameraArray& cam_list) { file.precision(10); file.setf(std::ios_base::scientific); size_t n_cams = cam_list.size(); for (size_t i = 0; i < n_cams; ++i) { Camera &cam = *(std::dynamic_pointer_cast<Camera>(cam_list[i])); file << cam.focal[0] << " " << cam.disto_coeffs[0] << " " << cam.disto_coeffs[1] << std::endl; file << cam.rotation.toRotationMatrix() << std::endl; file << cam.translation.transpose() << std::endl; } }
void DTMImage::WriteTextHeader( std::ofstream & ofs, int const & precision ) { std::ios::fmtflags flags = ofs.setf(std::ios::fmtflags()); ofs << std::fixed << std::setprecision(precision); ofs << "Dimensions: "; for ( int i = 0; i < 3; ++i ) ofs << this->dimensions[i] << " "; ofs << std::endl; ofs << "Origin: "; for ( int i = 0; i < 3; ++i ) ofs << this->origin[i] << " "; ofs << std::endl; ofs << "Spacings: "; for ( int i = 0; i < 3; ++i ) ofs << this->spacing[i] << " "; ofs << std::endl; ofs << "Increments: "; for ( int i = 0; i < 3; ++i ) ofs << this->indexIncrement[i] << " "; ofs << std::endl; ofs << "Scalar type: " << this->scalarType << std::endl; ofs << std::setprecision(6) << std::endl; std::ios::fmtflags newflags = ofs.setf(std::ios::fmtflags()); ofs.setf(flags,newflags); }
void write_points(std::ofstream &file, std::vector<Point> &point_list) { size_t n_points = point_list.size(); for (size_t i = 0; i < n_points; ++i) { Point &pt = point_list[i]; file.precision(10); file.setf(std::ios_base::scientific); file << pt.position.transpose() << std::endl; file << pt.color.transpose() << std::endl; write_visibility_list(file, pt); } }
int main(int argc, char *argv[]) { // Initialize pin & symbol manager PIN_InitSymbols(); PIN_Init(argc,argv); TraceFile.open(KnobOutputFile.Value().c_str()); TraceFile << hex; TraceFile.setf(ios::showbase); // Register Image to be called to instrument functions. IMG_AddInstrumentFunction(Image,0); //RTN_AddInstrumentFunction(InstrumentRoutine, 0); // Never returns PIN_StartProgram(); return 0; }
/** * \brief Internal conversion function, writes given timestamp to output file stream * \param timestamp timestamp for current message * \param stream Output file stream * */ void CBlfLogConverter::WriteTimestamp(ULONGLONG timestamp, std::ofstream& stream) const { // Be careful: in this function milliseconds uses for 10^-4 sec ULONGLONG hours = timestamp; hours /= 100000; ULONGLONG millisecond = hours % 10000; hours /= 10000; ULONGLONG seconds = hours % 60; hours /= 60; ULONGLONG minutes = hours % 60; hours /= 60; stream << std::dec << hours <<":" << minutes << ":" << seconds << ":" ; // Outputs milliseconds with adjusting by zero stream.setf(ios::right, ios::adjustfield); stream.fill('0'); stream << std::setw(4)<< std::dec << millisecond; }
void write_visibility_list(std::ofstream &file, Point& pt) { file.precision(4); file.unsetf(std::ios_base::scientific); file.setf(std::ios_base::fixed, std::ios_base::floatfield); size_t n_vis = pt.visibility_list.size(); file << n_vis << " "; for (size_t i = 0; i < n_vis; ++i) { Visibility &vis = pt.visibility_list[i]; file << vis.camera_idx << " " << vis.keypoint_idx << " " << vis.position.transpose() << " "; } file.unsetf(std::ios_base::fixed); file.unsetf(std::ios_base::floatfield); file << std::endl; }
int main(int argc, char *argv[]) { PIN_InitSymbols(); PIN_Init(argc, argv); TraceFile.open("args.out"); TraceFile << hex; TraceFile.setf(ios::showbase); IMG_AddInstrumentFunction(Image, 0); INS_AddInstrumentFunction(Ins, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
static VOID EmitMem(VOID * ea, INT32 size) { if (!KnobValues) return; switch(size) { case 0: TraceFile << setw(1); break; case 1: TraceFile << static_cast<UINT32>(*static_cast<UINT8*>(ea)); break; case 2: TraceFile << *static_cast<UINT16*>(ea); break; case 4: TraceFile << *static_cast<UINT32*>(ea); break; case 8: TraceFile << *static_cast<UINT64*>(ea); break; default: TraceFile.unsetf(ios::showbase); TraceFile << setw(1) << "0x"; for (INT32 i = 0; i < size; i++) { TraceFile << static_cast<UINT32>(static_cast<UINT8*>(ea)[i]); } TraceFile.setf(ios::showbase); break; } }
void InitObjFile() { if (g_obj.is_open()) { return; } std::ofstream file; file.open("logger.obj"); if (file.is_open()) { file.close(); } g_obj.open("logger.obj", std::ios::app); g_obj.setf(std::ios::fixed, std::ios::floatfield); g_objFrameIndex = 0; g_objObjectIndex = 0; g_objVertexBaseIndex = 1; g_objVertexIndex = 1; }
bool Mesh::SaveVRML2(std::ofstream & fout, const Material & material) const { if (fout.is_open()) { fout.setf(std::ios::fixed, std::ios::floatfield); fout.setf(std::ios::showpoint); fout.precision(6); size_t nV = m_points.Size(); size_t nT = m_triangles.Size(); fout << "#VRML V2.0 utf8" << std::endl; fout << "" << std::endl; fout << "# Vertices: " << nV << std::endl; fout << "# Triangles: " << nT << std::endl; fout << "" << std::endl; fout << "Group {" << std::endl; fout << " children [" << std::endl; fout << " Shape {" << std::endl; fout << " appearance Appearance {" << std::endl; fout << " material Material {" << std::endl; fout << " diffuseColor " << material.m_diffuseColor[0] << " " << material.m_diffuseColor[1] << " " << material.m_diffuseColor[2] << std::endl; fout << " ambientIntensity " << material.m_ambientIntensity << std::endl; fout << " specularColor " << material.m_specularColor[0] << " " << material.m_specularColor[1] << " " << material.m_specularColor[2] << std::endl; fout << " emissiveColor " << material.m_emissiveColor[0] << " " << material.m_emissiveColor[1] << " " << material.m_emissiveColor[2] << std::endl; fout << " shininess " << material.m_shininess << std::endl; fout << " transparency " << material.m_transparency << std::endl; fout << " }" << std::endl; fout << " }" << std::endl; fout << " geometry IndexedFaceSet {" << std::endl; fout << " ccw TRUE" << std::endl; fout << " solid TRUE" << std::endl; fout << " convex TRUE" << std::endl; if (nV > 0) { fout << " coord DEF co Coordinate {" << std::endl; fout << " point [" << std::endl; for (size_t v = 0; v < nV; v++) { fout << " " << m_points[v][0] << " " << m_points[v][1] << " " << m_points[v][2] << "," << std::endl; } fout << " ]" << std::endl; fout << " }" << std::endl; } if (nT > 0) { fout << " coordIndex [ " << std::endl; for (size_t f = 0; f < nT; f++) { fout << " " << m_triangles[f][0] << ", " << m_triangles[f][1] << ", " << m_triangles[f][2] << ", -1," << std::endl; } fout << " ]" << std::endl; } fout << " }" << std::endl; fout << " }" << std::endl; fout << " ]" << std::endl; fout << "}" << std::endl; return true; } return false; }
/** * \brief Internal conversion function, uses already prepared blf library and output file * \param pBlfLib blf library with loaded input file * \param stream Output file stream * \return Result code * */ HRESULT CBlfLogConverter::WriteToLog(BLF::IBlfLibrary* pBlfLib, std::ofstream& stream) const { if(pBlfLib == NULL) { return E_INVALIDARG; } SYSTEMTIME startTime = pBlfLib->GetStartTime(); size_t objectsCount = pBlfLib->GetBlfObjectsCount(); if(objectsCount <= 0) { return ERR_PROTOCOL_NOT_SUPPORTED; } AddFunctionHeader(stream, startTime.wDay, startTime.wMonth, startTime.wYear, startTime.wHour, startTime.wMinute, startTime.wSecond); for(size_t i = 0; i < objectsCount; i++) { BLF::IBlfObject* object = pBlfLib->GetBlfObject(i); if(object == NULL) { continue; } if(object->GetKind() == BLF::bokCanMessage) { BLF::ICanMessage* canMessage = object->GetICanMessage(); // It is should be impossible, that object has CanMessage type, but return NULL for GetICanMessage() ASSERT(canMessage != NULL); if(canMessage == NULL) { continue; } WriteTimestamp(canMessage->GetTimestamp(), stream); if(canMessage->GetDirection()==BLF::mdRx) { stream << " Rx "; } else { stream << " Tx "; } stream << canMessage->GetChannelNo() << " "; // suppress extended message bit stream << std::hex << (canMessage->GetId() & 0x7FFFFFFF ) << " "; stream.setf(ios::uppercase); // checks extended bit if((canMessage->GetId() & 0x80000000) == 0) { stream << "s "; // Standard message } else { stream << "x "; // Extended message } stream << (int)canMessage->GetDLC(); for (int i = 0 ; (i < canMessage->GetDLC()) ; ++i) { stream << " "; if (canMessage->GetData()[i] <= 0xf) { stream << '0'; } stream << std::hex; stream << (int)canMessage->GetData()[i]; stream.setf(ios::uppercase); } stream << "\n"; } } stream << "***END DATE AND TIME ***\n"; // Everythere above \n is used, but here \r\n like in asc to log parser stream << "***[STOP LOGGING SESSION]***\r\n"; return S_OK; }