2021-12-14 17:50:00 +05:00
|
|
|
import os, shutil
|
2021-11-04 18:26:13 +05:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
unittest.TestLoader.sortTestMethodsUsing = None
|
|
|
|
|
|
|
|
class TestShaping(unittest.TestCase):
|
|
|
|
def setUp(self):
|
2021-11-18 12:34:43 +05:00
|
|
|
try:
|
2021-12-14 17:50:00 +05:00
|
|
|
import netgen.occ
|
|
|
|
_ = netgen.occ.Pnt(0, 0, 0)
|
2021-11-18 12:34:43 +05:00
|
|
|
|
2021-12-14 17:50:00 +05:00
|
|
|
except Exception as e:
|
|
|
|
self.skipTest(e)
|
2021-11-18 12:34:43 +05:00
|
|
|
|
2021-11-18 22:00:30 +05:00
|
|
|
else:
|
|
|
|
from anisotropy import shaping
|
2021-11-04 18:26:13 +05:00
|
|
|
|
2021-11-18 22:00:30 +05:00
|
|
|
self.shaping = shaping
|
2021-11-04 18:26:13 +05:00
|
|
|
|
2021-12-14 17:50:00 +05:00
|
|
|
self.outputPath = os.path.join(os.path.dirname(__file__), "test_shaping_output")
|
2021-11-18 22:00:30 +05:00
|
|
|
os.makedirs(self.outputPath, exist_ok = True)
|
2021-11-04 18:26:13 +05:00
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
simple100 = self.shaping.Simple(direction = [1, 0, 0], alpha = 0.01)
|
|
|
|
simple001 = self.shaping.Simple(direction = [0, 0, 1], alpha = 0.01)
|
|
|
|
simple111 = self.shaping.Simple(direction = [1, 1, 1], alpha = 0.01)
|
|
|
|
|
|
|
|
simple100.build()
|
|
|
|
simple001.build()
|
|
|
|
simple111.build()
|
|
|
|
|
|
|
|
simple100.export(os.path.join(self.outputPath, "simple100.step"))
|
|
|
|
simple001.export(os.path.join(self.outputPath, "simple001.step"))
|
|
|
|
simple111.export(os.path.join(self.outputPath, "simple111.step"))
|
|
|
|
|
|
|
|
def test_bodyCentered(self):
|
|
|
|
bodyCentered100 = self.shaping.BodyCentered(direction = [1, 0, 0], alpha = 0.01)
|
|
|
|
bodyCentered001 = self.shaping.BodyCentered(direction = [0, 0, 1], alpha = 0.01)
|
|
|
|
bodyCentered111 = self.shaping.BodyCentered(direction = [1, 1, 1], alpha = 0.01)
|
|
|
|
|
|
|
|
bodyCentered100.build()
|
|
|
|
bodyCentered001.build()
|
|
|
|
bodyCentered111.build()
|
|
|
|
|
|
|
|
bodyCentered100.export(os.path.join(self.outputPath, "bodyCentered100.step"))
|
|
|
|
bodyCentered001.export(os.path.join(self.outputPath, "bodyCentered001.step"))
|
|
|
|
bodyCentered111.export(os.path.join(self.outputPath, "bodyCentered111.step"))
|
|
|
|
|
2021-11-18 00:48:17 +05:00
|
|
|
def test_faceCentered_lattice(self):
|
|
|
|
fc = self.shaping.FaceCentered([1, 0, 0], alpha = 0.01, filletsEnabled = True)
|
|
|
|
fc.build()
|
|
|
|
fc.lattice.WriteStep(os.path.join(self.outputPath, "fc_lattice.step"))
|
|
|
|
|
2021-11-04 18:26:13 +05:00
|
|
|
def test_faceCentered(self):
|
|
|
|
faceCentered100 = self.shaping.FaceCentered(direction = [1, 0, 0], alpha = 0.01)
|
|
|
|
faceCentered001 = self.shaping.FaceCentered(direction = [0, 0, 1], alpha = 0.01)
|
|
|
|
faceCentered111 = self.shaping.FaceCentered(direction = [1, 1, 1], alpha = 0.01)
|
|
|
|
|
|
|
|
faceCentered100.build()
|
|
|
|
faceCentered001.build()
|
|
|
|
faceCentered111.build()
|
|
|
|
|
|
|
|
faceCentered100.export(os.path.join(self.outputPath, "faceCentered100.step"))
|
|
|
|
faceCentered001.export(os.path.join(self.outputPath, "faceCentered001.step"))
|
|
|
|
faceCentered111.export(os.path.join(self.outputPath, "faceCentered111.step"))
|
|
|
|
|
|
|
|
def tearDown(self):
|
2021-12-14 17:50:00 +05:00
|
|
|
shutil.rmtree(self.outputPath)
|
2021-11-04 18:26:13 +05:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|