⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r2v.txt

📁 converting the raster to vector
💻 TXT
字号:
//C++ TO C# CONVERTER WARNING: The declaration of the following method implementation was not found:
//ORIGINAL LINE: void CFloodfillView::OnBoundaryDrawline()

public class CFloodfillView
{
	public void OnBoundaryDrawline()
	{
	
			FILE fp_In;
			string m_Dem_Path ="D:\\OTHER_CR\\uml\\contour\\erosed_150_200.bmp";
	
			fp_In =fopen(m_Dem_Path,"rb");
	
			fread(header, 54, 1, fp_In);
			fread(colors,1024,1,fp_In);
	
	//C++ TO C# CONVERTER TODO TASK: The memory management function 'malloc' has no equivalent in C#:
			data=(byte)malloc(sizeof(byte)*header.infoheader.height);
	
			for(int k =0;k<header.infoheader.height;k++)
			{
	//C++ TO C# CONVERTER TODO TASK: The memory management function 'malloc' has no equivalent in C#:
				data[k]=(byte)malloc(sizeof(byte)*header.infoheader.width);
			}
	
			CClientDC dc = new CClientDC(this);
	
			CPen green = new CPen(PS_SOLID,1,0x0000ff00);
	
			dc.SelectObject(green);
	
			for(int row =0;row<header.infoheader.height;row++)
			{
				for(int col =0;col<header.infoheader.width;col++)
				{
					data[row][col]=fgetc(fp_In);
	
					if(data[row][col]==255)
					{
						dc.SetPixel(col,640-row,0x0000f0000);
					}
	
				}
			}
	
			fclose(fp_In);
	
			MessageBox("DEM file Reading completed");
	
			int clr =0x00;
	
			no_obj=0;
	
	//C++ TO C# CONVERTER TODO TASK: The memory management function 'malloc' has no equivalent in C#:
			obj=(OBJECT)malloc(sizeof(OBJECT)*(no_obj+1));
	
			fp=fopen("D:\\OTHER_CR\\uml\\contour\\test.txt","w");
	
			for(row =1;row<header.infoheader.height-1;row++)
			{
				for(int col =1;col<header.infoheader.width-1;col++)
				{
					if(data[row][col]==255)
					{
	
						no_obj++;
	//C++ TO C# CONVERTER TODO TASK: The memory management function 'realloc' has no equivalent in C#:
						obj=(OBJECT)realloc(obj,sizeof(OBJECT)*(no_obj));
						obj[no_obj-1].nop=0;
	//C++ TO C# CONVERTER TODO TASK: The memory management function 'malloc' has no equivalent in C#:
						obj[no_obj-1].pnts=(POINT_XY)malloc(sizeof(POINT_XY)*(obj[no_obj-1].nop+1));
						clr =0xff00ff;
						FindBoundary(row,col,clr);
						if(obj[no_obj-1].nop<2)
						{
	//C++ TO C# CONVERTER TODO TASK: The memory management function 'realloc' has no equivalent in C#:
							obj=(OBJECT)realloc(obj,sizeof(OBJECT)*(--no_obj));
							//no_obj--;
	
						}
	
	
					}
	
				}
	
			}
	
			FILE vector;
			vector =fopen("D:\\other_cr\\uml\\contour\\vector.txt","w");
	
			fprintf(vector,"%d\n",no_obj);
	
			for(k =0;k<no_obj;k++)
			{
				fprintf(vector,"%d\n",obj[k].nop);
	
				for(int l =0;l<obj[k].nop;l++)
				{
	
					fprintf(vector,"%d %d \n",obj[k].pnts[l].x,obj[k].pnts[l].y);
	
	
				}
	
			}
	
			fclose(fp);
	
			fclose(vector);
	
			MessageBox("completed");
	
	}
}

//C++ TO C# CONVERTER WARNING: The declaration of the following method implementation was not found:
//ORIGINAL LINE: void CFloodfillView::FindBoundary(int X, int Y, int color)

public class CFloodfillView
{
	public void FindBoundary(int X, int Y, int color)
	{
	
		CClientDC dc = new CClientDC(this);
	
	
		for(int i =-1;i<2;i++)
		{
			for(int j =-1;j<2;j++)
			{
				if(data[i+X][j+Y]==255)
				{
					obj[no_obj-1].nop++;
					data[i + X][j + Y]=244;
					dc.SetPixel ((j + Y), 640-(i + X), color);
					Sleep(10);
	//C++ TO C# CONVERTER TODO TASK: The memory management function 'realloc' has no equivalent in C#:
					obj[no_obj-1].pnts=(POINT_XY)realloc(obj[no_obj-1].pnts,sizeof(POINT_XY)*(obj[no_obj-1].nop));
					obj[no_obj-1].pnts[obj[no_obj-1].nop-1].X =i + X;
					obj[no_obj-1].pnts[obj[no_obj-1].nop-1].Y =j + Y;
	
					fprintf(fp,"%d %d %u\n",obj[no_obj-1].pnts[obj[no_obj-1].nop-1].x,obj[no_obj-1].pnts[obj[no_obj-1].nop-1].y,color);
					if((i + X)!=0&&(j + Y)!=0)
						if((i + X)!=(header.infoheader.height-1) && (j + Y)!=(header.infoheader.width-1))
					FindBoundary(i + X, j + Y, color);
	
					break;
				}
	
			}
		}
	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -