Exemple #1
0
def _create_repeated_vessel():
    edges = [
        {
            'id':
            '2',
            'data': [
                MBFPoint(4613.07, -3181.37, -1873.73, 0.83),
                MBFPoint(4617.23, -3167.96, -1880.22, 3.11),
                MBFPoint(4617.23, -3167.96, -1880.22, 3.11)
            ]
        },
    ]
    vessel = {
        'version':
        '3',
        'colour':
        '#80FF00',
        'rgb': [0.5019607843137255, 1.0, 0.0],
        'type':
        'directed',
        'name':
        'Vessel Name 1',
        'nodes': [{
            'id': '0',
            'data': MBFPoint(4613.07, -3181.37, -1873.73, 0.83)
        }, {
            'id': '1',
            'data': MBFPoint(4617.23, -3167.96, -1880.22, 3.11)
        }],
        'edges':
        edges,
        'edgelists': [{
            'id': '0',
            'edge': '0',
            'sourcenode': '-1',
            'targetnode': '0'
        }, {
            'id': '1',
            'edge': '1',
            'sourcenode': '0',
            'targetnode': '-1'
        }, {
            'id': '2',
            'edge': '2',
            'sourcenode': '0',
            'targetnode': '1'
        }, {
            'id': '3',
            'edge': '3',
            'sourcenode': '1',
            'targetnode': '-1'
        }, {
            'id': '4',
            'edge': '4',
            'sourcenode': '1',
            'targetnode': '-1'
        }]
    }

    return vessel
Exemple #2
0
 def test_determine_connectivity_closed_contour(self):
     reset_node_id()
     contour = {'colour': '#00ff00', 'closed': True, 'name': 'Heart',
                'data': [MBFPoint(3, 3, 4, 1), MBFPoint(2, 1, 5, 1),
                         MBFPoint(3, 1, 4.2, 1)]}
     self.assertListEqual([[1, 2], [2, 3], [3, 1]],
                          determine_contour_connectivity(contour['data'], contour['closed']))
Exemple #3
0
 def test_determine_connectivity_branch(self):
     reset_node_id()
     tree = [
         MBFPoint(3, 3, 4, 2), [MBFPoint(2, 1, 5, 7)],
         [MBFPoint(2, 4, 8, 5.7)]
     ]
     self.assertListEqual([[1, 2], [1, 3]],
                          determine_tree_connectivity(tree))
Exemple #4
0
 def test_determine_connectivity_basic(self):
     reset_node_id()
     tree = [
         MBFPoint(3, 3, 4, 2),
         MBFPoint(2, 1, 5, 7),
         MBFPoint(3, 1, 4.2, 7.1)
     ]
     self.assertListEqual([[1, 2], [2, 3]],
                          determine_tree_connectivity(tree))
Exemple #5
0
    def test_write_ex_branch(self):
        ex_file = _resource_path("multi_tree.ex")
        if os.path.exists(ex_file):
            os.remove(ex_file)

        tree = {'rgb': [0, 0, 0],
                'data': [MBFPoint(3, 3, 4, 2), [MBFPoint(2, 1, 5, 7)], [MBFPoint(2, 4, 8, 5.7)]]}
        data = MBFData()
        data.add_tree(tree)

        write_ex(ex_file, data)
        self.assertTrue(os.path.exists(ex_file))
Exemple #6
0
    def test_write_ex_basic(self):
        ex_file = _resource_path("basic_tree.ex")
        if os.path.exists(ex_file):
            os.remove(ex_file)

        tree = {'rgb': [0, 0, 0],
                'data': [MBFPoint(3, 3, 4, 2), MBFPoint(2, 1, 5, 7), MBFPoint(3, 1, 4.2, 7.1)]}
        data = MBFData()
        data.add_tree(tree)

        write_ex(ex_file, data)
        self.assertTrue(os.path.exists(ex_file))
Exemple #7
0
    def test_write_ex_basic(self):
        ex_file = _resource_path("basic_contour.ex")
        if os.path.exists(ex_file):
            os.remove(ex_file)

        data = MBFData()
        contour = {'colour': '#00ff00', 'rgb': [0, 1, 0], 'closed': True, 'name': 'Heart',
                   'data': [MBFPoint(3, 3, 4, 1), MBFPoint(2, 1, 5, 1),
                            MBFPoint(3, 1, 4.2, 1)]}
        data.add_contour(contour)

        write_ex(ex_file, data)
        self.assertTrue(os.path.exists(ex_file))
Exemple #8
0
def _create_basic_vessel():
    points = [MBFPoint(5392.12, -3790.88, -1450.71, 0.0),
              MBFPoint(5388.43, -3792.66, -1450.71, 3.465),
              MBFPoint(5386.77, -3784.35, -1458.0, 2.995),
              MBFPoint(5385.11, -3776.05, -1465.29, 2.995),
              MBFPoint(5380.12, -3767.75, -1458.0, 2.425),
              MBFPoint(5375.25, -3762.97, -1462.01, 2.425),
              MBFPoint(5368.62, -3753.33, -1469.66, 2.375),
              MBFPoint(5362.75, -3744.75, -1472.56, 2.325),
              MBFPoint(5359.65, -3738.88, -1473.13, 2.085),
              MBFPoint(5351.89, -3731.22, -1472.58, 2.35),
              MBFPoint(5348.57, -3721.25, -1472.58, 2.35),
              MBFPoint(5340.27, -3712.95, -1479.87, 2.35),
              MBFPoint(5330.31, -3706.31, -1487.16, 2.35)]
    vessel = {'version': '3', 'colour': '#FFFF00', 'rgb': [1.0, 1.0, 0.0], 'type': 'directed',
              'name': 'Vessel Name 1', 'nodes': [],
              'edges': [{'id': '0', 'data': points}],
              'edgelists': [{'id': '0', 'edge': '0', 'sourcenode': '-1', 'targetnode': '-1'}]}

    return vessel
Exemple #9
0
def _create_advanced_vessel():
    edges = [{'id': '0',
              'data': [MBFPoint(4612.96, -3183.24, -1880.82, 0.83), MBFPoint(4613.07, -3181.37, -1873.73, 0.83)]},
             {'id': '1',
              'data': [MBFPoint(4613.07, -3181.37, -1873.73, 0.83), MBFPoint(4614.62, -3194.86, -1880.82, 2.615),
                       MBFPoint(4620.71, -3203.48, -1880.5, 2.35), MBFPoint(4627.9, -3211.47, -1895.4, 2.615),
                       MBFPoint(4636.21, -3221.43, -1888.11, 3.525), MBFPoint(4643.67, -3227.75, -1872.88, 4.04)]},
             {'id': '2',
              'data': [MBFPoint(4613.07, -3181.37, -1873.73, 0.83), MBFPoint(4617.23, -3167.96, -1880.22, 3.11),
                       MBFPoint(4617.23, -3167.96, -1880.22, 3.11)]},
             {'id': '3', 'data': [MBFPoint(4617.23, -3167.96, -1880.22, 3.11),
                                  MBFPoint(4622.92, -3168.29, -1873.53, 2.625),
                                  MBFPoint(4614.62, -3174.94, -1873.53, 2.56),
                                  MBFPoint(4612.96, -3184.9, -1873.53, 2.59)]},
             {'id': '4', 'data': [
                 MBFPoint(4617.23, -3167.96, -1880.22, 3.11), MBFPoint(4605.6, -3160.61, -1872.13, 3.11),
                 MBFPoint(4599.3, -3161.49, -1879.86, 2.49), MBFPoint(4588.05, -3158.33, -1873.53, 2.49),
                 MBFPoint(4579.75, -3150.03, -1880.82, 2.995), MBFPoint(4573.45, -3142.22, -1865.03, 2.995),
                 MBFPoint(4568.12, -3133.42, -1866.24, 2.995), MBFPoint(4561.48, -3125.12, -1873.53, 2.995),
                 MBFPoint(4556.5, -3116.82, -1873.53, 2.995), MBFPoint(4546.63, -3110.34, -1872.48, 2.995),
                 MBFPoint(4541.56, -3101.87, -1873.53, 2.885), MBFPoint(4534.25, -3093.46, -1863.1, 2.885),
                 MBFPoint(4528.38, -3086.97, -1866.8, 2.885), MBFPoint(4519.3, -3078.87, -1863.55, 2.985),
                 MBFPoint(4508.88, -3070.2, -1871.19, 2.985), MBFPoint(4501.7, -3062.02, -1880.82, 2.35),
                 MBFPoint(4493.4, -3057.04, -1873.53, 2.35), MBFPoint(4482.46, -3054.08, -1876.4, 3.355),
                 MBFPoint(4475.13, -3050.4, -1888.11, 3.355), MBFPoint(4474.3, -3051.5, -1878.73, 2.49),
                 MBFPoint(4463.51, -3055.38, -1880.82, 2.49), MBFPoint(4403.73, -3042.09, -1888.11, 1.66)]}]

    vessel = {'version': '3', 'colour': '#80FF00', 'rgb': [0.5019607843137255, 1.0, 0.0], 'type': 'directed',
              'name': 'Vessel Name 1',
              'nodes': [{'id': '0', 'data': MBFPoint(4613.07, -3181.37, -1873.73, 0.83)},
                        {'id': '1', 'data': MBFPoint(4617.23, -3167.96, -1880.22, 3.11)}], 'edges': edges,
              'edgelists': [{'id': '0', 'edge': '0', 'sourcenode': '-1', 'targetnode': '0'},
                            {'id': '1', 'edge': '1', 'sourcenode': '0', 'targetnode': '-1'},
                            {'id': '2', 'edge': '2', 'sourcenode': '0', 'targetnode': '1'},
                            {'id': '3', 'edge': '3', 'sourcenode': '1', 'targetnode': '-1'},
                            {'id': '4', 'edge': '4', 'sourcenode': '1', 'targetnode': '-1'}]}

    return vessel
Exemple #10
0
 def test_determine_connectivity_multiple_branch(self):
     reset_node_id()
     tree = [MBFPoint(3, 3, 4, 2), MBFPoint(3, 3, 4, 2), MBFPoint(3, 3, 4, 2),
             [MBFPoint(2, 1, 5, 7), MBFPoint(2, 1, 5, 7), MBFPoint(2, 1, 5, 7),
              [MBFPoint(2, 4, 8, 5.7), MBFPoint(2, 4, 8, 5.7), MBFPoint(2, 4, 8, 5.7),
               MBFPoint(2, 4, 8, 5.7)],
              [MBFPoint(2, 4, 8, 5.7), MBFPoint(2, 4, 8, 5.7), MBFPoint(2, 4, 8, 5.7)]],
             [MBFPoint(2, 4, 8, 5.7), MBFPoint(2, 4, 8, 5.7)]]
     self.assertListEqual([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9],
                           [9, 10], [6, 11], [11, 12], [12, 13], [3, 14], [14, 15]],
                          determine_tree_connectivity(tree))
Exemple #11
0
 def test_point_set(self):
     p = MBFPoint(6, 3, 4, 9)
     self.assertListEqual([6, 3, 4, 4.5], p.get())
Exemple #12
0
 def test_point(self):
     p = MBFPoint(1, 2, 4, 5)
     self.assertListEqual([1, 2, 4], p.coordinates())
     self.assertEqual(2.5, p.radius())