4 |
5 | thisFont=8bit_polyfont();
6 | x_shift=thisFont[0][0];
7 | y_shift=thisFont[0][1];
8 |
9 | hours=["one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];
10 |
11 | module clock_hour_words(word_offset=20.0,word_height=2.0) {
12 | for(i=[0:(len(hours)-1)]) assign( hourHandAngle=(i+1)*360/len(hours), theseIndicies=search(hours[i],thisFont[2],1,1) ) {
13 | rotate(90-hourHandAngle) translate([word_offset,0])
14 | for( j=[0:(len(theseIndicies)-1)] ) translate([j*x_shift,-y_shift/2]) {
15 | linear_extrude(height=word_height) polygon(points=thisFont[2][theseIndicies[j]][6][0],paths=thisFont[2][theseIndicies[j]][6][1]);
16 | }
17 | }
18 | }
19 |
20 | clock_hour_words(word_offset=16.0,word_height=5.0);
21 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/helpers.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 | const path = require('path')
3 | const assert = require('assert')
4 | const parser = require(path.join(__dirname, '../src/parserWrapper'))
5 |
6 | function check (filedir, testFileName) {
7 | var test = fs.readFileSync(path.join(__dirname, `${filedir}${testFileName}.scad`), 'utf8')
8 | var expected = fs.readFileSync(path.join(__dirname, `${filedir}${testFileName}.jscad`), 'utf8').replace(/\n/g, '')
9 | var actual = parser.parse(test).replace(/\n/g, '')
10 | assert.equal(actual, expected)
11 | }
12 |
13 | module.exports = {check}
14 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | test
4 |
5 |
6 |
7 |
8 | function r_from_dia(d) = d / 2;
9 |
10 | module rotcy(rot, r, h) {
11 | rotate(90, rot)
12 | cylinder(r = r, h = h, center = true);
13 | }
14 |
15 | difference() {
16 | sphere(r = r_from_dia(size));
17 | rotcy([0, 0, 0], cy_r, cy_h);
18 | rotcy([1, 0, 0], cy_r, cy_h);
19 | rotcy([0, 1, 0], cy_r, cy_h);
20 | }
21 |
22 | size = 50;
23 | hole = 25;
24 |
25 | cy_r = r_from_dia(hole);
26 | cy_h = r_from_dia(size * 2.5);
27 |
28 |
29 |
30 |
31 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/math_ops.scad:
--------------------------------------------------------------------------------
1 | echo( "Random Vector: ",rands(5,15,4,42));
2 | echo( "abs: ",abs(-9));
3 | echo( "sign: ",sign(9));
4 | echo( "sign: ",sign(-9));
5 | echo( "cos: ",cos(9));
6 | echo( "sin: ",sin(9));
7 | echo( "tan: ",tan(9));
8 | echo( "acos: ",acos(0.1));
9 | echo( "asin: ",asin(0.1));
10 | echo( "atan: ",atan(9));
11 | echo( "atan2: ",atan2(1,2));
12 |
13 | echo( "min: ",min(1,2));
14 | echo( "max: ",max(1,2));
15 | echo( "pow: ",pow(1,2));
16 | echo( "sqrt: ",sqrt(2));
17 | echo( "ln: ",ln(1));
18 |
19 | echo( "ceil: ",ceil(2.5));
20 | echo( "ceil: ",ceil(-2.5));
21 | echo( "floor: ",floor(2.5));
22 | echo( "floor: ",floor(-2.5));
23 | echo( "log: ",log(10));
24 | echo( "log: ",log(10,2));
25 | echo( "exp: ",exp(2));
26 |
27 | echo("sign");
28 | echo(sign(-5.0));
29 | echo(sign(0));
30 | echo(sign(8.0));
31 |
32 | echo("round");
33 | echo(round(2.5));// = x+1.
34 | echo(round(2.49));// = x.
35 | echo(round(-(2.5)));// = -(x+1).
36 | echo(round(-(2.49)));// = -x.
37 |
38 | echo(round(5.4));// //-> 5
39 | echo(round(5.5));// //-> 6
40 | echo(round(5.6));// //-> 6
41 |
42 | sphere();
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules.js:
--------------------------------------------------------------------------------
1 | const check = require('./helpers').check
2 |
3 | const filedir = 'modules/'
4 |
5 | exports['test modules'] = function () {
6 | check(filedir, 'modulesEx1')
7 | }
8 |
9 | exports['test modules child'] = function () {
10 | check(filedir, 'modulesChildEx1')
11 | }
12 |
13 | exports['test modules children'] = function () {
14 | check(filedir, 'modulesChildrenEx1')
15 | }
16 |
17 | exports['test modules parameters'] = function () {
18 | check(filedir, 'modulesParametersEx1')
19 | }
20 |
21 | if (module === require.main) require('test').run(exports)
22 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesChildEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.sphere({center: [0,0,0], radius: 30, resolution: 30}).translate([0,0,0]).union([CSG.sphere({center: [0,0,0], radius: 30, resolution: 30}).translate([65,0,0])]);
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesChildEx1.scad:
--------------------------------------------------------------------------------
1 | module lineup(num, space) {
2 | for (i = [0 : num-1])
3 | translate([ space*i, 0, 0 ]) child(0);
4 | }
5 |
6 | lineup(2, 65) sphere(30);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesChildrenEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.sphere({center: [0,0,0], radius: 30, resolution: 30}).scale([10,1,1]).union([CSG.cube({center: [5,5,5],radius: [5,5,5], resolution: 16}).scale([10,1,1])]).union([CSG.cylinder({start: [0,0,0], end: [0,0,50],radiusStart: 10, radiusEnd: 10, resolution: 30}).scale([10,1,1])]);
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesChildrenEx1.scad:
--------------------------------------------------------------------------------
1 | module elongate() {
2 | for (i = [0 : $children-1])
3 | scale([10 , 1, 1 ]) child(i);
4 | }
5 |
6 | elongate() { sphere(30); cube([10,10,10]); cylinder(r=10,h=50); }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,-50], end: [0,0,50],radiusStart: 10, radiusEnd: 10, resolution: 30}).translate([0,0,0]).transform(CSG.Matrix4x4.rotation([0,0,0], [1,0,0], 90));
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesEx1.scad:
--------------------------------------------------------------------------------
1 | module hole(distance, rot, size) {
2 | rotate(a = rot, v = [1, 0, 0]) {
3 | translate([0, distance, 0]) {
4 | cylinder(r = size, h = 100, center = true);
5 | }
6 | }
7 | }
8 | hole(0, 90, 10);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesParametersEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0.5,0.5,0.5],radius: [0.5,0.5,0.5], resolution: 16}).translate([0,-1,0]).setColor(1,0,0).union([(new CSG.Path2D([[0,0],[0,1],[0.5,1.5],[1,1],[1,0]],true)).innerToCAG().extrude({offset: [0, 0, 1], twistangle: 0,twiststeps: 2}).rotateX(90).rotateY(0).rotateZ(0).setColor(1,0,0).translate([2,0,0]),
5 | CSG.sphere({center: [0,0,0], radius: 0.5, resolution: 20}).translate([0.5,0.5,1]).union([CSG.cube({center: [0.5,0.5,0.5],radius: [0.5,0.5,0.5], resolution: 16})]).translate([0,-1,0]).setColor(0,1,0).translate([4,0,0]),
6 | (new CSG.Path2D([[0,0],[0,1],[0.5,1.5],[1,1],[1,0]],true)).innerToCAG().extrude({offset: [0, 0, 1], twistangle: 0,twiststeps: 2}).rotateX(90).rotateY(0).rotateZ(0).setColor(0,0,1).translate([6,0,0]),
7 | (new CSG.Path2D([[0,0],[0,1],[0.5,1.5],[1,1],[1,0]],true)).innerToCAG().extrude({offset: [0, 0, 1], twistangle: 0,twiststeps: 2}).rotateX(90).rotateY(0).rotateZ(0).setColor(0,0,0).translate([8,0,0]),
8 | CSG.sphere({center: [0,0,0], radius: 0.5, resolution: 20}).translate([0.5,0.5,1]).union([CSG.cube({center: [0.5,0.5,0.5],radius: [0.5,0.5,0.5], resolution: 16})]).translate([0,-1,0]).setColor(1,0,0).translate([10,0,0]),
9 | CSG.cube({center: [0.5,0.5,0.5],radius: [0.5,0.5,0.5], resolution: 16}).translate([0,-1,0]).setColor(0,0.5,0.5).translate([12,0,0])]);
10 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/modules/modulesParametersEx1.scad:
--------------------------------------------------------------------------------
1 | module house(roof="flat",paint=[1,0,0]){
2 | color(paint)
3 | if(roof=="flat"){
4 | translate([0,-1,0])
5 | cube();
6 | } else if(roof=="pitched"){
7 | rotate([90,0,0])
8 | linear_extrude(height=1)
9 | polygon(points=[[0,0],[0,1],[0.5,1.5],[1,1],[1,0]],paths=[ [0,1,2,3,4] ]);
10 | } else if(roof=="domical"){
11 | translate([0,-1,0])
12 | union(){
13 | translate([0.5,0.5,1]) sphere(r=0.5,$fn=20);
14 | cube();
15 | }
16 | }
17 | }
18 |
19 | union(){
20 | house();
21 | translate([2,0,0]) house("pitched");
22 | translate([4,0,0]) house("domical",[0,1,0]);
23 | translate([6,0,0]) house(roof="pitched",paint=[0,0,1]);
24 | translate([8,0,0]) house(paint=[0,0,0],roof="pitched");
25 | translate([10,0,0]) house(roof="domical");
26 | translate([12,0,0]) house(paint=[0,0.5,0.5]);
27 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids.js:
--------------------------------------------------------------------------------
1 | const check = require('./helpers').check
2 | const filedir = 'primitive_solids/'
3 |
4 | exports['test cube'] = function () {
5 | check(filedir, 'cubeEx1')
6 | check(filedir, 'cubeEx2')
7 | }
8 |
9 | exports['test sphere'] = function () {
10 | check(filedir, 'sphereEx1')
11 | check(filedir, 'sphereEx2')
12 | }
13 |
14 | exports['test cylinder'] = function () {
15 | check(filedir, 'cylinderEx1')
16 | check(filedir, 'cylinderEx2')
17 | check(filedir, 'cylinderEx3')
18 | check(filedir, 'cylinderEx5')
19 | }
20 |
21 | exports['test cylinder additional parameters'] = function () {
22 | check(filedir, 'cylinderEx4')
23 | }
24 |
25 | exports['test polyhedron'] = function () {
26 | check(filedir, 'polyhedronEx1')
27 | check(filedir, 'polyhedronEx2')
28 | }
29 |
30 | if (module === require.main) require('test').run(exports)
31 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cubeEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0.5,0.5,0.5],radius: [0.5,0.5,0.5], resolution: 16});
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cubeEx1.scad:
--------------------------------------------------------------------------------
1 | cube(size = 1, center = false);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cubeEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0,0,0],radius: [0.5,1,1.5], resolution: 16});
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cubeEx2.scad:
--------------------------------------------------------------------------------
1 | cube(size = [1,2,3], center = true);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,0], end: [0,0,10],radiusStart: 10, radiusEnd: 20, resolution: 30});
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx1.scad:
--------------------------------------------------------------------------------
1 | cylinder(h = 10, r1 = 10, r2 = 20, center = false);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,-5], end: [0,0,5],radiusStart: 20, radiusEnd: 10, resolution: 30});
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx2.scad:
--------------------------------------------------------------------------------
1 | cylinder(h = 10, r1 = 20, r2 = 10, center = true);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx3.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,0], end: [0,0,10],radiusStart: 20, radiusEnd: 20, resolution: 30});
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx3.scad:
--------------------------------------------------------------------------------
1 | cylinder(h = 10, r=20);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx4.jscad:
--------------------------------------------------------------------------------
1 | function main(){return CSG.cylinder({start: [0,0,0], end: [0,0,10],radiusStart: 20, radiusEnd: 20, resolution: 21});};
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx4.scad:
--------------------------------------------------------------------------------
1 | cylinder(h = 10, r=20, $fs=6);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx5.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,0], end: [0,0,10],radiusStart: 20, radiusEnd: 20, resolution: 100});
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/cylinderEx5.scad:
--------------------------------------------------------------------------------
1 | cylinder(h = 10, r=20, $fn=100);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/polyhedronEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.fromPolygons([new CSG.Polygon([new CSG.Vertex(new CSG.Vector3D([0,0,10])),new CSG.Vertex(new CSG.Vector3D([10,-10,0])),new CSG.Vertex(new CSG.Vector3D([10,10,0]))]),new CSG.Polygon([new CSG.Vertex(new CSG.Vector3D([0,0,10])),new CSG.Vertex(new CSG.Vector3D([-10,-10,0])),new CSG.Vertex(new CSG.Vector3D([10,-10,0]))]),new CSG.Polygon([new CSG.Vertex(new CSG.Vector3D([0,0,10])),new CSG.Vertex(new CSG.Vector3D([-10,10,0])),new CSG.Vertex(new CSG.Vector3D([-10,-10,0]))]),new CSG.Polygon([new CSG.Vertex(new CSG.Vector3D([0,0,10])),new CSG.Vertex(new CSG.Vector3D([10,10,0])),new CSG.Vertex(new CSG.Vector3D([-10,10,0]))]),new CSG.Polygon([new CSG.Vertex(new CSG.Vector3D([-10,10,0])),new CSG.Vertex(new CSG.Vector3D([10,10,0])),new CSG.Vertex(new CSG.Vector3D([10,-10,0]))]),new CSG.Polygon([new CSG.Vertex(new CSG.Vector3D([-10,10,0])),new CSG.Vertex(new CSG.Vector3D([10,-10,0])),new CSG.Vertex(new CSG.Vector3D([-10,-10,0]))])]);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/polyhedronEx1.scad:
--------------------------------------------------------------------------------
1 | polyhedron(
2 | points=[ [10,10,0],[10,-10,0],[-10,-10,0],[-10,10,0], // the four points at base
3 | [0,0,10] ], // the apex point
4 | triangles=[ [0,1,4],[1,2,4],[2,3,4],[3,0,4], // each triangle side
5 | [1,0,3],[2,1,3] ] // two triangles for square base
6 | );
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/polyhedronEx2.scad:
--------------------------------------------------------------------------------
1 | polyhedron
2 | (points = [
3 | [0, -10, 60], [0, 10, 60], [0, 10, 0], [0, -10, 0], [60, -10, 60], [60, 10, 60],
4 | [10, -10, 50], [10, 10, 50], [10, 10, 30], [10, -10, 30], [30, -10, 50], [30, 10, 50]
5 | ],
6 | triangles = [
7 | [0,3,2], [0,2,1], [4,0,5], [5,0,1], [5,2,4], [4,2,3],
8 | [6,8,9], [6,7,8], [6,10,11],[6,11,7], [10,8,11],
9 | [10,9,8], [3,0,9], [9,0,6], [10,6, 0],[0,4,10],
10 | [3,9,10], [3,10,4], [1,7,11], [1,11,5], [1,8,7],
11 | [2,8,1], [8,2,11], [5,11,2]
12 | ]
13 | );
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/sphereEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.sphere({center: [0,0,0], radius: 1, resolution: 5});
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/sphereEx1.scad:
--------------------------------------------------------------------------------
1 | sphere(r = 1);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/sphereEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.sphere({center: [0,0,0], radius: 2, resolution: 100});
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/primitive_solids/sphereEx2.scad:
--------------------------------------------------------------------------------
1 | // this will create a high resolution sphere with a 2mm radius
2 | sphere(2, $fn=100);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests.js:
--------------------------------------------------------------------------------
1 | const check = require('./helpers').check
2 | const filedir = 'submodule_tests/'
3 |
4 | exports['test transformed submodule'] = function () {
5 | check(filedir, 'transformedSubmoduleEx1')
6 | }
7 |
8 | exports['test transformed submodule with extra line'] = function () {
9 | check(filedir, 'transformedSubmoduleEx2')
10 | }
11 |
12 | exports['test transformed submodule with color mod'] = function () {
13 | check(filedir, 'transformedSubmoduleEx3')
14 | }
15 |
16 | exports['test nested submodules'] = function () {
17 | check(filedir, 'nestedSubmoduleEx1')
18 | check(filedir, 'nestedSubmoduleEx2')
19 | }
20 |
21 | if (module === require.main) require('test').run(exports)
22 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/nestedSubmoduleEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0,0,0],radius: [0.5,1,0.5], resolution: 16});
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/nestedSubmoduleEx1.scad:
--------------------------------------------------------------------------------
1 | module mycube2(a,b) {
2 | cube(size=[a, b, 1], center=true);
3 | }
4 |
5 | module mycube(a,b,c) {
6 | mycube2(a,b);
7 | }
8 |
9 | mycube(1,2,3);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/nestedSubmoduleEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0,0,0],radius: [0.5,1,1], resolution: 16});
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/nestedSubmoduleEx2.scad:
--------------------------------------------------------------------------------
1 | module mycube2(a,b) {
2 | module innercube(q1,q2){
3 | cube(size=[q1, q2, 2], center=true);
4 | }
5 | innercube(a,b);
6 | }
7 |
8 | module mycube1(a,b,c) {
9 | mycube2(a,b);
10 | }
11 |
12 | mycube1(1,2,3);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/transformedSubmoduleEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,-50], end: [0,0,50],radiusStart: 5, radiusEnd: 5, resolution: 16}).union([CSG.cube({center: [0,0,0],radius: [5,5,5], resolution: 16})]).translate([25,0,0]);
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/transformedSubmoduleEx1.scad:
--------------------------------------------------------------------------------
1 | module hole(size) {
2 | cylinder(r = size, h = 100, center = true);
3 | cube(size=[10, 10, 10], center=true);
4 | }
5 |
6 | translate([25, 0, 0]) {
7 | hole(5);
8 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/transformedSubmoduleEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,-50], end: [0,0,50],radiusStart: 5, radiusEnd: 5, resolution: 16}).union([CSG.cube({center: [0,0,0],radius: [5,5,5], resolution: 16})]).translate([25,0,0]).union([CSG.cube({center: [0,0,0],radius: [5,5,5], resolution: 16})]);
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/transformedSubmoduleEx2.scad:
--------------------------------------------------------------------------------
1 | module hole(size) {
2 | cylinder(r = size, h = 100, center = true);
3 | cube(size=[10, 10, 10], center=true);
4 | }
5 |
6 | translate([25, 0, 0]) {
7 | hole(5);
8 | }
9 |
10 | cube(size=[10, 10, 10], center=true);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/transformedSubmoduleEx3.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,-50], end: [0,0,50],radiusStart: 5, radiusEnd: 5, resolution: 16}).translate([25,0,0]).union([CSG.cube({center: [0,0,0],radius: [5,5,5], resolution: 16}).setColor(1,0,0).translate([25,0,0])]);
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/submodule_tests/transformedSubmoduleEx3.scad:
--------------------------------------------------------------------------------
1 | module hole(size) {
2 | cylinder(r = size, h = 100, center = true);
3 | }
4 |
5 | translate([25, 0, 0]) {
6 | hole(5);
7 | color("red")
8 | cube(size=[10, 10, 10], center=true);
9 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/test.scad:
--------------------------------------------------------------------------------
1 | square([20, 10]);
2 | cube(10);
3 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/testharness.js:
--------------------------------------------------------------------------------
1 | var parser = require('../src/OpenscadOpenjscadParser')
2 | var fs = require('fs')
3 |
4 | var openSCADText = fs.readFileSync(__dirname + '/test.scad', 'UTF8')
5 | var openJSCADResult = parser.parse(openSCADText)
6 |
7 | console.log(openJSCADResult)
8 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations.js:
--------------------------------------------------------------------------------
1 | const assert = require('assert')
2 | const check = require('./helpers').check
3 | const filedir = 'transformations/'
4 |
5 | exports['test scale'] = function () {
6 | check(filedir, 'scaleEx1')
7 | check(filedir, 'scaleEx2')
8 | }
9 |
10 | exports['test rotate'] = function () {
11 | check(filedir, 'rotateEx1')
12 | check(filedir, 'rotateEx2')
13 | }
14 |
15 | exports['test translate'] = function () {
16 | check(filedir, 'translateEx1')
17 | }
18 |
19 | exports['test mirror'] = function () {
20 | check(filedir, 'mirrorEx1')
21 | }
22 |
23 | exports['test multmatrix'] = function () {
24 | check(filedir, 'multmatrixEx1')
25 | check(filedir, 'multmatrixEx2')
26 | }
27 |
28 | exports['test color'] = function () {
29 | check(filedir, 'colorEx1')
30 | check(filedir, 'colorEx1')
31 | }
32 |
33 | /*exports['test minkowski'] = function () {
34 | // todo
35 | //assert.ok(false)
36 | }
37 |
38 | exports['test hull'] = function () {
39 | // todo
40 | //assert.ok(false)
41 | }*/
42 |
43 | if (module === require.main) require('test').run(exports)
44 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/colorEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [5,5,5],radius: [5,5,5], resolution: 16}).setColor(0.5019607843137255,0,0);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/colorEx1.scad:
--------------------------------------------------------------------------------
1 | color([ 128/255, 0/255, 0/255 ])
2 | cube(size=[10,10,10],center=false);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/colorEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.sphere({center: [0,0,0], radius: 5, resolution: 16}).setColor(1,0,0);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/colorEx2.scad:
--------------------------------------------------------------------------------
1 | color("red") sphere(5);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/mirrorEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [5,5,5],radius: [5,5,5], resolution: 16}).translate([5,0,-5]).mirrored(CSG.Plane.fromNormalAndPoint([0,1,0], [0,0,0]));
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/mirrorEx1.scad:
--------------------------------------------------------------------------------
1 | mirror([ 0, 1, 0 ])
2 | translate([5, 0, -5])
3 | cube(size=[10, 10, 10], center=false);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/multmatrixEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,0], end: [0,0,3],radiusStart: 5, radiusEnd: 5, resolution: 16}).transform(new CSG.Matrix4x4( [1,0,0,0,0,1,0,0,0,0,1,0,10,10,10,1] ));
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/multmatrixEx1.scad:
--------------------------------------------------------------------------------
1 | multmatrix(m = [ [1, 0, 0, 10],
2 | [0, 1, 0, 10],
3 | [0, 0, 1, 10],
4 | [0, 0, 0, 1]
5 | ]) cylinder(3,5,5);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/multmatrixEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cylinder({start: [0,0,0], end: [0,0,10],radiusStart: 10, radiusEnd: 10, resolution: 30}).union([CSG.cube({center: [5,5,5],radius: [5,5,5], resolution: 16})]).transform(new CSG.Matrix4x4( [0.7071067811865476,0.7071067811865475,0,0,-0.7071067811865475,0.7071067811865476,0,0,0,0,1,0,10,20,0,1] ));
5 | };
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/multmatrixEx2.scad:
--------------------------------------------------------------------------------
1 | angle=45;
2 | multmatrix(m = [ [cos(angle), -sin(angle), 0, 10],
3 | [sin(angle), cos(angle), 0, 20],
4 | [0, 0, 1, 0],
5 | [0, 0, 0, 1]
6 | ]) union() {
7 | cylinder(r=10.0,h=10,center=false);
8 | cube(size=[10,10,10],center=false);
9 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/rotateEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0,0,0],radius: [5,5,5], resolution: 16}).rotateX(0).rotateY(45).rotateZ(0);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/rotateEx1.scad:
--------------------------------------------------------------------------------
1 | rotate(a=[0,45,0]) {
2 | cube(size=[10, 10, 10], center=true);
3 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/rotateEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [5,5,5],radius: [5,5,5], resolution: 16}).transform(CSG.Matrix4x4.rotation([0,0,0], [1,1,0], 45));
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/rotateEx2.scad:
--------------------------------------------------------------------------------
1 | rotate(a=45, v=[1,1,0]) {
2 | cube(size=[10, 10, 10], center=false);
3 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/scaleEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0,0,0],radius: [5,5,5], resolution: 16}).scale([2,2,2]);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/scaleEx1.scad:
--------------------------------------------------------------------------------
1 | scale(v = [2,2,2]) {
2 | cube(size=[10, 10, 10], center=true);
3 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/scaleEx2.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [0,0,0],radius: [5,5,5], resolution: 16}).scale([2,2,2]);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/scaleEx2.scad:
--------------------------------------------------------------------------------
1 | scale(v = [2,2,2])
2 | cube(size=[10, 10, 10], center=true);
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/translateEx1.jscad:
--------------------------------------------------------------------------------
1 | function main(){
2 |
3 |
4 | return CSG.cube({center: [5,5,5],radius: [5,5,5], resolution: 16}).translate([5,0,-5]);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/transformations/translateEx1.scad:
--------------------------------------------------------------------------------
1 | translate(v = [5, 0, -5]) {
2 | cube(size=[10, 10, 10], center=false);
3 | }
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/undef_tests.scad:
--------------------------------------------------------------------------------
1 | echo("*", 3*undef);
2 | echo("!", !undef);
3 | echo("/", 3/undef);
4 | echo("+", 3+undef);
5 | echo("-", 3-undef);
6 | echo("&&", undef&&3);
7 | echo("&&", 3&&undef);
8 | echo("||", undef||3);
9 | echo("||", 3||undef);
10 | echo("%", 3%undef);
11 | echo("<", 3", 3>undef);
15 | echo(">=", 3>=undef);
16 | echo("==", 3==undef);
17 | echo("!=", 3==undef);
18 |
19 | echo( "abs: ",abs(undef));
20 | echo( "sign: ",sign(undef));
21 | echo( "cos: ",cos(undef));
22 | echo( "sin: ",sin(undef));
23 | echo( "tan: ",tan(undef));
24 | echo( "acos: ",acos(undef));
25 | echo( "asin: ",asin(undef));
26 | echo( "atan: ",atan(undef));
27 | echo( "atan2: ",atan2(1,undef));
28 | echo( "atan2: ",atan2(undef,2));
29 |
30 | echo( "min: ",min(undef,2));
31 | echo( "max: ",max(undef,2));
32 | echo( "max: ",max(undef,undef));
33 | echo( "pow: ",pow(undef,2));
34 | echo( "sqrt: ",sqrt(undef));
35 | echo( "ln: ",ln(undef));
36 |
37 | echo( "ceil: ",ceil(undef));
38 | echo( "floor: ",floor(undef));
39 | echo( "log: ",log(undef));
40 | echo( "log: ",log(undef,2));
41 | echo( "log: ",log(10,undef));
42 | echo( "exp: ",exp(undef));
43 |
44 | echo("sign", sign(undef));
45 | echo("round", round(undef));
46 |
47 |
48 | echo("str", str(undef));
49 | echo("len", len(undef));
50 |
51 |
52 | sphere();
53 |
--------------------------------------------------------------------------------
/packages/scad-deserializer/tests/vector_matrix_math.scad:
--------------------------------------------------------------------------------
1 |
2 | matrix_3x3 = [[10,20,30],[10,20,30],[10,20,30]];
3 | vector = [2,0,0];
4 | matrix_3x2 = [[1,0,0],[1,0,0]];
5 |
6 | group0 = ["3x3matrix","vector","number","3x2matrix"];
7 | group1 = [ matrix_3x3, vector, 2, matrix_3x2];
8 |
9 | function multiply(a,b) = a * b;
10 | function divide(a,b) = a / b;
11 | function add(a,b) = a + b;
12 | function minus(a,b) = a - b;
13 | function modulus(a,b) = a % b;
14 |
15 | function lt(a,b) = a < b;
16 | function lte(a,b) = a <= b;
17 | function eq(a,b) = a == b;
18 | function neq(a,b) = a != b;
19 | function gt(a,b) = a > b;
20 | function gte(a,b) = a >= b;
21 |
22 | group1_len = len(group1);
23 | for (i = [0:group1_len-1]){
24 | for (j = [0:group1_len-1]){
25 | echo(str(group0[i]," * ",group0[j], " = "),multiply(group1[i],group1[j]));
26 | echo(str(group0[i]," / ",group0[j], " = "),divide(group1[i],group1[j]));
27 | echo(str(group0[i]," + ",group0[j], " = "),add(group1[i],group1[j]));
28 | echo(str(group0[i]," - ",group0[j], " = "),minus(group1[i],group1[j]));
29 | echo(str(group0[i]," % ",group0[j], " = "),modulus(group1[i],group1[j]));
30 | echo(str(group0[i]," < ",group0[j], " = "),lt(group1[i],group1[j]));
31 | echo(str(group0[i]," <= ",group0[j], " = "),lte(group1[i],group1[j]));
32 | echo(str(group0[i]," == ",group0[j], " = "),eq(group1[i],group1[j]));
33 | echo(str(group0[i]," != ",group0[j], " = "),neq(group1[i],group1[j]));
34 | echo(str(group0[i]," > ",group0[j], " = "),gt(group1[i],group1[j]));
35 | echo(str(group0[i]," >= ",group0[j], " = "),gte(group1[i],group1[j]));
36 | }
37 | }
38 | echo("----");
39 | echo("!");
40 | echo("! matrix ", !matrix_3x3);
41 | echo("! vector ", !vector);
42 | echo("----");
43 |
44 | echo("?:");
45 | echo("?: matrix ", matrix_3x3?true:false);
46 | echo("?: vextor ", vector?true:false);
47 | echo("----");
48 |
49 | cube();
--------------------------------------------------------------------------------
/packages/stl-deserializer/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/packages/stl-deserializer/README.md:
--------------------------------------------------------------------------------
1 | ## @jscad/stl-deserializer
2 |
3 | > stl deserializer for the jscad project
4 |
5 | [](https://badge.fury.io/js/%40jscad%2Fstl-deserializer)
6 | [](https://travis-ci.org/jscad/stl-deserializer)
7 |
8 | ## Overview
9 |
10 | This deserializer converts raw stl data to jscad code (that can be evaluated to CSG/CAG).
11 |
12 | ## Table of Contents
13 |
14 | - [Installation](#installation)
15 | - [Usage](#usage)
16 | - [Contribute](#contribute)
17 | - [License](#license)
18 |
19 |
20 | ## Installation
21 |
22 | ```
23 | npm install @jscad/stl-deserializer
24 | ```
25 |
26 | ## Usage
27 |
28 |
29 | ```javascript
30 | const stlDeSerializer = require('@jscad/stl-deserializer')
31 |
32 | const rawData = fs.readFileSync('PATH/TO/file.stl')
33 | const csgData = stlDeSerializer.deserialize(rawData, undefined, {output: 'csg'})
34 |
35 | ```
36 |
37 |
38 | ## Contribute
39 |
40 | For questions about the API, please contact the [User Group](https://plus.google.com/communities/114958480887231067224)
41 |
42 | PRs accepted.
43 |
44 | Small Note: If editing this README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
45 |
46 |
47 | ## License
48 |
49 | [The MIT License (MIT)](./LICENSE)
50 | (unless specified otherwise)
51 |
--------------------------------------------------------------------------------
/packages/stl-deserializer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@jscad/stl-deserializer",
3 | "version": "1.0.0-alpha.d0fb3056",
4 | "description": "Stl deserializer for jscad project",
5 | "repository": "https://github.com/jscad/io",
6 | "main": "index.js",
7 | "scripts": {
8 | "test": "ava './test/test.js' --verbose --timeout 10000",
9 | "release-patch": "git checkout master && npm version patch && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
10 | "release-minor": "git checkout master && npm version minor && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
11 | "release-major": "git checkout master && npm version major && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags "
12 | },
13 | "contributors": [
14 | {
15 | "name": "Rene K. Mueller",
16 | "url": "http://renekmueller.com"
17 | },
18 | {
19 | "name": "z3dev",
20 | "url": "http://www.z3d.jp"
21 | },
22 | {
23 | "name": "Mark 'kaosat-dev' Moissette",
24 | "url": "http://kaosat.net"
25 | }
26 | ],
27 | "keywords": [
28 | "openjscad",
29 | "jscad",
30 | "csg",
31 | "deserializer",
32 | "stl"
33 | ],
34 | "license": "MIT",
35 | "dependencies": {
36 | "@jscad/csg": "0.7.0",
37 | "@jscad/io-utils": "^1.0.0-alpha.d0fb3056"
38 | },
39 | "devDependencies": {
40 | "ava": "^0.25.0"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/packages/stl-deserializer/vt2jscad.js:
--------------------------------------------------------------------------------
1 | // positions, triangles, normals and colors
2 | function vt2jscad (positions, triangles, normals, colors) {
3 | let src = ''
4 | src += 'polyhedron({ points: [\n '
5 | for (let i = 0, j = 0; i < positions.length; i++) {
6 | if (j++) src += ',\n '
7 | src += '[' + positions[i] + ']' // .join(", ");
8 | }
9 | src += '],\n polygons: [\n '
10 | for (let i = 0, j = 0; i < triangles.length; i++) {
11 | if (j++) src += ',\n '
12 | src += '[' + triangles[i] + ']' // .join(', ');
13 | }
14 | if (colors && triangles.length === colors.length) {
15 | src += '],\n\tcolors: [\n '
16 | for (let i = 0, j = 0; i < colors.length; i++) {
17 | if (j++) src += ',\n '
18 | src += '[' + colors[i] + ']' // .join(', ');
19 | }
20 | }
21 | src += '] })\n'
22 | return src
23 | }
24 |
25 | module.exports = {
26 | vt2jscad
27 | }
28 |
--------------------------------------------------------------------------------
/packages/stl-serializer/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/packages/stl-serializer/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 |
7 | # [0.2.0](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.1.3...@jscad/stl-serializer@0.2.0) (2018-11-25)
8 |
9 |
10 |
11 | ## [0.1.3](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.1.2...@jscad/stl-serializer@0.1.3) (2018-09-02)
12 |
13 |
14 | ### Bug Fixes
15 |
16 | * **svg deserializer:** fixed svg-deserializer to work with Inkscape files ([#72](https://github.com/jscad/io/issues/72)) ([f35ea5e](https://github.com/jscad/io/commit/f35ea5e))
17 |
18 |
19 |
20 |
21 |
22 | ## [0.1.2](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.1.1...@jscad/stl-serializer@0.1.2) (2018-03-15)
23 |
24 |
25 |
26 |
27 | **Note:** Version bump only for package @jscad/stl-serializer
28 |
29 |
30 | ## [0.1.1](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.1.0...@jscad/stl-serializer@0.1.1) (2017-12-14)
31 |
32 |
33 |
34 |
35 | **Note:** Version bump only for package @jscad/stl-serializer
36 |
37 |
38 | # [0.1.0](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.0.6...@jscad/stl-serializer@0.1.0) (2017-11-29)
39 |
40 |
41 | ### Features
42 |
43 | * add support for a status callback for de/serialization progress ([#49](https://github.com/jscad/io/issues/49)) ([f457cdb](https://github.com/jscad/io/commit/f457cdb))
44 |
45 |
46 |
47 |
48 |
49 | ## [0.0.6](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.0.5...@jscad/stl-serializer@0.0.6) (2017-11-04)
50 |
51 |
52 |
53 |
54 | **Note:** Version bump only for package @jscad/stl-serializer
55 |
56 |
57 | ## [0.0.5](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.0.4...@jscad/stl-serializer@0.0.5) (2017-10-30)
58 |
59 |
60 |
61 |
62 | **Note:** Version bump only for package @jscad/stl-serializer
63 |
64 |
65 | ## [0.0.4](https://github.com/jscad/io/compare/@jscad/stl-serializer@0.0.3...@jscad/stl-serializer@0.0.4) (2017-10-10)
66 |
67 |
68 |
69 |
70 | **Note:** Version bump only for package @jscad/stl-serializer
71 |
72 |
73 | ## 0.0.3 (2017-10-10)
74 |
75 |
76 |
77 |
78 | **Note:** Version bump only for package @jscad/stl-serializer
79 |
--------------------------------------------------------------------------------
/packages/stl-serializer/CSGToStla.js:
--------------------------------------------------------------------------------
1 | const { ensureManifoldness } = require('@jscad/io-utils')
2 | const {isCSG} = require('@jscad/csg')
3 |
4 | // objects must be an array of CSG objects (with polygons)
5 | const serializeText = (objects, options) => {
6 | options.statusCallback && options.statusCallback({progress: 0})
7 |
8 | let result = `solid JSCAD
9 | ${convertToStl(objects, options)}
10 | endsolid JSCAD
11 | `
12 | options.statusCallback && options.statusCallback({progress: 100})
13 | return [result]
14 | }
15 |
16 | const convertToStl = (objects, options) => {
17 | let result = []
18 | objects.forEach(function (object, i) {
19 | result.push(convertToFacets(object, options))
20 | options.statusCallback && options.statusCallback({progress: 100 * i / objects.length})
21 | })
22 | return result.join('\n')
23 | }
24 |
25 | const convertToFacets = (object, options) => {
26 | let result = []
27 | object.polygons.forEach(function (p, i) {
28 | result.push(convertToFacet(p))
29 | })
30 | return result.join('\n')
31 | }
32 |
33 | const vector3DtoStlString = (v) => {
34 | return `${v._x} ${v._y} ${v._z}`
35 | }
36 |
37 | const vertextoStlString = (vertex) => {
38 | return `vertex ${vector3DtoStlString(vertex.pos)}`
39 | }
40 |
41 | const convertToFacet = (polygon) => {
42 | let result = []
43 | if (polygon.vertices.length >= 3) {
44 | // STL requires triangular polygons. If our polygon has more vertices, create multiple triangles:
45 | let firstVertexStl = vertextoStlString(polygon.vertices[0])
46 | for (let i = 0; i < polygon.vertices.length - 2; i++) {
47 | let facet = `facet normal ${vector3DtoStlString(polygon.plane.normal)}
48 | outer loop
49 | ${firstVertexStl}
50 | ${vertextoStlString(polygon.vertices[i + 1])}
51 | ${vertextoStlString(polygon.vertices[i + 2])}
52 | endloop
53 | endfacet`
54 | result.push(facet)
55 | }
56 | }
57 | return result.join('\n')
58 | }
59 |
60 | module.exports = {
61 | serializeText
62 | }
63 |
--------------------------------------------------------------------------------
/packages/stl-serializer/README.md:
--------------------------------------------------------------------------------
1 | ## @jscad/stl-serializer
2 |
3 | > stl serializer for the jscad project (from CSG)
4 |
5 | [](https://badge.fury.io/js/%40jscad%2Fstl-serializer)
6 | [](https://travis-ci.org/jscad/stl-serializer)
7 |
8 | ## Overview
9 |
10 | This serializer outputs a 'blobable' array of data (from a CSG object)
11 | ie an array that can either be passed directly to a Blob (`new Blob(blobable)`)
12 | or converted to a Node.js buffer.
13 |
14 |
15 | ## Table of Contents
16 |
17 | - [Installation](#installation)
18 | - [Usage](#usage)
19 | - [Contribute](#contribute)
20 | - [License](#license)
21 |
22 |
23 | ## Installation
24 |
25 | ```
26 | npm install @jscad/stl-serializer
27 | ```
28 |
29 | ## Usage
30 |
31 |
32 | ```javascript
33 | const stlSerializer = require('@jscad/stl-serializer')
34 |
35 | const rawData = stlSerializer.serialize(CSGObject)
36 |
37 | //in browser (with browserify etc)
38 | const blob = new Blob(rawData)
39 |
40 | ```
41 |
42 |
43 | ## Contribute
44 |
45 | For questions about the API, please contact the [User Group](https://plus.google.com/communities/114958480887231067224)
46 |
47 | PRs accepted.
48 |
49 | Small Note: If editing this README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
50 |
51 |
52 | ## License
53 |
54 | [The MIT License (MIT)](./LICENSE)
55 | (unless specified otherwise)
56 |
--------------------------------------------------------------------------------
/packages/stl-serializer/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | JSCAD Object to STL Format Serialization
3 |
4 | ## License
5 |
6 | Copyright (c) 2018 JSCAD Organization https://github.com/jscad
7 |
8 | All code released under MIT license
9 |
10 | Notes:
11 | 1) CAG conversion to:
12 | none
13 | 2) CSG conversion to:
14 | STL mesh
15 | 3) Path2D conversion to:
16 | none
17 | */
18 |
19 | const {serializeBinary} = require('./CSGToStlb')
20 | const {serializeText} = require('./CSGToStla')
21 |
22 | const {ensureManifoldness} = require('@jscad/io-utils')
23 | const {toArray} = require('@jscad/io-utils/arrays')
24 | const {isCSG} = require('@jscad/csg')
25 |
26 | const mimeType = 'application/sla'
27 |
28 | const serialize = (...params) => {
29 | let options = {}
30 | let objects
31 | if (params.length === 0) {
32 | throw new Error('no arguments supplied to serialize function !')
33 | } else if (params.length === 1) {
34 | // assumed to be object(s)
35 | objects = Array.isArray(params[0]) ? params[0] : params
36 | } else if (params.length > 1) {
37 | options = params[0]
38 | objects = params[1]
39 | }
40 | // make sure we always deal with arrays of objects as inputs
41 | objects = toArray(objects)
42 |
43 | const defaults = {
44 | binary: true,
45 | statusCallback: null
46 | }
47 | options = Object.assign({}, defaults, options)
48 |
49 | // only use valid CSG objects
50 | let csgs = []
51 | objects.forEach(function (object, i) {
52 | if (isCSG(object) & object.polygons.length > 0) {
53 | csgs.push(ensureManifoldness(object))
54 | }
55 | })
56 | return options.binary ? serializeBinary(csgs, options) : serializeText(csgs, options)
57 | }
58 |
59 | module.exports = {
60 | mimeType,
61 | serialize
62 | }
63 |
--------------------------------------------------------------------------------
/packages/stl-serializer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@jscad/stl-serializer",
3 | "version": "1.0.0-alpha.d0fb3056",
4 | "description": "Stl serializer for jscad project",
5 | "repository": "https://github.com/jscad/io",
6 | "main": "index.js",
7 | "scripts": {
8 | "test": "ava './test.js' --verbose --timeout 10000",
9 | "release-patch": "git checkout master && npm version patch && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
10 | "release-minor": "git checkout master && npm version minor && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
11 | "release-major": "git checkout master && npm version major && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags "
12 | },
13 | "contributors": [
14 | {
15 | "name": "Rene K. Mueller",
16 | "url": "http://renekmueller.com"
17 | },
18 | {
19 | "name": "z3dev",
20 | "url": "http://www.z3d.jp"
21 | },
22 | {
23 | "name": "Mark 'kaosat-dev' Moissette",
24 | "url": "http://kaosat.net"
25 | }
26 | ],
27 | "keywords": [
28 | "openjscad",
29 | "jscad",
30 | "csg",
31 | "serializer",
32 | "stl"
33 | ],
34 | "license": "MIT",
35 | "dependencies": {
36 | "@jscad/csg": "0.7.0",
37 | "@jscad/io-utils": "^1.0.0-alpha.d0fb3056"
38 | },
39 | "devDependencies": {
40 | "ava": "^0.25.0"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/packages/svg-deserializer/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/packages/svg-deserializer/README.md:
--------------------------------------------------------------------------------
1 | ## @jscad/svg-deserializer
2 |
3 | > svg deserializer for the jscad project
4 |
5 | [](https://badge.fury.io/js/%40jscad%2Fsvg-deserializer)
6 | [](https://travis-ci.org/jscad/svg-deserializer)
7 |
8 | ## Overview
9 |
10 | This deserializer converts raw svg data to jscad code (that can be evaluated to CSG/CAG).
11 |
12 | ## Table of Contents
13 |
14 | - [Installation](#installation)
15 | - [Usage](#usage)
16 | - [Contribute](#contribute)
17 | - [Acknowledgements](#acknowledgements)
18 | - [Sponsors](#sponsors)
19 | - [License](#license)
20 |
21 |
22 | ## Installation
23 |
24 | ```
25 | npm install @jscad/svg-deserializer
26 | ```
27 |
28 | ## Usage
29 |
30 |
31 | ```javascript
32 | const svgDeSerializer = require('@jscad/svg-deserializer').deserialize
33 |
34 | const rawData = fs.readFileSync('PATH/TO/file.svg')
35 | const cagData = svgDeSerializer.deserialize(rawData, undefined, {output: 'csg'})
36 |
37 | ```
38 |
39 |
40 | ## Contribute
41 |
42 | For questions about the API, please contact the [User Group](https://plus.google.com/communities/114958480887231067224)
43 |
44 | PRs accepted.
45 |
46 | Small Note: If editing this README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
47 |
48 | ## Acknowledgements
49 |
50 | OpenJSCAD and its sub components are built upon great open source work, contribution & modules.
51 |
52 | ## Sponsors
53 |
54 | * The upgrades (direct CSG output from this deserializer) and refactoring have been very kindly sponsored by [Copenhagen Fabrication / Stykka](https://www.stykka.com/)
55 |
56 | ## License
57 |
58 | [The MIT License (MIT)](./LICENSE)
59 | (unless specified otherwise)
60 |
--------------------------------------------------------------------------------
/packages/svg-deserializer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@jscad/svg-deserializer",
3 | "version": "1.0.0-alpha.d0fb3056",
4 | "description": "Svg deserializer for jscad project",
5 | "repository": "https://github.com/jscad/io",
6 | "main": "index.js",
7 | "scripts": {
8 | "test": "ava './test.js'",
9 | "release-patch": "git checkout master && npm version patch && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
10 | "release-minor": "git checkout master && npm version minor && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
11 | "release-major": "git checkout master && npm version major && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags "
12 | },
13 | "contributors": [
14 | {
15 | "name": "Rene K. Mueller",
16 | "url": "http://renekmueller.com"
17 | },
18 | {
19 | "name": "z3dev",
20 | "url": "http://www.z3d.jp"
21 | },
22 | {
23 | "name": "Mark 'kaosat-dev' Moissette",
24 | "url": "http://kaosat.net"
25 | }
26 | ],
27 | "keywords": [
28 | "openjscad",
29 | "jscad",
30 | "csg",
31 | "deserializer",
32 | "svg"
33 | ],
34 | "license": "MIT",
35 | "dependencies": {
36 | "@jscad/csg": "0.7.0",
37 | "sax": "1.2.4"
38 | },
39 | "devDependencies": {
40 | "ava": "^0.25.0"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/packages/svg-serializer/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/packages/svg-serializer/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 |
7 | # [0.2.0](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.1.3...@jscad/svg-serializer@0.2.0) (2018-11-25)
8 |
9 |
10 |
11 |
12 | ## [0.1.3](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.1.2...@jscad/svg-serializer@0.1.3) (2018-09-02)
13 |
14 |
15 | ### Bug Fixes
16 |
17 | * **svg deserializer:** fixed svg-deserializer to work with Inkscape files ([#72](https://github.com/jscad/io/issues/72)) ([f35ea5e](https://github.com/jscad/io/commit/f35ea5e))
18 |
19 |
20 |
21 |
22 |
23 | ## [0.1.2](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.1.1...@jscad/svg-serializer@0.1.2) (2018-04-01)
24 |
25 |
26 | ### Bug Fixes
27 |
28 | * **svg-serializer:** return array instead of single item ([#60](https://github.com/jscad/io/issues/60)) ([28570a9](https://github.com/jscad/io/commit/28570a9))
29 |
30 |
31 |
32 |
33 |
34 | ## [0.1.1](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.1.0...@jscad/svg-serializer@0.1.1) (2017-12-14)
35 |
36 |
37 |
38 |
39 | **Note:** Version bump only for package @jscad/svg-serializer
40 |
41 |
42 | # [0.1.0](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.0.5...@jscad/svg-serializer@0.1.0) (2017-11-29)
43 |
44 |
45 | ### Features
46 |
47 | * add support for a status callback for de/serialization progress ([#49](https://github.com/jscad/io/issues/49)) ([f457cdb](https://github.com/jscad/io/commit/f457cdb))
48 |
49 |
50 |
51 |
52 |
53 | ## [0.0.5](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.0.4...@jscad/svg-serializer@0.0.5) (2017-11-20)
54 |
55 |
56 |
57 |
58 | **Note:** Version bump only for package @jscad/svg-serializer
59 |
60 |
61 | ## [0.0.4](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.0.3...@jscad/svg-serializer@0.0.4) (2017-11-04)
62 |
63 |
64 |
65 |
66 | **Note:** Version bump only for package @jscad/svg-serializer
67 |
68 |
69 | ## [0.0.3](https://github.com/jscad/io/compare/@jscad/svg-serializer@0.0.2...@jscad/svg-serializer@0.0.3) (2017-10-10)
70 |
71 |
72 |
73 |
74 | **Note:** Version bump only for package @jscad/svg-serializer
75 |
76 |
77 | ## 0.0.2 (2017-10-10)
78 |
79 |
80 |
81 |
82 | **Note:** Version bump only for package @jscad/svg-serializer
83 |
--------------------------------------------------------------------------------
/packages/svg-serializer/README.md:
--------------------------------------------------------------------------------
1 | ## @jscad/svg-serializer
2 |
3 | > svg serializer for the jscad project (from CSG)
4 |
5 | [](https://badge.fury.io/js/%40jscad%2Fsvg-serializer)
6 | [](https://travis-ci.org/jscad/svg-serializer)
7 |
8 | ## Overview
9 |
10 | This serializer outputs a 'blobable' array of data (from a CAG object)
11 | ie an array that can either be passed directly to a Blob (`new Blob(blobable)`)
12 | or converted to a Node.js buffer.
13 |
14 |
15 | ## Table of Contents
16 |
17 | - [Installation](#installation)
18 | - [Usage](#usage)
19 | - [Contribute](#contribute)
20 | - [License](#license)
21 |
22 |
23 | ## Installation
24 |
25 | ```
26 | npm install @jscad/svg-serializer
27 | ```
28 |
29 | ## Usage
30 |
31 |
32 | ```javascript
33 | const svgSerializer = require('@jscad/svg-serializer')
34 |
35 | const rawData = svgSerializer.serialize(CAGObject)
36 |
37 | //in browser (with browserify etc)
38 | const blob = new Blob(rawData)
39 |
40 | ```
41 |
42 |
43 | ## Contribute
44 |
45 | For questions about the API, please contact the [User Group](https://plus.google.com/communities/114958480887231067224)
46 |
47 | PRs accepted.
48 |
49 | Small Note: If editing this README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
50 |
51 |
52 | ## License
53 |
54 | [The MIT License (MIT)](./LICENSE)
55 | (unless specified otherwise)
56 |
--------------------------------------------------------------------------------
/packages/svg-serializer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@jscad/svg-serializer",
3 | "version": "1.0.0-alpha.d0fb3056",
4 | "description": "Svg serializer for jscad project",
5 | "repository": "https://github.com/jscad/io",
6 | "main": "index.js",
7 | "scripts": {
8 | "test": "ava './test.js' --verbose --timeout 10000",
9 | "release-patch": "git checkout master && npm version patch && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
10 | "release-minor": "git checkout master && npm version minor && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
11 | "release-major": "git checkout master && npm version major && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags "
12 | },
13 | "contributors": [
14 | {
15 | "name": "Rene K. Mueller",
16 | "url": "http://renekmueller.com"
17 | },
18 | {
19 | "name": "z3dev",
20 | "url": "http://www.z3d.jp"
21 | },
22 | {
23 | "name": "Mark 'kaosat-dev' Moissette",
24 | "url": "http://kaosat.net"
25 | }
26 | ],
27 | "keywords": [
28 | "openjscad",
29 | "jscad",
30 | "csg",
31 | "serializer",
32 | "svg"
33 | ],
34 | "license": "MIT",
35 | "dependencies": {
36 | "@jscad/csg": "0.7.0",
37 | "@jscad/io-utils": "^1.0.0-alpha.d0fb3056",
38 | "onml": "^0.4.1"
39 | },
40 | "devDependencies": {
41 | "ava": "^0.25.0"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/packages/x3d-serializer/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/packages/x3d-serializer/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 |
7 | # [0.2.0](https://github.com/jscad/io/compare/@jscad/x3d-serializer@0.1.2...@jscad/x3d-serializer@0.2.0) (2018-11-25)
8 |
9 |
10 |
11 |
12 | ## [0.1.2](https://github.com/jscad/io/compare/@jscad/x3d-serializer@0.1.1...@jscad/x3d-serializer@0.1.2) (2018-09-02)
13 |
14 |
15 | ### Bug Fixes
16 |
17 | * **svg deserializer:** fixed svg-deserializer to work with Inkscape files ([#72](https://github.com/jscad/io/issues/72)) ([f35ea5e](https://github.com/jscad/io/commit/f35ea5e))
18 |
19 |
20 |
21 |
22 |
23 | ## [0.1.1](https://github.com/jscad/io/compare/@jscad/x3d-serializer@0.1.0...@jscad/x3d-serializer@0.1.1) (2017-12-14)
24 |
25 |
26 |
27 |
28 | **Note:** Version bump only for package @jscad/x3d-serializer
29 |
30 |
31 | # [0.1.0](https://github.com/jscad/io/compare/@jscad/x3d-serializer@0.0.6...@jscad/x3d-serializer@0.1.0) (2017-11-29)
32 |
33 |
34 | ### Features
35 |
36 | * add support for a status callback for de/serialization progress ([#49](https://github.com/jscad/io/issues/49)) ([f457cdb](https://github.com/jscad/io/commit/f457cdb))
37 |
38 |
39 |
40 |
41 |
42 | ## [0.0.6](https://github.com/jscad/io/compare/@jscad/x3d-serializer@0.0.5...@jscad/x3d-serializer@0.0.6) (2017-11-04)
43 |
44 |
45 |
46 |
47 | **Note:** Version bump only for package @jscad/x3d-serializer
48 |
49 |
50 | ## [0.0.5](https://github.com/jscad/io/compare/@jscad/x3d-serializer@0.0.4...@jscad/x3d-serializer@0.0.5) (2017-10-30)
51 |
52 |
53 |
54 |
55 | **Note:** Version bump only for package @jscad/x3d-serializer
56 |
57 |
58 | ## [0.0.4](https://github.com/jscad/io/compare/@jscad/x3d-serializer@0.0.3...@jscad/x3d-serializer@0.0.4) (2017-10-10)
59 |
60 |
61 |
62 |
63 | **Note:** Version bump only for package @jscad/x3d-serializer
64 |
65 |
66 | ## 0.0.3 (2017-10-10)
67 |
68 |
69 |
70 |
71 | **Note:** Version bump only for package @jscad/x3d-serializer
72 |
--------------------------------------------------------------------------------
/packages/x3d-serializer/README.md:
--------------------------------------------------------------------------------
1 | ## @jscad/x3d-serializer
2 |
3 | > x3d serializer for the jscad project (from CSG)
4 |
5 | [](https://badge.fury.io/js/%40jscad%2Fx3d-serializer)
6 | [](https://travis-ci.org/jscad/x3d-serializer)
7 |
8 | ## Overview
9 |
10 | This serializer outputs a 'blobable' array of data (from a CSG object)
11 | ie an array that can either be passed directly to a Blob (`new Blob(blobable)`)
12 | or converted to a Node.js buffer.
13 |
14 | ## Table of Contents
15 |
16 | - [Installation](#installation)
17 | - [Usage](#usage)
18 | - [Contribute](#contribute)
19 | - [License](#license)
20 |
21 |
22 | ## Installation
23 |
24 | ```
25 | npm install @jscad/x3d-serializer
26 | ```
27 |
28 | ## Usage
29 |
30 |
31 | ```javascript
32 | const x3dSerializer = require('@jscad/x3d-serializer')
33 |
34 | const rawData = x3dSerializer.serialize(CSGObject)
35 |
36 | //in browser (with browserify etc)
37 | const blob = new Blob(rawData)
38 |
39 | ```
40 |
41 |
42 | ## Contribute
43 |
44 | For questions about the API, please contact the [User Group](https://plus.google.com/communities/114958480887231067224)
45 |
46 | PRs accepted.
47 |
48 | Small Note: If editing this README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
49 |
50 |
51 | ## License
52 |
53 | [The MIT License (MIT)](./LICENSE)
54 | (unless specified otherwise)
55 |
--------------------------------------------------------------------------------
/packages/x3d-serializer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@jscad/x3d-serializer",
3 | "version": "1.0.0-alpha.d0fb3056",
4 | "description": "X3d serializer for jscad project",
5 | "repository": "https://github.com/jscad/io",
6 | "main": "index.js",
7 | "scripts": {
8 | "test": "ava './test.js' --verbose --timeout 10000",
9 | "release-patch": "git checkout master && npm version patch && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
10 | "release-minor": "git checkout master && npm version minor && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags ",
11 | "release-major": "git checkout master && npm version major && git commit -a -m 'chore(dist): built dist/'; git push origin master --tags "
12 | },
13 | "contributors": [
14 | {
15 | "name": "Rene K. Mueller",
16 | "url": "http://renekmueller.com"
17 | },
18 | {
19 | "name": "z3dev",
20 | "url": "http://www.z3d.jp"
21 | },
22 | {
23 | "name": "Mark 'kaosat-dev' Moissette",
24 | "url": "http://kaosat.net"
25 | }
26 | ],
27 | "keywords": [
28 | "openjscad",
29 | "jscad",
30 | "csg",
31 | "serializer",
32 | "x3d"
33 | ],
34 | "license": "MIT",
35 | "dependencies": {
36 | "@jscad/csg": "0.7.0",
37 | "@jscad/io-utils": "^1.0.0-alpha.d0fb3056",
38 | "onml": "^0.4.1"
39 | },
40 | "devDependencies": {
41 | "ava": "^0.25.0"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/packages/x3d-serializer/test.js:
--------------------------------------------------------------------------------
1 | const test = require('ava')
2 | const {CSG} = require('@jscad/csg')
3 | const serializer = require('./index.js')
4 |
5 | test('serialize CSG objects to X3D', function (t) {
6 | const csg1 = new CSG()
7 |
8 | const observed1 = serializer.serialize({}, csg1)
9 | t.deepEqual(observed1, [expected1])
10 |
11 | const csg2 = new CSG.cube()
12 |
13 | const observed2 = serializer.serialize({}, csg2)
14 | t.deepEqual(observed2, [expected2])
15 |
16 | const csg3 = new CSG.cube({center: [5, 5, 5]}).setColor([0.5, 1, 0.5])
17 |
18 | const observed3 = serializer.serialize({}, [csg2, csg3])
19 | t.deepEqual(observed3, [expected3])
20 | })
21 |
22 | const expected1 = `
23 |
24 |
25 |
26 |
27 |
28 |
29 | `
30 |
31 | const expected2 = `
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | `
46 |
47 | const expected3 = `
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | `
68 |
--------------------------------------------------------------------------------
/test/helpers/nearlyEqual.js:
--------------------------------------------------------------------------------
1 | // Compare two numeric values for near equality.
2 | // the given test is fails if the numeric values are outside the given epsilon
3 | function nearlyEqual (t, a, b, epsilon, failMessage) {
4 | if (a === b) { // shortcut, also handles infinities and NaNs
5 | return true
6 | }
7 |
8 | var absA = Math.abs(a)
9 | var absB = Math.abs(b)
10 | var diff = Math.abs(a - b)
11 | if (a === 0 || b === 0 || diff < Number.EPSILON) {
12 | // a or b is zero or both are extremely close to it
13 | // relative error is less meaningful here
14 | if (diff > (epsilon * Number.EPSILON)) {
15 | failMessage = failMessage === undefined ? 'near zero Numbers outside of epsilon' : failMessage
16 | t.fail(failMessage+"("+a+","+b+")")
17 | }
18 | }
19 | // use relative error
20 | if ((diff / Math.min((absA + absB), Number.MAX_VALUE)) > epsilon) {
21 | failMessage = failMessage === undefined ? 'Numbers outside of epsilon' : failMessage
22 | t.fail(failMessage+"("+a+","+b+")")
23 | }
24 | }
25 |
26 | module.exports = {
27 | nearlyEqual: nearlyEqual
28 | }
29 |
--------------------------------------------------------------------------------