Skip to content

Commit

Permalink
fix(mesh): Update Mesh2D for consistency
Browse files Browse the repository at this point in the history
This commit also bumps the version of semantic release.
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jun 3, 2024
1 parent dbfb0be commit e47293e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ jobs:
with:
python-version: 3.7
- name: set up node # we need node for for semantic release
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v4
with:
node-version: 14.2.0
node-version: 22.2.0
- name: install python dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -57,8 +57,8 @@ jobs:
- name: run semantic release
id: new_release
run: |
nextRelease="`npx semantic-release@^17.0.0 --dryRun | grep -oP 'Published release \K.*? ' || true`"
npx semantic-release@^17.0.0
nextRelease="`npx semantic-release@^23.1.1 --dryRun | grep -oP 'Published release \K.*? ' || true`"
npx semantic-release@^23.1.1
echo "::set-output name=tag::$nextRelease"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/github",
{
"successComment": false,
"failTitle": false
}
],
["@semantic-release/exec", {
"publishCmd": "bash deploy.sh"
}]
Expand Down
10 changes: 8 additions & 2 deletions ladybug_geometry/_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,21 @@ def _interpret_input_from_face_vertices(faces, purge):
def _interpret_input_from_face_vertices_with_tolerance(faces, tolerance):
"""Get faces and vertices from a list of faces as points.
This differs from _interpret_input_from_face_vertices in that a tolerance
will be used to check for vertex equivalency instead of relying on
equality within floating point tolerance.
Args:
faces: A list of faces where each face is a list of points.
tolerance: A number for the tolerance to use when checking for duplicate vertices.
tolerance: A number for the tolerance to use when checking for
duplicate vertices.
Returns:
A tuple of vertices and faces.
"""

def index_of_equivalent_point(vertix_list, vertix):
"""Get the index of a vertix in a list of vertices using the is_equivalent test."""
"""Get the index within a list of vertices using the is_equivalent test."""
for i, other_vert in enumerate(vertix_list):
if vertix.is_equivalent(other_vert, tolerance):
return i
Expand Down
25 changes: 24 additions & 1 deletion ladybug_geometry/geometry2d/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,34 @@ def from_face_vertices(cls, faces, purge=True):
purge: A boolean to indicate if duplicate vertices should be shared between
faces. Default is True to purge duplicate vertices, which can be slow
for large lists of faces but results in a higher-quality mesh with
a smaller size in memory. Default is True.
a smaller size in memory. Note that vertices are only considered
duplicate if the coordinate values are equal to one another
within floating point tolerance. To remove duplicate vertices
within a specified tolerance other than floating point, the
from_purged_face_vertices method should be used instead.
"""
vertices, face_collector = cls._interpret_input_from_face_vertices(faces, purge)
return cls(tuple(vertices), tuple(face_collector))

@classmethod
def from_purged_face_vertices(cls, faces, tolerance):
"""Create a mesh from a list of faces with each face defined by Point3Ds.
This method is slower than 'from_face_vertices' but will result in a mesh
with fewer vertices and a smaller size in memory. This method is similar to
using the 'purge' option in 'from_face_vertices' but will result in more shared
vertices since it uses a tolerance to check equivalent vertices rather than
comparing within floating point tolerance.
Args:
faces: A list of faces with each face defined as a list of 3 or 4 Point3D.
tolerance: A number for the minimum difference between coordinate
values at which point vertices are considered equal to one another.
"""
vertices, faces = cls._interpret_input_from_face_vertices_with_tolerance(
faces, tolerance)
return cls(tuple(vertices), tuple(faces))

@classmethod
def from_polygon_triangulated(cls, boundary_polygon, hole_polygons=None):
"""Initialize a triangulated Mesh2D from a Polygon2D.
Expand Down
16 changes: 10 additions & 6 deletions ladybug_geometry/geometry3d/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ def from_face_vertices(cls, faces, purge=True):
purge: A boolean to indicate if duplicate vertices should be shared between
faces. Default is True to purge duplicate vertices, which can be slow
for large lists of faces but results in a higher-quality mesh with
a smaller size in memory. Default is True.
a smaller size in memory. Note that vertices are only considered
duplicate if the coordinate values are equal to one another
within floating point tolerance. To remove duplicate vertices
within a specified tolerance other than floating point, the
from_purged_face_vertices method should be used instead.
"""
vertices, face_collector = cls._interpret_input_from_face_vertices(faces, purge)
return cls(tuple(vertices), tuple(face_collector))
Expand All @@ -121,16 +125,16 @@ def from_purged_face_vertices(cls, faces, tolerance):
This method is slower than 'from_face_vertices' but will result in a mesh
with fewer vertices and a smaller size in memory. This method is similar to
using the 'purge' option in 'from_face_vertices' but will result in more shared
vertices since it uses the `is_equivalent` test to check the vertices rather than
the more strict `__eq__` comparison.
vertices since it uses a tolerance to check equivalent vertices rather than
comparing within floating point tolerance.
Args:
faces: A list of faces with each face defined as a list of 3 or 4 Point3D.
tolerance: A number for the tolerance to use when checking for duplicate vertices.
tolerance: A number for the minimum difference between coordinate
values at which point vertices are considered equal to one another.
"""
vertices, faces = cls._interpret_input_from_face_vertices_with_tolerance(
faces, tolerance
)
faces, tolerance)
return cls(tuple(vertices), tuple(faces))

@classmethod
Expand Down

0 comments on commit e47293e

Please sign in to comment.