Example #1
0
 def testCell(self):
     """Testing functions in Cell."""
     pts = [_Point(i) for i in range(3)]
     segs = [_Segment("0", pts[0], pts[1]), _Segment("1", pts[1], pts[0]), _Segment("2", pts[2], pts[2])]
     cell1 = _Cell("c1", _Path([segs[0].oseg(), segs[1].oseg()], iscycle=True))
     cell2 = _Cell(
         "c2", [_Path([segs[0].oseg(), segs[1].oseg()], iscycle=True), _Path([segs[2].oseg()], iscycle=True)]
     )
     self.assertEqual(cell1.toDomain(), {cell1: 1})
     self.assertEqual(cell1.bdOneChain(), {segs[0]: 1, segs[1]: 1})
     self.assertEqual(cell2.bdOneChain(), {segs[0]: 1, segs[1]: 1, segs[2]: 1})
Example #2
0
 def testDiff(self):
     """Testing diff function in Domain."""
     pts = [_Point(i) for i in range(4)]
     segs = [
         _Segment("0", pts[0], pts[1]),
         _Segment("1", pts[1], pts[2]),
         _Segment("2", pts[2], pts[0]),
         _Segment("3", pts[1], pts[3]),
         _Segment("4", pts[3], pts[0]),
     ]
     cell1 = _Cell("c1", _Path([seg.oseg() for seg in segs[0:3]], iscycle=True))
     cell2 = _Cell("c2", _Path([seg.oseg() for seg in segs[0:1] + segs[3:]], iscycle=True).opp())
     domain1 = cell1.toDomain() + cell2.toDomain()
     self.assertEqual(domain1.diff(), {segs[1]: 1, segs[2]: 1, segs[3]: -1, segs[4]: -1})
Example #3
0
    def setUp(self):
        self.n = 10
        self.pts = [_Point(i) for i in range(self.n)]
        self.segs = [_Segment(i, self.pts[i], self.pts[(i + 1) % self.n]) for i in range(self.n)]
        self.osegs = [seg.oseg() for seg in self.segs]
        self.osegsr = [seg.oseg().opp() for seg in self.segs]
        self.loopseg = _Segment("loop", self.pts[0], self.pts[0])
        self.oloopseg = self.loopseg.oseg()

        # These should construct valid paths
        self.path1 = _Path([], "empty")
        self.path2 = _Path([self.oloopseg], "small_loop", True)
        self.path3 = _Path(self.osegs[0:-1], "straight")
        self.path4 = _Path(self.osegs, "loop", True)
        self.path5 = _Path(self.osegs * 2, "twoloops")
        self.path6 = _Path(reversed(self.osegsr), "opploop", True)