Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Speeding up the 'Label Faces' component? #334

Open
ed-p-may opened this issue Dec 11, 2023 · 0 comments
Open

Speeding up the 'Label Faces' component? #334

ed-p-may opened this issue Dec 11, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ed-p-may
Copy link

Hi @chriswmackey , @mostaphaRoudsari ,

I am running into some performance issues with larger models, and wonder about a few possible speed-up items? Specifically, I would like to propose a small change to the Honeybee Label Faces component.

Scenario:

With large models with many non-convex surfaces, this component is running very slowly for me (in the example attached, 52 surfaces takes >4 seconds for this component to run).

I have tried to do some basic profiling of the component and I think that the main item causing the slowdown appears to be the face center calculation. Specifically line #100

cent_pt = f_geo.center if f_geo.is_convex else f_geo.pole_of_inaccessibility(p_tol)

The pole_of_inaccessibility method appears to be the one resulting in the long run-times what I can tell?


Proposed Change:

In order to speed up the component, I would propose changing to use the built-in ghpythonlib's Area function instead (which yields the centroid) for all non-convex surfaces, and then changing that line of the component to the following:

if f_geo.is_convex:
    cent_pt = f_geo.center
else:
    surface = from_face3d(f_geo)
    surface_center_point = ghpythonlib.components.Area(surface).centroid
    
    # HANDLE ANY 'L' shaped surfaces
    point, _, distance = ghpythonlib.components.SurfaceClosestPoint(surface_center_point, surface)
    if distance < TOLERANCE:
        surface_center_point = point
    
    cent_pt = to_point3d(surface_center_point)  

When I tried this revised implementation on my test-model, I was able to take the Label Face component's runtime from 4.3 seconds (for 52 non-convex surfaces) to 75 ms. So something like a ~98% reduction in this case.

Screenshot 2023-12-10 at 7 01 13 PM

Do you think I'm missing any cases here which pole_of_inaccessibility handles well that Area + SurfaceClosestPoint does not? From my tests, the Area component does a pretty reliable job at finding the mid-point for most cases that I seem to have.


Example Script:

I have attached an example GH script here with some sample geometry internalized, and with the proposed changed to the component to illustrate the issue and the proposed change.

exampel_label_faces.gh.zip

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants