diff --git a/setup.py b/setup.py index 013abb2..a02d21b 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="occwl", # package name - version="2.1.0", + version="2.1.1", author="Pradeep Kumar Jayaraman, Joseph G. Lambourne", author_email="pradeep.kumar.jayaraman@autodesk.com, joseph.lambourne@autodesk.com", description="Lightweight Pythonic wrapper around pythonocc", diff --git a/src/occwl/shape.py b/src/occwl/shape.py index 70c4d1f..ec1e87a 100644 --- a/src/occwl/shape.py +++ b/src/occwl/shape.py @@ -397,9 +397,9 @@ def convert_geometric_identity_transforms_to_identity(self): vertex.Location(identity) - def transform(self, a, copy=True): + def transform(self, a: np.ndarray, copy=True): """ - Apply the given 4x4 transform matrix to the solid + Apply the given 3x4 transform matrix to the solid. Args: a (nd.array) - Homogeneous transform matrix The transform that will be applied is @@ -413,6 +413,7 @@ def transform(self, a, copy=True): False - Apply the transform to the topods Locator if possible """ + assert (a.shape == (3, 4)), "Transform matrix must be 3x4" a = a.astype(np.float64) # Create an identity transform @@ -422,7 +423,7 @@ def transform(self, a, copy=True): # we don't want to set the values as this # would give us a geometric identity without # the identity flag set - if not np.allclose(a, np.eye(4)): + if not np.allclose(a, np.eye(3, 4)): trsf.SetValues( a[0,0], a[0,1], a[0,2], a[0, 3], a[1,0], a[1,1], a[1,2], a[1, 3], diff --git a/tests/test_solid.py b/tests/test_solid.py index dd55ab2..95faa04 100644 --- a/tests/test_solid.py +++ b/tests/test_solid.py @@ -51,3 +51,25 @@ def run_test(self, solid): self.assertTrue(split_solid is not None) num_edges_after_splitting = split_solid.num_edges() self.assertLessEqual(num_original_edges, num_edges_after_splitting) + +class TransformTester(TestBase): + def test_smoke(self): + box = Solid.make_box(1, 1, 1) + with self.subTest("identity"): + box.transform( + np.array([ + [1, 0, 0, 0], + [0, 1, 0, 0], + [0, 0, 1, 0], + ]), + copy=True, + ) + with self.subTest("nonidentity"): + box.transform( + np.array([ + [0, 1, 0, 1.], + [0, 0, 1, 2.], + [1, 0, 0, 3.], + ]), + copy=True, + ) \ No newline at end of file