simple linux cam

More
01 Apr 2022 13:14 - 01 Apr 2022 13:32 #238989 by Grotius
Replied by Grotius on topic simple linux cam
I'm a bit confused and I have to confess, that I don't understand your "PointInPolygon" at all.
That is ok, no worry. In previous post i tried to explain how "PointinPolygon" works.

In my understanding I don't have any point that I could use for your calculations.
The Cavaliercontour output contains lines, arc's etc.
At lower level you compare start & endpoints with PointInPolygon.

So I think, calculations should be possible without cutting the edge into dots
The PointInPolygon needs this dots. It's just a fast preprocess for calculating the exact intersection point.
When you think my previous post example is usefull, i can expand this example with calculating the exact intersection point.
 
The workflow :
1. Do the PIP for each line or arc and retrieve the status.
2. Todo: calculate the exact intersection point when status=intersecting. We know already wich side has to be trimmed.
3. Trim the piece we don't want from the shape. This process could be automized by useing the Occt SelectionModel to highlight
the current shape that has to be edited. And then reload the shape.
Last edit: 01 Apr 2022 13:32 by Grotius.

Please Log in or Create an account to join the conversation.

More
01 Apr 2022 14:51 #238991 by HansU
Replied by HansU on topic simple linux cam
@Reinhard Do you know pycam.sourceforge.net/screenshots/?

Sometimes it feels for me that everyone is building their own CAM tool. And I wonder if it is not better to concentrate the energy and work all together on one CAM tool.

Please Log in or Create an account to join the conversation.

More
01 Apr 2022 16:09 #238999 by Reinhard
Replied by Reinhard on topic simple linux cam
> Sometimes it feels for me that everyone is building their own CAM tool. And I wonder if it is not better to concentrate the
> energy and work all together on one CAM tool.


Yes, you're right! I didn't know the linked tool, but I tested every cam available for hobby users that I could find. Lot of them are abandoned or dead and others are left unfinished ...
For me the best are Cambam and Deskproto - the later is beautiful for 3D milling with 4 or 5 axis.
Cambam seems to be abandoned too and Deskproto does not really support technical pieces.
I read a lot about blender cam, but I never was able to get it working. Same is true for FreeCad cam.

So I tried to create an easy to use cam for technical pieces with up to 5 axis. I'm not interested in milling 3d surfaces like the linked sample. My testing data is a simple chuck adapter for a lathe (or 4th axis) that I milled many years ago.
That time I tried to use available cams to create toolpaths, but none of them was able to work it out so I ended up with manual coding.
And that adapter is nothing complicated.

That time I had no plans to write a cam. When linux version of deskproto came out, I spent much time with testing. The bugs of deskproto made me start coding a dxf-viewer. Just to see, whether my ideas are realistic and manageable.
When the dxf-viewer was working, I thought, well, I could try to create a cam.
But then on brainstorming about what features I want to support, I came to the conclusion, that I don't want to bother with DXF.
I never did some 2D drawings in CAD. Always used 3D.
... and as I already used opencascade for the linuxcnc controller app, I just investiged, what is possible with opencascade.
My sampledata is some CAD drawings created with freecad and exported in different formats ...

Actually I like the work and I love challenges that exceed my abilities :)
May be, I'm able to create something useful ...

>> So I think, calculations should be possible without cutting the edge into dots
> The PointInPolygon needs this dots. It's just a fast preprocess for calculating the exact intersection point.
> When you think my previous post example is usefull, i can expand this example with calculating the exact intersection point.


Thank you very much for your time and your support.
I stil don't understand PIP function, but I finally got into TubeShape.
Sorry, but your code may be sophisticated for some complicated shapes, but for my problems its a very poor implementation.
TubeShape cuts the circle into more than 600 pieces and then it iterates over these pieces.

As written, in my case workpiece may be either round or rectangle. I don't plan to support other shapes.
To find out, whether a point is inside of a circle, you just need to calculate the distance to the center of the circle. That's one call of sqrt() - so I guess, calculation will be much faster than iterating over 600 segments of a circle.

Calculation whether a point is inside a rectangle could be faster than the calculation of point in circle.
So the only missing math is to calculate the cutpoints with my offset contours. But I'm confident, that I find that out too.

Please Log in or Create an account to join the conversation.

More
01 Apr 2022 19:08 - 01 Apr 2022 19:20 #239008 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

Your conclusion is ok. Just check the sqrt function for circles and for a square simple math will do the job.
When using more diffucult raw material shapes, like L-shapes the Pip function will help you out.
Iterating 600x an be reduced to change the parameter in the for loop.

Orignal :
for(double i=0; i<;(2*M_PI); i+=0.01*M_PI){
Edited :
for(double i=0; i<;(2*M_PI); i+=0.5*M_PI){

This is for custom shapes :
PointInPolygon(gp_Pnt aPoint).CustomShape(std::vector<gp_Pnt> PointVec, int &InPolygon));

For calculating the final intersection i used Csharp examples in the past wich i converted to C++.
You don't have to understand how it works, It's important that it works, so you can go on with coding without
thinking how things work at mathematical level. I often tried to understand things, but when it's too complicated,
i let it go. For me it's important if somethings works, it's fine for me. For example kdl inverse kinematics, i don't
have to understand how inverse kinmematics works. But i can play with the library very well !

In different Cadcam repositories of previous work, you can find them conversed from Csharp to C++.
csharphelper.com/blog/2014/08/determine-...ines-intersect-in-c/
csharphelper.com/blog/2014/09/determine-...sects-a-circle-in-c/

After conversion you get something like for 3d line-line intersection c++:
github.com/grotius-cnc/occt-samples-qope...functions/LineLine.h

for 3d line-arc intersection in c++:
github.com/grotius-cnc/occt-samples-qope...nctions/LineSphere.h


2d trim + extend functions c++ :
github.com/grotius-cnc/qt_cadcam/tree/ma...cad_modify_functions
Last edit: 01 Apr 2022 19:20 by Grotius.

Please Log in or Create an account to join the conversation.

More
02 Apr 2022 02:58 #239044 by Reinhard
Replied by Reinhard on topic simple linux cam
Hi,

You don't have to understand how it works, It's important that it works, so you can go on with coding
without thinking how things work.


Hm, my math understanding is very limited - but I'm quite sure, if I can identify that a solution is bad for my usecase, then there must be a better solution out there. I only have to find it.
I don't work for money, so my coding don't need to be ready at certain time. I code for my fun - so I can spent time necessary to create good code. Well, what I consider good code ;)

Another example is my FalconView project. I was nearly done implementing all desired features, when I thought: might be a good idea to have each page converted into a plugin and so open a door for those that like to extend application. It cost me many many weeks of trial and error and a lot of headbanging. But finally I got it. Now you can decide at runtime, what pages you like to use.
... and it's only a small step to add a new page :)

i used Csharp examples in the past wich i converted to C++.

Thanks a lot for the pointer to csharphelper! That's a wonderful source for people like me. Math for beginners and with background info :D
 

Please Log in or Create an account to join the conversation.

More
02 Apr 2022 09:20 - 02 Apr 2022 09:20 #239047 by HansU
Replied by HansU on topic simple linux cam

Cambam seems to be abandoned too


Really? However, I am using SheetCAM at the moment. And yes it would be more comfortable to read in the 3D-file formats directly. It makes sometimes problems with contours when exporting to dxf. So wish you good luck on this and look forward for an alternative ;-)
Do you have your working repo public available?
Last edit: 02 Apr 2022 09:20 by HansU.

Please Log in or Create an account to join the conversation.

More
03 Apr 2022 15:20 #239180 by Reinhard
Replied by Reinhard on topic simple linux cam
Hi,

Really?

Well, dunno. I loosly follow cambam forum and I haven't read any post from the developer for years.
Additionally, when 1.0 for windows came out, he promised to publish linux 1.0 soon - but that never happened.

Do you have your working repo public available?

Not yet. I don't have any useful stuff already working. Too many problems and so little sparetime ;)

@grotius
May I ask for help again?

I found very nice samples for cutpoint calculations ( intersect circle with circle and intersection line and circle )
Could you please help me with opencascade?
Geom-classes of occ are parametric, so I need to rearrange the formulas to calculate the parameter from final coordinates.Formulas are documented in BRep-Format-specs: Line and Circle
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
03 Apr 2022 15:28 #239182 by Reinhard
Replied by Reinhard on topic simple linux cam
Wtf editor @$!±§

missing links: Formulas are documented in BRep-Format-specs: Line and Circle

Please Log in or Create an account to join the conversation.

More
04 Apr 2022 13:48 #239256 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

Nice code found.

For now i got a tiny tip for you.

This is a working qt program made by a Russian guy. It is a Occt sketcher program.
It includes a working trim algo. I tested the app a while ago and it works. It contains all the functions for trimming.
But you have to dig in. It's complicated written.

The app, see .pro file :
github.com/grotius-cnc/occt-samples-qope...cctQtLib/libscetcher

Direct to trim code :
github.com/grotius-cnc/occt-samples-qope...cher_CommandTrim.cxx 

I can help you with examples for trim with occt soon.  I think tomorrow or day after.

 

Please Log in or Create an account to join the conversation.

More
05 Apr 2022 03:03 #239297 by Reinhard
Replied by Reinhard on topic simple linux cam
I can help you with examples for trim with occt soon. 

Thank you, but I would prefer and need your help with occ-math. Actually I coded formulas from brep specs like this:

First the line
[color=#800080]gp_Pnt[/color][color=#c0c0c0] [/color][color=#800080]Util3D[/color]::[color=#00677c]calcLine[/color]([color=#000080]Handle[/color]([color=#800080]Geom_Line[/color])[color=#c0c0c0] [/color][color=#092e64]l[/color],[color=#c0c0c0] [/color][color=#808000]double[/color][color=#c0c0c0] [/color][color=#092e64]param[/color])[color=#c0c0c0] [/color][color=#808000]const[/color][color=#c0c0c0] [/color]{[color=#c0c0c0]  [/color][color=#808000]const[/color][color=#c0c0c0] [/color][color=#800080]gp_Ax1[/color]&[color=#c0c0c0] [/color][color=#092e64]axis[/color][color=#c0c0c0]  [/color]=[color=#c0c0c0] [/color][color=#092e64]l[/color][color=#00677c]->[/color][color=#00677c]Position[/color]();[color=#c0c0c0]  [/color][color=#800080]gp_Pnt[/color][color=#c0c0c0]        [/color][color=#092e64]start[/color]([color=#092e64]axis[/color].[color=#00677c]Location[/color]().[color=#00677c]X[/color](),[color=#c0c0c0] [/color][color=#092e64]axis[/color].[color=#00677c]Location[/color]().[color=#00677c]Y[/color](),[color=#c0c0c0] [/color][color=#092e64]axis[/color].[color=#00677c]Location[/color]().[color=#00677c]Z[/color]());[color=#c0c0c0]  [/color][color=#800080]gp_Dir[/color][color=#c0c0c0]        [/color][color=#092e64]dir[/color]([color=#092e64]axis[/color].[color=#00677c]Direction[/color]().[color=#00677c]X[/color](),[color=#c0c0c0] [/color][color=#092e64]axis[/color].[color=#00677c]Direction[/color]().[color=#00677c]Y[/color](),[color=#c0c0c0] [/color][color=#092e64]axis[/color].[color=#00677c]Direction[/color]().[color=#00677c]Z[/color]());[color=#c0c0c0]  [/color][color=#800080]gp_Pnt[/color][color=#c0c0c0]        [/color][color=#092e64]ap[/color][color=#c0c0c0] [/color]=[color=#c0c0c0] [/color][color=#092e64]l[/color][color=#00677c]->[/color][color=#00677c]Value[/color]([color=#092e64]param[/color]);[color=#c0c0c0]  [/color][color=#800080]gp_Pnt[/color][color=#c0c0c0]        [/color][color=#092e64]rv[/color][color=#c0c0c0] [/color]=[color=#c0c0c0] [/color][color=#092e64]start[/color];
 [color=#c0c0c0]  [/color][color=#092e64]rv[/color].[color=#00677c]SetX[/color]([color=#092e64]start[/color].[color=#00677c]X[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]param[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]dir[/color].[color=#00677c]X[/color]());[color=#c0c0c0]  [/color][color=#092e64]rv[/color].[color=#00677c]SetY[/color]([color=#092e64]start[/color].[color=#00677c]Y[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]param[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]dir[/color].[color=#00677c]Y[/color]());[color=#c0c0c0]  [/color][color=#092e64]rv[/color].[color=#00677c]SetZ[/color]([color=#092e64]start[/color].[color=#00677c]Z[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]param[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]dir[/color].[color=#00677c]Z[/color]());
 [color=#c0c0c0]  [/color][color=#092e64]l[/color][color=#00677c]->[/color][color=#00677c]D0[/color]([color=#092e64]param[/color],[color=#c0c0c0] [/color][color=#092e64]ap[/color]);
 [color=#c0c0c0]  [/color][color=#808000]return[/color][color=#c0c0c0] [/color][color=#092e64]rv[/color];[color=#c0c0c0]  [/color]}

and here the circle/arc
[color=#800080]gp_Pnt[/color][color=#c0c0c0] [/color][color=#800080]Util3D[/color]::[color=#00677c]calcCircle[/color]([color=#000080]Handle[/color]([color=#800080]Geom_Circle[/color])[color=#c0c0c0] [/color][color=#092e64]c[/color],[color=#c0c0c0] [/color][color=#808000]double[/color][color=#c0c0c0] [/color][color=#092e64]param[/color])[color=#c0c0c0] [/color][color=#808000]const[/color][color=#c0c0c0] [/color]{[color=#c0c0c0]  [/color][color=#808000]const[/color][color=#c0c0c0] [/color][color=#800080]gp_Ax2[/color]&[color=#c0c0c0] [/color][color=#092e64]axis[/color][color=#c0c0c0]  [/color]=[color=#c0c0c0] [/color][color=#092e64]c[/color][color=#00677c]->[/color][color=#00677c]Position[/color]();[color=#c0c0c0]  [/color][color=#800080]gp_Pnt[/color][color=#c0c0c0]        [/color][color=#092e64]center[/color]([color=#092e64]axis[/color].[color=#00677c]Location[/color]().[color=#00677c]X[/color](),[color=#c0c0c0] [/color][color=#092e64]axis[/color].[color=#00677c]Location[/color]().[color=#00677c]Y[/color](),[color=#c0c0c0] [/color][color=#092e64]axis[/color].[color=#00677c]Location[/color]().[color=#00677c]Z[/color]());[color=#c0c0c0]  [/color][color=#800080]gp_Dir[/color][color=#c0c0c0]        [/color][color=#092e64]dir[/color]([color=#092e64]axis[/color].[color=#00677c]Direction[/color]());[color=#c0c0c0]  [/color][color=#800080]gp_Dir[/color][color=#c0c0c0]        [/color][color=#092e64]xDir[/color]([color=#092e64]axis[/color].[color=#00677c]XDirection[/color]());[color=#c0c0c0]  [/color][color=#800080]gp_Dir[/color][color=#c0c0c0]        [/color][color=#092e64]yDir[/color]([color=#092e64]axis[/color].[color=#00677c]YDirection[/color]());[color=#c0c0c0]  [/color][color=#808000]double[/color][color=#c0c0c0]        [/color][color=#092e64]r[/color][color=#c0c0c0]  [/color]=[color=#c0c0c0] [/color][color=#092e64]c[/color][color=#00677c]->[/color][color=#00677c]Radius[/color]();[color=#c0c0c0]  [/color][color=#808000]double[/color][color=#c0c0c0]        [/color][color=#092e64]cp[/color][color=#c0c0c0] [/color]=[color=#c0c0c0] [/color][color=#00677c]cos[/color]([color=#092e64]param[/color]);[color=#c0c0c0]  [/color][color=#808000]double[/color][color=#c0c0c0]        [/color][color=#092e64]sp[/color][color=#c0c0c0] [/color]=[color=#c0c0c0] [/color][color=#00677c]sin[/color]([color=#092e64]param[/color]);[color=#c0c0c0]  [/color][color=#800080]gp_Pnt[/color][color=#c0c0c0]        [/color][color=#092e64]ap[/color][color=#c0c0c0] [/color]=[color=#c0c0c0] [/color][color=#092e64]c[/color][color=#00677c]->[/color][color=#00677c]Value[/color]([color=#092e64]param[/color]);[color=#c0c0c0]  [/color][color=#800080]gp_Pnt[/color][color=#c0c0c0]        [/color][color=#092e64]rv[/color];
 [color=#c0c0c0]  [/color][color=#092e64]rv[/color].[color=#00677c]SetX[/color]([color=#092e64]center[/color].[color=#00677c]X[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]r[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]cp[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]xDir[/color].[color=#00677c]X[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]r[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]sp[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]yDir[/color].[color=#00677c]X[/color]());[color=#c0c0c0]  [/color][color=#092e64]rv[/color].[color=#00677c]SetY[/color]([color=#092e64]center[/color].[color=#00677c]Y[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]r[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]cp[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]xDir[/color].[color=#00677c]Y[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]r[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]sp[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]yDir[/color].[color=#00677c]Y[/color]());[color=#c0c0c0]  [/color][color=#092e64]rv[/color].[color=#00677c]SetZ[/color]([color=#092e64]center[/color].[color=#00677c]Z[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]r[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]cp[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]xDir[/color].[color=#00677c]Z[/color]()[color=#c0c0c0] [/color]+[color=#c0c0c0] [/color][color=#092e64]r[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]sp[/color][color=#c0c0c0] [/color]*[color=#c0c0c0] [/color][color=#092e64]yDir[/color].[color=#00677c]Z[/color]());
 [color=#c0c0c0]  [/color][color=#092e64]c[/color][color=#00677c]->[/color][color=#00677c]D0[/color]([color=#092e64]param[/color],[color=#c0c0c0] [/color][color=#092e64]ap[/color]);
 [color=#c0c0c0]  [/color][color=#808000]return[/color][color=#c0c0c0] [/color][color=#092e64]rv[/color];[color=#c0c0c0]  [/color]}
Both functions return the same result as D0 or Value from geom classes.
So I would appreciate it a lot if you could show me, how to calculate the "param" from given position.

Please Log in or Create an account to join the conversation.

Moderators: Skullworks
Time to create page: 0.148 seconds
Powered by Kunena Forum