亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? listcontour.cpp

?? 等值線計算和繪制源程序
?? CPP
字號:
// ListContour.cpp: implementation of the CListContour class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ContourGL.h"
#include "ListContour.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CListContour::CListContour()
: CContour()
{
}

CListContour::~CListContour()
{
	CleanMemory();
}

void CListContour::Generate()
{
	// generate line strips
	CContour::Generate();
	// compact strips
	CompactStrips();
}

void CListContour::InitMemory()
{
	CContour::InitMemory();
	
	CLineStripList::iterator pos;
	CLineStrip* pStrip;
	
	if (!m_vStripLists.empty())
	{
		UINT i;
		// reseting lists
		ASSERT(m_vStripLists.size() == GetNPlanes());
		for (i=0;i<GetNPlanes();i++)
		{
			for (pos = m_vStripLists[i].begin(); pos!=m_vStripLists[i].end() ; pos++)
			{
				pStrip=(*pos);
				ASSERT(pStrip);

				pStrip->clear();
				delete pStrip;
			}
			m_vStripLists[i].clear();
		}
	}
	else
		m_vStripLists.resize(GetNPlanes());
}

void CListContour::CleanMemory()
{
	CContour::CleanMemory();
	
	CLineStripList::iterator pos;
	CLineStrip* pStrip;
	UINT i;

	// reseting lists
	ASSERT(m_vStripLists.size() == GetNPlanes());
	for (i=0;i<GetNPlanes();i++)
	{
		for (pos=m_vStripLists[i].begin(); pos!=m_vStripLists[i].end();pos++)
		{
			pStrip=(*pos);
			ASSERT(pStrip);
			pStrip->clear();
			delete pStrip;
		}
		m_vStripLists[i].clear();
	}
}

void CListContour::ExportLine(int iPlane,int x1, int y1, int x2, int y2)
{
	ASSERT(iPlane>=0);
	ASSERT(iPlane<GetNPlanes());
	
	// check that the two points are not at the beginning or end of the  some line strip
	UINT i1=y1*(m_iColSec+1)+x1;
	UINT i2=y2*(m_iColSec+1)+x2;
	
	CLineStrip* pStrip;
	
	CLineStripList::iterator pos;
	BOOL added=FALSE;
	for(pos=m_vStripLists[iPlane].begin(); pos!=m_vStripLists[iPlane].end() && !added; pos++)
	{
		pStrip=(*pos);
		ASSERT(pStrip);
		// check if points are appendable to this strip
		if (i1==pStrip->front())
		{
			pStrip->insert(pStrip->begin(),i2);
			return;
		}
		if (i1==pStrip->back())
		{
			pStrip->insert(pStrip->end(),i2);
			return;
		}
		if (i2==pStrip->front())
		{
			pStrip->insert(pStrip->begin(),i1);
			return;
		}
		if (i2==pStrip->back())
		{
			pStrip->insert(pStrip->end(),i1);
			return;
		}
	}
	
	// segment was not part of any line strip, creating new one
	pStrip=new CLineStrip;
	pStrip->insert(pStrip->begin(),i1);
	pStrip->insert(pStrip->end(),i2);
	m_vStripLists[iPlane].insert(m_vStripLists[iPlane].begin(),pStrip);
}

bool CListContour::ForceMerge(CLineStrip* pStrip1, CLineStrip* pStrip2) 
{
	
	CLineStrip::iterator pos;
	CLineStrip::reverse_iterator rpos;
	
	if (pStrip2->empty())
		return false;
	
	double x[4], y[4], weldDist;
	int index;
	index = pStrip1->front();
	x[0] = GetXi(index);
	y[0] = GetYi(index);
	index = pStrip1->back();
	x[1] = GetXi(index);
	y[1] = GetYi(index);
	index = pStrip2->front();
	x[2] = GetXi(index);
	y[2] = GetYi(index);
	index = pStrip2->back();
	x[3] = GetXi(index);
	y[3] = GetYi(index);
	
	weldDist = 10*(m_dDx*m_dDx+m_dDy*m_dDy);
	
	if ((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2])< weldDist)
    {
		for (pos=pStrip2->begin(); pos!=pStrip2->end();pos++)
		{
			index=(*pos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->end(),index);
		}
		pStrip2->clear();
		return true;
    }
	
	if ((x[3]-x[0])*(x[3]-x[0])+(y[3]-y[0])*(y[3]-y[0])< weldDist)
    {
		for (rpos=pStrip2->rbegin(); rpos!=pStrip2->rend();rpos++)
		{
			index=(*rpos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->begin(),index);
		}
		pStrip2->clear();
		return true;
    }
	
	if ((x[1]-x[3])*(x[1]-x[3])+(y[1]-y[3])*(y[1]-y[3])< weldDist)
    {
		for (rpos=pStrip2->rbegin(); rpos!=pStrip2->rend();rpos++)
		{
			index=(*rpos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->end(),index);
		}
		pStrip2->clear();
		return true;
    }

	if ((x[0]-x[2])*(x[0]-x[2])+(y[0]-y[2])*(y[0]-y[2])< weldDist)
    {
		for (pos=pStrip2->begin(); pos!=pStrip2->end();pos++)
		{
			index=(*pos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->begin(),index);
		}
		pStrip2->clear();
		return true;
    }

	return false;
}

bool CListContour::MergeStrips(CLineStrip* pStrip1, CLineStrip* pStrip2)
{
	CLineStrip::iterator pos;
	CLineStrip::reverse_iterator rpos;
	if (pStrip2->empty())
		return false;
	
	int index;

	// debugging stuff
	if (pStrip2->front()==pStrip1->front())
    {
		// retreiving first element
		pStrip2->pop_front();
		// adding the rest to strip1
		for (pos=pStrip2->begin(); pos!=pStrip2->end();pos++)
		{
			index=(*pos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->begin(),index);
		}
		pStrip2->clear();
		return true;
    }
	
	if (pStrip2->front()==pStrip1->back())
    {
		pStrip2->pop_front();
		// adding the rest to strip1
		for (pos=pStrip2->begin(); pos!=pStrip2->end();pos++)
		{
			index=(*pos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->end(),index);
		}
		pStrip2->clear();
		return true;
    }
	
	if (pStrip2->back()==pStrip1->front())
    {
		pStrip2->pop_back();
		// adding the rest to strip1
		for (rpos=pStrip2->rbegin(); rpos!=pStrip2->rend();rpos++)
		{
			index=(*rpos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->begin(),index);
		}
		pStrip2->clear();
		return true;
    }
	
	if (pStrip2->back()==pStrip1->back())
    {
		pStrip2->pop_back();
		// adding the rest to strip1
		for (rpos=pStrip2->rbegin(); rpos!=pStrip2->rend();rpos++)
		{
			index=(*rpos);
			ASSERT(index>=0);
			pStrip1->insert(pStrip1->end(),index);
		}
		pStrip2->clear();
		return true;
    }
	
	return false;
}

void CListContour::CompactStrips()
{
	CLineStrip* pStrip;
	CLineStrip* pStripBase;
	UINT i;
	CLineStripList::iterator pos,pos2;
	CLineStripList newList;
	bool again, changed;	
	
	const double weldDist = 10*(m_dDx*m_dDx+m_dDy*m_dDy);

	ASSERT(m_vStripLists.size() == GetNPlanes());
	for (i=0;i<GetNPlanes();i++)
	{
		again=true;
		while(again)
		{
			// REPEAT COMPACT PROCESS UNTILL LAST PROCESS MAKES NO CHANGE
			
			again=false;
			// building compacted list
			ASSERT(newList.empty());
			for (pos=m_vStripLists[i].begin(); pos!=m_vStripLists[i].end();pos++)
			{
				pStrip=(*pos);
				for (pos2=newList.begin(); pos2!=newList.end();pos2++)
				{
					pStripBase=(*pos2);
					changed=MergeStrips(pStripBase,pStrip);
					if (changed)
						again=true;
					if (pStrip->empty())
						break;
				}
				if (pStrip->empty())
					delete pStrip;
				else
					newList.insert(newList.begin(),pStrip);
			}
			
			
			// deleting old list
			m_vStripLists[i].clear();
			// Copying all
			for (pos2=newList.begin(); pos2 != newList.end(); pos2++)
			{
				pStrip=(*pos2);
				CLineStrip::iterator pos1 = pStrip->begin(),pos3;
				while (pos1!=pStrip->end()) 
				{
					pos3 = pos1; 
					pos3++;
					if ( (*pos1) == (*pos3))
						pStrip->erase(pos3);
					else 
						pos1++;
				}
				
				//if (!(pStrip->front()==pStrip->back() && pStrip->size()==2))
				if (pStrip->size()!=1) 	
					m_vStripLists[i].insert(m_vStripLists[i].begin(),pStrip );
				else 
					delete pStrip;
			}
			// emptying temp list
			newList.clear();
			
		} // OF WHILE(AGAIN) (LAST COMPACT PROCESS MADE NO CHANGES)
		
	
		if (m_vStripLists[i].empty())
			continue;
		///////////////////////////////////////////////////////////////////////
		// compact more
		int Nstrip,j,index,count;

		Nstrip = m_vStripLists[i].size(); 
		std::vector<bool> closed(Nstrip);
		double x,y;

		// First let's find the open and closed lists in m_vStripLists
		for(pos2 = m_vStripLists[i].begin(), j=0, count=0; pos2 != m_vStripLists[i].end(); pos2++, j++) 
		{
			pStrip = (*pos2);

			// is it open ?
			if (pStrip->front() != pStrip->back()) 
			{
				index = pStrip->front();
				x = GetXi(index); y = GetYi(index);
				index = pStrip->back();
				x -= GetXi(index); y -= GetYi(index);
				
				// is it "almost closed" ?
				if ( x*x+y*y < weldDist)
					closed[j] = true; 
				else 
				{ 
					closed[j] = false; 
					// updating not closed counter...
					count ++; 
				}
			} 
			else 
				closed[j] = true;
		}
		
		// is there any open strip ?
		if (count > 1) 
		{ 
			// Merge the open strips into NewList
			pos = m_vStripLists[i].begin();
			for(j=0;j<Nstrip;j++) 
			{
				if (closed[j] == false ) 
				{
					pStrip = (*pos);
					newList.insert(newList.begin(),pStrip);	
					pos = m_vStripLists[i].erase(pos);
				}
				else 
					pos ++;
			}
			
			// are they open strips to process ?
			while(newList.size()>1) 
			{
				pStripBase = newList.front();
				
				// merge the rest to pStripBase
				again = true;
				while (again) 
				{
					again = false;
					pos = newList.begin(); 
					for(pos++; pos!=newList.end();) 
					{
						pStrip = (*pos);
						changed = ForceMerge(pStripBase,pStrip);
						if (changed) 
						{ 
							again = true;
							delete pStrip;
							pos = newList.erase(pos);
						} 
						else 
							pos ++;
					}		      
				} // while(again)
				
				index = pStripBase->front();
				x = GetXi(index); y = GetYi(index);
				index = pStripBase->back();
				x -= GetXi(index); y -= GetYi(index);
				
				// if pStripBase is closed or not
				if (x*x+y*y < weldDist) 
				{
					m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
					newList.pop_front();
				} 
				else 
				{			
					if (OnBoundary(pStripBase)) 
					{
						TRACE(_T("# open strip ends on boundary, continue.\n"));
						m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
						newList.pop_front();
					} 
					else 
					{
						TRACE(_T("unpaird open strip at 1!"));
						exit(0);
					}
				}
			} // while(newList.size()>1);


			if (newList.size() ==1) 
			{
				pStripBase = newList.front();
				if (OnBoundary(pStripBase)) 
				{
					TRACE(_T("# open strip ends on boundary, continue.\n"));
					m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
					newList.pop_front();
				} 
				else 
				{
					TRACE(_T("unpaird open strip at 2!"));
					DumpPlane(i);
					exit(0);
				}
			}
			
			newList.clear();
			
		} 
		else if (count == 1) 
		{
			pos = m_vStripLists[i].begin();
			for(j=0;j<Nstrip;j++) 
			{
				if (closed[j] == false ) 
				{
					pStripBase = (*pos);
					break;
				}
				pos ++;
			}
			if (OnBoundary(pStripBase)) 
			{
				TRACE(_T("# open strip ends on boundary, continue.\n"));
			} 
			else 
			{
				TRACE(_T("unpaird open strip at 3!"));
				DumpPlane(i);
				exit(0);
			}
		}

		//////////////////////////////////////////////////////////////////////////////////////////////////
	}
}


bool CListContour::OnBoundary(CLineStrip* pStrip) 
{
	bool e1,e2;

	int index = pStrip->front();
	double x = GetXi(index), y = GetYi(index);
	if (x==m_pLimits[0] || x == m_pLimits[1] || 
		y == m_pLimits[2] || y == m_pLimits[3])
		e1 = true;
	else 
		e1 = false;
	
	index = pStrip->back();
	x = GetXi(index); y = GetYi(index);
	if (x==m_pLimits[0] || x == m_pLimits[1] || 
		y == m_pLimits[2] || y == m_pLimits[3])
		e2 = true;
	else 
		e2 = false;
	
	return (e1 && e2);
}

void CListContour::DumpPlane(UINT iPlane) const
{
	CLineStripList::const_iterator pos;
	UINT i;
	CLineStrip* pStrip;
	
	ASSERT(iPlane>=0);
	ASSERT(iPlane<GetNPlanes());
	TRACE(_T("Level : %d"),GetPlane(iPlane));
	
	TRACE(_T("Number of strips : %d\r\n"),m_vStripLists[iPlane].size());
	TRACE(_T("i np start end xstart ystart xend yend\r\n"));
	for (pos = m_vStripLists[iPlane].begin(), i=0; pos != m_vStripLists[iPlane].end(); pos++, i++)
	{
		pStrip=*pos;
		ASSERT(pStrip);
		TRACE(_T("%d %d %d %d %g %g %g %g\r\n"),i,pStrip->size(),pStrip->front(),pStrip->back(),
			GetXi(pStrip->front()),GetYi(pStrip->front()),
			GetXi(pStrip->back()),GetYi(pStrip->back()) );
	}
}

double CListContour::Area(CLineStrip* Line) 
{
	// if Line is not closed, return 0;
	
	double Ar = 0, x, y, x0,y0,x1, y1;
	int index;
	
	CLineStrip::iterator pos;
	pos = Line->begin();
	index = (*pos);
	x0 = x =  GetXi(index);
	y0 = y =  GetYi(index);
	
	pos ++;
	
	for(;pos!=Line->end();pos++) 
	{
		index = (*pos);  
		x1 = GetXi(index);
		y1 = GetYi(index);
		// Ar += (x1-x)*(y1+y);
		Ar += (y1-y)*(x1+x)-(x1-x)*(y1+y);
		x = x1;
		y = y1;  
		
	}
	
	
	//Ar += (x0-x)*(y0+y);
	Ar += (y0-y)*(x0+x)-(x0-x)*(y0+y);
	// if not closed curve, return 0;
	if ((x0-x)*(x0-x) + (y0-y)*(y0-y)>20*(m_dDx*m_dDx+m_dDy*m_dDy)) 
	{
		Ar = 0;
		TRACE(_T("# open curve!\n"));
	}
	//else   Ar /= -2;
	else Ar/=4;
	// result is \int ydex/2 alone the implicit direction.
	return Ar;
}

double CListContour:: EdgeWeight(CLineStrip* pLine, double R) 
{
	CLineStrip::iterator pos;
	int count = 0,index;
	double x,y;
	for(pos = pLine->begin(); pos!=pLine->end(); pos++) 
	{
		index = (*pos);
		x = GetXi(index); 
		y = GetYi(index);
		if (fabs(x) > R || fabs(y) > R) 
			count ++;
	}
	return (double)count/pLine->size();
}

bool::CListContour::PrintContour(char *fname) 
{
	std::ofstream file(fname);
	if (!file) 
	{ 
		TRACE(_T("cannot open output file.\n")); 
		return false; 
	}

	file << std::setprecision(10);
	
	UINT i, index;
	CLineStrip* pStrip;
	CLineStrip::iterator pos2;
	CLineStripList::iterator pos;
	
	for(i=0;i<GetNPlanes();i++) {
		for(pos = m_vStripLists[i].begin();pos!=m_vStripLists[i].end();pos++) 
		{
			pStrip = (*pos);
			for(pos2 = pStrip->begin();pos2!=pStrip->end();pos2++) 
			{
				index = (*pos2);
				file << GetXi(index)<<"\t"<<GetYi(index)<<"\n";
			}
			file<<"\n";
		}
	}
	file.close();
	return true;
	
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线视频官网| 欧美一三区三区四区免费在线看| 99在线精品视频| 日韩午夜激情av| 亚洲黄色免费网站| 高清不卡一区二区| 欧美不卡一区二区| 午夜免费欧美电影| 在线一区二区三区| 国产精品久久久久久久久动漫| 日韩电影在线观看网站| 色婷婷av一区二区三区大白胸| 久久久噜噜噜久久人人看| 日韩不卡一区二区| 91成人免费电影| 亚洲三级电影网站| 国产精品一区二区三区99| 日韩免费视频一区二区| 一二三区精品福利视频| 一本色道久久综合亚洲91| 国产人成亚洲第一网站在线播放| 免费成人在线影院| 欧美丰满高潮xxxx喷水动漫| 亚洲第一成人在线| 欧美日韩成人一区二区| 亚洲国产精品欧美一二99| 91视频精品在这里| 亚洲青青青在线视频| 99精品热视频| 亚洲欧美乱综合| 97精品国产露脸对白| 国产精品久久久久久久久动漫| 高清国产一区二区| 中文字幕制服丝袜成人av | 亚洲国产精品成人综合色在线婷婷| 日韩专区一卡二卡| 日韩精品一区二区三区在线播放 | 成人免费在线视频观看| 色综合咪咪久久| 亚洲精品美腿丝袜| 欧美日韩一区国产| 日韩av中文字幕一区二区三区 | 久久久久国产一区二区三区四区| 免费的国产精品| 久久久久久久久伊人| 国产成人免费av在线| 欧美国产乱子伦 | 国产一区二区精品久久91| 久久久久97国产精华液好用吗| 国产传媒日韩欧美成人| 国产精品第四页| 在线免费观看一区| 五月综合激情网| 精品精品国产高清a毛片牛牛 | 美女视频黄a大片欧美| 久久综合九色综合欧美98| 国产福利一区二区三区视频| 中文字幕一区av| 欧美高清你懂得| 国内精品国产三级国产a久久| 国产精品视频麻豆| 欧美性色黄大片| 国模一区二区三区白浆| 亚洲男人电影天堂| 日韩午夜精品电影| 一本色道**综合亚洲精品蜜桃冫| 亚洲成av人片在线观看无码| 久久久精品欧美丰满| 在线视频观看一区| 国精品**一区二区三区在线蜜桃| 中文字幕一区二区三区在线观看| 欧美老肥妇做.爰bbww视频| 国产麻豆精品久久一二三| 亚洲精品日韩专区silk| 26uuu亚洲婷婷狠狠天堂| 色综合久久久久综合体| 久久国产乱子精品免费女| 一区精品在线播放| 欧美一级片在线| 91啪在线观看| 国产成人精品亚洲午夜麻豆| 天天免费综合色| 中文字幕在线播放不卡一区| 91精品久久久久久久99蜜桃| 97精品国产97久久久久久久久久久久| 男人操女人的视频在线观看欧美| 亚洲欧美一区二区三区国产精品| 欧美大片国产精品| 欧美久久一区二区| 91丨porny丨首页| 国产精品主播直播| 九九九精品视频| 视频在线观看91| 亚洲自拍偷拍图区| 日韩美女视频一区二区| 国产亚洲一区二区三区| 欧美第一区第二区| 欧美一二三区精品| 欧美午夜视频网站| 色婷婷亚洲一区二区三区| 成人国产精品免费| 成人综合在线观看| 国产 日韩 欧美大片| 国产精品一区专区| 国产乱人伦偷精品视频不卡| 国产一区二区三区视频在线播放| 免费人成网站在线观看欧美高清| 亚洲大片在线观看| 亚洲国产精品久久人人爱| 一区二区三区在线视频免费 | 免费成人性网站| 日韩黄色片在线观看| 日韩和欧美一区二区三区| 日韩av电影免费观看高清完整版 | 精品午夜一区二区三区在线观看| 丝袜亚洲另类丝袜在线| 亚洲一线二线三线视频| 亚洲精品视频在线观看免费| 亚洲激情自拍偷拍| 亚洲综合一区二区三区| 一区二区三区不卡视频| 亚洲1区2区3区视频| 日本特黄久久久高潮| 午夜精品一区二区三区电影天堂| 亚洲成人精品一区| 热久久久久久久| 激情亚洲综合在线| 国产91精品一区二区麻豆网站| 国产xxx精品视频大全| 91啪在线观看| 欧美丰满高潮xxxx喷水动漫| 日韩欧美在线影院| www国产亚洲精品久久麻豆| 久久久.com| 亚洲激情中文1区| 天天免费综合色| 久久超级碰视频| 国产精品自拍三区| 91黄色免费版| 日韩欧美一区二区不卡| 久久久99精品免费观看| 亚洲激情在线播放| 麻豆精品一区二区三区| 成人精品鲁一区一区二区| 欧美性欧美巨大黑白大战| 5858s免费视频成人| 久久网站最新地址| 亚洲视频一区二区在线| 奇米精品一区二区三区在线观看一| 国产精品996| 欧美影院一区二区| 久久久久久电影| 亚洲高清三级视频| 成人黄色在线看| 欧美日韩aaa| 国产精品网站导航| 日韩精品每日更新| 成人激情黄色小说| 日韩三级在线观看| 亚洲欧美视频在线观看| 看电影不卡的网站| 91蝌蚪porny九色| 精品国产凹凸成av人网站| 亚洲欧洲99久久| 久88久久88久久久| 欧美日韩国产综合草草| 中文字幕一区不卡| 国产乱色国产精品免费视频| 欧美浪妇xxxx高跟鞋交| 国产精品乱人伦| 伦理电影国产精品| 色天天综合久久久久综合片| 久久久www成人免费无遮挡大片| 亚洲成av人片在线观看无码| 成人精品免费网站| 久久蜜桃av一区精品变态类天堂 | 欧美色图天堂网| 国产精品久久久久婷婷| 久久成人久久鬼色| 欧美一区二区三区性视频| 中文字幕在线视频一区| 国产.精品.日韩.另类.中文.在线.播放| 69堂亚洲精品首页| 亚洲 欧美综合在线网络| 一本久道久久综合中文字幕| 中文字幕不卡在线播放| 国产成人综合自拍| 久久久噜噜噜久久人人看 | www.在线欧美| 国产日韩欧美一区二区三区乱码| 麻豆国产精品一区二区三区 | 欧美国产一区在线| 国产精品综合久久| 久久久久久亚洲综合| 激情综合网av| 2020国产精品自拍| 国产精品一线二线三线精华| 久久婷婷国产综合国色天香| 精品在线播放午夜| 精品欧美乱码久久久久久1区2区|