def testParallelPlaneFaceFilter(self): c = CQ(makeUnitCube(centered=False)) # faces parallel to Z axis # these two should produce the same behaviour: for s in ["|Z", selectors.ParallelDirSelector(Vector(0, 0, 1))]: parallel_faces = c.faces(s) self.assertEqual(2, parallel_faces.size()) for f in parallel_faces.vals(): self.assertAlmostEqual( abs(f.normalAt(None).dot(Vector(0, 0, 1))), 1) self.assertEqual(2, c.faces( selectors.ParallelDirSelector(Vector( (0, 0, -1)))).size()) # same thing as above # just for fun, vertices on faces parallel to z self.assertEqual(8, c.faces("|Z").vertices().size()) # check that the X & Y center of these faces is the same as the box (ie. we haven't selected the wrong face) faces = c.faces(selectors.ParallelDirSelector(Vector( (0, 0, 1)))).vals() for f in faces: c = f.Center() self.assertAlmostEqual(c.x, 0.5) self.assertAlmostEqual(c.y, 0.5)
def testParallelPlaneFaceFilter(self): c = CQ(makeUnitCube()) #faces parallel to Z axis self.assertEqual(2, c.faces("|Z").size()) #TODO: provide short names for ParallelDirSelector self.assertEqual(2, c.faces(selectors.ParallelDirSelector(Vector((0,0,1)))).size()) #same thing as above self.assertEqual(2, c.faces(selectors.ParallelDirSelector(Vector((0,0,-1)))).size()) #same thing as above #just for fun, vertices on faces parallel to z self.assertEqual(8, c.faces("|Z").vertices().size())