def empty(coords: Tuple[int, int, int] = (0, 0, 0), resolution: float = 1, num_materials: int = len(material_properties)): """ Create a VoxelModel containing a single empty voxel at the specified coordinates. Args: coords: Model origin coordinates resolution: Number of voxels per mm num_materials: Number of material types in materials vector Returns: VoxelModel """ return VoxelModel.empty((1, 1, 1), coords, resolution, num_materials)
if __name__ == '__main__': dilate_radius = 2 # Import element template T = VoxelModel.fromVoxFile('lattice_element_1m.vox') T = T.dilateBounded(dilate_radius) # Create target volume model M = cylinder(30, 60).translate((30, 30, 0)) M = M.setCoords((0, 0, 0)) t = T.voxels.shape[0] size = M.voxels.shape # Create empty model to hold result V = VoxelModel.empty(size) # Add tiled lattice elements for x in range(int(np.ceil(size[0] / t))): for y in range(int(np.ceil(size[1] / t))): for z in range(int(np.ceil(size[2] / t))): T = T.setCoords((M.coords[0] + (x * t), M.coords[1] + (y * t), M.coords[2] + (z * t))) V = V | T # Intersect lattice with target volume V = M & V # Create Mesh mesh1 = Mesh.fromVoxelModel(T) mesh2 = Mesh.fromVoxelModel(M)