# DupBorder for Mesh C++

Hi,

I know how to do DupBorder of a Brep (it is nicely demonstrated in the Knowledge Base), but I need to do that for a mesh…and I`m not sure what is the easiest way to do it…any suggestions?

Thanks!
Milos

To find naked edges on a mesh (which I guess is what you want), take a look at `GetMeshEdgeList` in opennurbs_mesh.h, esp. the remark on line ~1770

``````      * If edge_type_partition[3] <= ei < edge_type_partition[4],
then edge_list[ei] is a boundary edge of exactly one mesh face.
These are also called "naked edges".
``````

Hi,

thanks. So i basically call the GetMeshEdgeList function and examine the “edge_list” to see if its value is between edge_type_partition[3] and edge_type_partition[4]. Two things confuse me:

1. “edge_list_partition” and “edge_type_partition” are both used in the description for what seems to be one array…are they the same thing?

2. edge_list is a structure of two ints as i see (int i , int j)…I I am guessing those are the indices for the m_V at the start and the end of the edge…but do I compare them both to the edge_type_partition? Only if they are both between [3] and [4] means that the edge is naked?

3. When I get all the edge_list array members that are naked, will they be ordered? If i go through them and connect successively the m_V vertices with the edgelist[x].i and edgelist[x].j indices, will i automatically get the border curve?

I am working on an interesting new plug-in that will be free and I need to solve this…
Thanks a lot!

Here is a C# version (using RhinoCommon). Perhaps you can translate this to C++:

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsDupMeshBorder.cs

Hi,

thanks…the translation was pretty simple:

for(i=0; i< mesh.Topology().m_tope.Count(); i++)
{
if( mesh.Topology().m_tope[i].m_topf_count != 0 && mesh.Topology().m_tope[i].m_topf_count == 1)
{
ON_Line edgeline( mesh.m_V[ mesh.Topology().m_tope[i].m_topvi[0] ], mesh.m_V[ mesh.Topology().m_tope[i].m_topvi[1] ] );

``````  mydoc->AddCurveObject( edgeline );
}
``````

}

…but…it worked fine for a simple mesh…once i tried a trimmed mesh it went wild (jpg attached)

What am I doing wrong?

``````ON_SimpleArray<ON_2dex> edgelist;
int edge_type_partition[5];

mesh.GetMeshEdgeList( edgelist, edge_type_partition );

for(i=0; i<edgelist.Count(); i++)
{
if( edge_type_partition[3] <= i < edge_type_partition[4] )
{
ON_Line edgeline( mesh.m_V[ edgelist[i].i ], mesh.m_V[ edgelist[i].j ] );