Hi,
I’m working at a surface unroll plugin.
By SampleTriangleMesh , I can import a wavefront .obj file and get corresponding ON_Mesh object.
I wonder if I can get this ON_Mesh objects’ raw vertex index(means the line number of vertices coordinates in .obj file) by CRhinoGetObject?
Currently I try to use code below to get raw vertex indices:
CRhGetMeshComponentRef gv(mesh_object->RuntimeSerialNumber());
gv.SetCommandPrompt(L"Select mesh vertex");
gv.SetGeometryFilter(CRhinoGetObject::meshvertex_filter);
gv.GetObjects(1, 0);
if (gv.CommandResult() != CRhinoCommand::success)
return ;
for (int i = 0; i < gv.ObjectCount(); i++) {
const ON_MeshComponentRef* mesh_vertex_ref = gv.Object(i).MeshComponentRef();
if (nullptr == mesh_vertex_ref) {
RhinoApp().Print(L"Selected vertex INVALID!");
return;
}
ON_3dPoint position;
const ON_MeshTopologyVertex* tempTopVertex;
unsigned int tIndex = mesh_vertex_ref->GetMeshTopologyVertexAndPoint(tempTopVertex, position);
int index = tempTopVertex->m_vi[0];
RhinoApp().Print(L"Selected mesh vertex[%d] index = %d, tIndex = %d, location:[ %d, %d, %d ]\n", i, index, tIndex, position.x, position.y, position.z);
ON_wString wstr;
wstr.Format(L"%d", i);
ON_TextDot dot(position, wstr, 0);
CRhinoTextDot* obj = new CRhinoTextDot();
obj->SetDot(dot);
RhinoApp().ActiveDoc()->AddObject(obj);
}
I tried to pick the cathead.obj (7.1 KB) boundary loop in clockwise.
Compared to some 3rdparty geometry processing library, OpenNurbs return different boundary Indices:
Selected mesh vertex[0] index = 419, tIndex = 85, location:[ -1152563064, -1445582913, -1318589320 ]
Selected mesh vertex[1] index = 442, tIndex = 89, location:[ 471415610, 1473620459, -2113261349 ]
Selected mesh vertex[2] index = 624, tIndex = 119, location:[ 1019247279, 142111878, 1137444779 ]
Selected mesh vertex[3] index = 631, tIndex = 120, location:[ 1726233256, 1475819482, 936783907 ]
Selected mesh vertex[4] index = 688, tIndex = 127, location:[ -1841132221, -1320788343, -1441184866 ]
Selected mesh vertex[5] index = 701, tIndex = 129, location:[ -1335906628, -189940634, 595385546 ]
Selected mesh vertex[6] index = 662, tIndex = 125, location:[ 0, -1477578701, -1985443122 ]
Selected mesh vertex[7] index = 622, tIndex = 118, location:[ 1497534837, 803468122, -360090058 ]
Selected mesh vertex[8] index = 603, tIndex = 113, location:[ -613527488, -1948609482, 1642670372 ]
Selected mesh vertex[9] index = 503, tIndex = 99, location:[ -2001770870, -1441184866, 2059110401 ]
Selected mesh vertex[10] index = 500, tIndex = 97, location:[ -1695996686, 8796093, -1985443122 ]
Selected mesh vertex[11] index = 434, tIndex = 88, location:[ 1436786820, -1477578701, -274328151 ]
| ON_TextDot number | OpenNurbs | libigl | other… |
|---|---|---|---|
| 0 | 85 | 85 | 85 |
| 1 | 89 | 89 | 89 |
| 2 | 119 | 119 | 119 |
| 3 | 120 | 120 | 120 |
| 4 | 127 | 127 | 127 |
| 5 | 129 | 129 | 129 |
| 6 | 125 | 125 | 125 |
| 7 | 118 | 118 | 118 |
| 8 | 113 | 113 | 113 |
| 9 | 99 | 98 | 98 |
| 10 | 97 | 97 | 97 |
| 11 | 88 | 88 | 88 |
