コード例 #1
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_insert():
    # without duplicates
    T = Delaunay3()
    T.insert(pts)
    assert (T.is_valid())
    # with duplicates
    T = Delaunay3()
    T.insert(pts_dup)
    assert (T.is_valid())
コード例 #2
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_io():
    fname = 'test_io2348_3.dat'
    Tout = Delaunay3()
    Tout.insert(pts)
    Tout.write_to_file(fname)
    Tin = Delaunay3()
    Tin.read_from_file(fname)
    assert (Tout.num_verts == Tin.num_verts)
    assert (Tout.num_cells == Tin.num_cells)
    os.remove(fname)
コード例 #3
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_num_facets():
    # without duplicates
    T = Delaunay3()
    T.insert(pts)
    print(T.num_finite_facets, T.num_infinite_facets, T.num_facets)
    assert (T.num_finite_facets == nfacets_fin)
    assert (T.num_infinite_facets == nfacets_inf)
    assert (T.num_facets == nfacets)
    # with duplicates
    T = Delaunay3()
    T.insert(pts_dup)
    print(T.num_finite_facets, T.num_infinite_facets, T.num_facets)
    assert (T.num_finite_facets == nfacets_fin)
    assert (T.num_infinite_facets == nfacets_inf)
    assert (T.num_facets == nfacets)
コード例 #4
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_vertices():
    T = Delaunay3()
    T.insert(pts)
    v = T.vertices
    assert (v.shape[0] == pts.shape[0])
    assert (v.shape[1] == pts.shape[1])
    assert (np.allclose(pts, v))
コード例 #5
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_vert():
    T = Delaunay3()
    T.insert(pts)
    vold = None
    for v in T.all_verts:
        idx = v.index
        pnt = v.point
        vol = v.dual_volume
        print(v, idx, pnt, vol)
        assert (v == v)
        if vold is not None:
            assert (v != vold)
        if v.is_infinite():
            assert (idx == np.iinfo(np.uint32).max)
            assert (np.isinf(pnt).all())
            assert (np.isclose(vol, -1.0))
        else:
            assert (np.allclose(pnt, pts[idx, :]))
            if idx == 0:
                assert (np.isclose(vol, 4.5))
            else:
                assert (np.isclose(vol, -1.0))
            c = v.cell
            v.set_cell(c)
            v.set_point(pnt)
        vold = v
コード例 #6
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_is_cell():
    T = Delaunay3()
    T.insert(pts)
    assert (T.is_cell(T.get_vertex(0), T.get_vertex(1), T.get_vertex(3),
                      T.get_vertex(5)))
    assert (not T.is_cell(T.get_vertex(0), T.get_vertex(1), T.get_vertex(3),
                          T.get_vertex(nverts_fin - 1)))
コード例 #7
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_clear():
    T = Delaunay3()
    T.insert(pts)
    T.clear()
    print(T.num_finite_verts, T.num_cells)
    assert (T.num_finite_verts == 0)
    assert (T.num_cells == 0)
コード例 #8
0
def test_vert():
    T = Delaunay3(left_edge, right_edge)
    T.insert(pts)
    vold = None
    for v in T.all_verts:
        idx = v.index
        pnt = v.point
        per = v.periodic_point
        off = v.periodic_offset
        vol = v.dual_volume
        print(pts[idx, :])
        print(v, idx, vol, pnt, per, off)
        assert (v == v)
        if vold is not None:
            assert (v != vold)
        if v.is_infinite():
            assert (idx == np.iinfo(np.uint32).max)
            assert (np.isinf(per).all())
            assert (np.isclose(vol, -1.0))
        else:
            assert (np.allclose(per, pts[idx, :]))
            if idx == 0:
                assert (np.isclose(vol, 4.5))
            c = v.cell
            v.set_cell(c)
            v.set_point(per)
        vold = v
コード例 #9
0
def test_locate():
    T = Delaunay3(left_edge, right_edge)
    T.insert(pts)
    for c in T.finite_cells:
        if c.has_offset:
            continue
        p = c.center
        print(c, p, T.locate(p))
        assert (c == T.locate(p))
        assert (c == T.locate(p, c))
        assert (c.vertex(0) == T.locate(c.vertex(0).point))
        assert (c.vertex(0) == T.locate(c.vertex(0).point, c))
        # TODO: check that is_equivalent is working
        # assert(c.facet(0).is_equivalent(T.locate(c.facet(0).edge(0).center)))
        # assert(c.facet(0).is_equivalent(
        #     T.locate(c.facet(0).edge(0).center, c)))
        # assert(c.facet(0) == T.locate(c.facet(0).center))
        # assert(c.facet(0) == T.locate(c.facet(0).center, c))
        # assert(c.facet(0).edge(0).is_equivalent(
        #     T.locate(c.facet(0).edge(0).center)))
        # assert(c.facet(0).edge(0).is_equivalent(
        #     T.locate(c.facet(0).edge(0).center, c)))
        # assert(c.facet(0).edge(0) == T.locate(c.facet(0).edge(0).center))
        # assert(c.facet(0).edge(0) == T.locate(c.facet(0).edge(0).center, c))
        break
コード例 #10
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_finite_cells():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for c in T.finite_cells:
        assert ((not c.is_infinite()))
        count += 1
    assert (count == T.num_finite_cells)
コード例 #11
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_finite_verts():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.finite_verts:
        assert ((not v.is_infinite()))
        count += 1
    assert (count == T.num_finite_verts)
コード例 #12
0
def test_num_edges():
    # without duplicates
    T = Delaunay3(left_edge, right_edge)
    T.insert(pts)
    print(T.num_finite_edges, T.num_infinite_edges, T.num_edges)
    assert (T.num_finite_edges == nedges_fin)
    assert (T.num_infinite_edges == nedges_inf)
    assert (T.num_edges == nedges)
    assert (T.num_stored_edges == T.num_sheets_total * nedges)
    # with duplicates
    T = Delaunay3(left_edge, right_edge)
    T.insert(pts_dup)
    print(T.num_finite_edges, T.num_infinite_edges, T.num_edges)
    assert (T.num_finite_edges == nedges_fin)
    assert (T.num_infinite_edges == nedges_inf)
    assert (T.num_edges == nedges)
    assert (T.num_stored_edges == T.num_sheets_total * nedges)
コード例 #13
0
def test_get_boundary_of_conflicts():
    T = Delaunay3(left_edge, right_edge)
    T.insert(pts)
    v = T.get_vertex(0)
    c = v.incident_cells()[0]
    p = c.circumcenter
    edges = T.get_boundary_of_conflicts(p, c)
    print(len(edges))
コード例 #14
0
def test_finite_cells():
    T = Delaunay3(left_edge, right_edge)
    T.insert(pts)
    count = 0
    for c in T.finite_cells:
        assert ((not c.is_infinite()))
        count += 1
    assert (count == T.num_stored_cells)
コード例 #15
0
ファイル: test_plot.py プロジェクト: langmm/cgal4py
def test_plot3D():
    fname_test = "test_plot3D.png"
    T = Delaunay3()
    T.insert(pts3)
    axs = T.plot(plotfile=fname_test, title='Test')
    os.remove(fname_test)
    # T.plot(axs=axs)
    del axs
コード例 #16
0
def test_finite_verts():
    T = Delaunay3(left_edge, right_edge)
    T.insert(pts)
    count = 0
    for v in T.finite_verts:
        assert ((not v.is_infinite()))
        count += 1
    assert (count == T.num_stored_verts)
コード例 #17
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_get_conflicts():
    T = Delaunay3()
    T.insert(pts)
    v = T.get_vertex(0)
    c = v.incident_cells()[0]
    p = c.circumcenter
    cells = T.get_conflicts(p, c)
    print(len(cells))
コード例 #18
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_get_conflicts_and_boundary():
    T = Delaunay3()
    T.insert(pts)
    v = T.get_vertex(0)
    c = v.incident_cells()[0]
    p = c.circumcenter
    cells, edges = T.get_conflicts_and_boundary(p, c)
    print(len(cells), len(edges))
コード例 #19
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_finite_edges():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for e in T.finite_edges:
        assert ((not e.is_infinite()))
        count += 1
    print(count)
    assert (count == T.num_finite_edges)
コード例 #20
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_flip():
    T = Delaunay3()
    T.insert(pts)
    for c in T.all_cells:
        out = T.flip(c, 0)
        # assert(out == True)
    assert (T.num_edges == nedges)
    for e in T.all_edges:
        out = e.flip()
        # assert(out == True)
        del out
コード例 #21
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_facet():
    T = Delaunay3()
    T.insert(pts)
    fold = None
    for f in T.all_facets:
        v1 = f.vertex(0)
        v2 = f.vertex(1)
        v3 = f.vertex(2)
        e1 = f.edge(0)
        e2 = f.edge(1)
        e3 = f.edge(2)
        c = f.cell
        i = f.ind
        inf = f.is_infinite()
        gab = f.is_Gabriel()
        print(f, v1.index, v2.index, v3.index, i, inf, gab, f.center)
        assert (f == f)
        assert (f.is_equivalent(f))
        if fold is not None:
            assert (f != fold)
        del (e1, e2, e3, c)

        p1 = f.center
        p2 = v1.point
        print(f.side(p1), p1)
        print(f.side(p2), p2)
        if f.is_infinite():
            assert (np.isinf(f.center).all())
            assert (f.side(p1) == -1)
            assert (f.side(p2) == -1)
        # else:
        #     p3 = 2*v1.point - f.center + np.arange(3)
        #     print(f.side(p3), p3)
        #     assert(f.side(p1) == -1)
        #     assert(f.side(p2) == 0)
        #     assert(f.side(p3) == 1)

        # # This segfaults inside CGAL function call
        # print(f.side_of_circle((v1.point+v2.point+v3.point)/3),
        #       (v1.point+v2.point+v3.point)/3)
        # print(f.side_of_circle(v1.point), v1.point)
        # print(f.side_of_circle((5*v1.point-v2.point-v3.point)/3),
        #       (5*v1.point-v2.point-v3.point)/3)
        # if f.is_infinite():
        #     assert(f.side_of_circle((v1.point+v2.point+v3.point)/3) == -1)
        #     assert(f.side_of_circle(v1.point) == -1)
        #     assert(f.side_of_circle((5*v1.point-v2.point-v3.point)/3) == -1)
        # else:
        #     # This segfaults...
        #     assert(f.side_of_circle((v1.point+v2.point+v3.point)/3) == -1)
        #     assert(f.side_of_circle(v1.point) == 0)
        #     assert(f.side_of_circle((5*v1.point-v2.point-v3.point)/3) == 1)

        fold = f
コード例 #22
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_facet_incident_cells():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_facets:
        c0 = 0
        for e in v.incident_cells():
            c0 += 1
            count += 1
        print(c0)
    print(count, 2 * T.num_facets)
    assert (count == 2 * T.num_facets)  # 96
コード例 #23
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_cell_incident_cells():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_cells:
        c0 = 0
        for e in v.incident_cells():
            c0 += 1
            count += 1
        print(c0)
    print(count, 4 * T.num_cells)
    assert (count == 4 * T.num_cells)  # 72
コード例 #24
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_facet_incident_verts():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_facets:
        c0 = 0
        for e in v.incident_vertices():
            c0 += 1
            count += 1
        print(c0)
    print(count, 3 * T.num_facets)
    assert (count == 3 * T.num_facets)  # 144
コード例 #25
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_facet_incident_facets():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_facets:
        c0 = 0
        for e in v.incident_facets():
            c0 += 1
            count += 1
        print(c0)
    print(count)
    assert (count == 480)
コード例 #26
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_edge_incident_cells():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_edges:
        c0 = 0
        for e in v.incident_cells():
            c0 += 1
            count += 1
        print(c0)
    print(count, 3 * T.num_facets)
    assert (count == 3 * T.num_facets)  # 144
コード例 #27
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_edge_incident_edges():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_edges:
        c0 = 0
        for e in v.incident_edges():
            c0 += 1
            count += 1
        print(c0)
    print(count)
    assert (count == 404)
コード例 #28
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_edge_incident_verts():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_edges:
        c0 = 0
        for e in v.incident_vertices():
            c0 += 1
            count += 1
        print(c0)
    print(count, 2 * T.num_edges)
    assert (count == 2 * T.num_edges)  # 68
コード例 #29
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_vert_incident_cells():
    T = Delaunay3()
    T.insert(pts)
    count = 0
    for v in T.all_verts:
        c0 = 0
        for c in v.incident_cells():
            c0 += 1
            count += 1
        print(v.index, c0)
    print(count, 4 * T.num_cells)
    assert (count == 4 * T.num_cells)  # 96
コード例 #30
0
ファイル: test_delaunay3.py プロジェクト: langmm/cgal4py
def test_move():
    T = Delaunay3()
    T.insert(pts)
    v0 = T.get_vertex(0)
    new_pos = np.zeros(3, 'float64')
    v = T.move(v0, new_pos)
    assert (np.allclose(v.point, new_pos))
    assert (np.allclose(v0.point, new_pos))
    v1 = T.get_vertex(1)
    v = T.move(v1, new_pos)
    assert (np.allclose(v.point, new_pos))
    assert (T.num_verts == (nverts - 1))