Skip to content
Snippets Groups Projects
Commit f53dbc80 authored by jack-parsons's avatar jack-parsons
Browse files

Adding centring test

parent a17e8f93
Branches
No related tags found
1 merge request!23Merge in Jack's changes
Pipeline #846 passed
...@@ -51,11 +51,13 @@ class TestBasicFunction(unittest.TestCase): ...@@ -51,11 +51,13 @@ class TestBasicFunction(unittest.TestCase):
#Amp.planarTrim([], plane=[]) #Amp.planarTrim([], plane=[])
def test_translate(self): def test_translate(self):
# Test translating method of AmpObject
from AmpScan.core import AmpObject from AmpScan.core import AmpObject
stlPath = self.get_path("sample_stl_sphere_BIN.stl") stlPath = self.get_path("sample_stl_sphere_BIN.stl")
amp = AmpObject(stlPath) 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)[:] start = amp.vert.mean(axis=0)[:]
amp.translate([1, -1, 0]) amp.translate([1, -1, 0])
end = amp.vert.mean(axis=0)[:] end = amp.vert.mean(axis=0)[:]
...@@ -75,6 +77,21 @@ class TestBasicFunction(unittest.TestCase): ...@@ -75,6 +77,21 @@ class TestBasicFunction(unittest.TestCase):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
amp.translate([0, 0, 0, 0]) 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): def get_path(self, filename):
""" """
Method to get the absolute path to the testing files Method to get the absolute path to the testing files
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment