Hi,
I am using ON_MeshTopology
to access ON_Mesh
data, but still not familiar with it. I want to find a ON_MeshTopologyVertices
adjacencies as picture below, can anyone told me how to do it?
For a mesh topological vertex (ON_MeshTopologyVertex), you can get a list of edges that start or end by looking at its m_topei array that has length m_topei_count. These numbers are indices in the topology’s m_tope array, giving a list of topological edges. Each edge has two topological vertices, in its m_topv array. One will be the index of the vertex you started at, the other the index of the vertex in the 1-ring.
If you want to have it sorted, call SortVertexEdges first.
Thank you for your reply,
Is that means that I still need to determine which one is the adjacenct vertex after I obtaining ON_MeshTopologyEdge.m_topvi[2]
from an ON_MeshTopologyVertex
,?
Here is my code implementation
const ON_MeshTopologyVertex& mesh_top_vertex = mesh_top.m_topv[index];
// traverse all TopologyEdge
for (int i = 0; i < mesh_top_vertex.m_tope_count; ++i) {
const ON_MeshTopologyEdge& mesh_top_edge = mesh_top.m_tope[i];
// determine which one is adjacent vertex
int adjVertexIndex;
if (mesh_top_edge.m_topvi[0] == index) {
adjVertexIndex = mesh_top_edge.m_topvi[1];
}
else {
adjVertexIndex = mesh_top_edge.m_topvi[0];
}
// do sth to adjVertexIndex
}
Found that the previously submitted code had many errors…
the modified version are as follows:
// Get TopologyVertex
const ON_MeshTopologyVertex& mesh_top_vertex = mesh_top.m_topv[index];
for (int i = 0; i < mesh_top_vertex.m_tope_count; ++i) {
// traverse all TopologyEdge
int topeIndex = mesh_top_vertex.m_topei[i];
const ON_MeshTopologyEdge& mesh_top_edge = mesh_top.m_tope[topeIndex];
// determine which one is adjacent vertex
int adjVertexIndex;
if (mesh_top_edge.m_topvi[0] == index) {
adjVertexIndex = mesh_top_edge.m_topvi[1];
}
else {
adjVertexIndex = mesh_top_edge.m_topvi[0];
}
looks good to me