ladybug-tools / ladybug-geometry

🐞 📦 A library with geometry objects used throughout the Ladybug Tools core libraries
https://www.ladybug.tools/ladybug-geometry/docs/
GNU Affero General Public License v3.0
23 stars 22 forks source link

Bug in Mesh2d.triangulation #203

Closed noamgat closed 3 years ago

noamgat commented 3 years ago

The following line in Mesh2d.triangulation is incomplete:

            _triangles = Mesh2D._quad_to_triangles([self._vertices[i] for i in face])

Reason being is that _quad_to_triangles return 0 based indices. These indices have to be re-adjusted to match the indices in the "face" object

The correct snippet should be:

        if len(face) == 3:
            _new_faces.append(face)
        else:
            _triangles = Mesh2D._quad_to_triangles([self._vertices[i] for i in face])
            _triangles = [tuple(face[vertex_idx] for vertex_idx in new_face) for new_face in _triangles]
            _new_faces.extend(_triangles)
noamgat commented 3 years ago

Wow github's web editor is amazing. https://github.com/ladybug-tools/ladybug-geometry/pull/204

chriswmackey commented 3 years ago

This one has been resolved. Thanks again, @noamgat