Classification of stable three-dimensional Dirac semimetals with nontrivial topology