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


C++ Polyhedron::winged_inserter方法代码示例

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


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

示例1: build_polyhedron

/// Assemble polyhedron from mesh
Polyhedron* build_polyhedron(const Mesh& mesh, double alpha)
{
	Polyhedron *object = new Polyhedron();

	Polyhedron::VertexInserter vi = object->vertex_inserter(); 

	cout << "Creating vertices.. " << endl;

	for(vector<Point>::const_iterator i = mesh.vertices.begin(); i != mesh.vertices.end(); ++i)
		*vi++ = new Vertex(*i);

	Polyhedron::WingedInserter wi = object->winged_inserter();

	cout << "Creating wingeds.. " << endl;

	for(vector<pair<int, int> >::const_iterator i = mesh.wingeds.begin(); i != mesh.wingeds.end(); ++i){
		Vertex *tail = object->begin_vertices()[i->first];
		Vertex *head = object->begin_vertices()[i->second];
		Winged *winged = new Winged(tail, head);
		*tail->winged_inserter() = winged;
		*head->winged_inserter() = winged;
		*wi++ = winged;
	}

	Polyhedron::FaceInserter fi = object->face_inserter();

	cout << "Creating faces.. " << endl;

	for(vector<std::vector<int> >::const_iterator i = mesh.faces.begin(); i != mesh.faces.end(); ++i){
		cout << "New face" << endl;
		Face *face = new Face();
		face->coboundary() = object;
		Face::VertexInserter fvi = face->vertex_inserter();
		for(vector<int>::const_iterator j = i->begin(); j != i->end(); ++j){
			*fvi++ = object->begin_vertices()[*j];
			cout << "Vertex # " << *j << endl;
		}
		face->normal() = norm(cross(*(*(face->begin_points()+2)) - *(*(face->begin_points()+1)), 
							  *(*face->begin_points())     - *(*(face->begin_points()+1))));
		*fi++ = face;
	}

	typedef Polyhedron::FaceIterator FI;

	cout << "Connecting winged/faces.. " << endl;

	for(FI face=object->begin_faces(); face!=object->end_faces(); ++face){
		cout << "New face" << endl;
		Face::WingedInserter fwi = (*face)->winged_inserter();
		typedef Face::VertexIterator VI;

		VI previous = --(*face)->end_vertices();
		for(VI current=(*face)->begin_vertices(); current!=(*face)->end_vertices(); ++current){

			cout << "current vertex is ";
			put_vertex(*(*current));
			cout << "previous vertex is ";
			put_vertex(*(*previous));

			typedef Vertex::WingedIterator WI;

			for(WI winged=(*current)->begin_wingeds(); winged != (*current)->end_wingeds(); ++winged){
				
				if(*current == (*winged)->head_vertex() && *previous == (*winged)->tail_vertex()){
					cout << "left edge: ";
					put_winged(*(*winged)); 
					(*winged)->left_face() = *face;
					*fwi++ = *winged;
				} else if (*current == (*winged)->tail_vertex() && *previous == (*winged)->head_vertex()){
					cout << "right edge: ";
					put_winged(*(*winged)); 
					(*winged)->right_face() = *face;
					*fwi++ = *winged;
				}
			}
			previous = current;
		}
	}

	typedef Polyhedron::VertexIterator VI;

	cout << "Creating vertex cells.. " << endl;

	Feature::CellInserter ci = object->cell_inserter(); 
	for(VI vertex=object->begin_vertices(); vertex!=object->end_vertices(); ++vertex){
		typedef Vertex::WingedIterator WI;
		Feature::CellInserter vci = (*vertex)->cell_inserter();

		for(WI winged=(*vertex)->begin_wingeds(); winged!=(*vertex)->end_wingeds(); ++winged)
			if(*vertex==(*winged)->head_vertex())
				(*vertex)->normal() = (*vertex)->normal() +  (*winged)->unit_vector();
			else if(*vertex==(*winged)->tail_vertex())
				(*vertex)->normal() = (*vertex)->normal() -  (*winged)->unit_vector();
		(*vertex)->normal() = normalize3((*vertex)->normal());

		for(WI winged=(*vertex)->begin_wingeds(); winged!=(*vertex)->end_wingeds(); ++winged){
			Vector normal;

			if(*vertex==(*winged)->head_vertex()){
//.........这里部分代码省略.........
开发者ID:mikowiec,项目名称:harvest,代码行数:101,代码来源:mesh.cpp


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