Skip to content

Commit

Permalink
fix(modeling): corrected hull of single unconvex solid
Browse files Browse the repository at this point in the history
  • Loading branch information
her01n authored Jul 28, 2024
1 parent baad57b commit b3901f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion packages/modeling/src/operations/hulls/hull.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const test = require('ava')

const { geom2, geom3, path2 } = require('../../geometries')

const { sphere, cuboid, ellipsoid } = require('../../primitives')
const { measureVolume } = require('../../measurements')

const { sphere, cuboid, ellipsoid, torus } = require('../../primitives')

const { center } = require('../transforms/center')

Expand Down Expand Up @@ -274,3 +276,9 @@ test('hull (multiple, overlapping, geom3)', (t) => {
t.notThrows(() => geom3.validate(obs))
t.is(pts.length, 92)
})

test('hull (single, unconvex, geom3)', (t) => {
const geometry = torus()
const obs = hull(geometry)
t.assert(measureVolume(obs) > measureVolume(geometry))
})
4 changes: 2 additions & 2 deletions packages/modeling/src/operations/hulls/hullGeom3.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const hullPoints3 = require('./hullPoints3')
const hullGeom3 = (...geometries) => {
geometries = flatten(geometries)

if (geometries.length === 1) return geometries[0]

// extract the unique vertices from the geometries
const unique = toUniquePoints(geometries)

if (unique.length === 0) return geom3.create()

return geom3.create(hullPoints3(unique))
}

Expand Down

0 comments on commit b3901f2

Please sign in to comment.