From 0f4887abe82106c631e85f6c981a730180d38607 Mon Sep 17 00:00:00 2001 From: R4Y23N Date: Fri, 21 Sep 2012 12:16:31 +0200 Subject: [PATCH 1/2] Fixed plasm.Struct.prototype.extrude function and added plasm.Struct.prototype.boundary function --- lib/plasm.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/plasm.js b/lib/plasm.js index c53426c..66ed4af 100644 --- a/lib/plasm.js +++ b/lib/plasm.js @@ -1199,19 +1199,40 @@ */ plasm.Struct.prototype.extrude = function (hlist) { - var struct = new plasm.Struct; + var newStruct = new plasm.Struct; this.models.forEach(function (model) { - struct.models.push(model.extrude(hlist)); + newStruct.models.push(model.extrude(hlist)); }); this.structs.forEach(function (struct) { - struct.structs.push(struct.extrude(hlist)); + newStruct.structs.push(struct.extrude(hlist)); }); - return struct; + return newStruct; }; + /** + * boundary + * + * @return {plasm.Struct} boundary + * @api public + */ + + plasm.Struct.prototype.boundary = function () { + var boundary = new plasm.Struct; + + this.models.forEach(function (model) { + boundary.models.push(model.boundary()); + }); + + this.structs.forEach(function (struct) { + boundary.models.push(struct.boundary()); + }); + + return boundary; + }; + /** * SimplicialComplex * From 230bd8117b42862ab84a2e43278b0463c1b9a087 Mon Sep 17 00:00:00 2001 From: R4Y23N Date: Fri, 21 Sep 2012 16:18:39 +0200 Subject: [PATCH 2/2] Optimized STRUCT function: doesn't clone models into temp array --- lib/plasm-fun.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plasm-fun.js b/lib/plasm-fun.js index 5b321bc..c8f5586 100644 --- a/lib/plasm-fun.js +++ b/lib/plasm-fun.js @@ -191,7 +191,7 @@ !(item instanceof plasm.Struct)) { transformations = COMP2([transformations, item]); } else { - temp.push(APPLY([transformations, item]).clone()); + //temp.push(APPLY([transformations, item]).clone()); objects.push(APPLY([transformations, item])); } });