Skip to content

Commit

Permalink
adding Extrusion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Nov 26, 2024
1 parent cc36835 commit dfe8cbf
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/javascript/extrusion.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const rhino3dm = require('rhino3dm')

let rhino
beforeEach( async() => {
rhino = await rhino3dm()
})

// objective: to test that creating and extrusion vs creating an extrusion with a place yield similar extrusions in different places
test('createExtrusion', async () => {

const circle1 = new rhino.Circle(1.0);
const extrusion1 = rhino.Extrusion.create(circle1.toNurbsCurve(), 10.0, true)
const plane = new rhino.Plane.worldXY()
plane.origin = [10,10,10]
const circle2 = new rhino.Circle(1.0);
circle2.plane = plane
const extrusion2 = rhino.Extrusion.createWithPlane(circle2.toNurbsCurve(), plane, 10.0, true)

const bb1 = extrusion1.getBoundingBox()
const bb2 = extrusion2.getBoundingBox()

expect(bb1.volume).toBeCloseTo(bb2.volume, 5)
expect(bb1.center === bb2.center).toBe(false)

})
25 changes: 25 additions & 0 deletions tests/python/test_Extrusion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import rhino3dm
import unittest

#objective: to test that creating and extrusion vs creating an extrusion with a place yield similar extrusions in different places
class TestExtrusion(unittest.TestCase):
def test_createExtrusion(self):

circle1 = rhino3dm.Circle( 1 )
extrusion1 = rhino3dm.Extrusion.Create(circle1.ToNurbsCurve(), 10, True)
plane = rhino3dm.Plane.WorldXY()
plane.Origin = rhino3dm.Point3d(10, 10, 10)
circle2 = rhino3dm.Circle( 1 )
circle2.Plane = plane
extrusion2 = rhino3dm.Extrusion.CreateWithPlane(circle2.ToNurbsCurve(), plane, 10, True)

bb1 = extrusion1.GetBoundingBox()
bb2 = extrusion2.GetBoundingBox()

self.assertAlmostEqual( bb1.Volume, bb2.Volume, 5 )
self.assertFalse( bb1.Center == bb2.Center )

if __name__ == '__main__':
print("running tests")
unittest.main()
print("tests complete")

0 comments on commit dfe8cbf

Please sign in to comment.