Skip to content

Commit

Permalink
Merge pull request #11 from fritzm/fritzm/cleanup
Browse files Browse the repository at this point in the history
Miscellaneous cleanups
  • Loading branch information
fritzm authored Nov 10, 2019
2 parents 00675a4 + 76e0d68 commit a1c34b2
Show file tree
Hide file tree
Showing 25 changed files with 469 additions and 282 deletions.
1 change: 0 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
'src/D2.cc',
'src/Direction2.cc',
'src/Line2.cc',
'src/NefPolyhedron2.cc',
'src/Point2.cc',
'src/Polygon2.cc',
'src/PolygonSet2.cc',
Expand Down
305 changes: 305 additions & 0 deletions cgal-demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CGAL = require('.')\n",
"true"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Polygon2 {}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"poly = new CGAL.Polygon2([\n",
" [0, 0.3],\n",
" [1, 0.6],\n",
" [2, 0.9]\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.7755575615628914e-17\n",
"false\n"
]
}
],
"source": [
"console.log(poly.area())\n",
"console.log(CGAL.collinear.apply(null, poly.coords()))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" [ '0', '5404319552844595/18014398509481984' ],\n",
" [ '1', '5404319552844595/9007199254740992' ],\n",
" [ '2', '8106479329266893/9007199254740992' ]\n",
"]\n",
"[ [ 0, 0.3 ], [ 1, 0.6 ], [ 2, 0.9 ] ]\n"
]
}
],
"source": [
"console.log(poly.toPOD())\n",
"console.log(poly.toPOD(false))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"false\n",
"false\n"
]
}
],
"source": [
"console.log(CGAL.collinear.apply(null, poly.toPOD()))\n",
"console.log(CGAL.collinear.apply(null, poly.toPOD(false)))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Polygon2 {}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"poly = new CGAL.Polygon2([\n",
" ['0', '0.3'],\n",
" ['1', '0.6'],\n",
" ['2', '0.9']\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"true\n"
]
}
],
"source": [
"console.log(poly.area())\n",
"console.log(CGAL.collinear.apply(null, poly.coords()))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ [ '0', '3/10' ], [ '1', '3/5' ], [ '2', '9/10' ] ]\n",
"[\n",
" [ 0, 0.30000000000000004 ],\n",
" [ 1, 0.6000000000000001 ],\n",
" [ 2, 0.8999999999999999 ]\n",
"]\n"
]
}
],
"source": [
"console.log(poly.toPOD())\n",
"console.log(poly.toPOD(false))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"true\n",
"false\n"
]
}
],
"source": [
"console.log(CGAL.collinear.apply(null, poly.toPOD()))\n",
"console.log(CGAL.collinear.apply(null, poly.toPOD(false)))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Polygon2 {}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p = new CGAL.Polygon2([[0,0],[1,0],[0,1]])"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PolygonSet2 {}"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ps = new CGAL.PolygonSet2([[0,0],[1,0],[0,1]])"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Arrangement2 {}"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = ps.arrangement()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{\n",
" numFaces: 2,\n",
" numUnboundedFaces: 1,\n",
" numBoundedFaces: 1,\n",
" numVertices: 3,\n",
" boundedFaces: [ [ [Array], [Array], [Array] ] ]\n",
"}"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.toPOD()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Javascript (Node.js)",
"language": "javascript",
"name": "javascript"
},
"language_info": {
"file_extension": ".js",
"mimetype": "application/javascript",
"name": "javascript",
"version": "12.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"private": true,
"repository": {},
"scripts": {
"test": "jasmine --reporter=jasmine-console-reporter"
"install": "scripts/install",
"test": "scripts/test",
"clean": "scripts/clean"
},
"engines": {
"node": ">=12.0.0"
Expand All @@ -23,7 +25,7 @@
"x64"
],
"dependencies": {
"node-addon-api": "*"
"node-addon-api": "^1.7.1"
},
"devDependencies": {
"jasmine": "^3.4.0",
Expand Down
3 changes: 3 additions & 0 deletions scripts/clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
node-gyp clean
rm -rf build
2 changes: 1 addition & 1 deletion scripts/preinstall → scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
if [[ !(-e build/Makefile) || (binding.gyp -nt build/Makefile) ]]; then
node-gyp configure
fi
node-gyp build -j 4
node-gyp build -j max
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
jasmine-node --verbose --captureExceptions $JASMINE_NODE_OPTS test
jasmine --reporter=jasmine-console-reporter
10 changes: 0 additions & 10 deletions spec/NefPolyhedron2.spec.js

This file was deleted.

4 changes: 2 additions & 2 deletions spec/Point2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("CGAL.Point2", function() {
var p = new CGAL.Point2([1,2]);
var q = p.transform([1, 0, 3, 0, 1, 3]);
expect(q instanceof CGAL.Point2).toBeTruthy();
expect(q.x()).toEqual(4);
expect(q.y()).toEqual(5);
expect(q.x().toPOD(false)).toEqual(4);
expect(q.y().toPOD(false)).toEqual(5);
});
});
8 changes: 4 additions & 4 deletions spec/Polygon2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ describe("CGAL.Polygon2", function() {

it ("area calculation should function as expected", function() {
var p1 = new CGAL.Polygon2([[0,0],[1,0],[1,1],[0,1]]);
expect(p1.area()).toBeCloseTo(1.0, 4);
expect(p1.area().toPOD(false)).toBeCloseTo(1.0, 4);
var p2 = new CGAL.Polygon2([[0,0],[1,0],[1,1]]);
expect(p2.area()).toBeCloseTo(0.5, 4);
expect(p2.area().toPOD(false)).toBeCloseTo(0.5, 4);
var p3 = new CGAL.Polygon2([[0,0],[0,1],[1,1],[1,0]]);
expect(p3.area()).toBeCloseTo(-1.0, 4);
expect(p3.area().toPOD(false)).toBeCloseTo(-1.0, 4);
});

it ("coords method should function as expected", function() {
Expand All @@ -103,7 +103,7 @@ describe("CGAL.Polygon2", function() {
it ("should support transformation", function() {
var p1 = new CGAL.Polygon2([[0, 0], [1, 0], [1, 1], [0, 1]]);
var p2;
expect(function() {p2 = CGAL.Polygon2.transform([1, 0, 3, 0, 1, 3], p1);}).not.toThrow();
expect(function() {p2 = p1.transform([1, 0, 3, 0, 1, 3]);}).not.toThrow();
expect(p2.toPOD(false)[0]).toEqual([3,3]);
});
});
8 changes: 3 additions & 5 deletions spec/PolygonSet2.spec.js

Large diffs are not rendered by default.

Loading

0 comments on commit a1c34b2

Please sign in to comment.