mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-21 03:49:38 +00:00
Merge pull request #1070 from revarbat/revarbat_dev
Added point attachment geometry.
This commit is contained in:
commit
e8e7c9bec9
2 changed files with 21 additions and 4 deletions
|
@ -2080,6 +2080,8 @@ function named_anchor(name, pos, orient=UP, spin=0) = [name, pos, orient, spin];
|
||||||
|
|
||||||
// Function: attach_geom()
|
// Function: attach_geom()
|
||||||
//
|
//
|
||||||
|
// Usage: Null/Point Geometry
|
||||||
|
// geom = attach_geom(...);
|
||||||
// Usage: Square/Trapezoid Geometry
|
// Usage: Square/Trapezoid Geometry
|
||||||
// geom = attach_geom(two_d=true, size=, [size2=], [shift=], ...);
|
// geom = attach_geom(two_d=true, size=, [size2=], [shift=], ...);
|
||||||
// Usage: Circle/Oval Geometry
|
// Usage: Circle/Oval Geometry
|
||||||
|
@ -2129,6 +2131,9 @@ function named_anchor(name, pos, orient=UP, spin=0) = [name, pos, orient, spin];
|
||||||
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
||||||
// axis = The vector pointing along the axis of a geometry. Default: UP
|
// axis = The vector pointing along the axis of a geometry. Default: UP
|
||||||
//
|
//
|
||||||
|
// Example(NORENDER): Null/Point Shape
|
||||||
|
// geom = attach_geom();
|
||||||
|
//
|
||||||
// Example(NORENDER): Cubical Shape
|
// Example(NORENDER): Cubical Shape
|
||||||
// geom = attach_geom(size=size);
|
// geom = attach_geom(size=size);
|
||||||
//
|
//
|
||||||
|
@ -2281,7 +2286,7 @@ function attach_geom(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
) :
|
) :
|
||||||
assert(false, "Unrecognizable geometry description.");
|
["point", cp, offset, anchors];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2315,6 +2320,7 @@ function _attach_geom_2d(geom) =
|
||||||
// Returns the `[X,Y,Z]` bounding size for the given attachment geometry description.
|
// Returns the `[X,Y,Z]` bounding size for the given attachment geometry description.
|
||||||
function _attach_geom_size(geom) =
|
function _attach_geom_size(geom) =
|
||||||
let( type = geom[0] )
|
let( type = geom[0] )
|
||||||
|
type == "point"? [0,0,0] :
|
||||||
type == "prismoid"? ( //size, size2, shift, axis
|
type == "prismoid"? ( //size, size2, shift, axis
|
||||||
let(
|
let(
|
||||||
size=geom[1], size2=geom[2], shift=point2d(geom[3]),
|
size=geom[1], size2=geom[2], shift=point2d(geom[3]),
|
||||||
|
@ -2555,6 +2561,12 @@ function _find_anchor(anchor, geom) =
|
||||||
pos2 = rot(from=UP, to=axis, p=pos),
|
pos2 = rot(from=UP, to=axis, p=pos),
|
||||||
vec2 = anch==CENTER? UP : rot(from=UP, to=axis, p=vec)
|
vec2 = anch==CENTER? UP : rot(from=UP, to=axis, p=vec)
|
||||||
) [anchor, pos2, vec2, oang]
|
) [anchor, pos2, vec2, oang]
|
||||||
|
) : type == "point"? (
|
||||||
|
let(
|
||||||
|
anchor = unit(point3d(anchor),CENTER),
|
||||||
|
pos = point3d(cp) + point3d(offset),
|
||||||
|
vec = unit(anchor,UP)
|
||||||
|
) [anchor, pos, vec, oang]
|
||||||
) : type == "spheroid"? ( //r
|
) : type == "spheroid"? ( //r
|
||||||
let(
|
let(
|
||||||
rr = geom[1],
|
rr = geom[1],
|
||||||
|
|
11
skin.scad
11
skin.scad
|
@ -3685,8 +3685,13 @@ function _textured_revolution(
|
||||||
assert(in_list(atype, _ANCHOR_TYPES), "Anchor type must be \"hull\" or \"intersect\"")
|
assert(in_list(atype, _ANCHOR_TYPES), "Anchor type must be \"hull\" or \"intersect\"")
|
||||||
let(
|
let(
|
||||||
regions = !is_path(shape,2)? region_parts(shape) :
|
regions = !is_path(shape,2)? region_parts(shape) :
|
||||||
shape[0].y <= last(shape).y? [[reverse(shape)]] :
|
closed? region_parts([shape]) :
|
||||||
[[shape]],
|
let(
|
||||||
|
clpoly = [[0,shape[0].y], each shape, [0,last(shape).y]],
|
||||||
|
dpoly = deduplicate(clpoly),
|
||||||
|
cwpoly = is_polygon_clockwise(dpoly) ? dpoly : reverse(dpoly)
|
||||||
|
)
|
||||||
|
[[ select(cwpoly,1,-2) ]],
|
||||||
checks = [
|
checks = [
|
||||||
for (rgn=regions, path=rgn)
|
for (rgn=regions, path=rgn)
|
||||||
assert(all(path, function(pt) pt.x>=0))
|
assert(all(path, function(pt) pt.x>=0))
|
||||||
|
@ -3747,7 +3752,7 @@ function _textured_revolution(
|
||||||
is_path(taper,2)? let(
|
is_path(taper,2)? let(
|
||||||
retaper = [
|
retaper = [
|
||||||
for (t=taper)
|
for (t=taper)
|
||||||
assert(t[0]>=0 && t[0]<=100, "taper lookup indices must be betweem 0 and 100 inclusive.")
|
assert(t[0]>=0 && t[0]<=100, "taper lookup indices must be between 0 and 100 inclusive.")
|
||||||
[t[0]/100, t[1]]
|
[t[0]/100, t[1]]
|
||||||
],
|
],
|
||||||
taperout = [[-1,retaper[0][1]], each retaper, [2,last(retaper)[1]]]
|
taperout = [[-1,retaper[0][1]], each retaper, [2,last(retaper)[1]]]
|
||||||
|
|
Loading…
Reference in a new issue