2024-06-20 23:29:18 -07:00
|
|
|
import unittest
|
2024-06-24 11:13:11 -07:00
|
|
|
import cadquery as Cq
|
2024-06-20 23:29:18 -07:00
|
|
|
import nhf.touhou.houjuu_nue as M
|
2024-07-12 23:16:04 -07:00
|
|
|
import nhf.touhou.houjuu_nue.joints as MJ
|
2024-07-07 12:15:47 -07:00
|
|
|
from nhf.checks import pairwise_intersection
|
2024-06-20 23:29:18 -07:00
|
|
|
|
2024-07-12 23:16:04 -07:00
|
|
|
class TestJoints(unittest.TestCase):
|
2024-07-11 08:42:13 -07:00
|
|
|
|
2024-07-12 23:16:04 -07:00
|
|
|
def test_shoulder_collision_0(self):
|
|
|
|
j = MJ.ShoulderJoint()
|
|
|
|
assembly = j.assembly()
|
|
|
|
self.assertEqual(pairwise_intersection(assembly), [])
|
|
|
|
def test_disk_collision_0(self):
|
|
|
|
j = MJ.DiskJoint()
|
2024-07-11 08:42:13 -07:00
|
|
|
assembly = j.assembly(angle=0)
|
|
|
|
self.assertEqual(pairwise_intersection(assembly), [])
|
2024-07-12 23:16:04 -07:00
|
|
|
def test_disk_collision_mid(self):
|
|
|
|
j = MJ.DiskJoint()
|
2024-07-11 08:42:13 -07:00
|
|
|
assembly = j.assembly(angle=j.movement_angle / 2)
|
|
|
|
self.assertEqual(pairwise_intersection(assembly), [])
|
2024-07-12 23:16:04 -07:00
|
|
|
def test_disk_collision_max(self):
|
|
|
|
j = MJ.DiskJoint()
|
2024-07-11 08:42:13 -07:00
|
|
|
assembly = j.assembly(angle=j.movement_angle)
|
|
|
|
self.assertEqual(pairwise_intersection(assembly), [])
|
|
|
|
|
2024-06-20 23:29:18 -07:00
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
2024-06-24 11:13:11 -07:00
|
|
|
def test_hs_joint_parent(self):
|
|
|
|
p = M.Parameters()
|
|
|
|
obj = p.hs_joint_parent()
|
2024-06-26 06:42:50 -07:00
|
|
|
self.assertIsInstance(obj.val().solids(), Cq.Solid, msg="H-S joint must be in one piece")
|
2024-07-07 12:15:47 -07:00
|
|
|
|
2024-06-20 23:29:18 -07:00
|
|
|
def test_wing_root(self):
|
|
|
|
p = M.Parameters()
|
2024-06-24 11:13:11 -07:00
|
|
|
obj = p.wing_root()
|
2024-07-07 12:15:47 -07:00
|
|
|
assert isinstance(obj, Cq.Assembly)
|
2024-06-30 19:03:16 -07:00
|
|
|
#self.assertIsInstance(obj.solids(), Cq.Solid, msg="Wing root must be in one piece")
|
2024-07-07 12:15:47 -07:00
|
|
|
bbox = obj.toCompound().BoundingBox()
|
2024-06-27 20:22:54 -07:00
|
|
|
|
|
|
|
msg = "Must fix 256^3 bbox"
|
|
|
|
self.assertLess(bbox.xlen, 255, msg=msg)
|
|
|
|
self.assertLess(bbox.ylen, 255, msg=msg)
|
|
|
|
self.assertLess(bbox.zlen, 255, msg=msg)
|
2024-07-08 22:32:49 -07:00
|
|
|
def test_wings_assembly(self):
|
|
|
|
p = M.Parameters()
|
|
|
|
p.wings_assembly()
|
2024-07-04 12:03:38 -07:00
|
|
|
def test_trident_assembly(self):
|
2024-06-25 06:11:48 -07:00
|
|
|
p = M.Parameters()
|
2024-06-26 06:42:50 -07:00
|
|
|
assembly = p.trident_assembly()
|
|
|
|
bbox = assembly.toCompound().BoundingBox()
|
|
|
|
length = bbox.zlen
|
|
|
|
self.assertGreater(length, 1300)
|
|
|
|
self.assertLess(length, 1700)
|
2024-07-07 21:45:10 -07:00
|
|
|
#def test_assemblies(self):
|
|
|
|
# p = M.Parameters()
|
|
|
|
# p.check_all()
|
2024-06-20 23:29:18 -07:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|