1. 程式人生 > >C++和OpenGl實現的三維雷達波形函式模糊圖

C++和OpenGl實現的三維雷達波形函式模糊圖

模糊函式(Ambiguity Function,AF)是評價雷達波形優劣和進行波形分析的基本工具。它可以清晰直觀的描述波形與對應匹配濾波器的特徵。模糊函式在分析距離/速度解析度、距離/多普勒模糊和副瓣效能方面應用廣泛。

上面這句話粘自很多年前的碩士論文,在寫這篇部落格時,本人已經不搞雷達很多年,由於需要評價雷達發射波形的優劣,需要對設計波形進行模糊函式評價,藉助matlab可以直接畫出模糊函式圖,而本人一貫不愛用matlab,所以看了兩本OpenGl教材後,自己寫了個模糊函式三維程式,基本思路就是按照幅度由低到高依次設定藍/青/綠/黃/紅,然後根據三點計演算法線方向,設定光照,生成三維效果秒殺matlab,由於這個程式需要整合在mfc中,所以將mfc的panel控制元件作為整個OpenGl畫布。程式碼如下:全部程式可以到我的GitHub主頁下載,裡面還包括遺傳演算法的具體實現。

這個程式多年前寫的,程式碼寫的很垃圾,也沒有很多註釋,只是實現了功能,整個程式vs2008和vs2010都可以除錯通過(需要先配置好OpenGl安裝環境)

1.AmbiguityFunction.h

 /* Copyright (c) 2011-2013 Zhang Zhao(ZZ), [email protected]
 *
 /*****************************************************************************
 *                               AmbiguityFunction.h
 *模糊函式類的標頭檔案
 * Zhang Zhao, 2011-2013
 *****************************************************************************/

#pragma once

struct DataAF{
	double x;
	double z;
	double h;
};

class AmbiguityFunction
{
public:
	int i;
	int SignalChoose;
	DataAF Data[200][200];
public:
	AmbiguityFunction(void);
	AmbiguityFunction(int index);
	~AmbiguityFunction(void);

	void initDataSinalPulse(float pulseWidth=1,float Dopller=5);
	void initDataLFM(float pulseWidth=1,float Dopller=5);
	void initDataPulseSeries(float pulseWidth,float Dopller,float pulsePri,int N);
	void initDataPhaseCode(float pulseWidth,float Dopller, double Code[],int N);
	void initDataMultiPhaseCode(float pulseWidth,float Dopller, double Code[],int N);
	void initDataFrankPhaseCode(float pulseWidth,float Dopller, double Code[],int N);

	double GetMax(); 
	double GetMin();
	double SiglePulse(double T0,double T,double fd);
	double LFM(double T0,double T,double fd,double FM);
	double PulseSeries(double T0,double T,double fd,float TPri,int N);
	double PhaseCode(float t1,float td,float fd,double Code[],int N);
	double MultiPhaseCode(float t1,float td,float fd,double Code[],int N);
	double FrankPhaseCode(float t1,float td,float fd,double Code[],int N);
};

2.AmbiguityFunction.cpp

 /* Copyright (c) 2011-2013 Zhang Zhao(ZZ), [email protected]
 *
 /*****************************************************************************
 *                               AmbiguityFunction.cpp
 *模糊函式類的實現檔案
 * Zhang Zhao, 2011-2013
 *****************************************************************************/


#include "StdAfx.h"
#include "math.h"
#include "AmbiguityFunction.h"
#include "Complex.h"

#define pi 3.1415926

AmbiguityFunction::AmbiguityFunction(void)
{
	i=0;
	SignalChoose=0;
}

AmbiguityFunction::AmbiguityFunction(int index)
{
    i=index;
}

AmbiguityFunction::~AmbiguityFunction(void)
{
}

void AmbiguityFunction::initDataSinalPulse(float pulseWidth,float Dopller) 
{
	for (int i = 0;i<200;i++)
	{
		for (int j = 0;j<200;j++)
		{
			double measure=0.01;
			double x_m=measure*pulseWidth;
			double z_m=measure*Dopller;
			Data[i][j].x = i*x_m-100*x_m;
			Data[i][j].z = j*z_m-100*z_m;

			Data[i][j].h=2*SiglePulse(pulseWidth,Data[i][j].x,Data[i][j].z);

			Data[i][j].x/=pulseWidth;
			Data[i][j].z/=Dopller;
		}
	}
}


void AmbiguityFunction::initDataLFM(float pulseWidth,float Dopller)
{
	for (int i = 0;i<200;i++)
	{
		for (int j = 0;j<200;j++)
		{
			double measure=0.01;
			double x_m=measure*pulseWidth;
			double z_m=measure*Dopller;
			Data[i][j].x = i*x_m-100*x_m;
			Data[i][j].z = j*z_m-100*z_m;
			Data[i][j].h=2*LFM(pulseWidth,Data[i][j].x,Data[i][j].z,Dopller/pulseWidth);
			Data[i][j].x/=pulseWidth;
			Data[i][j].z/=Dopller;
		}
	}
}



void AmbiguityFunction::initDataPulseSeries(float pulseWidth,float Dopller,float pulsePri,int N)
{
	for (int i = 0;i<200;i++)
	{
		for (int j = 0;j<200;j++)
		{
			double measure=0.01;
			double x_m=measure*((pulsePri*(N-1))+0.133);
			double z_m=measure*(Dopller+0.133);
			Data[i][j].x = i*x_m-100*x_m;
			Data[i][j].z = j*z_m-100*z_m;
			Data[i][j].h=2*PulseSeries(pulseWidth,Data[i][j].x,Data[i][j].z,pulsePri,N);
			Data[i][j].x/=((pulsePri*(N-1))+0.133);
			Data[i][j].z/=(Dopller+0.133);
			//Trace("%f,%f,%f",Data[i][j].x,Data[i][j].x,Data[i][j].x);
		}
	}
}


double AmbiguityFunction::GetMax()
{
	double TmpMax = Data[0][0].h;
	for (int i = 0;i<200;i++)
	{
		for (int j=0;j<200;j++)
		{
			TmpMax = max((double)Data[i][j].h,(double)TmpMax);
		}
	}
	return TmpMax;
}

double AmbiguityFunction::GetMin() 
{
	double Tmpmin = Data[0][0].h;

	for (int i = 0;i<200;i++)
	{
		for (int j=0;j<200;j++)
		{
			Tmpmin = min((double)Data[i][j].h,(double)Tmpmin);
		}
	}
	return Tmpmin;
}

double AmbiguityFunction::SiglePulse(double T0,double T, double fd)
{
		double TempT=1-fabs(T)/T0;
		double TempTC=pi*fd*(T0-fabs(T));
		double TempSin;
		double eps=0.000001;

		TempSin=sin(TempTC+eps);
		TempSin/=(TempTC+eps);

		return fabs(TempSin*TempT);//*(TempSin*TempT);
}

double AmbiguityFunction::LFM(double T0,double T, double fd,double FM)
{
		double TempT=1-fabs(T)/T0;
		double TempTC=pi*T0*(FM*T+fd)*TempT;
		double TempSin;
		if(TempTC==0.0)
			TempSin=1;
		else
		{
			TempSin=sin(TempTC);
			TempSin/=TempTC;
		}
		return fabs(TempSin*TempT);//*(TempSin*TempT);
}



double AmbiguityFunction::PulseSeries(double T0,double T,double fd,float TPri,int N)
{
	double AmbiValue=0.0;
	double TempLeft;
	double TempRight;
	double eps=0.000001;

	for(int q=-(N-1);q<=N-1;q++)
	{
		double TempC=pi*fd*(N-fabs((double)q)*TPri);
		double TempSin=sin(TempC+eps);

		double fm=(pi*fd*TPri);
		double fmSin=sin(fm+eps);

		TempRight=TempSin/fmSin;

		if(TempRight==1)
			TempRight=(N-fabs((double)q)*TPri)/TPri;

		TempRight=fabs(TempRight);

		if(fabs(T-q*TPri)<=T0)
		{
			TempLeft=SiglePulse(T0,T-q*TPri,fd);
			AmbiValue+=(TempRight*TempLeft);
		}

	}
	AmbiValue/=N;

	return fabs (AmbiValue);
}




void AmbiguityFunction::initDataPhaseCode(float pulseWidth,float Dopller,double Code[],int N)   //N為子脈衝個數,pulseWidth為子脈衝寬度
{
	for (int i = 0;i<200;i++)
	{
		for (int j = 0;j<200;j++)
		{
			double measure=0.01;
			double x_m=measure*pulseWidth*N;
			double z_m=measure*Dopller;
			Data[i][j].x = i*x_m-100*x_m;
			Data[i][j].z = j*z_m-100*z_m;

			Data[i][j].h=2*PhaseCode(pulseWidth,Data[i][j].x,Data[i][j].z,Code,N);

			Data[i][j].x/=(pulseWidth*N);
			Data[i][j].z/=Dopller;
		}
	}
}





double AmbiguityFunction::PhaseCode (float t1,float td,float fd,double Code[],int N)
{
	double AmbiValue=0.0;
	Complex Value;
	Complex TempLeft;
	Complex TempRight;

	/////////////////////////////////////////////////////計算第一個公式的值,為複數
	for(int m=-(N-1);m<=N-1;m++)
	{
		if(fabs(td-m*t1)<=t1)
		{
			double sinC=pi*fd*(t1-fabs(td-m*t1));
			double sinValue=sin(sinC);
			double middle=sinValue/sinC;            //中間值

			if(sinC==0)
				middle=1;

            double right=(t1-fabs(td-m*t1))/t1;     //右邊值

			double ejC=pi*fd*(t1-(td-m*t1));
			Complex ejLeft;
			ejLeft.ej (ejC);
			TempLeft=ejLeft*(middle*right);
		}
		else
		{
			TempLeft.SetVal(0,0);
		}


		/////////////////////////////////////////////////////計算第二個公式的值,為複數
		if(m>=0)
		{
			TempRight.SetVal (0,0);
			for(int k=0;k<=N-1-m;k++)
			{
				double ejC=2*pi*fd*k*t1;
				Complex ejRight;
				ejRight.ej(ejC);
				double Ck=Code[k]*Code[k+m];
				//ejRight=ejRight*Ck;
				TempRight+=(ejRight*Ck);
			}
			TempRight/=N;
		}
		else
		{
			TempRight.SetVal (0,0);
			for(int k=-m;k<=N-1;k++)
			{
				double ejC=2*pi*fd*k*t1;
				Complex ejRight;
				ejRight.ej(ejC);
				double Ck=Code[k]*Code[k+m];
				//ejRight=ejRight*Ck;
				TempRight+=(ejRight*Ck);
			}
			TempRight/=N;
		}


		Value+=(TempLeft*TempRight);
	}
    AmbiValue=Value.GetModule ();
	return (AmbiValue);
}





void AmbiguityFunction::initDataMultiPhaseCode(float pulseWidth,float Dopller,double Code[],int N)   //N為子脈衝個數,pulseWidth為子脈衝寬度
{
	for (int i = 0;i<200;i++)
	{
		for (int j = 0;j<200;j++)
		{
			double measure=0.01;
			double x_m=measure*pulseWidth*N;
			double z_m=measure*Dopller;
			Data[i][j].x = i*x_m-100*x_m;
			Data[i][j].z = j*z_m-100*z_m;

			Data[i][j].h=2*MultiPhaseCode(pulseWidth,Data[i][j].x,Data[i][j].z,Code,N);

			Data[i][j].x/=(pulseWidth*N);
			Data[i][j].z/=Dopller;
		}
	}
}





double AmbiguityFunction::MultiPhaseCode (float t1,float td,float fd,double Code[],int N)
{
	double AmbiValue=0.0;
	Complex Value;
	Complex TempLeft;
	Complex TempRight;

	//////////////////////////////////////////////////16位Frank碼訊號相位賦值
	Complex MultiCode[50];
    for(int i=0;i<50;i++)
	{
		MultiCode[i].ej(Code[i]);
	}

	/////////////////////////////////////////////////////計算第一個公式的值,為複數
	for(int m=-(N-1);m<=N-1;m++)
	{
		if(fabs(td-m*t1)<=t1)
		{
			double sinC=pi*fd*(t1-fabs(td-m*t1));
			double sinValue=sin(sinC);
			double middle=sinValue/sinC;            //中間值

			if(sinC==0)
				middle=1;

            double right=(t1-fabs(td-m*t1))/t1;     //右邊值

			double ejC=pi*fd*(t1-(td-m*t1));
			Complex ejLeft;
			ejLeft.ej (ejC);
			TempLeft=ejLeft*(middle*right);
		}
		else
		{
			TempLeft.SetVal(0,0);
		}


		/////////////////////////////////////////////////////計算第二個公式的值,為複數
		if(m>=0)
		{
			TempRight.SetVal (0,0);
			for(int k=0;k<=N-1-m;k++)
			{
				double ejC=2*pi*fd*k*t1;
				Complex Ck=MultiCode[k];
				Complex Ckm=MultiCode[k+m];
				Ckm.Conj ();
		
				Complex ejRight;
				ejRight.ej(ejC);
				ejRight*=(Ck*Ckm);
				TempRight+=ejRight;
			}
			TempRight/=N;
		}
		else
		{
			TempRight.SetVal (0,0);
			for(int k=-m;k<=N-1;k++)
			{
				double ejC=2*pi*fd*k*t1;
				Complex Ck=MultiCode[k];
				Complex Ckm=MultiCode[k+m];
				Ckm.Conj ();

				Complex ejRight;
				ejRight.ej(ejC);
				ejRight*=(Ck*Ckm);
				TempRight+=ejRight;
			}
			TempRight/=N;
		}


		Value+=(TempLeft*TempRight);
	}
    AmbiValue=Value.GetModule ();
	return AmbiValue;
}





void AmbiguityFunction::initDataFrankPhaseCode(float pulseWidth,float Dopller,double Code[],int N)   //N為子脈衝個數,pulseWidth為子脈衝寬度
{
	for (int i = 0;i<200;i++)
	{
		for (int j = 0;j<200;j++)
		{
			double measure=0.01;
			double x_m=measure*pulseWidth*N;
			double z_m=measure*Dopller;
			Data[i][j].x = i*x_m-100*x_m;
			Data[i][j].z = j*z_m-100*z_m;

			Data[i][j].h=2*FrankPhaseCode(pulseWidth,Data[i][j].x,Data[i][j].z,Code,N);

			Data[i][j].x/=(pulseWidth*N);
			Data[i][j].z/=Dopller;
		}
	}
}





double AmbiguityFunction::FrankPhaseCode (float t1,float td,float fd,double Code[],int N)
{
	double AmbiValue=0.0;
	Complex Value;
	Complex TempLeft;
	Complex TempRight;

	//////////////////////////////////////////////////16位Frank碼訊號相位賦值
	Complex MultiCode[16];
	MultiCode[0].SetReal(1);MultiCode[0].SetImag (0);
	MultiCode[1].SetReal(1);MultiCode[1].SetImag (0);
	MultiCode[2].SetReal(1);MultiCode[2].SetImag (0);
	MultiCode[3].SetReal(1);MultiCode[3].SetImag (0);
	MultiCode[4].SetReal(1);MultiCode[4].SetImag (0);
	MultiCode[5].SetReal(0);MultiCode[5].SetImag (1);

	MultiCode[6].SetReal(-1);MultiCode[6].SetImag (0);
	MultiCode[7].SetReal(0);MultiCode[7].SetImag (-1);
	MultiCode[8].SetReal(1);MultiCode[8].SetImag (0);
	MultiCode[9].SetReal(-1);MultiCode[9].SetImag (0);
	MultiCode[10].SetReal(1);MultiCode[10].SetImag (0);

	MultiCode[11].SetReal(-1);MultiCode[11].SetImag (0);
	MultiCode[12].SetReal(1);MultiCode[12].SetImag (0);
	MultiCode[13].SetReal(0);MultiCode[13].SetImag (-1);
	MultiCode[14].SetReal(-1);MultiCode[14].SetImag (0);
	MultiCode[15].SetReal(0);MultiCode[15].SetImag (1);



	/////////////////////////////////////////////////////計算第一個公式的值,為複數
	for(int m=-(N-1);m<=N-1;m++)
	{
		if(fabs(td-m*t1)<=t1)
		{
			double sinC=pi*fd*(t1-fabs(td-m*t1));
			double sinValue=sin(sinC);
			double middle=sinValue/sinC;            //中間值

			if(sinC==0)
				middle=1;

            double right=(t1-fabs(td-m*t1))/t1;     //右邊值

			double ejC=pi*fd*(t1-(td-m*t1));
			Complex ejLeft;
			ejLeft.ej (ejC);
			TempLeft=ejLeft*(middle*right);
		}
		else
		{
			TempLeft.SetVal(0,0);
		}


		/////////////////////////////////////////////////////計算第二個公式的值,為複數
		if(m>=0)
		{
			TempRight.SetVal (0,0);
			for(int k=0;k<=N-1-m;k++)
			{
				double ejC=2*pi*fd*k*t1;
				Complex Ck=MultiCode[k];
				Complex Ckm=MultiCode[k+m];
				Ckm.Conj ();
		
				Complex ejRight;
				ejRight.ej(ejC);
				ejRight*=(Ck*Ckm);
				TempRight+=ejRight;
			}
			TempRight/=N;
		}
		else
		{
			TempRight.SetVal (0,0);
			for(int k=-m;k<=N-1;k++)
			{
				double ejC=2*pi*fd*k*t1;
				Complex Ck=MultiCode[k];
				Complex Ckm=MultiCode[k+m];
				Ckm.Conj ();

				Complex ejRight;
				ejRight.ej(ejC);
				ejRight*=(Ck*Ckm);
				TempRight+=ejRight;
			}
			TempRight/=N;
		}


		Value+=(TempLeft*TempRight);
	}
    AmbiValue=Value.GetModule ();
	return AmbiValue;
}

3.mfc呼叫

void CSignalDlg::InitOpenGL ()
{
	///////////////////////////////////SignalOpenGL INIT/////////////////////////////////////
	CWnd *wnd=GetDlgItem(IDC_AF);
	AfDC=::GetDC(wnd->m_hWnd);

	if(SetWindowPixelFormat(AfDC)==FALSE)
		return;

	if(CreateViewGLContext(AfDC)==FALSE)
		return;
	glPolygonMode(GL_FRONT,GL_FILL);
	glPolygonMode(GL_BACK,GL_FILL);
	///////////////////////////////////////////
	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);

	glViewport(0,0,rectAF.Width (),rectAF.Height ());

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45.0f,400/450.0f, .01f, 200.0f);      /////////////////////設定視角,此處高寬比為固定值
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glShadeModel(GL_SMOOTH);       // Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);    // Black Background
	glClearDepth(1.0f);         // Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);       // Enables Depth Testing
	glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
	
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnable (GL_LINE_STIPPLE);
	/////////////////////////////////////////////////////////////////////////////////////////////////



	SetLight();    //////////////////////////////////////////設定光源
}

void CSignalDlg::SetLight() 
{
	//////////////////////////////////////////OpenGLLight INIT///////////////////////////////////////
	GLfloat mat_specular[] = { 0.4, 0.4, 0.4, 0.2 };     //設定鏡面光
	GLfloat mat_shininess[] = { 20.0 };
	GLfloat light_position[] = { -1.0, 1.0, 1.0,1.0 };  //設定光源位置
	GLfloat white_light[]={1.0,1.0,1.0,1.0};     //設定光

	glShadeModel(GL_SMOOTH);
	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
	glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
	
	glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
	glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
	//glLightfv(GL_LIGHT0,GL_AMBIENT,light_position);
	glLightfv(GL_LIGHT0,GL_POSITION,light_position);
   

	glColorMaterial(GL_FRONT,GL_DIFFUSE);
	glEnable(GL_COLOR_MATERIAL);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
}



void CSignalDlg::RenderScene()  
{

	//////////////////////////////////////////////////////////////////
	glClearColor(1.0f,1.0f,1.0f,1.0f);                      /////////////////// 設定場景背景色
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();


	//調整場景初始位置
	glTranslatef(0.0f,0.0f,-4.5f);      /////////////////// 場景向後退
	glTranslatef(0.0f,-0.6f,0.0f);      /////////////////// 場景向下退
	//glTranslatef(0.1f,-0.0f,0.0f);      /////////////////// 場景向右退


	glRotated(m_xRotate, 1.0, 0.0, 0.0);    ///////////////////////////////////////響應滑鼠轉動

	

	////////////////////////////////////////////////調整場景初始大小
	glScalef(m_ScaleX,m_ScaleY,m_ScaleZ);

	//初始座標轉動,設定為以X軸轉20度,以Y軸轉-45度
	glRotated(25, 1.0, 0.0, 0.0);          //////////////////X軸轉20度
	glRotated(-45, 0.0, 1.0, 0.0);         //////////////////以Y軸轉-45度
	
	glRotated(time_Rotate, 0.0, 1.0, 0.0);  ///////////////////////////////////////響應時間轉動

	glRotated(m_yRotate, 0.0, 1.0, 0.0);    ///////////////////////////////////////響應滑鼠轉動
  

	glPolygonMode(GL_FRONT, GL_FILL);   ////////////////////////// 設定正面為填充方式
	glPolygonMode(GL_BACK, GL_LINE);    ////////////////////////// 設定反面為線條方式


	

	glPointSize(1.0f);
	
    
	////////////////////////////////////////////////////////////////////////繪製單位向量	
	glLineStipple (1, 0xFFFF);                         ///////////////////設定畫筆為實線
	glBegin(GL_LINES);
	//X座標軸  為紅色
	glColor3f(1.0f,0.0f,0.0f);
	glVertex3f(0.0f,0.0f,0.0f);
	glVertex3f(0.1f,0.0f,0.0f);

	//Z座標軸  為藍色
	glColor3f(0.0f,0.0f,1.0f);
	glVertex3f(0.0f,0.0f,0.0f);
	glVertex3f(0.0f,0.0f,0.1f);

     //Y座標軸  為綠色
	glColor3f(0.0f,1.0f,0.0f);
	glVertex3f(0.0f,0.0f,0.0f);
	glVertex3f(0.0f,0.1f,0.0f);

	glEnd();


	////////////////////////////////////////////////////////////////////////繪製實線座標
	glLineStipple (1, 0xFFFF);                         ///////////////////設定畫筆為實線
	glBegin(GL_LINES);
	glColor3f(0.2f,0.2f,0.2f);

	glVertex3f(-1.0f,0.0f,1.0f);
	glVertex3f(1.0f,0.0f,1.0f);

	glVertex3f(1.0f,0.0f,-1.0f);
	glVertex3f(1.0f,0.0f,1.0f);

	glVertex3f(-1.0f,0.0f,1.0f);
	glVertex3f(-1.0f,2.0f,1.0f);

	/*glVertex3f(-1.0f,0.0f,-1.0f);
	glVertex3f(-1.0f,2.0f,-1.0f);*/
	
	glEnd();





	if(labelShow==true)
	{
		////////////////////////////////////////////////////////////////////////繪製虛線座標 橫線Left
		glLineStipple (1, 0x3333);                         ///////////////////設定畫筆為虛線 
		glBegin(GL_LINES);
		glColor3f(0.2f,0.2f,0.2f);
		for(int i=0;i<=5;i+=1)
		{

			float m_y=i*0.4f;
			glVertex3f(-1.0f,m_y,1.0f);
			glVertex3f(-1.0f,m_y,-1.0f);

		}
		glEnd();

		//

		////////////////////////////////////////////////////////////////////////繪製虛線座標  豎線Left
		glLineStipple (1, 0x3333);                         ///////////////////設定畫筆為虛線 
		glBegin(GL_LINES);
		glColor3f(0.2f,0.2f,0.2f);
		for(int i=-2;i<=1;i+=1)
		{

			float m_z=i*0.5f;
			glVertex3f(-1.0f,0,m_z);
			glVertex3f(-1.0f,2,m_z);

		}
		glEnd();

		//////////////////////////////////////////////////////////////////////繪製虛線座標  橫線Right
		glLineStipple (1, 0x3333);                         ///////////////////設定畫筆為虛線 
		glBegin(GL_LINES);
		glColor3f(0.2f,0.2f,0.2f);
		for(int i=0;i<=5;i+=1)
		{

			float m_y=i*0.4f;
			glVertex3f(-1.0f,m_y,-1.0f);
			glVertex3f(1.0f,m_y,-1.0f);

		}
		glEnd();


		////////////////////////////////////////////////////////////////////////繪製虛線座標  豎線Right
		glLineStipple (1, 0x3333);                         ///////////////////設定畫筆為虛線 
		glBegin(GL_LINES);
		glColor3f(0.2f,0.2f,0.2f);
		for(int i=-2;i<=2;i+=1)
		{

			float m_y=i*0.5f;
			glVertex3f(m_y,0,-1.0f);
			glVertex3f(m_y,2,-1.0f);

		}
		glEnd();
	}


	////////////////////////////////////////////////////////////////////////繪製實線刻度 Left
	glLineStipple (1, 0xFFFF);                         ///////////////////設定畫筆為實線
	glBegin(GL_LINES);
	glColor3f(0.2f,0.2f,0.2f);
	for(int i=-2;i<=2;i+=1)
	{
		
		float m_x=i*0.5f;
		glVertex3f(m_x,0.0f,1.0f);
	    glVertex3f(m_x,0.0f,1.05f);
		
	}
	glEnd();

	
	////////////////////////////////////////////////////////////////////////繪製實線刻度 Right
	glLineStipple (1, 0xFFFF);                         ///////////////////設定畫筆為實線
	glBegin(GL_LINES);
	glColor3f(0.2f,0.2f,0.2f);
	for(int i=-2;i<=2;i+=1)
	{
		
		float m_z=i*0.5f;
		glVertex3f(1.0f,0.0f,m_z);
	    glVertex3f(1.05f,0.0f,m_z);
		
	}
	glEnd();


	////////////////////////////////////////////////////////////////////////繪製實線刻度 高度
	glLineStipple (1, 0xFFFF);                         ///////////////////設定畫筆為實線
	glBegin(GL_LINES);
	glColor3f(0.2f,0.2f,0.2f);
	for(int i=0;i<=5;i+=1)
	{
		
		float m_y=i*0.4f;
		glVertex3f(-1.0f,m_y,1.0f);
	    glVertex3f(-1.05f,m_y,1.0f);
		
	}
	glEnd();


	////////////////////////////////////////////////////////////////////////繪製刻度字型 高度
	wglUseFontBitmaps(wglGetCurrentDC(),0,256,1000);
	glListBase(1000);
	glColor3f(0.1,0.3,0.7);
	//glColor3f(0.0,1.0,1.0);

	glRasterPos3f(-1.1f,0.0-0.02,1.1f);
	glCallLists(3,GL_UNSIGNED_BYTE,"0.0");
	glRasterPos3f(-1.1f,0.4-0.02,1.1f);
	glCallLists(3,GL_UNSIGNED_BYTE,"0.2"); 
	glRasterPos3f(-1.1f,0.8-0.02,1.1f);
	glCallLists(3,GL_UNSIGNED_BYTE,"0.4"); 
	glRasterPos3f(-1.1f,1.2-0.02,1.1f);
	glCallLists(3,GL_UNSIGNED_BYTE,"0.6"); 
	glRasterPos3f(-1.1f,1.6-0.02,1.1f);
	glCallLists(3,GL_UNSIGNED_BYTE,"0.8"); 
	glRasterPos3f(-1.1f,2.0-0.02,1.1f);
	glCallLists(1,GL_UNSIGNED_BYTE,"1"); 

    ////////////////////////////////////////////////////////////////////////繪製刻度字型 Left

	float T[5]={-tLabel,-tLabel/2,0,tLabel/2,tLabel};
	CString strT[5]={_T("-1.0"),_T("-0.5"),_T("0"),_T("0.5"),_T("1.0")};
	for(int i=0;i<5;i++)
	{
		strT[i].Format(_T("%.1f"),T[i]);
	}
	char *s1=(char *)(LPCTSTR)strT[0];
	char *s2=(char *)(LPCTSTR)strT[1];
	char *s3=(char *)(LPCTSTR)strT[2];
	char *s4=(char *)(LPCTSTR)strT[3];
	char *s5=(char *)(LPCTSTR)strT[4];



	glRasterPos3f(-1.0f,-0.1f,1.1f);
	glCallLists((GLsizei) strlen(s1), GL_UNSIGNED_BYTE, (GLubyte *) s1); 
	glRasterPos3f(-1.0+0.5f,-0.1f,1.1f);
	glCallLists((GLsizei) strlen(s2), GL_UNSIGNED_BYTE, (GLubyte *) s2); 
	glRasterPos3f(-1.0+1.0f,-0.1f,1.1f);
	glCallLists((GLsizei) strlen(s3), GL_UNSIGNED_BYTE, (GLubyte *) s3); 
	glRasterPos3f(-1.0+1.5f,-0.1f,1.1f);
	glCallLists((GLsizei) strlen(s4), GL_UNSIGNED_BYTE, (GLubyte *) s4); 
	glRasterPos3f(-1.0+2.0f,-0.1f,1.1f);
	glCallLists((GLsizei) strlen(s5), GL_UNSIGNED_BYTE, (GLubyte *) s5); 

	////////////////////////////////////////////////////////////////////////繪製刻度字型 Right

	float fd[5]={-fdLabel,-fdLabel/2,0,fdLabel/2,fdLabel};
	CString strfd[5]={_T("-1.0"),_T("-0.5"),_T("0"),_T("0.5"),_T("1.0")};
	for(int i=0;i<5;i++)
	{
		strfd[i].Format(_T("%.1f"),fd[i]);
	}
	char *sd1=(char *)(LPCTSTR)strfd[0];
	char *sd2=(char *)(LPCTSTR)strfd[1];
	char *sd3=(char *)(LPCTSTR)strfd[2];
	char *sd4=(char *)(LPCTSTR)strfd[3];
	char *sd5=(char *)(LPCTSTR)strfd[4];


	glRasterPos3f(1.1f,-0.1f,-1.0f);
	glCallLists((GLsizei) strlen(sd1), GL_UNSIGNED_BYTE, (GLubyte *) sd1); 
	glRasterPos3f(1.1f,-0.1f,-1.0+0.5f);
	glCallLists((GLsizei) strlen(sd2), GL_UNSIGNED_BYTE, (GLubyte *) sd2);  
	glRasterPos3f(1.1f,-0.1f,-1.0+1.0f);
	glCallLists((GLsizei) strlen(sd3), GL_UNSIGNED_BYTE, (GLubyte *) sd3); 
	glRasterPos3f(1.1f,-0.1f,-1.0+1.5f);
	glCallLists((GLsizei) strlen(sd4), GL_UNSIGNED_BYTE, (GLubyte *) sd4); 
	glRasterPos3f(1.1f,-0.1f,-1.0+2.0f);
	glCallLists((GLsizei) strlen(sd5), GL_UNSIGNED_BYTE, (GLubyte *) sd5); 



	cisePos=inciseSlide.GetPos();

    /////////////////////////////////////////////////////////繪製模糊函式圖//////////////////////////////////////////////////////
    

    double Max = AF.GetMax();          //////////////////////////////////////獲取最高值點              
	double Min = 0;//AF.GetMin();      //////////////////////////////////////獲取最低值點,預設最小值為0  
	double mid = (Max-Min)/2.0;        //////////////////////////////////////獲取中間點
	double mid_up = (mid+Max)/2.0-0.1;     //////////////////////////////////////獲取中上點  0.1為調節綠色的分量值
	double mid_down = (mid+Min)/2.0;   //////////////////////////////////////獲取中下點  0.1為調節綠色的分量值
	double R=0;           //////////////////////////////////////定義紅色分量
	double G=0;           //////////////////////////////////////定義綠色分量
	double B=0;           //////////////////////////////////////定義藍色分量

	if(incise==0)
	{
		for (int j = 2;j<200-3;j++)
		{
			glBegin(GL_TRIANGLE_STRIP);
			for (int i = 2;i<200-3;i++)
			{
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點顏色
				if (AF.Data[i][j].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j].h-mid_down)/(mid-mid_down); //////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.1,1-B);
					}

				}
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點法線

				float v1[]={AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z};
				float v2[]={AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z};
				float v3[]={AF.Data[i+1][j].x,AF.Data[i+1][j].h ,AF.Data [i+1][j].z};
				float norm[]={0.0,0.0,0.0};
				normal(v1,v2,v3,norm);
				glNormal3f(norm[0],norm[1],norm[2]);
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點位置
				glVertex3f(AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z);



				//////////////////////////////////////////////////////////////////////////////////////////////計算第二個點顏色
				if (AF.Data[i][j+1].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j+1].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j+1].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j+1].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j+1].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j+1].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j+1].h-mid_down)/(mid-mid_down);//////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.0,1-B);
					}

				}
				//////////////////////////////////////////////////////////////////////////////////////////////計算第二個點位置
				glNormal3f(norm[0],norm[1],norm[2]);
				glVertex3f(AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z);

			}
			glEnd();
		}
	}


	else if(incise==1)
	{
		for (int j = 2;j<200-3;j++)
		{
			glBegin(GL_TRIANGLE_STRIP);
			for (int i = 2;i<=cisePos;i++)
			{
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點顏色
				if (AF.Data[i][j].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j].h-mid_down)/(mid-mid_down); //////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.1,1-B);
					}

				}
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點法線

				float v1[]={AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z};
				float v2[]={AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z};
				float v3[]={AF.Data[i+1][j].x,AF.Data[i+1][j].h ,AF.Data [i+1][j].z};
				float norm[]={0.0,0.0,0.0};
				normal(v1,v2,v3,norm);
				glNormal3f(norm[0],norm[1],norm[2]);
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點位置
				glVertex3f(AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z);



				//////////////////////////////////////////////////////////////////////////////////////////////計算第二個點顏色
				if (AF.Data[i][j+1].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j+1].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j+1].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j+1].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j+1].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j+1].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j+1].h-mid_down)/(mid-mid_down);//////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.0,1-B);
					}

				}
				//////////////////////////////////////////////////////////////////////////////////////////////計算第二個點位置
				glNormal3f(norm[0],norm[1],norm[2]);
				glVertex3f(AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z);

			}
			glEnd();
		}
		glBegin(GL_TRIANGLE_STRIP);
		for (int j = 2;j<200-3;j++)
		{
			glNormal3f(1,0,0);
			glColor3f(1.0,0.0,0.0);
			glVertex3f(AF.Data[cisePos][j].x,0 ,AF.Data [cisePos][j].z);
			
			glNormal3f(1,0,0);
			glColor3f(1.0,0.0,0.0);
			glVertex3f(AF.Data[cisePos][j].x,AF.Data[cisePos][j].h ,AF.Data [cisePos][j].z);
		}
		glEnd();
	}


	else if(incise==2)
	{
		for (int j = cisePos;j<200-3;j++)
		{
			glBegin(GL_TRIANGLE_STRIP);
			for (int i = 2;i<200-3;i++)
			{
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點顏色
				if (AF.Data[i][j].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j].h-mid_down)/(mid-mid_down); //////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.1,1-B);
					}

				}
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點法線

				float v1[]={AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z};
				float v2[]={AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z};
				float v3[]={AF.Data[i+1][j].x,AF.Data[i+1][j].h ,AF.Data [i+1][j].z};
				float norm[]={0.0,0.0,0.0};
				normal(v1,v2,v3,norm);
				glNormal3f(norm[0],norm[1],norm[2]);
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點位置
				glVertex3f(AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z);



				//////////////////////////////////////////////////////////////////////////////////////////////計算第二個點顏色
				if (AF.Data[i][j+1].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j+1].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j+1].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j+1].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j+1].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j+1].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j+1].h-mid_down)/(mid-mid_down);//////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.0,1-B);
					}

				}
				//////////////////////////////////////////////////////////////////////////////////////////////計算第二個點位置
				glNormal3f(norm[0],norm[1],norm[2]);
				glVertex3f(AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z);

			}
			glEnd();
		}
		glBegin(GL_TRIANGLE_STRIP);
		for (int i = 2;i<200-3;i++)
		{
			glNormal3f(0,0,-1);
			glColor3f(1.0,0.0,0.0);
			glVertex3f(AF.Data[i][cisePos].x,0,AF.Data [i][cisePos].z);
			
			glNormal3f(0,0,-1);
			glColor3f(1.0,0.0,0.0);
			glVertex3f(AF.Data[i][cisePos].x,AF.Data[i][cisePos].h ,AF.Data [i][cisePos].z);
		}
		glEnd();
	}




	else if(incise==3)
	{
		for (int j = 2;j<200-3;j++)
		{
			glBegin(GL_TRIANGLE_STRIP);
			for (int i = 2;i<200-3;i++)
			{
				//////////////////////////////////////////////////////////////////////////////////////////////計算第一個點顏色
				if (AF.Data[i][j].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j].h-mid_down)/(mid-mid_down); //////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.1,1-B);
					}

				}


				if(AF.Data[i][j].h<cisePos*0.01)
				{
					float v1[]={AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z};
					float v2[]={AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z};
					float v3[]={AF.Data[i+1][j].x,AF.Data[i+1][j].h ,AF.Data [i+1][j].z};
					float norm[]={0.0,0.0,0.0};
					normal(v1,v2,v3,norm);
					glNormal3f(norm[0],norm[1],norm[2]);                                       //////////////////計算第一個點法線
					glVertex3f(AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z);///////////////////////////////計算第一個點位置
				}
				else
				{
					glNormal3f(0,1,0);                                       //////////////////計算第一個點法線
					glVertex3f(AF.Data[i][j].x,cisePos*0.01,AF.Data [i][j].z);///////////////////////////////計算第一個點位置
				}



				//////////////////////////////////////////////////////////////////////////////////////////////計算第二個點顏色
				if (AF.Data[i][j+1].h>=mid)                              //////////////////////////////////////判斷處於上半部分
				{
					if(AF.Data[i][j+1].h>=mid_up)                        //////////////////////////////////////判斷處於上4/4部分
					{
						G = (AF.Data[i][j+1].h-mid_up)/(Max-mid_up);     //////////////////////////////////////計算綠色分量值
						glColor3f(1.0,1.0-G,0.0);
					}
					else                                               //////////////////////////////////////判斷處於上3/4部分
					{
						R = (AF.Data[i][j+1].h-mid)/(mid_up-mid);        //////////////////////////////////////計算紅色分量值
						glColor3f(R,1.0,0.0);
					}
				}
				else                                                   //////////////////////////////////////判斷處於下半部分
				{
					if(AF.Data[i][j+1].h <=mid_down)                     //////////////////////////////////////判斷處於下1/4部分
					{
						G = (AF.Data[i][j+1].h-Min)/(mid_down-Min);      //////////////////////////////////////計算綠色分量值
						glColor3f(0.0,G,1.0);
					}
					else                                               //////////////////////////////////////判斷處於下2/4部分
					{
						B = (AF.Data[i][j+1].h-mid_down)/(mid-mid_down);//////////////////////////////////////計算藍色分量值
						glColor3f(0.0,1.0,1-B);
					}

				}


				if(AF.Data[i][j+1].h<cisePos*0.01)
				{
					float v1[]={AF.Data[i][j].x,AF.Data[i][j].h ,AF.Data [i][j].z};
					float v2[]={AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z};
					float v3[]={AF.Data[i+1][j].x,AF.Data[i+1][j].h ,AF.Data [i+1][j].z};
					float norm[]={0.0,0.0,0.0};
					normal(v1,v2,v3,norm);
					glNormal3f(norm[0],norm[1],norm[2]);                                       //////////////////計算第一個點法線
					glVertex3f(AF.Data[i][j+1].x,AF.Data[i][j+1].h ,AF.Data [i][j+1].z);///////////////////////////////計算第一個點位置
				}
				else
				{
					glNormal3f(0,1,0);                                       //////////////////計算第一個點法線
					glVertex3f(AF.Data[i][j+1].x,cisePos*0.01,AF.Data [i][j+1].z);///////////////////////////////計算第一個點位置
				}

			}
			glEnd();
		}
	}




    /////////////////////////////////////////////////////////繪製模糊函式圖//////////////////////////////////////////////////////
	SwapBuffers(AfDC);
}