C++ CadCam program development with CodeBlocks instead of QT
24 May 2021 12:56 - 24 May 2021 13:11 #210054
by Grotius
Replied by Grotius on topic C++ CadCam program development with CodeBlocks instead of QT
Hi Joco,
I have good news.
I cloned the libdxfrw from your link and build it with :
If you have problem's doing this, just install the linux-pro edition. Then you have also the same qt edition as me.
At the end of the build i could see where the lib was installed, and see the include paths.
Then i started a qt project and added the following lines in the .pro file :
If you add this to the .pro file, your src files will be copied to the build dir, wich is handy
Oke then i tested the dxf write. This was quite easy. Writing the dxf is done in the examplewriter.cpp class.
But reading the dxf took more time.
But after 4 hours of digging. I got into this result :
The data is retrieved by :Every block is a entity (line, arc, etc). In the mainwindow you see i itterate through the blocks.
Attached a very raw code for you. This code has to be cleaned up, and maybe rewritten to make it more readable.
The dx_data.h file stores the dxf information after the dxf is readed in.
An sich this works ok. But i don't like the programming style.
examplewriter.h is the same as dx_iface.h. The imporant thing is they contain : DRW_Interface
These files are for saving the dxf. This saving has to be done in a way that the dxf info is complete.
"iface" is a synonym for interface.
The most helpfull example on github was : example
I borrowed some code, and it worked.
We are now ready to set up the code very organised.
I think a single cpp + h file could do the interface job for us.
Are you able to organize this template class? If you think not, no problem, just correspond it to me. And i will create something.
I have good news.
I cloned the libdxfrw from your link and build it with :
autoreconf -vfi (optional)
./configure
make
make install (as root)
If you have problem's doing this, just install the linux-pro edition. Then you have also the same qt edition as me.
At the end of the build i could see where the lib was installed, and see the include paths.
Then i started a qt project and added the following lines in the .pro file :
INCLUDEPATH+= /usr/local/include/libdxfrw0/ \
LIBS+=-ldxfrw -L/usr/local/lib
If you add this to the .pro file, your src files will be copied to the build dir, wich is handy
# this copies the configuration files etc to the build direcory. So user has only to edit the source directory.
copydata.commands = $(COPY_DIR) $$PWD/* $$OUT_PWD
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata
Oke then i tested the dxf write. This was quite easy. Writing the dxf is done in the examplewriter.cpp class.
But reading the dxf took more time.
But after 4 hours of digging. I got into this result :
The data is retrieved by :
auto blocks = _data->mBlock->ent;
Attached a very raw code for you. This code has to be cleaned up, and maybe rewritten to make it more readable.
The dx_data.h file stores the dxf information after the dxf is readed in.
An sich this works ok. But i don't like the programming style.
examplewriter.h is the same as dx_iface.h. The imporant thing is they contain : DRW_Interface
These files are for saving the dxf. This saving has to be done in a way that the dxf info is complete.
"iface" is a synonym for interface.
The most helpfull example on github was : example
I borrowed some code, and it worked.
We are now ready to set up the code very organised.
I think a single cpp + h file could do the interface job for us.
Are you able to organize this template class? If you think not, no problem, just correspond it to me. And i will create something.
Last edit: 24 May 2021 13:11 by Grotius.
Please Log in or Create an account to join the conversation.
24 May 2021 20:54 #210102
by Joco
Replied by Joco on topic C++ CadCam program development with CodeBlocks instead of QT
Thanks.
looks like the "autoreconf -vfi " is what makes the difference for me. The -vfi being the key. I had used autoreconf but had no idea that the .compile file was created by it if the correct flags are in place. So I thought that file was missing from the repo.
Have pulled down the sample to start looking at. Is there a missing .h and .cpp file? The examplereader.h seems to be missing? At least that is where the compile fails at and I'm not seeing the file. And looks like the supporting cpp file is also missing. Unless I am supposed to grab them from somwhere else?
looks like the "autoreconf -vfi " is what makes the difference for me. The -vfi being the key. I had used autoreconf but had no idea that the .compile file was created by it if the correct flags are in place. So I thought that file was missing from the repo.
Have pulled down the sample to start looking at. Is there a missing .h and .cpp file? The examplereader.h seems to be missing? At least that is where the compile fails at and I'm not seeing the file. And looks like the supporting cpp file is also missing. Unless I am supposed to grab them from somwhere else?
Please Log in or Create an account to join the conversation.
24 May 2021 21:24 - 24 May 2021 21:25 #210108
by Joco
Replied by Joco on topic C++ CadCam program development with CodeBlocks instead of QT
Grotius - any advice on what you consider a solid and clearly written c++ tutorial or primer would be useful. I’m ok with C so not ground zero. And OO concepts is fine from a lot of Objective-C, python stuff. It’s the C++ specific language and ways of doing things that I’m having to get my head around. For example it wasn’t until I figured out that Interface was just another way to talk about virtual classes under a specific usage pattern that started to get a sense of what was being talked about.
Cheers - James.
Cheers - James.
Last edit: 24 May 2021 21:25 by Joco.
Please Log in or Create an account to join the conversation.
25 May 2021 12:18 - 25 May 2021 12:25 #210216
by Grotius
Replied by Grotius on topic C++ CadCam program development with CodeBlocks instead of QT
Hi Joco,
Ok nice you got it compiled.
The libdxfrw has a quite confusing interface with virtual and override stuff. Normally i don't use this.
I think we started with the hard part. The dxfrw lib.
But today i am working on it to get it running.
I just finished a clean example how to load and save the dxf file.
And how to add a line to the dxf and save it with the drawing. At this stage it's functional.
Now the dxfrw source code is inside the project. So we don't need any install any more.
Now i will add the opencascade viewer to the project, so we can display the dxf content.
Take a look at my current progress : archive-transfer
If you read it, focus on the mainwindow class.
An exersize could be, add a extra line to the code, or even an arc. And check if the line appears in Librecad.
Maybe play some around with the layout. You have to design a layout. So you can start with that.
I don't have really a tutorial. If you can do C. You may write parts in c.
If i have question's about c-c++ i like to click sites as: geeksforgeeks, stackoverflow, etc.
But i like very basic c++. I hate things like : template classes, virtual, overide etc.
Ok nice you got it compiled.
The libdxfrw has a quite confusing interface with virtual and override stuff. Normally i don't use this.
I think we started with the hard part. The dxfrw lib.
But today i am working on it to get it running.
I just finished a clean example how to load and save the dxf file.
And how to add a line to the dxf and save it with the drawing. At this stage it's functional.
Now the dxfrw source code is inside the project. So we don't need any install any more.
Now i will add the opencascade viewer to the project, so we can display the dxf content.
Take a look at my current progress : archive-transfer
If you read it, focus on the mainwindow class.
An exersize could be, add a extra line to the code, or even an arc. And check if the line appears in Librecad.
Maybe play some around with the layout. You have to design a layout. So you can start with that.
I don't have really a tutorial. If you can do C. You may write parts in c.
If i have question's about c-c++ i like to click sites as: geeksforgeeks, stackoverflow, etc.
But i like very basic c++. I hate things like : template classes, virtual, overide etc.
Last edit: 25 May 2021 12:25 by Grotius.
Please Log in or Create an account to join the conversation.
25 May 2021 13:47 - 25 May 2021 19:01 #210224
by Grotius
Replied by Grotius on topic C++ CadCam program development with CodeBlocks instead of QT
Hi Joco,
Just tested loading a dxf and add the primitives to the opencascade.
It looks like the arc's are ok.
filetransfer.io/data-package/MPpXn05n#link
Ok at this stage we can:
1. Load a dxf and save a dxf.
2. Display the dxf content in opencascade.
3. Add primitives to the dxf and save the dxf.
To test:
1. Load and save a dwg file. This should be also supported by the libdxfrw.
2. Show a gantry machine (stepfile based) with dxf preview.
Program strategy:
1. Using a central databucket (std::vector) of type "struct" to store the primitives (line,arc,circle etc).
- This databucket contains the base data of all primitives. We use this databucket for contour calculations, tangential, nesting etc.
- Then when a dxf is loaded, the dxf data is applied => copied to the databucket.
- The opencascade is then showing the contents of the data bucket.
- When a item is clicked in opencascade screen, we know wich item of the databucket is selected, this is important to edit (correct) lead-in and lead-out places.
- We have to use at least one rotation-translation matrix to let the user rotate, move the g-code output in 3d space.
A matrix implementation is here : github.com/grotius-cnc/matrix_3D
Instead of using above matrix. We can also use the opencascade matrix, wich is easyer to use.
2. This repository has a quite robust contour recognize algoritme inside : github.com/grotius-cnc/QT_CadCam_rev0
Maybe we can use this one. The algoritme was tested in the past and performing better then sheetcam when using big files.
3. Is it usefull to create a live preview (demo) of the cut path.
Joco can write down how he want's to do the program sequence.
One of the hard parts that will come is changing the lead-in positions.
[edit]
Just added some extra opencascade code to preview the ellipse and ellipse arc's.
If it's a 3d dxf, the opencascade display's the ellipse and ellipse arc in 3d.
Just tested loading a dxf and add the primitives to the opencascade.
It looks like the arc's are ok.
filetransfer.io/data-package/MPpXn05n#link
Ok at this stage we can:
1. Load a dxf and save a dxf.
2. Display the dxf content in opencascade.
3. Add primitives to the dxf and save the dxf.
To test:
1. Load and save a dwg file. This should be also supported by the libdxfrw.
2. Show a gantry machine (stepfile based) with dxf preview.
Program strategy:
1. Using a central databucket (std::vector) of type "struct" to store the primitives (line,arc,circle etc).
- This databucket contains the base data of all primitives. We use this databucket for contour calculations, tangential, nesting etc.
- Then when a dxf is loaded, the dxf data is applied => copied to the databucket.
- The opencascade is then showing the contents of the data bucket.
- When a item is clicked in opencascade screen, we know wich item of the databucket is selected, this is important to edit (correct) lead-in and lead-out places.
- We have to use at least one rotation-translation matrix to let the user rotate, move the g-code output in 3d space.
A matrix implementation is here : github.com/grotius-cnc/matrix_3D
Instead of using above matrix. We can also use the opencascade matrix, wich is easyer to use.
2. This repository has a quite robust contour recognize algoritme inside : github.com/grotius-cnc/QT_CadCam_rev0
Maybe we can use this one. The algoritme was tested in the past and performing better then sheetcam when using big files.
3. Is it usefull to create a live preview (demo) of the cut path.
Joco can write down how he want's to do the program sequence.
One of the hard parts that will come is changing the lead-in positions.
[edit]
Just added some extra opencascade code to preview the ellipse and ellipse arc's.
If it's a 3d dxf, the opencascade display's the ellipse and ellipse arc in 3d.
Attachments:
Last edit: 25 May 2021 19:01 by Grotius.
The following user(s) said Thank You: tommylight, Joco
Please Log in or Create an account to join the conversation.
25 May 2021 19:28 #210250
by Joco
I totally agree. It is very easy to make c++ that is obscure and hard to understand using those features. Simple c++ is good. I’ll try and get some time to look at the new stuff. That last post i think I actually followed.
And slow down! Some of us need to sleep. . Probably too many projects not helping.
Cheers - J.
Replied by Joco on topic C++ CadCam program development with CodeBlocks instead of QT
But i like very basic c++. I hate things like : template classes, virtual, overide etc.
I totally agree. It is very easy to make c++ that is obscure and hard to understand using those features. Simple c++ is good. I’ll try and get some time to look at the new stuff. That last post i think I actually followed.
And slow down! Some of us need to sleep. . Probably too many projects not helping.
Cheers - J.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
25 May 2021 19:50 - 25 May 2021 20:54 #210255
by Grotius
Replied by Grotius on topic C++ CadCam program development with CodeBlocks instead of QT
Hi Joco,
And slow down! Some of us need to sleep. Ok.
Simple c++ is good.
Clean coding is a art.
Oke. Now last item for today. The 3d cubic spline. I did this code before a few weeks ago for the robot project.
It will take no long time.
I now have also added the lwpolyline. I spotted a bug in the dxfrwlib. It has no z value for lwpolylines. Catcha.
[edit]
Ok the spline is also done. Now it's bed time. Good night !
To test i downloaded a sample dxf file from : www.cncdesignshop.com/promotions/free-dxf-file-downloads.html
It loaded ok.
And slow down! Some of us need to sleep. Ok.
Simple c++ is good.
Clean coding is a art.
Oke. Now last item for today. The 3d cubic spline. I did this code before a few weeks ago for the robot project.
It will take no long time.
I now have also added the lwpolyline. I spotted a bug in the dxfrwlib. It has no z value for lwpolylines. Catcha.
[edit]
Ok the spline is also done. Now it's bed time. Good night !
To test i downloaded a sample dxf file from : www.cncdesignshop.com/promotions/free-dxf-file-downloads.html
It loaded ok.
Attachments:
Last edit: 25 May 2021 20:54 by Grotius.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19202
- Thank you received: 6436
25 May 2021 21:52 #210273
by tommylight
Replied by tommylight on topic C++ CadCam program development with CodeBlocks instead of QT
What is this "sleep" you talk about?And slow down! Some of us need to sleep. . Probably too many projects not helping.
Please Log in or Create an account to join the conversation.
26 May 2021 00:00 #210287
by Joco
Yeah - he's going faster than I can keep up at the moment. Between work and some other projects I only get a couple of hours on this at most a day or every couple of days.
BUT I am starting to track and understand things better as I get more into my head C++. I'm sure I will get there. Back in the day when I was working in a gaming mod group I managed to teach myself quaternions and their application in 3d space. Had to do it as that was how the 3d modeling apps scritping language got around gimble lock. Gosh that's going back a looong time.
Replied by Joco on topic C++ CadCam program development with CodeBlocks instead of QT
What is this "sleep" you talk about?
Yeah - he's going faster than I can keep up at the moment. Between work and some other projects I only get a couple of hours on this at most a day or every couple of days.
BUT I am starting to track and understand things better as I get more into my head C++. I'm sure I will get there. Back in the day when I was working in a gaming mod group I managed to teach myself quaternions and their application in 3d space. Had to do it as that was how the 3d modeling apps scritping language got around gimble lock. Gosh that's going back a looong time.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
26 May 2021 03:22 #210300
by Joco
Replied by Joco on topic C++ CadCam program development with CodeBlocks instead of QT
I managed to butcher my dev vm. Fixed now. Nice shiny new Mint20.
For opencascade compiled from source and installed. Got the latest sample Grotius supplied compiled and runnning. All over lunch. This evening hope to have some learning time with the code base.
For opencascade compiled from source and installed. Got the latest sample Grotius supplied compiled and runnning. All over lunch. This evening hope to have some learning time with the code base.
Please Log in or Create an account to join the conversation.
Moderators: Skullworks
Time to create page: 0.149 seconds