Skip to content

Commit

Permalink
Update bindings (#1023)
Browse files Browse the repository at this point in the history
* add setTolerance to WASM bindings

* update manifold_revolve C API

* fix formatting
  • Loading branch information
elalish authored Nov 5, 2024
1 parent 82140d3 commit 2b29dca
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 29 deletions.
3 changes: 2 additions & 1 deletion bindings/c/include/manifold/manifoldc.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ ManifoldManifold *manifold_extrude(void *mem, ManifoldPolygons *cs,
double twist_degrees, double scale_x,
double scale_y);
ManifoldManifold *manifold_revolve(void *mem, ManifoldPolygons *cs,
int circular_segments);
int circular_segments,
double revolve_degrees);
ManifoldManifold *manifold_compose(void *mem, ManifoldManifoldVec *ms);
ManifoldManifoldVec *manifold_decompose(void *mem, ManifoldManifold *m);

Expand Down
5 changes: 3 additions & 2 deletions bindings/c/manifoldc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@ ManifoldManifold *manifold_extrude(void *mem, ManifoldPolygons *cs,
}

ManifoldManifold *manifold_revolve(void *mem, ManifoldPolygons *cs,
int circular_segments) {
auto m = Manifold::Revolve(*from_c(cs), circular_segments);
int circular_segments,
double revolve_degrees) {
auto m = Manifold::Revolve(*from_c(cs), circular_segments, revolve_degrees);
return to_c(new (mem) Manifold(m));
}

Expand Down
1 change: 1 addition & 0 deletions bindings/wasm/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ EMSCRIPTEN_BINDINGS(whatever) {
.function("numPropVert", &Manifold::NumPropVert)
.function("_boundingBox", &Manifold::BoundingBox)
.function("tolerance", &Manifold::GetTolerance)
.function("setTolerance", &Manifold::SetTolerance)
.function("genus", &Manifold::Genus)
.function("volume", &Manifold::Volume)
.function("surfaceArea", &Manifold::SurfaceArea)
Expand Down
1 change: 1 addition & 0 deletions bindings/wasm/examples/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const manifoldMemberFunctions = [
'refineToLength',
'refineToTolerance',
'setProperties',
'setTolerance',
'asOriginal',
'trimByPlane',
'split',
Expand Down
6 changes: 6 additions & 0 deletions bindings/wasm/manifold-encapsulated-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,12 @@ export class Manifold {
*/
tolerance(): number;

/**
* Return a copy of the manifold with the set tolerance value.
* This performs mesh simplification when the tolerance value is increased.
*/
setTolerance(tolerance: number): Manifold;

/**
* The genus is a topological property of the manifold, representing the
* number of "handles". A sphere is 0, torus 1, etc. It is only meaningful for
Expand Down
41 changes: 15 additions & 26 deletions include/manifold/linalg.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// linalg.h - 2.2 - Single-header public domain linear algebra library
// Copyright 2024 The Manifold Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Based on linalg.h - 2.2 - Single-header public domain linear algebra library
//
// The intent of this library is to provide the bulk of the functionality
// you need to write programs that frequently use small, fixed-size vectors
Expand All @@ -17,31 +31,6 @@
// Some features are deprecated. Define LINALG_FORWARD_COMPATIBLE to remove
// them.

// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>

#pragma once
#ifndef LINALG_H
#define LINALG_H
Expand Down

0 comments on commit 2b29dca

Please sign in to comment.