def extrude(self, displaced): """ radially extrude a surface mesh into a solid given a bounded surface, return a closed solid create extra options; rather than plain radial extrude, we can also do swepth sphere extrude; better for casting """ points = len(self.vertices) #construct edge information edges = self.edges() boundary = npi.multiplicity(self.order_edges(edges)) == 1 eb = edges[boundary] if len(eb) == 0: raise Exception('Surface to be extruded is closed, thus does not have a boundary') #construct closed solid boundary_tris = np.concatenate(( np.concatenate((eb[:,::-1], eb[:,0:1]+points),axis=1), np.concatenate((eb[:,::+1]+points, eb[:,1:2]),axis=1) )) copy_tris = self.faces[:, ::-1] + points solid_points = np.concatenate((self.vertices, displaced)) solid_tris = np.concatenate((self.faces, copy_tris, boundary_tris)) mesh = Mesh(solid_points, solid_tris) if mesh.volume() < 0: mesh.faces = mesh.faces[:, ::-1] return mesh
def boundary(self): edges = self.edges() return edges[npi.multiplicity(self.order_edges(edges)) == 1]