def test_addFace_errorIfThirdFaceAdded(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        mock_face1 = self.maker.OCCFace()
        mock_face1.Edges[1] = self.mock_Edge0
        trackedFace1 = TrackedFace(mock_face1, 'Face001')
        mock_face2 = self.maker.OCCFace()
        mock_face2.Edges[2] = self.mock_Edge0
        trackedFace2 = TrackedFace(mock_face2, 'Face002')

        self.trackedEdge.addFace(self.trackedFace)
        self.trackedEdge.addFace(trackedFace1)

        self.assertEqual(self.trackedEdge._faceNames, ['Face000', 'Face001'])
        self.assertRaises(ValueError, self.trackedEdge.addFace, trackedFace2)
示例#2
0
class TestTrackedFace(unittest.TestCase):
    def setUp(self):
        self.maker = MockObjectMaker()
        self.mock_face0 = self.maker.OCCFace()
        self.trackedFace = TrackedFace(self.mock_face0, 'Face000')

    def test_createNewTrackedFace(self):
        self.assertEqual(self.mock_face0, self.trackedFace._occObj)
        self.assertEqual('Face000', self.trackedFace._name)

    def test_updateOCCFace(self):
        mock_face1 = self.maker.OCCFace()

        self.trackedFace.updateOCCFace(mock_face1)
    def test_addFace_noSharedEdge(self):
        mock_face1 = self.maker.OCCFace()
        trackedFace1 = TrackedFace(mock_face1, 'Face001')

        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        self.trackedEdge.addFace(self.trackedFace)

        self.assertRaises(ValueError, self.trackedEdge.addFace, trackedFace1)
    def test_isValid_true(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        mock_face1 = self.maker.OCCFace()
        mock_face1.Edges[1] = self.mock_Edge0
        trackedFace1 = TrackedFace(mock_face1, 'Face001')

        self.trackedEdge.addFace(self.trackedFace)
        self.trackedEdge.addFace(trackedFace1)

        self.assertTrue(self.trackedEdge.isValid())
    def test_addFace_yesSharedEdgeSecondFace(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        mock_face1 = self.maker.OCCFace()
        mock_face1.Edges[1] = self.mock_Edge0
        trackedFace1 = TrackedFace(mock_face1, 'Face001')

        self.trackedEdge.addFace(self.trackedFace)
        self.trackedEdge.addFace(trackedFace1)

        self.assertEqual(self.trackedEdge._faceNames, ['Face000', 'Face001'])
示例#6
0
    def addFace(self, OCCFace):
        '''Adds OCCFace to the list of tracked Faces

        returns the topological name of the added Face'''
        for face in self._faceTrackers:
            occFace = face.getOCCFace()
            if occFace.isEqual(OCCFace):
                msg = 'A given OpenCascade Face may only be tracked once.'
                raise ValueError(msg)
        name = self._makeName('Face')
        trackedFace = TrackedFace(OCCFace, name)
        self._faceTrackers.append(trackedFace)

        self._checkEdges(trackedFace)
        return name
 def setUp(self):
     self.maker = MockObjectMaker()
     self.mock_Edge0 = self.maker.OCCEdge()
     mock_Face0 = self.maker.OCCFace()
     self.trackedFace = TrackedFace(mock_Face0, 'Face000')
     self.trackedEdge = TrackedEdge(self.mock_Edge0, 'Edge000')
class TestTrackedEdge(unittest.TestCase):
    """Tests the TrackedEdge object"""
    def setUp(self):
        self.maker = MockObjectMaker()
        self.mock_Edge0 = self.maker.OCCEdge()
        mock_Face0 = self.maker.OCCFace()
        self.trackedFace = TrackedFace(mock_Face0, 'Face000')
        self.trackedEdge = TrackedEdge(self.mock_Edge0, 'Edge000')

    def test_getOCCEdge(self):
        fetchedEdge = self.trackedEdge.getOCCEdge()
        self.assertTrue(fetchedEdge.isEqual(self.mock_Edge0))

    def test_createNewTrackedEdge(self):
        self.trackedEdge._name = 'Edge000'
        self.trackedEdge._valid = False

    def test_addFace_noSharedEdge(self):
        mock_face1 = self.maker.OCCFace()
        trackedFace1 = TrackedFace(mock_face1, 'Face001')

        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        self.trackedEdge.addFace(self.trackedFace)

        self.assertRaises(ValueError, self.trackedEdge.addFace, trackedFace1)

    def test_addFace_yesSharedEdgeFirstFace(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        self.trackedEdge.addFace(self.trackedFace)

        self.assertEqual(self.trackedEdge._faceNames, ['Face000'])

    def test_addFace_yesSharedEdgeSecondFace(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        mock_face1 = self.maker.OCCFace()
        mock_face1.Edges[1] = self.mock_Edge0
        trackedFace1 = TrackedFace(mock_face1, 'Face001')

        self.trackedEdge.addFace(self.trackedFace)
        self.trackedEdge.addFace(trackedFace1)

        self.assertEqual(self.trackedEdge._faceNames, ['Face000', 'Face001'])

    def test_addFace_errorIfThirdFaceAdded(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        mock_face1 = self.maker.OCCFace()
        mock_face1.Edges[1] = self.mock_Edge0
        trackedFace1 = TrackedFace(mock_face1, 'Face001')
        mock_face2 = self.maker.OCCFace()
        mock_face2.Edges[2] = self.mock_Edge0
        trackedFace2 = TrackedFace(mock_face2, 'Face002')

        self.trackedEdge.addFace(self.trackedFace)
        self.trackedEdge.addFace(trackedFace1)

        self.assertEqual(self.trackedEdge._faceNames, ['Face000', 'Face001'])
        self.assertRaises(ValueError, self.trackedEdge.addFace, trackedFace2)

    def test_isValid_false(self):
        self.assertFalse(self.trackedEdge.isValid())

    def test_isValid_true(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        mock_face1 = self.maker.OCCFace()
        mock_face1.Edges[1] = self.mock_Edge0
        trackedFace1 = TrackedFace(mock_face1, 'Face001')

        self.trackedEdge.addFace(self.trackedFace)
        self.trackedEdge.addFace(trackedFace1)

        self.assertTrue(self.trackedEdge.isValid())

    def test_delFace(self):
        self.trackedFace._occObj.Edges[0] = self.mock_Edge0
        self.trackedEdge.addFace(self.trackedFace)
        self.trackedEdge.delFace(self.trackedFace.getName())

        self.assertTrue(len(self.trackedEdge._faceNames) == 0)
示例#9
0
 def setUp(self):
     self.maker = MockObjectMaker()
     self.mock_face0 = self.maker.OCCFace()
     self.trackedFace = TrackedFace(self.mock_face0, 'Face000')