Hi jacdelad
I have inspected your code! It's very interesting for me because I see in your code all my first problems, including try to parse the files dirctly with regular expressions. What I miss in your code is an effective grafical object structure! That's same problem I ran into! It might be not a big problem if you do not want to manipulate the objects and if you do not want to scale rotate ...!
I guess you will run into a big speed problem and a mathematical problem if want to zoom and rotate the 3D-Board.
Because you have regular expressions in the PlotGerber function you have to process the regular expressions every time you do a small
rotation. And if you want to change to 3D Output it's much more effective to convert all objects to Meshes and use the PB Mesh and 3D functions.
This will be much much faster as a manual 3D plot with the 2D Grafic library. Mesh-functions using the massive parallel power of GPU.
I guess you read some of the posts of marc256, he ran into same problems with his CAD-viewer, using the PB drawing library!
----------------------------------------
I figured out and I guess (but I'm not really sure, because I did not finish my 2D/3D Vector Oject Library)
To handle all this 3D Stuff like STL, IGES, STEP ... and Gerber it's basically all the same.
So if we find an effective abstract solution for the internal Object Structure, it is possible to handle all this formats with nearly the same code base.
But this will be a small CAD enginge and it is not so easy to code!
My favorite way now is:
Parse the File and create an abstract internal 3D Object Structrue of very basic objects defined in the Gerber, IGES, STEP -format!
Now forget the orignal file and work only with the internal Object Structure.
The internal Object Structure should contain all definitins of the Gerber Specification
like Rectangle, ObRound, Circle, Polygon
With the internal Object structure it is possible to use standard 3D-Grafic Vector Matrix functions to zoom, rotate ... without an extra overhad!
The biggest problem of my favorite way is: it needs much more developping time
A note on regluar expressions.
I did a lot of speed research in PB and Regular Expression is arraound 10 times slower than Pointer based String operations.
But it's much easier to do!
Here a sample of how I think about a GerberStructrue
Code: Select all
Structure objGerber_Base
EndStructure
Structure objGerber_Circle Extends objGerber_Base
EndStructure
Structure objGerber_Obround Extends objGerber_Base
EndStructure
; .
; .
; .
I had the greate hope that we can use some of your code for general 3D File handling.
But your code is very special to gerber!