mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
fix vnf_validate isect bug, plus doc tweaks
This commit is contained in:
parent
35f1dc4cb0
commit
c7950a7475
3 changed files with 58 additions and 45 deletions
|
@ -1711,7 +1711,7 @@ function point_in_polygon(point, poly, nonzero=false, eps=EPSILON) =
|
||||||
// Description:
|
// Description:
|
||||||
// Takes a possibly bounded line, and a 2D or 3D planar polygon, and finds their intersection. Note the polygon is
|
// Takes a possibly bounded line, and a 2D or 3D planar polygon, and finds their intersection. Note the polygon is
|
||||||
// treated as its boundary and interior, so the intersection may include both points and line segments.
|
// treated as its boundary and interior, so the intersection may include both points and line segments.
|
||||||
// If the line does not intersect the polygon returns `undef`.
|
// If the line does not intersect the polygon then returns `undef`.
|
||||||
// In 3D if the line is not on the plane of the polygon but intersects it then you get a single intersection point.
|
// In 3D if the line is not on the plane of the polygon but intersects it then you get a single intersection point.
|
||||||
// Otherwise the polygon and line are in the same plane, or when your input is 2D, you will get a list of segments and
|
// Otherwise the polygon and line are in the same plane, or when your input is 2D, you will get a list of segments and
|
||||||
// single point lists. Use `is_vector` to distinguish these two cases.
|
// single point lists. Use `is_vector` to distinguish these two cases.
|
||||||
|
|
86
vnf.scad
86
vnf.scad
|
@ -1772,8 +1772,8 @@ module debug_vnf(vnf, faces=true, vertices=true, opacity=0.5, size=1, convexity=
|
||||||
// vnf_validate(vnf);
|
// vnf_validate(vnf);
|
||||||
// Example(3D,Edges): FACE_ISECT Errors; Faces Intersect
|
// Example(3D,Edges): FACE_ISECT Errors; Faces Intersect
|
||||||
// vnf = vnf_join([
|
// vnf = vnf_join([
|
||||||
// vnf_triangulate(linear_sweep(square(100,center=true), height=100)),
|
// linear_sweep(square(100,center=true), height=100),
|
||||||
// move([75,35,30],p=vnf_triangulate(linear_sweep(square(100,center=true), height=100)))
|
// move([75,35,30],p=linear_sweep(square(100,center=true), height=100))
|
||||||
// ]);
|
// ]);
|
||||||
// vnf_validate(vnf,size=2,check_isects=true);
|
// vnf_validate(vnf,size=2,check_isects=true);
|
||||||
// Example(3D,Edges): HOLE_EDGE Errors; Edges Adjacent to Holes.
|
// Example(3D,Edges): HOLE_EDGE Errors; Edges Adjacent to Holes.
|
||||||
|
@ -1893,43 +1893,51 @@ function _vnf_validate(vnf, show_warns=true, check_isects=false) =
|
||||||
) t_juncts? issues :
|
) t_juncts? issues :
|
||||||
let(
|
let(
|
||||||
isect_faces = !check_isects? [] : unique([
|
isect_faces = !check_isects? [] : unique([
|
||||||
for (i = [0:1:len(faces)-2]) let(
|
for (i = [0:1:len(faces)-2])
|
||||||
f1 = faces[i],
|
let(
|
||||||
poly1 = select(varr, faces[i]),
|
f1 = faces[i],
|
||||||
plane1 = plane3pt(poly1[0], poly1[1], poly1[2]),
|
poly1 = select(varr, faces[i]),
|
||||||
normal1 = [plane1[0], plane1[1], plane1[2]]
|
plane1 = plane3pt(poly1[0], poly1[1], poly1[2]),
|
||||||
)
|
normal1 = [plane1[0], plane1[1], plane1[2]]
|
||||||
for (j = [i+1:1:len(faces)-1]) let(
|
)
|
||||||
f2 = faces[j],
|
for (j = [i+1:1:len(faces)-1])
|
||||||
poly2 = select(varr, f2),
|
let(
|
||||||
val = poly2 * normal1
|
f2 = faces[j],
|
||||||
)
|
poly2 = select(varr, f2),
|
||||||
if( min(val)<=plane1[3] && max(val)>=plane1[3] ) let(
|
val = poly2 * normal1
|
||||||
plane2 = plane_from_polygon(poly2),
|
)
|
||||||
normal2 = [plane2[0], plane2[1], plane2[2]],
|
// The next test skips f2 if it lies entirely on one side of the plane of poly1
|
||||||
val = poly1 * normal2
|
if( min(val)<=plane1[3] && max(val)>=plane1[3] )
|
||||||
)
|
let(
|
||||||
if( min(val)<=plane2[3] && max(val)>=plane2[3] ) let(
|
plane2 = plane_from_polygon(poly2),
|
||||||
shared_edges = [
|
normal2 = [plane2[0], plane2[1], plane2[2]],
|
||||||
for (edge1 = pair(f1, true), edge2 = pair(f2, true))
|
val = poly1 * normal2
|
||||||
if (edge1 == [edge2[1], edge2[0]]) 1
|
)
|
||||||
]
|
// Skip if f1 lies entirely on one side of the plane defined by poly2
|
||||||
)
|
if( min(val)<=plane2[3] && max(val)>=plane2[3] )
|
||||||
if (!shared_edges) let(
|
let(
|
||||||
line = plane_intersection(plane1, plane2)
|
shared_edges = [
|
||||||
)
|
for (edge1 = pair(f1, true), edge2 = pair(f2, true))
|
||||||
if (!is_undef(line)) let(
|
if (edge1 == [edge2[1], edge2[0]]) 1
|
||||||
isects = polygon_line_intersection(poly1, line)
|
]
|
||||||
)
|
)
|
||||||
if (!is_undef(isects))
|
if (shared_edges==[])
|
||||||
for (isect = isects)
|
let(
|
||||||
if (len(isect) > 1) let(
|
line = plane_intersection(plane1, plane2)
|
||||||
isects2 = polygon_line_intersection(poly2, isect, bounded=true)
|
)
|
||||||
)
|
if (is_def(line))
|
||||||
if (!is_undef(isects2))
|
let(
|
||||||
for (seg = isects2)
|
isects = polygon_line_intersection(poly1, line)
|
||||||
if (seg[0] != seg[1])
|
)
|
||||||
_vnf_validate_err("FACE_ISECT", seg)
|
if (is_def(isects))
|
||||||
|
for (isect = isects)
|
||||||
|
if (len(isect) > 1)
|
||||||
|
let(
|
||||||
|
isects2 = polygon_line_intersection(poly2, isect, bounded=true)
|
||||||
|
)
|
||||||
|
if (is_def(isects2))
|
||||||
|
for (seg = isects2)
|
||||||
|
if (len(seg)>1 && seg[0] != seg[1]) _vnf_validate_err("FACE_ISECT", seg)
|
||||||
]),
|
]),
|
||||||
issues = concat(issues, isect_faces)
|
issues = concat(issues, isect_faces)
|
||||||
) isect_faces? issues :
|
) isect_faces? issues :
|
||||||
|
|
15
walls.scad
15
walls.scad
|
@ -18,7 +18,7 @@ include<rounding.scad>
|
||||||
// Synopsis: Makes an open cross-braced rectangular wall.
|
// Synopsis: Makes an open cross-braced rectangular wall.
|
||||||
// SynTags: Geom
|
// SynTags: Geom
|
||||||
// Topics: FDM Optimized, Walls
|
// Topics: FDM Optimized, Walls
|
||||||
// See Also: corrugated_wall(), thinning_wall(), thinning_triangle(), narrowing_strut()
|
// See Also: hex_panel(), corrugated_wall(), thinning_wall(), thinning_triangle(), narrowing_strut()
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// sparse_wall(h, l, thick, [maxang=], [strut=], [max_bridge=]) [ATTACHMENTS];
|
// sparse_wall(h, l, thick, [maxang=], [strut=], [max_bridge=]) [ATTACHMENTS];
|
||||||
|
@ -81,7 +81,7 @@ module sparse_wall(h=50, l=100, thick=4, maxang=30, strut=5, max_bridge=20, anch
|
||||||
// Synopsis: Makes an open cross-braced rectangular wall.
|
// Synopsis: Makes an open cross-braced rectangular wall.
|
||||||
// SynTags: Geom
|
// SynTags: Geom
|
||||||
// Topics: FDM Optimized, Walls
|
// Topics: FDM Optimized, Walls
|
||||||
// See Also: sparse_wall(), corrugated_wall(), thinning_wall(), thinning_triangle(), narrowing_strut()
|
// See Also: sparse_wall(), hex_panel(), corrugated_wall(), thinning_wall(), thinning_triangle(), narrowing_strut()
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// sparse_wall2d(size, [maxang=], [strut=], [max_bridge=]) [ATTACHMENTS];
|
// sparse_wall2d(size, [maxang=], [strut=], [max_bridge=]) [ATTACHMENTS];
|
||||||
|
@ -153,7 +153,7 @@ module sparse_wall2d(size=[50,100], maxang=30, strut=5, max_bridge=20, anchor=CE
|
||||||
// Synopsis: Makes an open cross-braced cuboid
|
// Synopsis: Makes an open cross-braced cuboid
|
||||||
// SynTags: Geom
|
// SynTags: Geom
|
||||||
// Topics: FDM Optimized, Walls
|
// Topics: FDM Optimized, Walls
|
||||||
// See Also: sparse_wall(), corrugated_wall(), thinning_wall(), thinning_triangle(), narrowing_strut(), cuboid()
|
// See Also: sparse_wall(), hex_panel(), corrugated_wall(), thinning_wall(), thinning_triangle(), narrowing_strut(), cuboid()
|
||||||
// Usage:
|
// Usage:
|
||||||
// sparse_cuboid(size, [dir], [maxang=], [struct=]
|
// sparse_cuboid(size, [dir], [maxang=], [struct=]
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -220,10 +220,15 @@ module sparse_cuboid(size, dir=RIGHT, strut=5, maxang=30, max_bridge=20,
|
||||||
|
|
||||||
|
|
||||||
// Module: hex_panel()
|
// Module: hex_panel()
|
||||||
|
// Synopsis: Create a hexagon braced panel of any shape
|
||||||
|
// SynTags: Geom
|
||||||
|
// Topics: FDM Optimized, Walls
|
||||||
|
// See Also: sparse_wall(), hex_panel(), corrugated_wall(), thinning_wall(), thinning_triangle(), narrowing_strut()
|
||||||
// Usage:
|
// Usage:
|
||||||
// hex_panel(shape, wall, spacing, [frame=], [bevel=], [bevel_frame=], [h=|height=|l=|length=], [anchor=], [orient=], [spin=])
|
// hex_panel(shape, wall, spacing, [frame=], [bevel=], [bevel_frame=], [h=|height=|l=|length=], [anchor=], [orient=], [spin=])
|
||||||
// Description:
|
// Description:
|
||||||
// Produces a panel with a honeycomb interior. The panel consists of a frame containing
|
// Produces a panel with a honeycomb interior that can be rectangular with optional beveling, or
|
||||||
|
// an arbitrary polygon shape without beveling. The panel consists of a frame containing
|
||||||
// a honeycob interior. The frame is laid out in the XY plane with the honeycob interior
|
// a honeycob interior. The frame is laid out in the XY plane with the honeycob interior
|
||||||
// and then extruded to the height h. The shape argument defines the outer bounderies of
|
// and then extruded to the height h. The shape argument defines the outer bounderies of
|
||||||
// the frame.
|
// the frame.
|
||||||
|
@ -246,7 +251,7 @@ module sparse_cuboid(size, dir=RIGHT, strut=5, maxang=30, max_bridge=20,
|
||||||
// shape = 3D size vector or a 2D path
|
// shape = 3D size vector or a 2D path
|
||||||
// strut = thickness of hexagonal bracing
|
// strut = thickness of hexagonal bracing
|
||||||
// spacing = center-to-center spacing of hex cells in the honeycomb.
|
// spacing = center-to-center spacing of hex cells in the honeycomb.
|
||||||
// --
|
// ---
|
||||||
// frame = width of the frame around the honeycomb. Default: same as strut
|
// frame = width of the frame around the honeycomb. Default: same as strut
|
||||||
// bevel = list of edges to bevel on rectangular case when shape is a size vector; allowed options are RIGHT, LEFT, BACK, or FRONT, or those directions with BOTTOM added. Default: []
|
// bevel = list of edges to bevel on rectangular case when shape is a size vector; allowed options are RIGHT, LEFT, BACK, or FRONT, or those directions with BOTTOM added. Default: []
|
||||||
// bevel_frame = width of the frame applied at bevels. Default: same as frame
|
// bevel_frame = width of the frame applied at bevels. Default: same as frame
|
||||||
|
|
Loading…
Reference in a new issue