nicklockwood / Euclid

A Swift library for creating and manipulating 3D geometry
MIT License
639 stars 53 forks source link

Offset (Displacement Modifier) #83

Open ralphgeorg-s opened 2 years ago

ralphgeorg-s commented 2 years ago

the library is amazing. I would like to add a displacement - for example 0.5mm - so that the objects are not water-tight. Is there an option?

nicklockwood commented 2 years ago

I'm not sure I understand. What do you want to displace?

ralphgeorg-s commented 2 years ago

In blender its called - overlap threshold https://blender.stackexchange.com/questions/143741/boolean-difference-with-offset

nicklockwood commented 2 years ago

OK, I think I understand. This feature doesn't exist in Euclid currently, but isn't hard to add.

ralphgeorg-s commented 2 years ago

Thx for your answer. Can you guide us on how to do this?

nicklockwood commented 2 years ago

@ralphgeorg-s I'll add the feature soon.

ralphgeorg-s commented 2 years ago

that's amazing, thx.

nicklockwood commented 2 years ago

@ralphgeorg-s I've pushed the feature to the develop branch. Use it like this:

let smallerMesh = mesh.inset(by: 0.01)
let biggerMesh = mesh.inset(by: -0.01)
nicklockwood commented 2 years ago

@ralphgeorg-s actually it seems a little buggy for some meshes. I'll let you know when it's fixed.

nicklockwood commented 2 years ago

@ralphgeorg-s OK, it's working better now. There are still some issues with concave meshes, but that may not be an issue for you. Let me know if it solves your problem.

ralphgeorg-s commented 2 years ago

Thx so much, we will test.

ralphgeorg-s commented 2 years ago

@nicklockwood - we tried yesterday night - but it takes hours to calculate. We do have some complex files.

nicklockwood commented 2 years ago

@ralphgeorg-s OK, I'll do some work to optimize it. Can you send me a sample file I can use for testing?

ralphgeorg-s commented 2 years ago

https://drive.google.com/drive/folders/19vGaDcbvOKZanJKtieztAbt8U1B1J8Ok?usp=sharing

On Tue, Feb 22, 2022 at 11:53 AM Nick Lockwood @.***> wrote:

@ralphgeorg-s https://github.com/ralphgeorg-s OK, I'll do some work to optimize it. Can you send me a sample file I can use for testing?

— Reply to this email directly, view it on GitHub https://github.com/nicklockwood/Euclid/issues/83#issuecomment-1048004690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AX24NWDSNINF3CZRNCZE7W3U4O5SBANCNFSM5OY2VBBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

nicklockwood commented 2 years ago

@ralphgeorg-s I've improved the performance of Mesh.inset(by:) - it should now be near-instant.

ralphgeorg-s commented 2 years ago

Hi Nick,

with inset, the simple objects get messed up. Without the calculation is clean. Any idea why that happens?

The last change works really well. The cal. is done super quick. Inset 0.05 means 50 microns?

[image: Screen Shot 2022-02-24 at 8.29.36 AM.png] [image: photo_2022-02-24 08.29.28.jpeg]

On Tue, Feb 22, 2022 at 5:08 PM Nick Lockwood @.***> wrote:

@ralphgeorg-s https://github.com/ralphgeorg-s I've improved the performance of Mesh.inset(by:) - it should now be near-instant.

— Reply to this email directly, view it on GitHub https://github.com/nicklockwood/Euclid/issues/83#issuecomment-1048258250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AX24NWHIU4SYLNZVHHXCW7DU4QCMDANCNFSM5OY2VBBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

nicklockwood commented 2 years ago

@ralphgeorg-s the screenshots you shared didn't come through. Perhaps you can share some code I can use to reproduce the issue with the models you already provided?

Inset 0.05 means 50 microns?

Euclid uses abstract distance units, so it will be relative to whatever the original model scale was. If your original model scale is in mm then 0.05 will be 50 microns (unless you've applied a scale transform to the model after loading it).

nicklockwood commented 2 years ago

@ralphgeorg-s any update?

ralphgeorg-s commented 2 years ago

Hi, not yet. when the offset is zero - then the boolean difference is perfect. I used a cube ad a pipe. When you set an offset the models break in pieces.

ralphgeorg-s commented 2 years ago
Screen Shot 2022-05-12 at 7 13 20 PM Screen Shot 2022-05-12 at 7 14 03 PM Screen Shot 2022-05-12 at 7 26 28 PM

when we add the Mesh.inset(by:) - the mesh is not clean somehow. the second screenshot is with inset zero - super clean,

do you have any ideas or advice? thx for your help. ralph