コード例 #1
0
int getFaceOrder(Edge *e, vector<Vertex>& pts) {
	int count = 1;
	Edge *iter = e->Lnext();

	if (iter->Left() == NULL) {
		return -1;
	}
	if (iter == NULL) {
		cout << "Erro: ponteiro next == NULL\n";
		return -1;
	}

	pts.clear();
	pts.push_back(*e->Orig());

	while (iter != e && count < 100) {
		count++;
		pts.push_back(*iter->Orig());
		iter = iter->Lnext();
	}

	if (count == 100) {
		cout << "Erro: loop infinito\n";
		return -1;
	}

	return count;
}
コード例 #2
0
Point getFaceCentroid(Face *f) {
	int count = 1;
	Point p(-1,-1);

	if (f == NULL)
		return p;

	Edge *e = f->getEdge();
	Edge *iter = e->Lnext();

	p = e->Orig()->p;

	while (iter != e) {
		Point np = iter->Orig()->p;
		p += np;
		count++;
		iter = iter->Lnext();
	}

	p.x /= count;
	p.y /= count;

	return p;
}