www.pudn.com > Map_OpenGL.rar > Map_TinObject.cpp


// Map_TinObject.cpp: implementation of the CMap_TinObject class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "Map_OpenGL.h" 
#include "Map_TinObject.h" 
#include "Map_DemObject.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CMap_TinObject::CMap_TinObject() 
{ 
 
} 
 
CMap_TinObject::~CMap_TinObject() 
{ 
 
} 
 
	 
void CMap_TinObject::ReadFile(CString filename) 
{ 
	FILE* fp; 
	fp=fopen(filename,"rt"); 
	ASSERT(fp); 
 
	if(fp==NULL) 
	{ 
		AfxMessageBox("数据文件没有打开!"); 
		return; 
	} 
 
	fscanf(fp,"%d %d",&m_dotnumber,&m_triangenumber); 
 
	dot_x	=	new float[m_dotnumber]; 
	dot_y	=	new float[m_dotnumber]; 
	dot_h	=	new float[m_dotnumber]; 
 
	m_f		=	new  int[m_triangenumber]; 
	m_s		=	new  int[m_triangenumber]; 
	m_t		=	new  int[m_triangenumber]; 
 
	for(int i=0;idot_x[i]) 
		{ 
			x_min=dot_x[i]; 
		} 
		else 
		{ 
			x_min=x_min; 
		} 
	} 
	return x_min; 
} 
 
 
 
float CMap_TinObject::GetYMax() 
{ 
	float y_max; 
	y_max=dot_y[0]; 
	for(int i=1;idot_y[i]) 
		{ 
			y_min=dot_y[i]; 
		} 
		else 
		{ 
			y_min=y_min; 
		} 
	} 
	return y_min; 
} 
 
 
 
float CMap_TinObject::GetHMax() 
{ 
	float h_max; 
	h_max=dot_h[0]; 
	for(int i=1;idot_h[i]) 
		{ 
			h_min=dot_h[i]; 
		} 
		else 
		{ 
			h_min=h_min; 
		} 
	} 
	return h_min; 
} 
 
void CMap_TinObject::TinShow(CDC* pDC) 
{ 
 
	float m_x1,m_y1; 
	float m_x2,m_y2; 
	float m_x3,m_y3; 
 
	CPoint m_point[3]; 
 
	CPen newpen,*oldpen; 
	newpen.CreatePen(1,1,RGB(24,25,182)); 
	oldpen=pDC->SelectObject(&newpen); 
	 
 
	for(int i=0;iPolyline(m_point,3); 
	} 
	pDC->SelectObject(oldpen); 
 
 
 
	float dx,dy,dh; 
	long m_dotx,m_doty; 
	int r,g,b; 
 
	for(int j=0;jSelectObject(&newbrush); 
 
		CRect m_rect; 
		m_rect.left=m_dotx-2; 
		m_rect.right=m_dotx+2; 
		m_rect.top=m_doty-2; 
		m_rect.bottom=m_doty+2; 
 
		pDC->FillRect(m_rect,&newbrush); 
		pDC->SelectObject(oldbrush);		 
	} 
} 
 
 
void CMap_TinObject::GetMidDate(float& midx,float& midy,float& midz) 
{ 
	midx=(m_tinright+m_tinleft)/2; 
	midy=(m_MinHeight+m_MaxHeight)/2; 
	midz=m_tintop; 
} 
 
void CMap_TinObject::Show3DMode() 
{ 
	Triange_dem tin[3]; 
 
	glPushMatrix(); 
 
	for(int i=0;i