Skip to content
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

Generalize grow, refactor math, random #1246

Merged
merged 16 commits into from
May 10, 2024
Merged

Generalize grow, refactor math, random #1246

merged 16 commits into from
May 10, 2024

Conversation

pentacular
Copy link
Member

@pentacular pentacular commented May 7, 2024

Grow/Trim

This mostly changes grow to do a minkowski sum with a convex hull upon points, segments, polygons, and meshes.

Trim is added as a lower dimensional counterpoint -- given a mesh it grows the individual faces, given a polygon it grows the individual edges.

This allows, e.g., x.cut(trim(Orb(1))) to trim x by 1 mm in all dimenions.

The tool can be two dimensional, e.g., x.grow(Arc(1)) to grow in x and y by one mm without affecting z.

The tool can be asymmetric, e.g., x.grow(Box(1)) to grow in x and y by one mm, with sharp axis-aligned edges.

Or x.grow(Orb(cut(XY()))) to grow rounded in all directions other than positive z.

Random
The main use of random numbers so far is to produce a set of N values.

x.random(4, 12, (a, b, c, d) => ...) generates the first four numbers of seed 12 and binds them to a, b, c, d.

The Nth set of M random numbers can be selected with the third integer argument.

e.g., Seq({ to: 20 }, t => random(4, 12, t, (a, b, c, d) => ...))

will repeat 20 times using different groups of 4 random values.

@BarbourSmith
Copy link
Contributor

The tool can be asymmetric, e.g., x.grow(Box(1)) to grow in x and y by one mm, with sharp axis-aligned edges.

Or x.grow(Orb(cut(XY()))) to grow rounded in all directions other than positive z

This is slick

Copy link
Contributor

@BarbourSmith BarbourSmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intensional that these bounding boxes all went away?

image

Does this look right?

image

typedef CGAL::Exact_predicates_exact_constructions_kernel EK;
typedef CGAL::Surface_mesh<EK::Point_3> Surface_mesh;
size_t size = geometry->size();
static int Grow(Geometry* geometry, size_t count) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does count do here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Count is the number of geometries in the input (as opposed to the tool).

There's probably a better naming choice for that.

@@ -19,7 +19,7 @@ export const computeBoundingBox = (inputs) => {
case STATUS_EMPTY:
return;
default:
throw new Error(`Unexpected status ${status}`);
throw new Error(`Unexpected status ${status} in computeBoundingBox`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are nice 👍

@pentacular
Copy link
Member Author

Is it intensional that these bounding boxes all went away?

Yes, I finally deleted all of the existing ones to force generation, since the bounding boxes were sometimes under the pixel threshold.

I'm hoping that gauges provide a better alternative.

image Does this look right? image

Ah, thanks for noticing that.

I've removed fromPolygons and fixed fromPolygonSoup to make sure it bounds a volume when closed.

@pentacular pentacular merged commit 94b74ed into master May 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants