QT C++ code samples

More
6 years 9 months ago #155477 by tommylight
Replied by tommylight on topic QT C++ code samples
Deb install works, with a minor issue that gdebi remains unaware of it being installed, meaning after install has finished it will not change to "reinstall package", it remains as "install package".
Also if starting the install again, it is not aware that it is already installed.
It does make the menu entry under Programming.
Thank you.

Please Log in to join the conversation.

More
6 years 9 months ago #155751 by grijalvap
Replied by grijalvap on topic QT C++ code samples
is this project open source?

Please Log in to join the conversation.

More
6 years 9 months ago #155753 by tommylight
Replied by tommylight on topic QT C++ code samples

grijalvap wrote: is this project open source?

GOSL = Grotius Open Source Licence ! :)
I am sure he insists on open source everything, and IIRC he mentioned it on this thread.

Please Log in to join the conversation.

More
6 years 8 months ago #156988 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

Are you intending to make this available later for OS other than Linux?
Yes yes, i am coding cross platform and using the standard lib's now. If i do so i don't have to stay with QT.

is this project open source?
I am thinking about this for a long time. The standard CadCam edition will be free to use for everyone without a time limit etc.
So if the program evolve's, and user's are happy. It may become a big software platform over time. We never know how this will work out in time.
But i am thinking about some additional future plugins like autonesting etc. If there is a coder that want's to write this plugin, i think
it's fair that this coder can ask a donation, but still the standard edition is free. Furthermore i don't like to share code while the program is not finished. Later on this year a nice CadCam version will appear !

Updates
A big issue was the spline function. I used a Cubic bezier curve as spline. This was not good. Bezier curve's have startpoints cq endpoints that can not be used by dxf files. So i had to look for a Cubic spline like this : mathworld.wolfram.com/CubicSpline.html

The math was to heavy for me to solve. I did not find any plug an play solution that are dealing with a cubic spline in relation to elapsed time. But attached a minimal c++ QT project that does a cubic spline. A nice hollander helped me a lot !!
www.wiskundeforum.nl/viewtopic.php?f=37&t=12717

At this point we can load dxf files completely very soon !! Have to integrate the spline code, and update the dxf read file code.
Then test wich autocad dxf versions are compatible. So far, that is good news.. Then the program can be used with inkscape !!

Important update
I left QT...

Started blanco with C++ Codeblocks.. So coming time i will review and update all my previous code to Codeblocks.
A lot of work to do, but i think a good choice for the future !

Therefore i will start a new topic for C++ Codeblocks. So far so good !!

Cadcam program in codeblocks, opengl working. Programming is little harder in relation to QT, less debug message's..

Attachment not found

Please Log in to join the conversation.

More
6 years 5 months ago #168007 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

A short update of the Qt cadcam program until now.

I am building a new CadCam program from scratch. This is my 3rth attempt.
It will include a Cad section and a Cam section with offset operations for plasma and milling machines and it will include pocket operations for milling machines. It will be 2d.
For 3d i am a fan of Freecad.

My c++ knowledge is after one year at a more usable level. I am sure it will be nice from here.

See attached beginning program code, display.h is interesting.
Object.h is a structure style, used to store all data like lines, splines, circles, arc's etc. This is a powerfull program style with automatic memory allocation. For example, The structure style can morph a line into a spline etc.

The file input_data.h is a file wich is used to add user data.
The file display.h is used to dispay the data.

So far so good !

@grijalvap,
Yes it is open source.

Please Log in to join the conversation.

More
6 years 5 months ago #168533 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi, a short update,

The contour recognize algoritme works quite nice and is almost ready.
Every object start- or endpoint within the user tollerance is calculated to
a close or open contour path with a unspecified direction, cw or ccw direction is calculated later on and before when we look
at contour depth's.

I am happy with the current programming style. See the attached source code.

Next thing to program is a pocket algoritme. I have designed the pocket algoritme on a paper several times, and i am confident it will be a usefull algoritme for linuxcnc.

The good news is, the pocket operation is capable to offset bezier curves, splines, etc. This is quite remarkable.
The spline output for Linuxcnc gcode can be selected as a G5 or as a linestrip output. This is quite easy to do for me now.

Take a look at the object open ends. The blue closed contours are within a example used tollerance. White is open contour.

Attachment not found





Have fun with coding your C++ application.
With great power, comes great ...

Please Log in to join the conversation.

More
6 years 4 months ago #170122 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi all linux fans, a c++ update today.

Currently writing a more robust contour algoritme. It's written as a header only library.

Output:
Grey : open path's
Red : single object, such as a spline with identical start- & endpoint.
Purple : closed contours that are build up from 2 objects.
Blue : closed contours that are build up from 3 objects or more.

Sequence:
All closed contours and open path's have the contour sequence.

Next step's are programmed, tested etc, but not integrated in this example.
Steps:
Area calculation for cw and ccw (for info: if area is positive we got cw, if area is negative we got ccw)
Add contour depth's (pip=point in polygon algoritme)

Oke, here are a few hardcore contour test's that are difficult to do with conventional cam program's.

I started with a downloaded picture, followed by the inkscape dxf output:

Attachment not found



Then we press the cam button in the CadCam program and wait a few seconds:

Attachment not found



Ok we try another one, earh map:

Attachment not found



Another from the matrix:

Attachment not found



Evolution:

Attachment not found



Ai:

Attachment not found



So far so good. Have a nice day !
C++ header file included.

Please Log in to join the conversation.

More
6 years 4 months ago #170850 by Grotius
Replied by Grotius on topic QT C++ code samples
Project update.

Today i added gcode output. The gcode output looks okey. Tested with ncviewer several times.
Splines are morphed into linestrips with a user defined accuracy, set to 1.

Depth cutting sequence okey.
Keep parts together cutting sequence okey.
Cw and ccw cutting sequence okey.

Time to add the G5 for splines. Have to practice with linuxcnc a little bit to find out how to program the G5 output in a correct way.

End of this week i will try to deploy an app image, for current version.
My current linux system is too new to deploy an app image. No problem, i will grab a other hard drive later on.

Attachment not found



Project source code attached.

Please Log in to join the conversation.

More
6 years 4 months ago #171407 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

Today we are at a new level. Finally starting with the pocket algoritme.

Have made a offset.h file that can offset all types of curves.
At the moment it can offset : line, linestrip, polygon, arc, circle, ellipse, bezier curve, rectangular.

Attachment not found



The pocket algoritme is quite a difficult algoritme to design.

Some of the reason's why a pocket algoritme is quite difficult is because it can form islands :

Another example of pockets with inside contours :

With some contour shapes, you need to place an extra arc, to reattach the contour again :

Attachment not found



Before i start writing this procedure in c++, i write the workflow down on paper :

1. To keep it simple, we start at the yellow contours, they are up to date for a pocket operation.
2. We do a contour offset with a value of -2mm for the yellow ones.
3. We do a intersection loop trhough the contour objects.
4. We do a contour offset with a value of +2mm for eventually insides of contour 0.
5. Intersection loop again.

6. Check if offset paths are closed, if not, place arc's to close the contour.
7. Check if offset paths are closed, if yes, go on, if not, message the user to get a cup of coffee, user is trapped in a infinite while loop :P
6. Now we check if the offset path's are self intersecting and or intersecting with other offset paths. If yes : start at a free line (non intersecting line, arc or watherver) at the intersection point, go to the left at that point, reattach to intersected object, and select objects wich are done. (later on we delete all non selected).
7. We have to look when to stop the pocket offset loop.

This is how it would look like :

Attachment not found



I am curious now how difficult it will be to get this right...

Last week i thought about the auto nesting algoritme for some time. I have good hope for that.

Please Log in to join the conversation.

More
6 years 4 months ago #171912 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

A few days working on the pocket algoritme.

Changed a lot of source code of the program to work with iterators. This means when using a style like this:
for(int i=0; i<coffee.size(); i++){
for(int j=0; j<milk.size(); i++){
//do some things
}}
It will work until a certain level. The pc will miss some data at some points if you use above style.
This results in unexpected errors.

Okey a better style is using iterators.
std::vector<int>::iterator it;
for(it=coffee.begin() it<coffee.end() it++){
it->milk = 1;
}
Now the program is more fail safe. And the c++ editor warning are also gone.

Okey lets show a basic imported dxf drawing. It got lines, splines, arc's and circles.

Attachment not found



Okey the contours are calculated. This programming work was already done and checked. Later on i will change this
source code with more iterator style.

Attachment not found



Okey now we do a raw offset to the contours. The splines are offsetted as linestrips. So the splines are still one object, with multiple
controlpoints. This is important.

Attachment not found



Okey now we connect the items with an arc to get a closed contour again.

Attachment not found



And now i have thought about a technique to find out what we need, and what we dont need anymore.
For now only for one closed contour.
1. we start somewhere at the cyan line. the direction is still ccw for a yellow offset.
2. if we spot the first intersection point, we remember this point.
3. we loop through the contour until we meet the rembered point again. Okey now the calculation starts.
4. we save the xy intersection point.
5. we follow the path, we save every point that we pass (endpoints of each invidual item) until we meet the intersection point again.
6. now we do a area calculation of the points. If area>0, all objects we have passed are not to be used.


Attachment not found



c++ source code attached.

Please Log in to join the conversation.

Time to create page: 0.184 seconds
Powered by Kunena Forum