ON_Brep::GetMesh() returns wrong meshes

Hello, I would like to extract the rendering datas from a rhino file using openNurbs. This is my code.

ON_SimpleArray<const ON_Mesh*> meshs;
aBrep->GetMesh(ON::MeshType(4), meshs);

This is the original model.

This is the meshes I got.


I wonder how can I get the correct meshes? Thank you.

Can you post the 3dm file where this is a problem? And is the object by any chance located very far from the orign? This may be a known limitation of meshes in single precision

https://www.wiki.mcneel.com/rhino/farfromorigin

Hi @sw11,

Here is a guide you might find helpful.

If not, then please post the 3dm file - thanks.

– Dale

Yes, the position is about 3.6millions of units from origin. I have posted the file below.

walkway.3dm (6.6 MB)
This is the original file.

Hi @dale @menno ,
Since I have too much .3dm files with survey datas, is there any other way to solve this kind of accuracy problem without modifying the original model?

You can try to tesselate your BREP surfaces:

for (int faceIndex = 0; faceIndex < aBrep->m_F.Count(); ++faceIndex)
{
    const int surfaceIndex = onface.SurfaceIndexOf();

    if (surfaceIndex >= 0 && surfaceIndex < aBrep->m_S.Count())
    {
        ON_Surface* surface = aBrep->m_S[surfaceIndex];
        if (surface)
        {
            ON_BrepLoop* outerLoop = onface.OuterLoop();

            for (int loopIndex = 0; loopIndex < onface.LoopCount(); ++loopIndex)
            {
                    ON_BrepLoop* loop = onface.Loop(loopIndex);
                    if (loop != outerLoop)
                    {
                    }
                }
            }
        }
    }	
}

@sw,

Your file looks correct when opened in Rhino with a shaded viewport, which uses the cached render mesh.

What problem are we trying to help you solve?

– Dale