Ejemplo n.º 1
0
 def test_copy(self):
     t1 = AffineTransform()
     t1.scale(2, 3)
     t1.rotate(3)
     t2 = copy.copy(t1)
     self.assertEqual(t1.m, t2.m)
     self.assertEqual(t1, t2)
Ejemplo n.º 2
0
def traverseAndRefactor( handler, root, validroot, transform ):
	
	valid = isValidVolume(root)
	if validroot == 0: valid = True
	#elif valid:
	#	valid = root.solid.fitsInside(validroot.solid)
	#	if not valid: handler.droppednofit += 1
	
	if valid:
		transform = AffineTransform()
		validroot = root
	
	daugh = root.daughters
	root.daughters = []
	
	for d in daugh:
		if d.logvol == 0:
			d.logvol = handler.logvols[ d.logvolref ]
			
		oldtform = AffineTransform.Create(d.rotation, d.position)
		newtform = transform.mult( oldtform )
		if traverseAndRefactor( handler, d.logvol, validroot, newtform ):
			d.rotation = newtform.rot
			d.position = newtform.trans
			validroot.daughters.append( d )
			handler.totalsolids += 1
		else: handler.droppedsolids += 1
		
	return valid
Ejemplo n.º 3
0
 def test_scale(self):
     t = AffineTransform()
     t.scale(4.0, 3.0)
     r = t.transformRect(0, 0, 1, 1)
     re = (0, 0, 4, 3)
     for i in range(0, len(r)):
         self.assertAlmostEqual(r[i], re[i])
Ejemplo n.º 4
0
 def test_translate(self):
     translation = (100, 200)
     t = AffineTransform()
     t.translate(translation[0], translation[1])
     p = t.transformPoint(0, 0)
     for i in range(0, len(p)):
         self.assertAlmostEqual(p[i], translation[i])
Ejemplo n.º 5
0
	def getTransform( self ):
		return AffineTransform( self.rotation, self.position )
Ejemplo n.º 6
0
 def test_equality(self):
     t1 = AffineTransform()
     t1.scale(2, 3)
     t1.rotate(3)
     t2 = AffineTransform()
     t2.scale(2, 3)
     t2.rotate(3)
     self.assertTrue(t1 == t2)
     t3 = AffineTransform()
     t3.scale(4, 5)
     self.assertFalse(t2 == t3)
     self.assertFalse(t3 == None)
Ejemplo n.º 7
0
 def test_invert(self):
     t = AffineTransform()
     t.rotate(-math.pi / 2.0)
     t.scale(4.0, 3.0)
     t.translate(100, 100)
     p = t.transformPoint(0, 0)
     t.invert()
     p = t.transformPoint(p[0], p[1])
     for i in range(0, len(p)):
         self.assertAlmostEqual(p[i], 0)
Ejemplo n.º 8
0
    def test_multiply(self):
        t1 = AffineTransform()
        t1.rotate(math.pi / 2.0)
        t2 = AffineTransform()
        t2.translate(2, 4)
        t3 = AffineTransform()
        t3.scale(3, 5)

        p = (20, 20)

        p1 = (p[0], p[1])
        p1 = t1.transformPoint(p1[0], p1[1])
        p1 = t2.transformPoint(p1[0], p1[1])
        p1 = t3.transformPoint(p1[0], p1[1])

        t4 = AffineTransform()
        t4.multiply(t1)
        t4.multiply(t2)
        t4.multiply(t3)

        p2 = t4.transformPoint(p[0], p[1])

        for i in range(0, len(p1)):
            self.assertAlmostEqual(p1[i], p2[i])
Ejemplo n.º 9
0
 def test_rotate(self):
     t = AffineTransform()
     t.rotate(-math.pi / 2.0)
     s = t.transformSize(0.0, 2.0)
     self.assertAlmostEqual(round(s[0]), 2.0)
     self.assertAlmostEqual(round(s[1]), 0.0)