コード例 #1
0
ファイル: gs_project.cpp プロジェクト: wolf-pf/ogs_kb1
/**************************************************************************
   GeoSys-Method:
   Task:
   Programing:
   01/2005 OK Implementation
   last modification:
**************************************************************************/
void GSPAddMemberNew(std::string path_base_orig,std::string path_base_copy,std::string type)
{
	// Copy file to GSP directory
	std::string path_base_type_orig = path_base_orig + "." + type;
	std::string path_base_type_copy = path_base_copy + "." + type;
	char input_text[MAX_ZEILE];
	FILE* gsp_member_file_orig = NULL;
	FILE* gsp_member_file_copy = NULL;
	gsp_member_file_orig = fopen(path_base_type_orig.c_str(),"rt");
	gsp_member_file_copy = fopen(path_base_type_copy.c_str(),"w+t");
	if(!gsp_member_file_orig) //OK4104
		return;
	while(!feof(gsp_member_file_orig))
	{
		fgets(input_text,MAX_ZEILE,gsp_member_file_orig);
		FilePrintString(gsp_member_file_copy,input_text);
	}
	fclose(gsp_member_file_orig);
	fclose(gsp_member_file_copy);
	// Check GSP member and remove existing GSP type
	GSPRemoveMember(type);
	// Add GSP member
	int pos;
	char a = '\\';
	pos = (int)path_base_copy.find_last_of(a);
	std::string path = path_base_copy.substr(0,pos);
	std::string base = path_base_copy.substr(pos + 1,std::string::npos);
	CGSProject* m_gsp = NULL;
	m_gsp = new CGSProject;
	m_gsp->path = path;
	m_gsp->base = base;
	m_gsp->type = type;
	gsp_vector.push_back(m_gsp);
}
コード例 #2
0
ファイル: geo_dom.cpp プロジェクト: MichaelRink/ogs5
/**************************************************************************
   GeoLib-Method: GEOReadVolume
   Task: Read volume data from file
   Programing:
   07/2003 OK Implementation
**************************************************************************/
int CGLDomain::Read(char* data,FILE* f)
{
	int pos = 0,pos_s = 0;
	int p = 0;
	char* sub;
	int begin;
	int ok = 1;
	int p_sub = 0;
	char name[80];
	double ddummy;

	LineFeed(f);
	FilePrintString(f,"; ------------------------------------------");
	LineFeed(f);
	FilePrintString(f,"; GeoLib - Domain");
	LineFeed(f);

	//---------------------------------------------------------------------
	// Loop over all volumes
	while (StrTestHash(&data[p += pos],&pos))
	{
		CGLDomain* m_domain = NULL;
		m_domain = new CGLDomain;
		/* Write keyword */
		LineFeed(f);
		FilePrintString(f,"#DOMAIN");
		LineFeed(f);
		//-------------------------------------------------------------------
		// Check sub keywords
		sub = new char[(int)strlen(data) + 2];
		while (StrReadSubKeyword(sub, data, p += pos, &begin, &p))
		{
			ok = StrReadStr(name, sub, f, /*TFString,*/ &p_sub) && ok;
			pos = 0;
			//-----------------------------------------------------------------
			if (!strcmp(name, "$NAME"))
			{
				ok = (StrReadStr(name,&sub[p_sub],f,/*TFString,*/ &pos) && ok);
				LineFeed(f);
				m_domain->name = name;
			}
			//-----------------------------------------------------------------
			if (!strcmp(name, "$COORDINATES"))
			{
				pos_s = 0;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->x_min = ddummy;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->x_max = ddummy;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->y_min = ddummy;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->y_max = ddummy;
				LineFeed(f);
			}
			pos = 0;
		} // sub-keyword
		delete (sub);
		// insert into list
		Insert(m_domain);
	}

	return 1;
}