This paper investigates path planning strategies for additive manufacturing processes such as powder bed fusion. The state of the art mainly studies trajectories based on existing patterns. Parametric optimization on these patterns or allocating them to the object areas are the main strategies. We propose in this work a more systematic optimization approach without any a priori restriction on the trajectories. The typical optimization problem is to melt the desired structure, without overheating (to avoid thermally induced residual stresses) and possibly with a minimal path length. The state equation is the heat equation with a source term depending on the scanning path. First, in a steady-state context, shape optimization tools are applied to trajec-tories. Second, for time-dependent problems, an optimal control method is considered instead. In both cases, gradient type algorithms are deduced and tested on 2-d examples. Numerical results are discussed, leading to a better understanding of the problem and thus to short-and long-term perspectives.