compas icon indicating copy to clipboard operation
compas copied to clipboard

CellNetwork.cell_neighbors() modification

Open 2twenity opened this issue 10 months ago • 2 comments

What type of change is this?

  • [x] Bug fix in a backwards-compatible manner.
  • [x] New feature in a backwards-compatible manner.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • [x] I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • [ ] I ran all tests on my computer and it's all green (i.e. invoke test).
  • [x] I ran lint on my computer and there are no errors (i.e. invoke lint).
  • [x] I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • [x] I have added tests that prove my fix is effective or that my feature works.
  • [ ] I have added necessary documentation (if appropriate)

Some description.

CellNetwork.cell_neighbors

I've been trying to analyze connections between building elements using CellNetwork.cell_neighbors method and found out that simple common faces search could not work, because faces can point at the vertices with same coordinates, but which have different indexes, because there's no duplicate vertex check in CellNetwork.add_vertex method. Therefore I've modified the comparison logic to simple common vertices search. If 2 cells have more than 2 vertices in common, they might be adjacent. (Maybe a condition that points don't lie on the same line should be considered as well). This method performed quite well in a graph construction process of an HVAC received from Speckle.

Screenshot 2025-03-23 at 16 08 30

I've added this particular CellNetwork to tests/compas/datastructures/fixtures folder.

CellNetwork.add_mesh

Also I've implemeted add_mesh method to CellNetwork which simple decomposes mesh to vertices and faces, checks if it's manifold and adds as a Cell to CellNetwork

2twenity avatar Mar 24 '25 10:03 2twenity

hi,

thanks for this. would you mind fixing the lint in the code so the workflows can run properly?

we will automate this in the future, but for now this needs to be done locally...

thanks!

tomvanmele avatar Mar 28 '25 16:03 tomvanmele

Hi @2twenity! Thank you for the PR!

romanarust avatar Mar 29 '25 15:03 romanarust