This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/papercraft/openjscad/node_modules/@jscad/io-utils/test.js

35 lines
1.3 KiB
JavaScript

const test = require('ava')
const {CSG} = require('@jscad/csg')
const ensureManifoldness = require('./ensureManifoldness.js')
// NOTE : this test is BAD WAY, and too dependent on the current implementation , we need actual checks
// such as https://gamedev.stackexchange.com/questions/61878/how-check-if-an-arbitrary-given-mesh-is-a-single-closed-mesh
// https://stackoverflow.com/questions/761026/is-a-closed-polygonal-mesh-flipped
// https://blender.stackexchange.com/questions/20956/is-there-a-way-to-check-a-mesh-for-problems
// https://pypi.python.org/pypi/trimesh/2.2.8
test('ensureManifoldness of csg objects (single input)', function (t) {
const input = new CSG.cube()
t.deepEqual(input.isCanonicalized, false)
t.deepEqual(input.isRetesselated, false)
const observed = ensureManifoldness(input)
t.deepEqual(observed.isCanonicalized, true)
t.deepEqual(observed.isRetesselated, true)
})
test('ensureManifoldness of csg objects (array of inputs)', function (t) {
const input = [
new CSG.cube(),
new CSG.sphere(),
new CSG.cube()
]
input.map(x => {
t.deepEqual(x.isCanonicalized, false)
t.deepEqual(x.isRetesselated, false)
})
const observed = ensureManifoldness(input)
observed.map(x => {
t.deepEqual(x.isCanonicalized, true)
t.deepEqual(x.isRetesselated, true)
})
})