jimy-byerley / pymadcad

Simple yet powerful CAD (Computer Aided Design) library, written with Python.
https://madcad.netlify.app/
GNU Lesser General Public License v3.0
205 stars 15 forks source link

Pierce doesnt seem to be working. Help requested. #104

Closed bfialkoff closed 3 months ago

bfialkoff commented 3 months ago

Hi,

As part of a project I am working on i am trying to pierce a surface mesh (or web) and a cone type mesh. I have many pairs of surface meshes each of which need to be pierce with a cone.

However, something doesn't seem to be working properly. I have 2 test cases in particular and in one case the operation returns what I expect and in the other case the pierce function seems to be ignored. I can't seem to find any clear indication of what is wrong.

The code i am using is super simple and I've uploaded 4 plys that i am working with.

from madcad import show, pierce
from madcad.io import ply_read
i = 1
surface_mesh = ply_read('surface_mesh_{i}.ply')
cone_mesh = ply_read('cone_mesh_{i}.ply')
p = pierce(surface_mesh, cone_mesh, side=False)

Viewing the results with i=1 (i.e the first pair) doesn't seem to work but with i=2 (the 2nd pair) it does seem to give the expected results.

I'd really appreciate any help.

Thanks :)

meshes_and_cones.zip

jimy-byerley commented 3 months ago

Hello your surface meshes have badly oriented triangles, you can easily fix that by calling .orient() on them

the following worked for me:

cone_mesh_1 = read('/tmp/meshes_and_cones/cone_mesh_1.ply')
cone_mesh_2 = read('/tmp/meshes_and_cones/cone_mesh_2.ply')
surface_mesh_1 = read('/tmp/meshes_and_cones/surface_mesh_1.ply').orient()
surface_mesh_2 = read('/tmp/meshes_and_cones/surface_mesh_2.ply').orient()

r1 = pierce(surface_mesh_1, cone_mesh_1)
r2 = pierce(surface_mesh_2, cone_mesh_2)