Fixed error with handling clipper

no longer need to comment clipper error alerts
This commit is contained in:
casperlamboo 2015-07-06 22:59:58 +02:00
parent fee357b910
commit 151dee5ee9
3 changed files with 12 additions and 8 deletions

View File

@ -4884,8 +4884,8 @@
else ClipperLib.Clipper.Round = R2; // eg. browser.chrome || browser.firefox || browser.opera
ClipperLib.Clipper.TopX = function (edge, currentY)
{
//if (edge.Bot == edge.Curr) console.warn ("edge.Bot = edge.Curr");
//if (edge.Bot == edge.Top) console.warn ("edge.Bot = edge.Top");
//if (edge.Bot == edge.Curr) alert ("edge.Bot = edge.Curr");
//if (edge.Bot == edge.Top) alert ("edge.Bot = edge.Top");
if (currentY == edge.Top.Y)
return edge.Top.X;
return edge.Bot.X + ClipperLib.Clipper.Round(edge.Dx * (currentY - edge.Bot.Y));
@ -6596,7 +6596,7 @@
}
catch (err)
{
//console.warn(err.message);
console.warn(err.message);
}
};
// ---------------------------------

View File

@ -3,7 +3,7 @@
"bottomThickness": 0.4,
"topThickness": 0.8,
"shellThickness": 0.4,
"brimOffset": 5.0,
"brimOffset": 4.0,
"fillGridSize": 5.0,
"infillOverlap": 0.5,
"travelSpeed": 200.0,

View File

@ -32,14 +32,16 @@ D3D.Paths.prototype.setPaths = function (paths) {
D3D.Paths.prototype._clip = function (path, type) {
'use strict';
var solution = new ClipperLib.Paths();
var solution = new ClipperLib.PolyTree();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(type, solution);
return new D3D.Paths(solution, this.closed);
var paths = this.closed ? ClipperLib.Clipper.ClosedPathsFromPolyTree(solution) : ClipperLib.Clipper.OpenPathsFromPolyTree(solution);
return new D3D.Paths(paths, this.closed);
};
D3D.Paths.prototype.union = function (path) {
'use strict';
@ -236,12 +238,14 @@ D3D.Paths.prototype.draw = function (context, color) {
//context.fillText(i, point.X*2, point.Y*2);
context.beginPath();
var length = this.closed ? (shape.length + 1) : shape.length;
for (var j = 0; j < length; j ++) {
for (var j = 0; j < shape.length; j ++) {
var point = shape[j % shape.length];
context.lineTo(point.X*2, point.Y*2);
}
if (this.closed) {
context.closePath();
}
context.stroke();
}
};