Negative volume issue

Hi,

I’ve got an issue with Brep.GetVolume() reporting a negative volume that I’m unable to fix

volume_issue.3dm (183.3 KB)

The brep in the file is not solid, calling Brep.CapPlanarHoles() will make it solid yet when trying to get te volume it is a negative value

However If I add the brep to the document first and grab the brep from the document, the volume on that brep is positive. So somewhere in that proces the negative volume issue is fixed.

I’m looking for a way to fix that negative volume without the adding to document loop.

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

id = rs.GetObject('select brep', preselect=True)
brep = rs.coercebrep(id)

capped_brep = brep.CapPlanarHoles(sc.doc.ModelAbsoluteTolerance)

capped_brep.Standardize()
capped_brep.Compact()

#here we get a negative volume : -2283643.74245
print 'capped_brep.GetVolume()  ',capped_brep.GetVolume()

#adding the brep to the document and reading the brep back from the doc
capped_id = sc.doc.Objects.AddBrep(capped_brep)
doc_brep = rs.coercebrep(capped_id)

#here we get a positive volume : 2283643.74245
print 'doc_brep.GetVolume()  ',doc_brep.GetVolume()

Thanks
-Willem

EDIT for those with a similar issues:
to fix the incorrect solid orientation

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

id = rs.GetObject('select brep', preselect=True)
brep = rs.coercebrep(id)


capped_brep = brep.CapPlanarHoles(sc.doc.ModelAbsoluteTolerance)

if capped_brep.SolidOrientation == Rhino.Geometry.BrepSolidOrientation.Inward:
    capped_brep.Flip()
    

print 'capped_brep.GetVolume()  ',capped_brep.GetVolume()

Not at a computer, but are any surface normals pointing in instead of out?

Jeremy

Hi Jeremy,

I expected to fix this with Brep.Standardize()

However you made me check all Face Orientations and also Brep.SolidOrientation
and I found that the Brep.SolidOrientation is Inward where it should be Outward

However @dale this seems to be new behaviour I did not encounter before.
Would it not be expected that Brep.CapPlanarHoles will fix a solid orientation to being outward?

Maybe I’m wrong so I’ll build in a check against the Brep.SolidOrientation being Inward.

Thanks
-Willem

I don’t believe Brep.CapPlanarHoles has ever checked for orientation.

– Dale

1 Like