From f53dbc8090b4785a91e83f28bc5f7c93f8168167 Mon Sep 17 00:00:00 2001 From: jack-parsons <jack.parsons.uk@icloud.com> Date: Mon, 22 Jul 2019 17:18:52 +0100 Subject: [PATCH] Adding centring test --- tests/sample_test.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/sample_test.py b/tests/sample_test.py index 05e0071..68950ad 100644 --- a/tests/sample_test.py +++ b/tests/sample_test.py @@ -51,11 +51,13 @@ class TestBasicFunction(unittest.TestCase): #Amp.planarTrim([], plane=[]) def test_translate(self): + # Test translating method of AmpObject + from AmpScan.core import AmpObject stlPath = self.get_path("sample_stl_sphere_BIN.stl") amp = AmpObject(stlPath) - # Check that everything has been translated by 1 + # Check that everything has been translated correctly to a certain accuracy start = amp.vert.mean(axis=0)[:] amp.translate([1, -1, 0]) end = amp.vert.mean(axis=0)[:] @@ -75,6 +77,21 @@ class TestBasicFunction(unittest.TestCase): with self.assertRaises(ValueError): amp.translate([0, 0, 0, 0]) + def test_centre(self): + # Test the centre method of AmpObject + from AmpScan.core import AmpObject + stlPath = self.get_path("sample_stl_sphere_BIN.stl") + amp = AmpObject(stlPath) + + # Translate the mesh + amp.translate([1, 0, 0]) + # Recenter the mesh + amp.centre() + centre = amp.vert.mean(axis=0) + + # Check that the mesh is centred correctly (to at least the number of decimal places of ACCURACY) + self.assertTrue(all(centre[i] < (10**-TestBasicFunction.ACCURACY) for i in range(3))) + def get_path(self, filename): """ Method to get the absolute path to the testing files -- GitLab