Exemplo n.º 1
0
char MembraneDeformer::buildTopology()
{
	const unsigned nv = m_mesh->getNumVertices();
	
	m_topology = new VertexAdjacency[nv];
	
	for(unsigned i = 0; i < nv; i++) {
		VertexAdjacency & v = m_topology[i];
		v.setIndex(i);
		v.m_v = &(m_mesh->getVertices()[i]);
	}
	
	const unsigned nf = m_mesh->getNumFaces();
	unsigned a, b, c;
	
	for(unsigned i = 0; i < nf; i++) {
		a = m_mesh->getIndices()[i * 3];
		b = m_mesh->getIndices()[i * 3 + 1];
		c = m_mesh->getIndices()[i * 3 + 2];
		Facet * f = new Facet(&m_topology[a], &m_topology[b], &m_topology[c]);
		f->setIndex(i);
		for(unsigned j = 0; j < 3; j++) {
			Edge * e = f->edge(j);
			m_topology[e->v0()->getIndex()].addEdge(e);
			m_topology[e->v1()->getIndex()].addEdge(e);
		}
	}
	
	for(unsigned i = 0; i < nv; i++) {
		m_topology[i].findNeighbors();
		m_topology[i].computeWeights();
		m_topology[i].computeDifferentialCoordinate();
	}
	return 1;
}
Exemplo n.º 2
0
char MeshLaplacian::buildTopology()
{
	const unsigned nv = getNumVertices();
	
	m_adjacency = new VertexAdjacency[nv];
	
	for(unsigned i = 0; i < nv; i++) {
		VertexAdjacency & v = m_adjacency[i];
		v.setIndex(i);
		v.m_v = &_vertices[i];
	}
	
	const unsigned nf = getNumFaces();
	unsigned a, b, c;
	
	for(unsigned i = 0; i < nf; i++) {
		a = _indices[i * 3];
		b = _indices[i * 3 + 1];
		c = _indices[i * 3 + 2];
		Facet * f = new Facet(&m_adjacency[a], &m_adjacency[b], &m_adjacency[c]);
		f->setIndex(i);
		for(unsigned j = 0; j < 3; j++) {
			Edge * e = f->edge(j);
			m_adjacency[e->v0()->getIndex()].addEdge(e);
			m_adjacency[e->v1()->getIndex()].addEdge(e);
		}
		m_faces.push_back(f);
	}
	
	for(unsigned i = 0; i < nv; i++) {
		m_adjacency[i].findNeighbors();
		m_adjacency[i].computeWeights();
		m_adjacency[i].computeDifferentialCoordinate();
		//m_adjacency[i].verbose();
	}
	return 1;
}