Example #1
0
File: CMesh.cpp Project: MADAI/RHIC
void CMesh::addInitialFlow() {
	flipEdge();
	list<CCell*>::iterator it, end;
	for ( it=activeCells.begin(), end=activeCells.end(); it != end; ++it){
#ifdef HYDRO_BOOST_THREADS
		(*it)->setHelper(helperVector[0]);
#endif
		(*it)->addInitialFlow();
	}
	flipEdge();		
}
Example #2
0
bool PolygonSplitter::detectUnclosed()
{
	vector<int> end_verts;
	vector<int> start_verts;

	// Go through all vertices
	for (unsigned a = 0; a < vertices.size(); a++)
	{
		// If the vertex has no outgoing edges, we have an unclosed polygon
		if (vertices[a].edges_out.empty())
			end_verts.push_back(a);
		// Same if it has no incoming
		else if (vertices[a].edges_in.empty())
			start_verts.push_back(a);
	}

	// If there are no end/start vertices, the polygon is closed
	if (end_verts.empty() && start_verts.empty())
		return false;
	else if (verbose)
	{
		// Print invalid vertices info if verbose
		string info = "Vertices with no outgoing edges: ";
		for (unsigned a = 0; a < end_verts.size(); a++)
		{
			info += S_FMT("%1.2f", vertices[end_verts[a]].x);
			info += ",";
			info += S_FMT("%1.2f", vertices[end_verts[a]].y);
			info += " ";
		}
		wxLogMessage(info);
		info = "Vertices with no incoming edges: ";
		for (unsigned a = 0; a < start_verts.size(); a++)
		{
			info += S_FMT("%1.2f", vertices[start_verts[a]].x);
			info += ",";
			info += S_FMT("%1.2f", vertices[start_verts[a]].y);
			info += " ";
		}
		wxLogMessage(info);
	}

	// Check if any of this is caused by flipped edges
	for (unsigned a = 0; a < end_verts.size(); a++)
	{
		vertex_t& ev = vertices[end_verts[a]];

		// Check all the edges coming out of this vertex,
		// and see if any go into another 'unattacted' vertex
		for (unsigned e = 0; e < ev.edges_in.size(); e++)
		{
			edge_t& edge = edges[ev.edges_in[e]];

			bool flipped = false;
			for (unsigned b = 0; b < start_verts.size(); b++)
			{
				vertex_t& sv = vertices[start_verts[b]];

				if (edge.v1 == start_verts[b] && edge.v2 == end_verts[a])
					flipEdge(ev.edges_in[e]);	// Flip the edge
			}
		}
	}

	// Re-check vertices
	end_verts.clear();
	start_verts.clear();
	for (unsigned a = 0; a < vertices.size(); a++)
	{
		if (!vertices[a].ok)
			continue;

		// If the vertex has no outgoing edges, we have an unclosed polygon
		if (vertices[a].edges_out.empty())
			end_verts.push_back(a);
		else if (vertices[a].edges_in.empty())
			start_verts.push_back(a);
	}

	// If there are no end/start vertices, the polygon is closed
	if (end_verts.empty() && start_verts.empty())
		return false;

	// If it still isn't closed, check for completely detached edges and 'remove' them
	for (unsigned a = 0; a < edges.size(); a++)
	{
		if (vertices[edges[a].v1].edges_in.empty() &&
		        vertices[edges[a].v2].edges_out.empty())
		{
			// Invalidate edge
			edges[a].ok = false;

			// Invalidate vertices
			vertices[edges[a].v1].ok = false;
			vertices[edges[a].v2].ok = false;
		}
	}

	// Re-check vertices
	end_verts.clear();
	start_verts.clear();
	for (unsigned a = 0; a < vertices.size(); a++)
	{
		if (!vertices[a].ok)
			continue;

		// If the vertex has no outgoing edges, we have an unclosed polygon
		if (vertices[a].edges_out.empty())
			end_verts.push_back(a);
		else if (vertices[a].edges_in.empty())
			start_verts.push_back(a);
	}

	// If there are no end/start vertices, the polygon is closed
	if (end_verts.empty() && start_verts.empty())
		return false;

	// Not closed
	return true;
}
Example #3
0
File: CMesh.cpp Project: MADAI/RHIC
void CMesh::initNS() {	
	list<CCell*>::iterator it, end;
	for ( it=activeCells.begin(), end=activeCells.end(); it != end; ++it)
		(*it)->initNS();
	flipEdge();	
}