当前位置: 首页>>代码示例>>C++>>正文


C++ FaceSet::RemoveFaceV方法代码示例

本文整理汇总了C++中FaceSet::RemoveFaceV方法的典型用法代码示例。如果您正苦于以下问题:C++ FaceSet::RemoveFaceV方法的具体用法?C++ FaceSet::RemoveFaceV怎么用?C++ FaceSet::RemoveFaceV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FaceSet的用法示例。


在下文中一共展示了FaceSet::RemoveFaceV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateDelaunayOnSphere

void PointSet::CreateDelaunayOnSphere(PointSet* ps, FaceSet* fs, double* progress, std::stringstream* myMsg)
{
	double dummy = 0;
	if ( progress==NULL ) progress = &dummy;

	int p_num =  ps->GetCount();

	PointSet tmpPS;

	tmpPS.count = p_num;
	tmpPS.capacity = p_num*2+4;
	tmpPS.points = new Point4D [tmpPS.capacity];

	const double OVERWRAP = 0.1;
	int* OverwrapID = new int [p_num*2];
	memset( OverwrapID, -1, sizeof(int)*2*p_num );

	double center[3];
	// Estimate Center
	{
		double pntRange[] = {
			DBL_MAX,	 DBL_MAX,	 DBL_MAX,
			-DBL_MAX,	-DBL_MAX,	-DBL_MAX,
		};
		for ( int i=0 ; i < p_num; i++ ) {
			Point4D pnt = ps->GetPoint4DAt(i);
			for ( int j=0; j < 3; j++ ) {
				pntRange[j+0] = ( pntRange[j+0]>pnt.GetPoint(j) ? pnt.GetPoint(j) : pntRange[j+0]);
				pntRange[j+3] = ( pntRange[j+3]<pnt.GetPoint(j) ? pnt.GetPoint(j) : pntRange[j+3]);
			}
		}
		for ( int j=0; j < 3; j++ ) {
			center[j] = ( pntRange[j+3]+pntRange[j+0] )/2;
		}
	}

	// Project onto Sphere
	{
		Point4D Center( center[0], center[1], center[2] );
		for ( int i=0; i < p_num; i++ ) {
			double CntPnt[3];
			(ps->GetPoint4DAt(i)-Center).GetPoint(CntPnt);

			double lng = atan(CntPnt[1]/CntPnt[2])+( CntPnt[2]>0 ? 0 : M_PI ) +M_PI/2;
			double lat = atan( CntPnt[0]/sqrt(CntPnt[1]*CntPnt[1]+CntPnt[2]*CntPnt[2]) ) +M_PI/2;
		
			OverwrapID[i] = i;
			tmpPS.points[i].SetPoint( lng, lat, lng*lng+lat*lat);
			if ( lng < OVERWRAP ) {
				OverwrapID[tmpPS.count] = i;
				tmpPS.points[tmpPS.count++].SetPoint( lng+2*M_PI, lat, (lng+2*M_PI)*(lng+2*M_PI)+lat*lat );
			}
		}
	}

	// 外接4角形の作成
	tmpPS.count += 4;
	tmpPS.points[tmpPS.count-4].SetPoint(  6*M_PI,	 2*M_PI, M_PI*M_PI*40 );
	tmpPS.points[tmpPS.count-3].SetPoint(  6*M_PI,	-1*M_PI, M_PI*M_PI*37 );
	tmpPS.points[tmpPS.count-2].SetPoint( -2*M_PI,	-1*M_PI, M_PI*M_PI*5 );
	tmpPS.points[tmpPS.count-1].SetPoint( -2*M_PI,	 2*M_PI, M_PI*M_PI*8 );

	FaceSet myFS;
	myFS.AddNewFace( tmpPS.count-2, tmpPS.count-3, tmpPS.count-4 );
	myFS.AddNewFace( tmpPS.count-4, tmpPS.count-1, tmpPS.count-2 );
	if ( !myFS.CheckDelaunay( &tmpPS ) ) {
		// AfxMessageBox("Invalid initial Delaunay.", MB_ICONERROR);
		// return;
		throw "Invalid initial Delaunay.";
	}
	myFS.MakeDelaunay( &tmpPS, progress, myMsg );

	for ( int i=1; i <= 4; i++ ) {
		myFS.RemoveFaceV(tmpPS.count-i);
	}

	// IDの整理
	{
		int f_num = myFS.GetFaceCount(), *f_list=NULL ;
		myFS.GetFaceIDList( &f_list, true );
		for ( int i=0; i < f_num; i++ ) {
			myFS.RemoveFace(i);
			ASSERT(OverwrapID[f_list[i*3+0]]!=-1);
			ASSERT(OverwrapID[f_list[i*3+1]]!=-1);
			ASSERT(OverwrapID[f_list[i*3+2]]!=-1);
			myFS.AddNewFace( OverwrapID[f_list[i*3+0]], OverwrapID[f_list[i*3+1]], OverwrapID[f_list[i*3+2]] );
		}
		delete [] f_list;
	}
	myFS.Unduplication();

	delete [] OverwrapID;

	*fs = myFS;
}
开发者ID:denizevrenci,项目名称:Masters_project,代码行数:95,代码来源:PointSet.cpp

示例2: CreateDelaunay

void PointSet::CreateDelaunay(PointSet* ps, double* projMat, FaceSet* fs, double* progress, std::stringstream* myMsg)
{
	double dummy = 0;
	if ( progress==NULL ) progress = &dummy;
	double max[]={ -DBL_MAX, -DBL_MAX, }, min[]={ DBL_MAX, DBL_MAX, }, cent[2], radius; 

	PointSet tmpPS;

	tmpPS.count = ps->GetCount()+4;
	tmpPS.points = new Point4D [tmpPS.count];

	CvMat M_Prj, M_Src, M_Trg;
	cvInitMatHeader( &M_Prj, 4, 4, CV_64FC1, projMat );
	for ( int i=0; i < tmpPS.count-4; i++ ) {
		double p[2][4];
		ps->GetPoint4DAt(i).GetPoint(p[0]);
		p[0][3] = 1;
		cvInitMatHeader( &M_Src, 4, 1, CV_64FC1, p[0] );
		cvInitMatHeader( &M_Trg, 4, 1, CV_64FC1, p[1] );
		cvMatMul( &M_Prj, &M_Src, &M_Trg );
		p[1][2] = (p[1][0]*p[1][0]+p[1][1]*p[1][1]);
		p[1][3] = 1;

		if ( p[1][0] < min[0] ) min[0]=p[1][0];
		if ( p[1][0] > max[0] ) max[0]=p[1][0];
		if ( p[1][1] < min[1] ) min[1]=p[1][1];
		if ( p[1][1] > max[1] ) max[1]=p[1][1];

		tmpPS.points[i].SetPoint(p[1]);
	}
	min[0] -= 1;
	min[1] -= 1;
	max[0] += 1;
	max[1] += 1;
	cent[0] = ( max[0]+min[0] )/2;
	cent[1] = ( max[1]+min[1] )/2;
	radius = sqrt( (max[0]-min[0])*(max[0]-min[0]) + (max[1]-min[1])*(max[1]-min[1]) );

	// 外接4角形の作成
	for ( int i=1; i <= 4; i++ ) {
		double coord[2] = {
			cent[0]+radius*cos(M_PI/2*i)*1.01,
			cent[1]+radius*sin(M_PI/2*i),
		};
		tmpPS.points[tmpPS.count-i].SetPoint( coord[0], coord[1], coord[0]*coord[0]+coord[1]*coord[1] );
	}

	FaceSet myFS;
	myFS.AddNewFace( tmpPS.count-2, tmpPS.count-3, tmpPS.count-4 );
	myFS.AddNewFace( tmpPS.count-4, tmpPS.count-1, tmpPS.count-2 );
	if ( !myFS.CheckDelaunay( &tmpPS ) ) {
		//AfxMessageBox("Invalid initial Delaunay.", MB_ICONERROR);
		//return;
		throw "Invalid initial Delaunay.";
	}
	myFS.MakeDelaunay( &tmpPS, progress, myMsg );
	for ( int i=1; i <= 4; i++ ) {
		myFS.RemoveFaceV(tmpPS.count-i);
	}
	*fs = myFS;
}
开发者ID:denizevrenci,项目名称:Masters_project,代码行数:61,代码来源:PointSet.cpp


注:本文中的FaceSet::RemoveFaceV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。