cull polish lines under model
This commit is contained in:
parent
4833301cb3
commit
a26b02a4f0
3 changed files with 39 additions and 8 deletions
|
|
@ -318,6 +318,10 @@ var gs_base_point = exports;
|
|||
return BASE.newLine(np1, np2, KEYS.NONE);
|
||||
};
|
||||
|
||||
PRO.offset = function(x, y, z) {
|
||||
return newPoint(this.x + x, this.y + y, this.z + z);
|
||||
};
|
||||
|
||||
/**
|
||||
* checks if a point is inside of a polygon
|
||||
* does not check children/holes
|
||||
|
|
|
|||
|
|
@ -221,21 +221,45 @@ var gs_kiri_fdm = exports;
|
|||
|
||||
let polys = [];
|
||||
pa.forEach(p => {
|
||||
// rotate and test for self-intersection (points under model)
|
||||
p.ensureXY();
|
||||
let ox = p._aligned == 'yz' ? 0.1 : 0;
|
||||
let oy = p._aligned == 'yz' ? 0 : 0.1;
|
||||
p.forEachPoint(pt => {
|
||||
let int = p.intersections(
|
||||
pt.offset(ox,oy,0),
|
||||
pt.offset(ox*10000,oy*10000,0));
|
||||
if (int.length > 0) {
|
||||
pt._under = true;
|
||||
}
|
||||
});
|
||||
p.restoreXY();
|
||||
|
||||
let lastp = undefined;
|
||||
let poly = [];
|
||||
// look for qualifying segments
|
||||
p.forEachSegment((p1, p2) => {
|
||||
// return when both below
|
||||
// eliminate segments that projected up
|
||||
// intersect with the polygon (bottom faces)
|
||||
if (p1._under || p2._under) {
|
||||
return;
|
||||
}
|
||||
// skip when both below layer range
|
||||
if (p1.z < zb && p2.z < zb) {
|
||||
return;
|
||||
}
|
||||
// return when both above
|
||||
// skip when both above layer range
|
||||
if (p1.z > zt && p2.z > zt) {
|
||||
return;
|
||||
}
|
||||
// return when vertical
|
||||
// skip vertical
|
||||
if (p1.x === p2.x && p1.y === p2.y) {
|
||||
return;
|
||||
}
|
||||
// skip horizontal
|
||||
// if (p1.z === p2.z) {
|
||||
// return;
|
||||
// }
|
||||
// order points lowest to highest
|
||||
let swap = false;
|
||||
if (p1.z > p2.z) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ var gs_kiri_slicer = exports;
|
|||
|
||||
var slicer = self.kiri.slicer = {
|
||||
slice: slice,
|
||||
sliceWidget: sliceWidget
|
||||
sliceWidget: sliceWidget,
|
||||
connectLines: connectLines
|
||||
};
|
||||
|
||||
var KIRI = self.kiri,
|
||||
|
|
@ -489,11 +490,13 @@ var gs_kiri_slicer = exports;
|
|||
if (topoMode) {
|
||||
var lines = slice.lines, llen = lines.length, idx, line;
|
||||
// shared points causing problems
|
||||
for (idx=0; idx<llen; idx++) { line = lines[idx];
|
||||
for (idx=0; idx<llen; idx++) {
|
||||
line = lines[idx];
|
||||
line.p1 = line.p1.clone();
|
||||
line.p2 = line.p2.clone();
|
||||
}
|
||||
for (idx=0; idx<llen; idx++) { line = lines[idx];
|
||||
for (idx=0; idx<llen; idx++) {
|
||||
line = lines[idx];
|
||||
if (options.swapX) {
|
||||
line.p1.swapXZ();
|
||||
line.p2.swapXZ();
|
||||
|
|
@ -535,7 +538,7 @@ var gs_kiri_slicer = exports;
|
|||
* @param {number} [index]
|
||||
* @returns {Array}
|
||||
*/
|
||||
function connectLines(input, index) {
|
||||
function connectLines(input) {
|
||||
// map points to all other points they're connected to
|
||||
var DBUG = BASE.debug,
|
||||
CONF = BASE.config,
|
||||
|
|
@ -653,7 +656,7 @@ var gs_kiri_slicer = exports;
|
|||
closed = 0,
|
||||
open = 0;
|
||||
|
||||
paths.forEach(function(path, index) {
|
||||
paths.forEach(function(path) {
|
||||
// use longest perimeter vs longest path?
|
||||
if (!longest || path.length > longest.length) longest = path;
|
||||
if (!path.open) closed++; else open++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue