Exemple #1
0
bool meshOperation::consistentlyOriented( mesh & m )
{
	std::vector<tuple3i> & faces  = m.getFaces();
	std::vector<std::vector<int>> & v2f = m.getNeighborFaces();
	tuple3i fc_a,fc_b;

	int nrVerts = v2f.size();

	bool consistent = true;
	for(int i = 0; i < nrVerts; i++){
		std::vector<int> & fcs = v2f[i];
		for(int j = 0; j < fcs.size() - 1; j++){
			fc_a = faces[fcs[j]];
			fc_b = faces[fcs[j+1]];
			if((fc_a.a == fc_b.b && fc_a.b == fc_b.a)||
				(fc_a.a == fc_b.c && fc_a.b == fc_b.b)||
				(fc_a.a == fc_b.a && fc_a.b == fc_b.c)||
				(fc_a.b == fc_b.b && fc_a.c == fc_b.a)||
				(fc_a.b == fc_b.c && fc_a.c == fc_b.b)||
				(fc_a.b == fc_b.a && fc_a.c == fc_b.c)||
				(fc_a.c == fc_b.b && fc_a.a == fc_b.a)||
				(fc_a.c == fc_b.c && fc_a.a == fc_b.b)||
				(fc_a.c == fc_b.a && fc_a.a == fc_b.c)){
					continue;
			}
			consistent = false;
			break;

		}
		if(!consistent){
			break;
		}
	}
	return consistent;
}
Exemple #2
0
int meshOperation::getNegFace( tuple2i anEdge, mesh & m )
{
	int fc1, fc2;
	getNbrFaces(anEdge,&fc1,&fc2,m.getNeighborFaces());
	int orientation = m.getFaces()[fc1].orientation(anEdge);
	if(orientation == -1){
		return fc1;
	}
	else{
		assert(orientation == 1);
		assert(fc2 == -1 || m.getFaces()[fc2].orientation(anEdge)==-1);
		return fc2;
	}
}
Exemple #3
0
int meshOperation::getNext( int center_idx, int v, mesh  & m )
{
	vector<tuple3i> & faces = m.getFaces(); 
	vector<int> & neighbor_faces = m.getNeighborFaces()[center_idx];
	tuple3i  face;

	for(vector<int>::iterator it = neighbor_faces.begin(); it != neighbor_faces.end(); it++){
		face = faces[*it];
		if(face.a == v && face.c == center_idx){
			return face.b;
		}
		if(face.b == v && face.a == center_idx){
			return face.c;
		}
		if(face.c == v && face.b == center_idx){
			return face.a;
		}
	}

	return -1;
}
Exemple #4
0
float meshOperation::sumAnglesWheel( int from, int center, int to, mesh & m )
{
	vector<int> & nbrs = m.getNeighbors()[center];
	vector<int> & nbr_fcs = m.getNeighborFaces()[center];


	int actual = from, next, lps = 0;
	float angle = 0;

	do{
		next = meshOperation::getPrevious(center,actual, m);
		if(next < 0 || lps > int(nbrs.size())){
			throw std::runtime_error("Assertion failed at sum Angle Wheel");
		}
		angle += tuple3f::angle( m.vertices[actual], m.vertices[center], m.vertices[next]);
		actual = next;
		lps++;
	}
	while (actual != to);

	return angle;
}