add triangle fill

This commit is contained in:
Stewart Allen 2019-05-02 21:52:54 -04:00
commit e2dc9541bb
5 changed files with 96 additions and 21 deletions

View file

@ -151,7 +151,8 @@ var gs_kiri_fdm = exports;
if (!vaseMode && spro.sliceFillSparse > 0.0) {
forSlices(0.8, 1.0, function(slice) {
slice.doSparseLayerFill({
spacing: fillSpacing,
lineWidth: sdev.nozzleSize,
spacing: fillOffset,
density: spro.sliceFillSparse,
bounds: widget.getBoundingBox(),
height: spro.sliceHeight,

View file

@ -15,12 +15,14 @@ var gs_kiri_fill = exports;
ROUND = UTIL.round,
DEG2RAD = Math.PI / 180,
FILL = self.kiri.fill = {
hex: sparseFillHexFull,
gyroid: sparseFillGyroid
hex: fillHexFull,
grid: fillGrid,
gyroid: fillGyroid,
triangle: fillTriangle
};
function sparseFillHexFull(target) {
sparseFillHex(target, true);
function fillHexFull(target) {
fillHex(target, true);
}
/**
@ -29,9 +31,9 @@ var gs_kiri_fill = exports;
* @param {Object} target
* @param {boolean} full continuous walls
*/
function sparseFillHex(target, full) {
function fillHex(target, full) {
// compute segment lengths (vert/horiz and 45)
var spacing = target.offset() / 2,
let spacing = target.offset() / 2,
vhlen = (1 - target.density()) * 4 + spacing,
anxlen = ROUND(Math.cos(30 * DEG2RAD) * vhlen, 7),
anylen = ROUND(Math.sin(30 * DEG2RAD) * vhlen, 7),
@ -92,7 +94,7 @@ var gs_kiri_fill = exports;
}
}
function sparseFillGyroid(target) {
function fillGyroid(target) {
let bounds = target.bounds();
let height = target.zHeight();
let span_x = bounds.max.x - bounds.min.x;
@ -118,4 +120,72 @@ var gs_kiri_fill = exports;
});
}
function fillGrid(target) {
let bounds = target.bounds();
let height = target.zHeight();
let span_x = bounds.max.x - bounds.min.x;
let span_y = bounds.max.y - bounds.min.y;
let density = target.density();
let tile = 1 + (1 - density) * 5;
let tile_x = span_x / tile;
let tile_y = span_y / tile;
let tile_z = 1 / tile;
let offset = target.offset() / 2;
for (let tx=0; tx<=tile_x; tx++) {
target.newline();
for (let ty=0; ty<=tile_y; ty++) {
let bx = tx * tile + bounds.min.x;
let by = ty * tile + bounds.min.y;
if ((tx + ty) % 2) {
target.emit(bx + offset, by);
target.emit(bx + tile - offset, by + tile);
} else {
target.emit(bx + tile - offset, by);
target.emit(bx + offset, by + tile);
}
}
}
}
function fillTriangle(target) {
let bounds = target.bounds();
let height = target.zHeight();
let span_x = bounds.max.x - bounds.min.x;
let span_y = bounds.max.y - bounds.min.y;
let density = target.density();
let tile = 1 + (1 - density) * 5;
let tile_x = span_x / tile;
let tile_y = span_y / tile;
let tile_z = 1 / tile;
let line_w = target.lineWidth() / 2;
let offset = target.offset();
for (let tx=0; tx<=tile_x; tx++) {
target.newline();
for (let ty=0; ty<=tile_y; ty++) {
let bx = tx * tile + bounds.min.x;
let by = ty * tile + bounds.min.y;
if ((tx + ty) % 2) {
target.emit(bx, by);
target.emit(bx + tile - offset - line_w, by + tile);
} else {
target.emit(bx + tile - offset - line_w, by);
target.emit(bx, by + tile);
}
}
}
for (let tx=0; tx<=tile_x; tx++) {
target.newline();
for (let ty=0; ty<=tile_y; ty++) {
let bx = tx * tile + bounds.min.x;
let by = ty * tile + bounds.min.y;
target.emit(bx + tile - line_w, by);
target.emit(bx + tile - line_w, by + tile);
}
}
}
})();

View file

@ -390,7 +390,9 @@ var gs_kiri_slice = exports;
opt = options || {};
slice.tops.forEach(function(top) {
if (opt.vase) top.poly = top.poly.clone(false);
if (opt.vase) {
top.poly = top.poly.clone(false);
}
// top.thinner = [];
top.traces = [];
top.inner = [];
@ -617,6 +619,7 @@ var gs_kiri_slice = exports;
line = [],
// callback passed to pluggable infill algorithm
target = {
lineWidth: function() { return options.lineWidth },
bounds: function() { return bounds },
zIndex: function() { return scope.index },
zValue: function() { return scope.z },

View file

@ -201,15 +201,11 @@ self.kiri.license = exports.LICENSE;
// --------------- (default)
settings = {
infill:[
{
name: "vase"
},
{
name: "hex"
},
{
name: "gyroid"
}
{ name: "vase" },
{ name: "hex" },
{ name: "grid" },
{ name: "gyroid" },
{ name: "triangle" }
],
// CAM only
tools:[
@ -2508,10 +2504,10 @@ self.kiri.license = exports.LICENSE;
sliceTopLayers: UC.newInput("top layers", {title:"top solid layer count", convert:UC.toInt, modes:FDM}),
process: UC.newGroup("fill", control, {modes:FDM}),
sliceFillOverlap: UC.newInput("shell overlap", {title:"overlap with shell\nas % of nozzle width\nhigher bonds better\n0.0 - 1.0", convert:UC.toFloat, bound:UC.bound(0.0,2.0), modes:FDM}),
sliceFillAngle: UC.newInput("solid angle", {title:"base angle in degrees", convert:UC.toFloat, modes:FDM}),
sliceFillSparse: UC.newInput("percentage", {title:"for infill areas\n0.0 - 1.0", convert:UC.toFloat, bound:UC.bound(0.0,1.0), modes:FDM}),
sliceFillType: UC.newSelectField("type", {modes:FDM}, "infill"),
sliceFillSparse: UC.newInput("percentage", {title:"for infill areas\n0.0 - 1.0", convert:UC.toFloat, bound:UC.bound(0.0,1.0), modes:FDM}),
sliceFillAngle: UC.newInput("solid angle", {title:"base angle in degrees", convert:UC.toFloat, modes:FDM}),
sliceFillOverlap: UC.newInput("shell overlap", {title:"overlap with shell\nas % of nozzle width\nhigher bonds better\n0.0 - 1.0", convert:UC.toFloat, bound:UC.bound(0.0,2.0), modes:FDM}),
// laser
laserOffset: UC.newInput("cut offset", {title:"millimeters\nadjust for beam width", convert:UC.toFloat, modes:LASER}),

View file

@ -187,6 +187,11 @@ button[del] {
margin: 1px;
}
.control select {
margin-bottom: 1px !important;
margin-right: 2px !important;
}
/** ******************************************************************
* ID
******************************************************************* */