Schlömilch's formula is generalized and applied to the thermal Casimir effect of a fermionic field confined a three-dimensional rectangular box. The analytic expressions of the Casimir energy and Casimir force are derived for arbitrary temperature and edge sizes. The low and high temperature limits and finite temperature cases are considered for the entire parameter space spanned by edge sizes and/or temperature. In the low temperature limit, it is found that for typical rectangular box, the effective 2-dimensional parameter space spanned by the two edge size ratios can be split into four regions. In one region, all three forces between three pairs of faces are attractive, and in another two regions, the force along the longest edge becomes repulsive and in the last region the force along both the longest and medium sized edge becomes repulsive. Three forces cannot be made simultaneously repulsive. For the waveguide under low temperature, the Casimir force along the longer side of the waveguide cross-section transforms from attractive to repulsive when the aspect ratio of the cross-section exceed a critical value. For the parallel plate scenario under low temperature, our results agrees with previous works. For high tempera limit, it is shown that both the Casimir energy and force approach zero due to the high temperature suppression of the quantum fluctuation responsible for the Casimir energy. For the finite temperature case, we separate the parameter space into four subcases (C1 to C4) and various edge size and temperature effects are analyzed. In general, we found that in all cases the Casimir energy is always negative, while the Casimir force at any finite or low temperature can be either repulsive or attractive depending on the sizes of the edges. For the case (C1) that is similar to parallel plates with relatively high temperature, it is found that the Casimir force is always attractive, regardless the change of the plate separation. At the given temperature, The Casimir energy/force densities approach the infinite parallel plate limit even when the plate edge size is 2 times the plate separation. For the case (C2) that is similar to a waveguide with relatively high temperature, the Casimir force along the longer side of the waveguide cross-section transform from attractive to repulsive when this side exceed a critical value. This critical point forms a boundary in the parameter space when the shorter edge of the waveguide cross-section changes and the boundary values decreases with respect to temperature increase. Case (C3) covers the low temperature parallel plate, typical rectangular box and waveguide geometries. For the waveguide case, the force along the waveguide longitude also transform from attractive to repulsive when the waveguide length exceed certain critical value. These critical values changes with respect to temperature in a nontrivial way. For the typical waveguide case (C4) at low temperature, the Casimir energy density along the longitudinal direction is a constant while force density dec...