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


C++ MyMesh::vv_iter方法代码示例

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


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

示例1: deleteVertex

void deleteVertex( MyMesh::VertexHandle h ){
	vector<MyMesh::VertexHandle> vs;
	for( MyMesh::VVIter v = mesh.vv_iter( h ) ; v  ; ++v ){
		vs.push_back( v );
	}	

	mesh.request_vertex_status();
	mesh.request_face_status();
	mesh.request_edge_status();
	cout << "v count: " <<  vs.size() << endl;
	mesh.delete_vertex( h , false );
	mesh.garbage_collection();

	vector<MyMesh::VertexHandle> vhandles;
	
	for( size_t i = 1 ; i < vs.size() - 1 ; i++ ){
		vhandles.clear();
		if( !mesh.status( vs[0]).deleted() && !mesh.status( vs[i]).deleted() && !mesh.status( vs[i+1]).deleted() ){
			vhandles.push_back( vs[0] );
			vhandles.push_back( vs[i] );
			vhandles.push_back( vs[i+1] );
			mesh.add_face( vhandles );
		}
	}
	mesh.release_vertex_status();
	mesh.release_face_status();
	mesh.release_edge_status();
}
开发者ID:MarkRunWu,项目名称:Digital-Processing,代码行数:28,代码来源:use_openMesh.cpp

示例2: SolveLinearSystem

void SolveLinearSystem(MyMesh* mesh,std::vector<int> controlPoint_indexes){
	if(mesh==NULL)
	{
		return ;
	}
	//Ax=B
	LinearSystemLib::GeneralSparseMatrix GA;//Ax=B 的 A
	double** B_X = new double*[1];//Ax=B 的 B 針對x座標解
	double** B_Y = new double*[1];//Ax=B 的 B 針對y座標解
	double** B_Z = new double*[1];//Ax=B 的 B 針對z座標解
	double** solution_X = 0;//Ax=B x的解 針對x座標解
	double** solution_Y = 0;//Ax=B x的解 針對y座標解
	double** solution_Z = 0;//Ax=B x的解 針對z座標解
	//
	int n_vertices = mesh->n_vertices();//Mesh's total vertex
	int n_control_point = controlPoint_indexes.size();//total control point
	//Set matrix size
	GA.Create(n_vertices+n_control_point, n_vertices);
	B_X[0] = new double[n_vertices+n_control_point];
	B_Y[0] = new double[n_vertices+n_control_point];
	B_Z[0] = new double[n_vertices+n_control_point];
	//填上半部矩陣 點對點
	for(MyMesh::VIter v_it = mesh->vertices_begin(); v_it!=mesh->vertices_end(); ++v_it)
	{
		MyMesh::VHandle vh = v_it.handle();
		int row,col;//要放入的r,c
		int vv_total = 0;//點對點的總量
		double element;//要放入矩陣的元素

		row = v_it.handle().idx();//Set row index
		GA.SetElement(row,row,1);//if row == column , set 1 to (row,column)

		//先獲得點對點總量
		for(MyMesh::VVIter vv_it = mesh->vv_iter(v_it.handle());vv_it;++vv_it)
		{
			vv_total++;
		}
		//要放入矩陣的元素 為 -1/vv_total
		element = double(-1) / double(vv_total);
		//放入矩陣的元素
		for(MyMesh::VVIter vv_it = mesh->vv_iter(v_it.handle());vv_it;++vv_it)
		{
			col = vv_it.handle().idx();//Set column index
			GA.SetElement(row,col,element);//Set element
			//printf("row : %d , col : %d , element : %f\n",row,col,element);
		}

		//Set B's element 上半部為0
		B_X[0][row] = 0.0;
		B_Y[0][row] = 0.0;
		B_Z[0][row] = 0.0;
	}
	//Control point
	for(int i=0;i<controlPoint_indexes.size();i++)
	{
		//填下半部矩陣 control point
		GA.SetElement(n_vertices+i,controlPoint_indexes[i],1);
		//Set control point to B's 下半部
		MyMesh::VHandle vh = mesh->vertex_handle(controlPoint_indexes[i]);
		B_X[0][ n_vertices+i ] = mesh->point(vh)[0];
		B_Y[0][ n_vertices+i ] = mesh->point(vh)[1];
		B_Z[0][ n_vertices+i ] = mesh->point(vh)[2];
	}
	//Solve linear system
	LinearSystemLib::SparseLinearSystem sls_X(new LinearSystemLib::StableSparseMatrix(GA), B_X, 1);
	LinearSystemLib::SparseLinearSystem sls_Y(new LinearSystemLib::StableSparseMatrix(GA), B_Y, 1);
	LinearSystemLib::SparseLinearSystem sls_Z(new LinearSystemLib::StableSparseMatrix(GA), B_Z, 1);
	try
	{
		bool result;
		result = LinearSystemLib::LeastSquareSparseLSSolver::GetInstance()->Solve( &sls_X, solution_X );
		result = LinearSystemLib::LeastSquareSparseLSSolver::GetInstance()->Solve( &sls_Y, solution_Y );
		result = LinearSystemLib::LeastSquareSparseLSSolver::GetInstance()->Solve( &sls_Z, solution_Z );
	} 
	catch( std::exception e )
	{
		printf("Error : %s",e.what());
		//cerr << e.what() << endl;
		return ;
	}
	//Set point to mesh
	for(int i=0;i<n_vertices;i++)
	{
		MyMesh::VHandle vh = mesh->vertex_handle(i);
		mesh->point(vh)[0] =  solution_X[0][i];
		mesh->point(vh)[1] =  solution_Y[0][i];
		mesh->point(vh)[2] =  solution_Z[0][i];
	}

	printf("Solve success");
}
开发者ID:MarkRunWu,项目名称:Digital-Processing,代码行数:91,代码来源:use_openMesh.cpp


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