Here is an applet which demonstrates the principles of the z-buffer algorithm
Follow the steps to create the result of superposition of the segments
All those developments are released under Cecill licence.
The project Forms Generator is available on a svn, contact me for more information. In the future, a project might be created on sourceforge.