Beispiel #1
0
int meshOperation::getPosFace( tuple2i anEdge, vector<vector<int>> & neighbor_faces , mesh & m )
{
	int fc1, fc2;
	getNbrFaces(anEdge,&fc1,&fc2,neighbor_faces);
	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;
	}
}
Beispiel #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;
	}
}
Beispiel #3
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;
}
Beispiel #4
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;
}
Beispiel #5
0
void meshOperation::getOrientedEdges( mesh & m, vector<tuple3i> & target_fc_halfEdges, vector<tuple2i> & target_halfEdges )
{
	vector<tuple3i> & faces = m.getFaces();
	vector<tuple3i>::iterator it;
	vector<tuple2i>::iterator el;
	target_halfEdges.clear();
	target_fc_halfEdges.clear();

	tuple2i halfedge;
	int sign;
	for(it = faces.begin(); it!= faces.end(); it++){

		halfedge.set((it->a < it->b ? (*it).a: (*it).b),
			(it->a < it->b ? (*it).b: (*it).a));
		el = lower_bound(target_halfEdges.begin(),target_halfEdges.end(), halfedge);
		if(el==target_halfEdges.end() || el->a != halfedge.a || el->b != halfedge.b){
			target_halfEdges.insert(el,halfedge);
		}

		//halfedge.set((*it).b, (*it).c);
		halfedge.set((it->b < it->c ? (*it).b: (*it).c),
			(it->b < it->c ? (*it).c: (*it).b));
		el = lower_bound(target_halfEdges.begin(),target_halfEdges.end(), halfedge);
		if(el==target_halfEdges.end() || el->a != halfedge.a || el->b != halfedge.b){
			target_halfEdges.insert(el,halfedge);
		}

		//halfedge.set((*it).c, (*it).a);
		halfedge.set((it->a < it->c ? (*it).a: (*it).c),
			(it->a < it->c ? (*it).c: (*it).a));
		el = lower_bound(target_halfEdges.begin(),target_halfEdges.end(), halfedge);
		if(el==target_halfEdges.end() || el->a != halfedge.a || el->b != halfedge.b){
			target_halfEdges.insert(el,halfedge);
		}
	}

	sign = 1;
	tuple3i halfedge_index;
	for(it = faces.begin(); it!= faces.end(); it++){
		//halfedge.set(it->a, it->b);
//		sign = (it->a < it->b ? 1: -1);
		halfedge.set((it->a < it->b ? (*it).a: (*it).b),
			(it->a < it->b ? (*it).b: (*it).a));
		el = lower_bound(target_halfEdges.begin(),target_halfEdges.end(), halfedge);
		halfedge_index.a = sign * (el - target_halfEdges.begin());

		//halfedge.set(it->b, it->c);
//		sign = (it->b < it->c ? 1: -1);
		halfedge.set((it->b < it->c ? (*it).b: (*it).c),
			(it->b < it->c ? (*it).c: (*it).b));
		el = lower_bound(target_halfEdges.begin(),target_halfEdges.end(), halfedge);
		halfedge_index.b = sign*(el - target_halfEdges.begin());

		//halfedge.set(it->c, it->a);
//		sign = (it->c < it->a ? 1: -1);
		halfedge.set((it->a < it->c ? (*it).a: (*it).c),
			(it->a < it->c ? (*it).c: (*it).a));
		el = lower_bound(target_halfEdges.begin(),target_halfEdges.end(), halfedge);
		halfedge_index.c = sign*(el - target_halfEdges.begin());
		target_fc_halfEdges.push_back(halfedge_index);
	}


}