-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
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 |
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.
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) { |
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.
What does count do here?
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.
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`); |
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.
These are nice 👍
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.