diff --git a/web/app/sketcher/canvas.js b/web/app/sketcher/canvas.js
index eae4891d..a314caa3 100644
--- a/web/app/sketcher/canvas.js
+++ b/web/app/sketcher/canvas.js
@@ -31,8 +31,13 @@ TCAD.TWO.Styles = {
lineWidth : 1,
strokeStyle : "#bcffc1",
fillStyle : "#00FF00"
- }
+ },
+ BOUNDS : {
+ lineWidth : 2,
+ strokeStyle : "#fff5c3",
+ fillStyle : "#000000"
+ }
};
TCAD.TWO.utils = {};
diff --git a/web/app/sketcher/io.js b/web/app/sketcher/io.js
index 3e520a11..4ee24428 100644
--- a/web/app/sketcher/io.js
+++ b/web/app/sketcher/io.js
@@ -185,6 +185,58 @@ TCAD.IO.prototype._serializeSketch = function() {
return sketch;
};
+TCAD.IO.prototype.updateBoundary = function (boundary) {
+ if (this.boundaryLayer === undefined) {
+ this.boundaryLayer = new TCAD.TWO.Layer("bounds", TCAD.TWO.Styles.BOUNDS);
+ this.viewer.layers.push(this.boundaryLayer);
+ }
+ var edges = [];
+ var bbox = [Number.MAX_VALUE, Number.MAX_VALUE, - Number.MAX_VALUE, - Number.MAX_VALUE];
+ var flattenPolygon = function(points) {
+ var n = points.length;
+ for ( var p = n - 1, q = 0; q < n; p = q ++ ) {
+ edges.push([points[p].x, points[p].y, points[q].x, points[q].y]);
+ bbox[0] = Math.min(bbox[0], points[p].x);
+ bbox[1] = Math.min(bbox[1], points[p].y);
+ bbox[2] = Math.max(bbox[2], points[q].x);
+ bbox[3] = Math.max(bbox[3], points[q].y);
+ }
+ };
+
+ flattenPolygon(boundary.shell);
+ for (var i = 0; i < boundary.holes.length; ++i ) {
+ flattenPolygon(boundary.holes[i]);
+ }
+// if (bbox[0] < Number.MAX_VALUE && bbox[1] < Number.MAX_VALUE && -bbox[2] < Number.MAX_VALUE && -bbox[3] < Number.MAX_VALUE) {
+// this.viewer.showBounds(bbox[0], bbox[1], bbox[2], bbox[3])
+// }
+
+ for (var l = 0; l < this.viewer.layers.length; ++l) {
+ var layer = this.viewer.layers[l];
+ for (var i = 0; i < layer.objects.length; ++i) {
+ var obj = layer.objects[i];
+ if (obj.edge !== undefined) {
+ var edge = edges[obj.edge];
+ if (edge !== undefined && edge != null) {
+ obj.a.x = edge[0];
+ obj.a.y = edge[1];
+ obj.b.x = edge[2];
+ obj.b.y = edge[3];
+ edges[obj.edge] = null;
+ }
+ }
+ }
+ }
+ for (var i = 0; i < edges.length; ++i ) {
+ var edge = edges[i];
+ if (edge != null) {
+ var seg = this.viewer.addSegment(edge[0], edge[1], edge[2], edge[3], this.boundaryLayer);
+ seg.accept(function(o){o.aux = true; return true;});
+ seg.edge = i;
+ }
+ }
+};
+
TCAD.IO.prototype.parseConstr = function (c, index) {
function find(id) {
var p = index[id];
@@ -206,3 +258,12 @@ TCAD.IO.prototype.serializeConstr = function (c) {
return c.serialize();
};
+TCAD.IO.prototype.svgExport = function (c) {
+
+ //
+ //
+ //
+ //
+ //var out = "