zalo / CascadeStudio

A Full Live-Scripted CAD Kernel in the Browser
https://zalo.github.io/CascadeStudio/
MIT License
998 stars 122 forks source link

Add a `Mirror` command #122

Closed Billiam closed 2 years ago

Billiam commented 2 years ago

Adds a Mirror command.

I feel like this should be doable with a single transformation, but I could not manage to get SetMirror with gp_ax2 argument to actually mirror the shape, rather than creating a rotation.

It looks like passing a single Point to SetMirror does work, but requires rotating, and reversing the faces afterward.

Example

vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/zalo/cascade-studio/27syGMeef1UnQ4wRq2X9tJY49Qed
âś… Preview: https://cascade-studio-git-fork-billiam-feature-mirror-zalo.vercel.app

zalo commented 2 years ago

Thanks for the PR!

Looking at this thread, it seems like I have the wrong overload of the SetMirror transformation exposed… https://dev.opencascade.org/content/mirroring-objects

I’ll look into fixing that since I know funny things/edge cases can happen when solids are buried under too many transformations.

(Due to the version of OCC in the main branch, only one overload of a function (per # of arguments) is exposed at a time; the embind branch fixes this at the cost of a bit of extra overhead)

The build for that is happening here: https://github.com/zalo/opencascade.js/runs/3944135079

Billiam commented 2 years ago

Due to the version of OCC in the main branch, only one overload of a function (per # of arguments) is exposed at a time

Oh, I was wondering how that worked.

I can reopen a new PR when that's changed, or update this one as you like.

zalo commented 2 years ago

I just committed the new WASM and simplified mirroring function.

For reference, how that works is I make a commit to this repo (an ancient fork of opencascade.js that I like because it's smallish, loads fastish, and doesn't mangle the names of the functions) and Github Actions commits the build products back into it: https://github.com/zalo/opencascade.js/commits/master

The latest OpenCascade.js integrates in this branch, and it handles all of the function overloads (at the cost of appending numbers to the function names).

Either way, this PR is looking good now, so I'm merging it...

Billiam commented 2 years ago

Thank you!