openNURBS reports brep valid, but Rhino3D reports invalid


I use ON_Brep::IsValid() to determine whether the brep I have created is ok. I have found that this can report a brep is ok, but that after writing it to a 3dm file and opening it in Rhino3D, Rhino3D can report the brep is invalid. Should I be using a different test in opennurbs to check the validity of my brep?

I wasn’t sure how to find any additional information in Rhino3D to diagnose why it thought it was invalid, but after some playing around I managed to stop it occurring. Specifically, I was creating a trimmed plane surface, but I wasn’t setting the ON_PlaneSurface extents or domain. When I started setting them based on the edge curve coordinates, Rhino3D stopped reporting the brep was invalid, and so my guess is Rhino3D was complaining because my brep edge curves, trim curves or vertices were outside my planesurface extents and/or domain (I didn’t play enough to work out which one was the culprit, but perhaps you can advise?).

It seems surprising that I can create an object in opennurbs that opennurbs reports is valid, but then Rhino3D claim is invalid, so I presume I am not using the correct function to check the validity of my brep object, which is why I post this question.

Many thanks,

Surprising indeed! You can get more details on why the BRep is not valid using

ON_wString err;
ON_TextLog log(err);
if (!brep->IsValid(&log))

Also, can you post a 3dm file with the geometry?

I have attached two 3dm files, and have referenced the object in question below, which is a small triangular plane at the origin (apologies as I get given 3dm files to modify, and never start from scratch, so there are a few other irrelevant objects in the file):
DefaultPlane.3dm (784.9 KB)
PseudoInfinitePlane.3dm (784.9 KB)

DefaultPlane.3dm (opennurbs valid, Rhino invalid)
ID: 26cad06c-21e9-42e8-aa7f-d2330d2152f2 (76)
Object name: (not named)
Layer name: FRONT

PseudoInfinitePlane.3dm (opennurbs valid, Rhino valid)
ID: 9ff441c2-004a-4150-9b1b-a2e365130ab8 (76)
Object name: (not named)
Layer name: FRONT

Unfortunately the sample code you posted won’t work for me, ignoring the fact that the branch won’t be followed considering opennurbs returns true for brep->IsValid(), because I am using the free version of opennurbs, which doesn’t define the RhinoApp() function.

@dale, I will also take this opportunity to attach a third 3dm file (crash.3dm), which causes Rhino3D to crash, and was a result of me making a mistake during creation of ON_PolyLineCurve in opennurbs, in case it is useful for Rhino development. To get Rhino to crash, open the 3dm file, tell Rhino to select all objects in the layer labelled “FRONT”, and then click the “Details…” button to show object details, and Rhino will crash.
crash.3dm (782.6 KB)

Hi @stephen.banks,

The invalid Brep in DefaultPlane.3dm has this issue:

ON_Brep.m_T[0] 2d curve is not inside surface domain.

I’ve logged an issue to figure out why Rhino flags this as an invalid Brep and openNURBS does not.

Also, I’ve logged an issue for crash.3dm. This should be fixed in the next Rhino7 SR.

Thanks for reporting.

– Dale

1 Like