MCPcopy
hub / github.com/CadQuery/cadquery / testParallelPlaneFaceFilter

Method testParallelPlaneFaceFilter

tests/test_selectors.py:190–212  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

188 self.assertEqual(comp.compounds(loose_selector).size(), 0)
189
190 def testParallelPlaneFaceFilter(self):
191 c = CQ(makeUnitCube(centered=False))
192
193 # faces parallel to Z axis
194 # these two should produce the same behaviour:
195 for s in ["|Z", selectors.ParallelDirSelector(Vector(0, 0, 1))]:
196 parallel_faces = c.faces(s)
197 self.assertEqual(2, parallel_faces.size())
198 for f in parallel_faces.vals():
199 self.assertAlmostEqual(abs(f.normalAt(None).dot(Vector(0, 0, 1))), 1)
200 self.assertEqual(
201 2, c.faces(selectors.ParallelDirSelector(Vector((0, 0, -1)))).size()
202 ) # same thing as above
203
204 # just for fun, vertices on faces parallel to z
205 self.assertEqual(8, c.faces("|Z").vertices().size())
206
207 # check that the X & Y center of these faces is the same as the box (ie. we haven't selected the wrong face)
208 faces = c.faces(selectors.ParallelDirSelector(Vector((0, 0, 1)))).vals()
209 for f in faces:
210 c = f.Center()
211 self.assertAlmostEqual(c.x, 0.5)
212 self.assertAlmostEqual(c.y, 0.5)
213
214 def testParallelEdgeFilter(self):
215 c = CQ(makeUnitCube())

Callers

nothing calls this directly

Calls 9

makeUnitCubeFunction · 0.90
VectorClass · 0.85
dotMethod · 0.80
facesMethod · 0.45
sizeMethod · 0.45
valsMethod · 0.45
normalAtMethod · 0.45
verticesMethod · 0.45
CenterMethod · 0.45

Tested by

no test coverage detected