mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-09-01 01:31:44 +02:00
Merge pull request #665 from adrianVmariano/master
remove debug.scad, hide affine.scad
This commit is contained in:
@@ -1666,4 +1666,76 @@ function mask2d_ogee(pattern, excess=0.01, anchor=CENTER, spin=0) =
|
||||
|
||||
|
||||
|
||||
// Section: Debugging polygons
|
||||
|
||||
// Module: debug_polygon()
|
||||
// Usage:
|
||||
// debug_polygon(points, paths, [convexity=], [size=]);
|
||||
// Description:
|
||||
// A drop-in replacement for `polygon()` that renders and labels the path points.
|
||||
// Arguments:
|
||||
// points = The array of 2D polygon vertices.
|
||||
// paths = The path connections between the vertices.
|
||||
// ---
|
||||
// convexity = The max number of walls a ray can pass through the given polygon paths.
|
||||
// size = The base size of the line and labels.
|
||||
// Example(Big2D):
|
||||
// debug_polygon(
|
||||
// points=concat(
|
||||
// regular_ngon(or=10, n=8),
|
||||
// regular_ngon(or=8, n=8)
|
||||
// ),
|
||||
// paths=[
|
||||
// [for (i=[0:7]) i],
|
||||
// [for (i=[15:-1:8]) i]
|
||||
// ]
|
||||
// );
|
||||
module debug_polygon(points, paths, convexity=2, size=1)
|
||||
{
|
||||
paths = is_undef(paths)? [[for (i=[0:1:len(points)-1]) i]] :
|
||||
is_num(paths[0])? [paths] :
|
||||
paths;
|
||||
echo(points=points);
|
||||
echo(paths=paths);
|
||||
linear_extrude(height=0.01, convexity=convexity, center=true) {
|
||||
polygon(points=points, paths=paths, convexity=convexity);
|
||||
}
|
||||
for (i = [0:1:len(points)-1]) {
|
||||
color("red") {
|
||||
up(0.2) {
|
||||
translate(points[i]) {
|
||||
linear_extrude(height=0.1, convexity=10, center=true) {
|
||||
text(text=str(i), size=size, halign="center", valign="center");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = [0:1:len(paths)-1]) {
|
||||
path = paths[j];
|
||||
translate(points[path[0]]) {
|
||||
color("cyan") up(0.1) cylinder(d=size*1.5, h=0.01, center=false, $fn=12);
|
||||
}
|
||||
translate(points[path[len(path)-1]]) {
|
||||
color("pink") up(0.11) cylinder(d=size*1.5, h=0.01, center=false, $fn=4);
|
||||
}
|
||||
for (i = [0:1:len(path)-1]) {
|
||||
midpt = (points[path[i]] + points[path[(i+1)%len(path)]])/2;
|
||||
color("blue") {
|
||||
up(0.2) {
|
||||
translate(midpt) {
|
||||
linear_extrude(height=0.1, convexity=10, center=true) {
|
||||
text(text=str(chr(65+j),i), size=size/2, halign="center", valign="center");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
Reference in New Issue
Block a user