attempt to fix flat detection and processing
This commit is contained in:
parent
0f05861b54
commit
f89953bb32
2 changed files with 10 additions and 19 deletions
|
|
@ -139,7 +139,7 @@ var gs_kiri_slicer = exports;
|
||||||
}
|
}
|
||||||
// auto-detect flats for cam faces and to avoid slicing directly on flats
|
// auto-detect flats for cam faces and to avoid slicing directly on flats
|
||||||
if (p1.z === p2.z && p2.z === p3.z && p1.z > bounds.min.z) {
|
if (p1.z === p2.z && p2.z === p3.z && p1.z > bounds.min.z) {
|
||||||
var zkey = UTIL.round(p1.z, 5),
|
var zkey = p1.z.toFixed(5),
|
||||||
area = Math.abs(UTIL.area2(p1,p2,p3)) / 2;
|
area = Math.abs(UTIL.area2(p1,p2,p3)) / 2;
|
||||||
if (!zFlat[zkey]) {
|
if (!zFlat[zkey]) {
|
||||||
zFlat[zkey] = area;
|
zFlat[zkey] = area;
|
||||||
|
|
@ -201,8 +201,7 @@ var gs_kiri_slicer = exports;
|
||||||
for (key in zFlat) {
|
for (key in zFlat) {
|
||||||
// todo make threshold for flat detection configurable
|
// todo make threshold for flat detection configurable
|
||||||
if (!zFlat.hasOwnProperty(key) || zFlat[key] < 100) continue;
|
if (!zFlat.hasOwnProperty(key) || zFlat[key] < 100) continue;
|
||||||
key = parseFloat(key) + 0.001;
|
if (!zIndexes.contains(key) && key >= zMin) zIndexes.push(parseFloat(key));
|
||||||
if (!zIndexes.contains(key) && key >= zMin) zIndexes.push(key);
|
|
||||||
}
|
}
|
||||||
// sort top down
|
// sort top down
|
||||||
zIndexes.sort(function(a,b) {
|
zIndexes.sort(function(a,b) {
|
||||||
|
|
@ -362,25 +361,20 @@ var gs_kiri_slicer = exports;
|
||||||
* @param {number} [height] optional real height (fdm)
|
* @param {number} [height] optional real height (fdm)
|
||||||
*/
|
*/
|
||||||
function sliceZ(z, height) {
|
function sliceZ(z, height) {
|
||||||
z = UTIL.round(z,5);
|
|
||||||
|
|
||||||
// avoid slicing directly on flat faces as it greatly increases
|
|
||||||
// the chances of artifacts, broken joins and excessive path walks
|
|
||||||
if (zFlat[z]) {
|
|
||||||
if (z) {
|
|
||||||
z -= 0.001;
|
|
||||||
} else {
|
|
||||||
z += 0.001;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var phash = {},
|
var phash = {},
|
||||||
lines = [],
|
lines = [],
|
||||||
|
onflat = zFlat[z.toFixed(5)] > 0,
|
||||||
slice = newSlice(z, options.view ? options.view.newGroup() : null),
|
slice = newSlice(z, options.view ? options.view.newGroup() : null),
|
||||||
bucket = bucketCount == 1 ? points : buckets[Math.floor(z * zScale)];
|
bucket = bucketCount == 1 ? points : buckets[Math.floor(z * zScale)];
|
||||||
|
|
||||||
if (!bucket) return;
|
if (!bucket) return;
|
||||||
|
|
||||||
|
if (onflat) {
|
||||||
|
// annotate slices with cam flats for finishing waterlines
|
||||||
|
if (options.cam) slice.hasFlats = true;
|
||||||
|
z += 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
// iterate over matching buckets for this z offset
|
// iterate over matching buckets for this z offset
|
||||||
for (var i = 0; i < bucket.length;) {
|
for (var i = 0; i < bucket.length;) {
|
||||||
p1 = bucket[i++];
|
p1 = bucket[i++];
|
||||||
|
|
@ -423,9 +417,6 @@ var gs_kiri_slicer = exports;
|
||||||
slice.index = slices.length;
|
slice.index = slices.length;
|
||||||
slice.lines = removeDuplicateLines(lines);
|
slice.lines = removeDuplicateLines(lines);
|
||||||
|
|
||||||
// annotate slices with cam flats for finishing waterlines
|
|
||||||
if (options.cam) slice.hasFlats = zFlat[z] > 0;
|
|
||||||
|
|
||||||
// for topo slices, we just need the raw lines
|
// for topo slices, we just need the raw lines
|
||||||
if (!topoMode) {
|
if (!topoMode) {
|
||||||
slice.groups = connectLines(slice.lines, slices.length);
|
slice.groups = connectLines(slice.lines, slices.length);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
var exports = {
|
var exports = {
|
||||||
COPYRIGHT:"Copyright (C) 2014-2018 Stewart Allen <sa@grid.space> - All Rights Reserved",
|
COPYRIGHT:"Copyright (C) 2014-2018 Stewart Allen <sa@grid.space> - All Rights Reserved",
|
||||||
LICENSE:"See the license.md file included with the source distribution",
|
LICENSE:"See the license.md file included with the source distribution",
|
||||||
VERSION:"1.2.4c"
|
VERSION:"1.2.4d"
|
||||||
};
|
};
|
||||||
if (!module) var module = {};
|
if (!module) var module = {};
|
||||||
module.exports = exports;
|
module.exports = exports;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue