I can't think of a more complex and difficult approach to generating gcode. That is why CAM programs have been written. It would help if you could explain what it is that you are feeding your gcode into. The proper CAM tool to use really is dependent on the application - i.e. what is going to consume the g-code. It is simply x-y router paths, or 3d surface milling, etc?