- Posts: 508
- Thank you received: 94
simple linux cam
- Reinhard
- Offline
- Platinum Member
-
Less
More
4 years 6 months ago #239713
by Reinhard
Replied by Reinhard on topic simple linux cam
Here's the code (as separate post):
Code:
Handle(Geom_Line) line = Handle(Geom_Line)::DownCast(c);
qDebug() << "cutCurve (line):" << first << " | " << last << " <> " << orientation;
double dx = p1.X() - p0.X();
double dy = p1.Y() - p0.Y();
double gf = dy / dx;
double cf = rMaster / sqrt(1 + gf * gf);
double dr = sqrt(dx * dx + dy * dy);
double D = p0.X() * p1.Y() - p1.X() * p0.Y();
double res = rMaster * rMaster * dr * dr - D * D;
double sig = dy < 0 ? -1 : 1;
double cx0 = cf * gf;
double cy0 = -cf;
double cx1 = -cx0;
double cy1 = -cy0;
double x0 = ( D * dy + sig * dx * sqrt(res)) / (dr * dr);
double x1 = ( D * dy - sig * dx * sqrt(res)) / (dr * dr);
double y0 = (-D * dx + abs(dy) * sqrt(res)) / (dr * dr);
double y1 = (-D * dx + abs(dy) * sqrt(res)) / (dr * dr);
double col = first + (last - first) / 2;
if (res <= 0) qDebug() << "OUPS - fine calculations means no cutpoints?!?";
qDebug() << "cutpoints: " << cx0 << " / " << cy0
<< " and " << cx1 << " / " << cy1;
qDebug() << "alt cp: " << x0 << " / " << y0
<< " and " << x1 << " / " << y1;
// Core().view3D()->createAxisCross({cx0, cy0, 0}, 2, nullptr, Quantity_NOC_BLACK);
// Core().view3D()->createAxisCross({cx1, cy1, 0}, 2, nullptr, Quantity_NOC_WHITE);
Core().view3D()->createAxisCross({x0, y0, 0}, 2, nullptr, Quantity_NOC_BLACK);
Core().view3D()->createAxisCross({x1, y1, 0}, 2, nullptr, Quantity_NOC_WHITE);
// double param0 = ElCLib::Parameter(line->Lin(), {cx0, cy0, p0.Z()});
// double param1 = ElCLib::Parameter(line->Lin(), {cx1, cy1, p0.Z()});
double param0 = ElCLib::Parameter(line->Lin(), {x0, y0, p0.Z()});
double param1 = ElCLib::Parameter(line->Lin(), {x1, y1, p0.Z()});
if (param0 >= first && param0 <= last) {
qDebug() << "<<< first cutpoint is part of line segment ==> "
<< first << " <> " << param0 << " <> " << last << "orientation:" << orientation;
if (param0 < col) {
qDebug() << "\tsecond part is part of interest";
edge = BRepBuilderAPI_MakeEdge(c, {x0, y0, p0.Z()}, p1);
}
else {
qDebug() << "\tfirst part is part of interest";
edge = BRepBuilderAPI_MakeEdge(c, p0, {x0, y0, p0.Z()});
}
}
else if (param1 >= first && param1 <= last) {
qDebug() << ">>> second cutpoint is part of line segment ==> "
<< first << " <> " << param1 << " <> " << last << "orientation:" << orientation;
if (param1 < col) {
qDebug() << "\tsecond part is part of interest";
edge = BRepBuilderAPI_MakeEdge(c, {x1, y1, p0.Z()}, p1);
}
else {
qDebug() << "\tfirst part is part of interest";
edge = BRepBuilderAPI_MakeEdge(c, p0, {x1, y1, p0.Z()});
}
}
else {
qDebug() << "?!?!? - none of the calculated cutpoints is inside of line parameters?!?"
<< first << " <> " << param0 << "|" << param1 << last;
edge = BRepBuilderAPI_MakeEdge(c, first, last);
}
}
- Reinhard
- Offline
- Platinum Member
-
Less
More
- Posts: 508
- Thank you received: 94
4 years 6 months ago #239734
by Reinhard
Replied by Reinhard on topic simple linux cam
Hi,
I found a nice page about math basics for circle intersetions . Based on that I created my own formulas matching the opencascade classes.
The best of it - it works to 100% - it clipped all arcs as expected. Whoohoo
I found a nice page about math basics for circle intersetions . Based on that I created my own formulas matching the opencascade classes.
The best of it - it works to 100% - it clipped all arcs as expected. Whoohoo
- Reinhard
- Offline
- Platinum Member
-
Less
More
- Posts: 508
- Thank you received: 94
- Thorhian
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 1
4 years 6 months ago #240002
by Thorhian
Replied by Thorhian on topic simple linux cam
Hi Reinhard! I just wanted to thank you for this awesome work you’ve done so far. I’ve followed some of FreeCADs path development, and it’s nice to see other people interested in FOSS CAM programming. Just know that I’m rooting for you and the people working on FreeCAD as well. Also, I’m no math expert, so I don’t think I can help too much (yet), but starting towards the end of last year I started a project to make a prototype 3D adaptive roughing algorithm, utilizing OpenGL shader code to do some of the heavy lifting. It’s in Python besides the small amount of GLSL code, but at some point I want to port it to C++ or Rust once I actually get the Python prototype to make real tool paths. I’ve only got some of the core rendering done along with some functions for checking pixels with a given capsule shape (two circles with the same radius and a rectangle that has two lines tangential with the circles) to use when I finally sit down to start working on the tool path generation. The repo is here
github.com/Thorhian/Path_Tinkering
, but I haven’t figured out what license to use yet. Probably LGPL for FreeCAD compatibility but I haven’t decided yet. I bet you would be welcome on the gitter chat for the FreeCAD workbench too BTW.
The following user(s) said Thank You: silopolis
- Reinhard
- Offline
- Platinum Member
-
Less
More
- Posts: 508
- Thank you received: 94
4 years 6 months ago #240005
by Reinhard
Replied by Reinhard on topic simple linux cam
Hi Thorhian,
thank you for your interest! I already solved my math problems and I have lot more problems in using opencascade in a proper way. opencascade is like a russian doll - when you reach to understand a level, you realize, that there is another level below, that does other fancy things that break your work.
So there's quite a lot I stil have to learn. I'm sorry, but I don't have time to worry about freecad or python. I started using opencascade, for not having to bother with opengl.
Don't know - may be that was a wrong decision. May be I should decrease usage of opencascade and do more math on my own?
Sadly I don't know other opencascade developers to share ideas - and opencascade forum is not helpful.
thank you for your interest! I already solved my math problems and I have lot more problems in using opencascade in a proper way. opencascade is like a russian doll - when you reach to understand a level, you realize, that there is another level below, that does other fancy things that break your work.
So there's quite a lot I stil have to learn. I'm sorry, but I don't have time to worry about freecad or python. I started using opencascade, for not having to bother with opengl.
Don't know - may be that was a wrong decision. May be I should decrease usage of opencascade and do more math on my own?
Sadly I don't know other opencascade developers to share ideas - and opencascade forum is not helpful.
- Thorhian
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 1
4 years 6 months ago #240009
by Thorhian
Replied by Thorhian on topic simple linux cam
I mean, FreeCAD uses a lot of Python, but at its core it uses open cascade as well. It wouldn’t surprise me if you found some devs who know a good amount about it in the overall community.
Time to create page: 0.823 seconds