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


C++ HalfEdge::getPrev方法代码示例

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


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

示例1: subdivideMesh

	void Mesh::subdivideMesh() {

		//vectors storing all new vertices and faces to update mesh later
		vector<Vertex*> allNewVerts;
		vector<Face*> allNewFaces;

		//compute centroids because they'll be corrupted after the edge vertex addition
		vector<glm::vec3> centroids;
		for (int c = 0; c < faces->size(); c++) {
			faces->at(c)->centroid = faces->at(c)->getCentroid();
			centroids.push_back(faces->at(c)->getCentroid());
		}

		//add edge vertices
		vector<HalfEdge*> hes;
		for (int i = 0; i < halfedges->size(); i++) {
			if (!containsOrSym(halfedges->at(i), hes)) {
				hes.push_back(halfedges->at(i));
			}
		}

		//move edge vertices according to Catmull-Clark
		vector<HalfEdge*> newhes;
		vector<glm::vec3> newpos;
		HalfEdge* he;
		HalfEdge* hv;
		for (int k = 0; k < hes.size(); k++) {
			hv = hes.at(k);
			glm::vec3 cent1 = hv->f->centroid;
			glm::vec3 cent2 = hv->sym->f->centroid;
			he = addVertex(hes.at(k));
			allNewVerts.push_back(he->v);
			glm::vec3 oldpos = (cent1 + cent2 + *he->next->v->xyz + *he->getPrev()->v->xyz)/4.0f;
			newpos.push_back(oldpos);
			newhes.push_back(he);
		}

		//For each face, create centroid vertex, create splitting halfedges and set next pointers for the next pass.
		Face* fa;
		Vertex* vn;
		HalfEdge* nh;
		HalfEdge* newhtocent = 0;
		HalfEdge* newhtomid = 0;
		Face* newF;
		glm::vec3 centr;
		vector<Face*> newfaces;
		for (int n = 0; n < faces->size(); n++) {
			newfaces.clear(); //clear previous face's vector
			fa = faces->at(n); 

			//initialize and position centroid vertex
			vn = new Vertex(0, 0, 0, new QString("545"));
			*vn->xyz = fa->centroid;
			allNewVerts.push_back(vn);
			//find a pointer to a newly added midpoint on this face
			for (int x = 0; x < newhes.size(); x++) {
				nh = newhes.at(x);
				if (nh->f == fa) {
					break;
				}
				if (nh->sym->f == fa) {
					nh = nh->sym->next;
					break;
				}
			}

			//Traverse the face, fixing pointers and creating split faces, all of which include the centroid
			HalfEdge* first = nh;
			while (true) {
				newF = new Face(NULL, fa->color->x, fa->color->y, fa->color->z, new QString("1010"));
				newhtomid = new HalfEdge(newF, nh->v, nh->next, NULL);
				newhtocent = new HalfEdge(newF, vn, newhtomid, NULL);
				newF->first = newhtocent;
				allNewFaces.push_back(newF);
				newfaces.push_back(newF);
				newhes.push_back(newhtomid);
				newhes.push_back(newhtocent);
				nh->next->f = newF;
				nh = nh->next->next;
				nh->f = newF;
				if (nh == first) {
					break;
				}
			}
			
			Face* fa2;
			//Now that the pointers are appropriately set, go back and fix each of the pointers that were left before
			for (int h = 0; h < newfaces.size(); h++) {
				nh = newfaces.at(h)->first;
				nh->next->next->next->next = nh;
				fa = newfaces.at(h);
				int q;
				if (h + 1 == newfaces.size()) {
					q = 0;
				} else {
					q = h + 1;
				}
				nh = fa->first;
				nh->sym = NULL;
				fa2 = newfaces.at(q);
//.........这里部分代码省略.........
开发者ID:jdesai927,项目名称:skulptor,代码行数:101,代码来源:mesh.cpp


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