def apply_transformation(self, structure):
        # get the new sites
        new_sites = self._voronoi_points(structure)
        if self._midpoints:
            dms = self._delaunay_midpoints(structure)
            for i in range(len(new_sites)):
                new_sites[i].extend(dms[i])

        # insert the new sites with dummy species
        se = structure
        dummy = DummySpecie()
        for i, sites_list in enumerate(new_sites):
            for ns in sites_list:
                if self._bl == {}:
                    se.append(self._sp, ns, coords_are_cartesian=True, validate_proximity=False)
                elif structure[i].specie in self._bl.keys():
                    bv = ns - structure[i].coords
                    bv *= self._bl[structure[i].specie] / np.linalg.norm(bv)
                    coords = structure[i].coords + bv
                    se.append_site(self._sp, coords, coords_are_cartesian=True, validate_proximity=False)
        logging.debug("Starting moving to unit cell")
        se = IStructure.get_reduced_structure(se)
        logging.debug("Finished moving to unit cell")

        structure = se  # .modified_structure

        # delete sites that are closer than the bond distance
        to_delete = []
        for sp, d in self._bl.items():
            neighbors = structure.get_all_neighbors(d * 0.999)
            for i in range(len(structure)):
                if structure[i].specie == dummy:
                    for n in neighbors[i]:
                        if n[0].specie == sp:
                            to_delete.append(i)
                            break
        se.remove_sites(to_delete)

        # replace the dummy species to get the correct composition
        if self._n:
            # amt = self._n / se.modified_structure.composition[dummy]
            amt = self._n / se.composition[dummy]
            se.replace_species({dummy: {self._sp: amt}})

        return se  # .modified_structure