IsValid: Brep vs. components

When a brep’s IsValid is False, shouldn’t the relevant components’ IsValid also be False?

Running the following code on the breps in IsValid.3dm (32.0 KB)
shows where this is not the case.

import rhinoscriptsyntax as rs

def checkBrepComponents(collection):
    print '-'*80
    print collection.ToString()
    print 'Component count:', collection.Count
    print "Indices of invalid components:",
    for i in range(collection.Count):
        if not collection[i].IsValid: print i,
    print

def main():
    idBreps = rs.GetObjects("Select surfaces/polysurfaces", preselect=True,
            filter=rs.filter.polysurface)
    if idBreps is None: return
    
    for i, idBrep in enumerate(idBreps):
        print '-'*80 + '\n' + '-'*80 + '\n' + "Brep:", i
        rgBrep = rs.coercebrep(idBrep)
        
        b, log = rgBrep.IsValidWithLog() # rgBrep.IsValid
        if not b:
            print log
            map(checkBrepComponents, (rgBrep.Faces, rgBrep.Edges,
                    rgBrep.Vertices, rgBrep.Loops, rgBrep.Trims,
                    rgBrep.Surfaces, rgBrep.Curves2D, rgBrep.Curves3D))

if __name__ == "__main__": main()

Thank you,
Steve

Hi Steve,

No. While it is possible for a component to be valid on its own, it can be invalid when all other components are taken into account, as you are seeing with the three Breps in your sample model.

For example:

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

The data structure of this trim curve is (probably) valid. But when compared to the underlying surface, its domain is invalid.

Hope this helps.

– Dale

Dale,

Using RhinoCommon, two ways I can think to identify the bad faces of an actual polysurface are:

  1. Create a brep of each face using DuplicateFace().
  2. Search the log of IsValidWithLog().

Do you have any other suggestions?