An automatic and optimal selection of parts orientation in additive manufacturing