Dislocation and disclination loops in the virtual-defect method