Пример #1
0
    def test_close_mesh(self):
        mesh_a = self.cutSphere_C.copy()

        boundary_prev = stop.mesh_boundary(mesh_a)

        # Correctness
        assert (len(boundary_prev) == 2)

        mesh_a_closed, nvertices_added = stop.close_mesh(mesh_a)

        # Coherence
        assert (len(mesh_a_closed.vertices) == len(mesh_a.vertices) +
                nvertices_added)

        boundary_closed = stop.mesh_boundary(mesh_a_closed)

        # Mesh is now closed
        assert (len(boundary_closed) == 0)

        # Non modification of the vertices which are not on the boundaries
        sbase = (set(range(len(mesh_a.vertices))))
        sbound1 = (set(boundary_prev[0]))
        sbound2 = (set(boundary_prev[1]))
        sbound = sbound1.union(sbound2)
        snot_bound = (sbase.difference(sbound))

        for i in snot_bound:
            assert (mesh_a.vertices[i] == mesh_a_closed.vertices[i]).all()
Пример #2
0
###############################################################################
# show the largest submesh with the boundaries of cutted parts
visb_sc4 = splt.visbrain_plot(mesh=cuted_mesh, caption='open mesh')
# create points with vispy
for bound in boundaries:
    points = cuted_mesh.vertices[bound]
    s_rad = SourceObj('rad', points, color='blue', symbol='square',
                      radius_min=10)
    visb_sc4.add_to_subplot(s_rad)
    lines = Line(pos=cuted_mesh.vertices[bound], width=10, color='r')
    # wrap the vispy object using visbrain
    l_obj = VispyObj('line', lines)
    visb_sc4.add_to_subplot(l_obj)
visb_sc4.preview()

###############################################################################
# ================= close_mesh =================
# close the largest submesh
mesh_closed, nb_verts_added = stop.close_mesh(cuted_mesh)

# The closed mesh is watertight while before closing if was not
print(mesh.is_watertight)
print(mesh_closed.is_watertight)

###############################################################################
# show the closed mesh
visb_sc5 = splt.visbrain_plot(mesh=mesh_closed,
                              caption='closed mesh')
visb_sc5.preview()