Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Mesh3D.remove_degenerate_triangles() -> flat triangle not taken into account #1350

Open
1 of 2 tasks
MackJoly opened this issue Apr 3, 2024 · 1 comment
Open
1 of 2 tasks

Comments

@MackJoly
Copy link
Contributor

MackJoly commented Apr 3, 2024

  • I'm submitting a ...

    • bug report
    • feature request
  • What is the current behavior?
    I have a triangle from a STL with 3 points aligned and it is not delete by remove_degenerate_triangles method

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem Avoid reference to other packages

Those are my points aligned:
point1: Point3D(-0.6205590209960937, 0.349411376953125, 0.17962226867675782)
point2: Point3D(-0.6205590209960937, 0.349411376953125, 0.407595458984375)
point3: Point3D(-0.6205590209960937, 0.349411376953125, 0.384592529296875)

  • What is the expected behavior?
    Aligned point to be deleted OR method Mesh3D.to_triangles3d to not fail because of those three aligned points

  • What is the motivation / use case for changing the behavior?
    Customer

  • Possible fixes
    Check with normalize vector in order to verify that they are not aligned

  • Please tell us about your environment:

    • branch: master
    • commit: latest
    • python version: 3.9.13
@MackJoly
Copy link
Contributor Author

MackJoly commented Apr 3, 2024

Another possiblity is to put a try except:
def to_triangles3d(self):
"""
Export the mesh faces as Triangle3D objects.

    :return: The triangles comosing the mesh.
    :rtype: list[Triangle3D]
    """
    # pylint: disable=import-outside-toplevel, cyclic-import
    from volmdlr.faces import Triangle3D

    triangles3d = []
    for vertex1, vertex2, vertex3 in self.remove_degenerate_triangles(tol=1e-6).triangles_vertices():
        point1 = volmdlr.Point3D(*vertex1)
        point2 = volmdlr.Point3D(*vertex2)
        point3 = volmdlr.Point3D(*vertex3)

        try:
            triangles3d.append(Triangle3D(point1, point2, point3))
        except ZeroDivisionError:
            continue

    return triangles3d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant