I couldn't find my way around the finer details of the C++ to Python interface.
So I started following "plan B" and wrote the first code for my new C++ TPG plugin.
Aparently having 2 TPGs in a single plugin doesn't work out.
(Switching to the CAM workbench gives errors about unimplemented methods in the second plugin.)
Having a second plugin seems to work out. But it just isn't displayed in the list yet.
(Working on that.)
My repository:
https://github.com/MarcusWolschon/FreeCAD_sf_master
My plan:
Status: working on step (0).
Adding comments as I go along to make not-obvious parts of the code,
that I manage to understand, easier to understand for later developers.
0)
The plugin shall load and pass-through the config options of another TPG.
(first compiled in, later as a configurable TPGDescriptor)
1)
This plugin shall execute that TPG.
2)
Since the output is a python program, I can't post-process a single g-code line at a time but will have to store it.
3)
Then execute the stored python program to generate the g-code and store that g-code
4)
Then post-process the g-code one line at a time,
changing 3(4) axis coordinates into 4(5) axis coordinates with inverse kinematic.
The coordinates are chosen, so the tool hits the geometry with the tip at the same location in space and
the tool is parallel to the surface normal of the geometry at that point.
5)
Doing hit-tests to determine if the tool, collet or spindle hits another part of the geometry and
a) defaulting to the original coordinates or
b) finding a less perfect alignment.
6)
Analyse if the single movement needs to be broken up into smaller parts to avoid such a collision.