-
Notifications
You must be signed in to change notification settings - Fork 137
wasm: fix CrossSection slice and project bindings #930
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #930 +/- ##
==========================================
- Coverage 91.84% 88.29% -3.55%
==========================================
Files 37 62 +25
Lines 4976 8643 +3667
Branches 0 1046 +1046
==========================================
+ Hits 4570 7631 +3061
- Misses 406 1012 +606 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, another example / test would be great to show people how to use slice/project. The difficulty is I like our examples to be high quality - simple, readable, cool-looking. If you're up to the challenge that would be great.
bindings/wasm/bindings.js
Outdated
@@ -284,11 +284,17 @@ Module.setup = function() { | |||
}; | |||
|
|||
Module.Manifold.prototype.slice = function(height = 0.) { | |||
return Module.CrossSection(this._Slice(height)); | |||
const polygonsVec = this._Slice(height); | |||
const result = new CrossSectionCtor(polygonsVec, 2 /* positive */); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about fillRule2Int('Positive')
as elsewhere, for maintainability?
ec020bd
to
d8e590f
Compare
I leaned into the default yellow rendering and made a cheesy example. Let me know if that works for you. Also, how do I run the auto code formatter to fix the one broken CI check? I installed |
Would you mind adding a screenshot? As to formatting, it looks like our |
a9c034a
to
8c80049
Compare
8c80049
to
684eadd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -51,6 +51,34 @@ export const examples = { | |||
return result; | |||
}, | |||
|
|||
Auger: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the example! But I'm also really picky about public examples, so I went ahead and made my own instead. Please don't feel slighted; it's just my own aesthetics.
@@ -153,7 +153,7 @@ jobs: | |||
cp ../manifold.* ./dist/ | |||
- name: Upload WASM files | |||
uses: actions/upload-artifact@v4 | |||
if: matrix.exception == 'ON' | |||
if: matrix.exception == 'ON' && github.event_name == 'push' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully this will fix the accidental update problem.
Resolves #929 by calling the
CrossSectionCtor
directly. These functions already have the vector returned by the_Slice
/_Project
so thepolygons2vec
isn't needed. I just copied what theCrossSection
wrapper did w/out it.I'm not sure if the memory management with
disposePolygons
is correct, but my tests in with a local ManifoldCAD work after this change.I also couldn't figure out how to add new tests. AFAICT, it's just running the examples? It might be worth adding a
slice
example anyway. Happy to add as part of this PR if you point me in the right direction.