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


C++ Solid::numFaces方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
	// Read in the obj file
	Solid mesh;
	OBJFileReader of;
	std::ifstream in(argv[1]);
	of.readToSolid(&mesh, in);
	
	
	
	

	//answer part
	Solid meshCopy;
	mesh.copy(meshCopy);
	
	//storing all vertices
	int i=0;
	SolidVertexIterator veriter(&mesh);
	Vertex *allvert[mesh.numVertices()];
	for(i=0;!veriter.end();i++,++veriter)
	{
		allvert[i]=*veriter;
	}
	
	//storing all edges
	SolidEdgeIterator eiter(&mesh);
	Edge *alledges[mesh.numEdges()];
	for(i=0;!eiter.end();i++,++eiter)
	{
		alledges[i]=*eiter;
	}
	
	
	Edge *swapList[mesh.numFaces()];
	Edge *splitSwap[2]={NULL,NULL};
	
	//getting max face
	SolidFaceIterator fciter(&mesh);
	int maxfcid=-1;
	for(; !fciter.end(); ++fciter)
	{
		if((*fciter)->id()>maxfcid)
			maxfcid=(*fciter)->id();
	}
	
	//splitting and swapping by iterating through edges
	SolidEdgeIterator eitercpy(&meshCopy);
	int j;
	double x,y,z;
	for(i=0,j=0;i<(sizeof(alledges)/sizeof(*alledges));i++,++eitercpy)
	{
		splitSwap[0]=splitSwap[1]=NULL;
		Vertex *evert1= mesh.edgeVertex1(alledges[i]);
		Vertex *evert2= mesh.edgeVertex2(alledges[i]);
		Vertex *ver1=mesh.edgeSplit(alledges[i],splitSwap,maxfcid);
		if(splitSwap[0]!=NULL)
			swapList[j++]=splitSwap[0];
		if(splitSwap[1]!=NULL)
			swapList[j++]=splitSwap[1];
		
		//position of new vertex determined here
		if(mesh.isBoundary(*eitercpy))
		{
			//printf("Check");
			x=(evert1->point()(0)/2)+(evert2->point()(0)/2);
			y=(evert1->point()(1)/2)+(evert2->point()(1)/2);
			z=(evert1->point()(2)/2)+(evert2->point()(2)/2);
			//printf("\n%f %f %f\n",x,y,z);
		}
		else
		{
			x=((evert1->point()(0))+(evert2->point()(0)))*(3.0/8.0);
			y=((evert1->point()(1))+(evert2->point()(1)))*(3.0/8.0);
			z=((evert1->point()(2))+(evert2->point()(2)))*(3.0/8.0);
			x+=(((((*eitercpy)->halfedge(0))->he_next())->target())->point()(0)/8.0)+(((((*eitercpy)->halfedge(1))->he_next())->target())->point()(0)/8.0);
			y+=(((((*eitercpy)->halfedge(0))->he_next())->target())->point()(1)/8.0)+(((((*eitercpy)->halfedge(1))->he_next())->target())->point()(1)/8.0);
			z+=(((((*eitercpy)->halfedge(0))->he_next())->target())->point()(2)/8.0)+(((((*eitercpy)->halfedge(1))->he_next())->target())->point()(2)/8.0);
		}
		
		ver1->point()=Point(x,y,z);
	}
	
	
	for(i=0;i<(sizeof(swapList)/sizeof(*swapList));i++)
	{
		Edge *e=swapList[i];
		mesh.edgeSwap(e,((e->halfedge(0))->he_next())->target(),((e->halfedge(1))->he_next())->target());
	}
	
	
	
	
	//new position of old vertices determined here
	SolidVertexIterator veritercpy(&meshCopy);
	double tem1,tem2,tem3,alpha;
	for(i=0;i<(sizeof(allvert)/sizeof(*allvert));i++,++veritercpy)
	{
		Vertex *oldv=allvert[i];
		//printf("\n%f %f %f -> ",oldv->point()(0),oldv->point()(1),oldv->point()(2));
//.........这里部分代码省略.........
开发者ID:snrao310,项目名称:LoopSubdivition-for-HalfEdgeMesh-Library,代码行数:101,代码来源:Subdivision.cpp


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