AreaMassProperties.Compute(Brep) vs. _Area time

10.3801 seconds for Rhino.RhinoApp.RunScript("_Area", False)
113.331 seconds for Rhino.Geometry.AreaMassProperties.Compute(brep)

It would help if Compute had a timeout parameter for troublesome breps such as the one in:
AreaMassPropertiesComputeTime.3dm (43.0 KB)

Is there any way to quickly identify such breps?

import Rhino
import rhinoscriptsyntax as rs
from System.Diagnostics import Stopwatch

def main():
    guidBrep = rs.GetObject("Select surface", rs.filter.surface, preselect=True, select=True)
    if guidBrep is None: return
    
    stopwatch = Stopwatch()
    
    s = 'Rhino.RhinoApp.RunScript("_Area", False)'
    stopwatch.Start()
    eval(s)
    stopwatch.Stop()
    print "{} seconds for {}".format(stopwatch.Elapsed.TotalSeconds, s)
    
    brep = rs.coercebrep(guidBrep)
    
    s = "Rhino.Geometry.AreaMassProperties.Compute(brep)"
    stopwatch.Restart()
    areaMassProp = eval(s)
    stopwatch.Stop()
    print "Area = {}".format(areaMassProp.Area)
    print "{} seconds for {}".format(stopwatch.Elapsed.TotalSeconds, s)

if __name__ == '__main__': main()

Thank you,
Steve

Hi Steve, looks slightly buggy to me. If i _ShrinkTrimmedSrf i got this in V5:

0.2855 seconds for Rhino.RhinoApp.RunScript("_Area", False)
0.0126 seconds for Rhino.Geometry.AreaMassProperties.Compute(brep) 

but this in the WIP:

21.5226 seconds for Rhino.RhinoApp.RunScript("_Area", False)
214.3793 seconds for Rhino.Geometry.AreaMassProperties.Compute(brep)

i think the reason is the crazy parameterisation of the surface. If you use _Reparameterize with the _Automatic option, i get this in the WIP:

0.0878 seconds for Rhino.RhinoApp.RunScript("_Area", False)
0.02 seconds for Rhino.Geometry.AreaMassProperties.Compute(brep)

You may check both domains of the surface (or of a virtual copy) and set them with surface.SetDomain() to an interval from 0 to a value optained by surface.GetSurfaceSize()

c.

I just realized that the surface has 6 columns of control points spanning less than 0.0003. (ModelAbsoluteTolerance is 0.0002). The surface has a fully-multiple knot relative to this set of control points.

V5’s _ShrinkTrimmedSrfToEdge reduces the 6 columns to 1, but
V6’s _ShrinkTrimmedSrfToEdge leaves them at 6 but at a span of 9e-8.

V5, V6 times (s) for _Area
10.6672, 10.336: No modification
10.5569, 10.3338: _ShrinkTrimmedSrf only
0.1257, 12.9157: _ShrinkTrimmedSrfToEdge only
0.1272, 10.3923: _Reparameterize _Automatic only

(-1.9e-11 to 1.0) (-2.3e-07 to 1.0): Original surface domains (u) (v)
(-1.9e-11 to 0.9996) (-2.3e-07 to 0.7851): _ShrinkTrimmedSrfToEdge only in V5 & V6
(0.0 to 0.4598) (0.0 to 1.3104): _Reparameterize _Automatic only in V5 & V6

Hi Steve,

if you have many of these i would just detect them by the uv domain values and if one is negative, create a virtual copy and proceed as described above.

btw. _RemoveMultiKnot did not found any multiple knots, i’ve tried that first.

c.

Thanks for looking at this. From analyzing domains, knots, and control points before and after the aforementioned commands, I think the answer is to address the almost stacked control points.

Regardless, a timeout parameter for AreaMassProperties.Compute would be beneficial. The area mass properties UI commands have “Press Esc to cancel”.

_RemoveMultiKnot does not report fully-multiple knots.

Hi @spb, @clement,

The Area command and AreaMassProperties.Compute do very different things. Yes, they both compute the area. But AreaMassProperties.Compute also calculates area first moments, area second moments, and area product moments. This probably accounts for the difference in speed.

If you just want area, use Brep.GetArea.

Does this help?

– Dale

@dale, please see my first reply, i think this thread is less about the difference between both commands but about a possible bug. Changing the bogus parameterisation of the surface caused that:

Rhino.Geometry.AreaMassProperties.Compute(brep)

time changed from 214 seconds to 0.02 seconds using the WIP.

c.

@spb, can you give us any details as to how this surface was created? Did you use just Rhino commands? What it imported from some other application?

Thanks,

– Dale

I see. I often use AreaMassProperties to get the area centroid. Here are more comparable results:

10.589 seconds for Rhino.RhinoApp.RunScript("_Area", False)
10.5286 seconds for brep.GetArea()

.

53.1131 seconds for Rhino.RhinoApp.RunScript("_AreaCentroid", False)
116.3615 seconds for Rhino.Geometry.AreaMassProperties.Compute(brep)

The point from _AreaCentroid is not on the face.

It’s from a STEP file. I want to be able to identify brep faces like this one before using them.

I opened a bug on You Track RH-40368. This should work.