simple linux cam

More
31 Mar 2022 12:36 #238891 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

If you follow the link from CavalieContours from my last post, you'll see, where I got stuck with cc.

I followed your CavalierContour link. And the solution is to use "cavalier's pocket operation" instead of " cavalier's offset operation".
Then you will end up without the yellow circle included. The solution is straight forward.

The result i mean look like this picture : raw.githubusercontent.com/grotius-cnc/Ca...evolution_pocket.png
Repository link : github.com/grotius-cnc/cadcam_pockets

Just selecting the same faces than with picture from last post only in different order result in completely different behaviour.
Still looking for a way to make opencascade do what I want.


Instead of offsetting a (non-closed) wire, why not use a closed wire (retrieved face boundary) and do a inside pocket operation.

To sort those edges for cavaliercontours polyline you maybe need to flip the direction of an edge. The geom-classes have some Revert/Reverted methods, so I thought reverting a line that goes from A to B would lead to a line from B to A, but that's not true.

This is indeed the case. All cavalier inputs has to be ordered. This need's to be done by a (your custom) algo.
Simple cam uses such a algo.

So - may be I should go for my own math objects and use occ for display only ...

Doing some math by your own is certainly a good initiative.
Occt functions like : double dist=point1.Distance(point2) are nice to use.

Ok resume.
Do you need a Cavaliercontour interface where you can put in a "occt unordered wire" and it then gives back a pocket shape result in the form off a compound?
 

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

More
31 Mar 2022 12:50 #238892 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

Currently doing a course with Ghidra to do some reverse engineering on DraftSight.

I hope to bypass the activation process by adding a few jumps in the elf file.
And then hope to run DrafSight without any registration for entire Linux community.

Ghidra break's down compiled code and show's it as c++, and it's interesting to break down also
DraftSight library's into c++ code.

If you have any math code request's just ask.

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

More
31 Mar 2022 13:13 - 31 Mar 2022 13:23 #238899 by Reinhard
Replied by Reinhard on topic simple linux cam
Hi Grotius,

> I followed your CavalierContour link. And the solution is to use "cavalier's pocket operation" instead of " cavalier's offset
> operation".


Sorry, but you did not get the point. I did not use pocket operation by intention. That's not what I want!
I want the outline offset contour cut by the workpiece shape (cylinder or box), so result should be open polylines (which I want to connect at my will)
All CavalierContour curves are concentric curves - and that is pretty useless for milling.

Anyway - I'm working to get desired result by using opencascade stuff. Hardcore coding :(
This concentric curves are created with opencascade only. Now I need to cut out the unwanted parts ...
 


> Do you need a Cavaliercontour interface where you can put in a "occt unordered wire" and it then gives back a pocket shape
> result in the form off a compound?


No, I already have that interfaces worked out. Actually I don't see any benefit from using CavalierContour respect to toolpath creation. The only benefit for me is the easy to use storage format and for so I can store compact contours.
Attachments:
Last edit: 31 Mar 2022 13:23 by Reinhard.

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

More
31 Mar 2022 14:36 #238907 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

For my understanding, if you look at the first contour offset path in red, you need the intersection points with the
raw material (purple shape) and then do a trim. (trim away the red contour outside the raw material)?
 

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

More
31 Mar 2022 14:50 - 31 Mar 2022 14:52 #238909 by Reinhard
Replied by Reinhard on topic simple linux cam
Hi,

> you need the intersection points with the raw material (purple shape) and then do a trim. (trim away the red contour outside
> the raw material)?


Of cause. Using a CAD I'd know how to do that.
With opencascade its not that easy.
Here I cut the rotated blue box by planes containing the selected faces - and result looks as expected (well I joined 3 cut parts into one cyan part)


Trying similar with the offset curves gives this ridiculous result:

I cut each offset curve by the golden cylinder, which is a bit bigger than the blue one.
According to opencascade docs the splitter splits the objects and result contains both parts.
I display result with alternating colors (yellow and blue) to see, which is inside of cutpoint and what is outside.
From what I see on screen, I can't recognize any cutpoint at all.

Sadly I don't know how to cut CavalierContour curves :(
Attachments:
Last edit: 31 Mar 2022 14:52 by Reinhard.

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

More
31 Mar 2022 18:10 - 31 Mar 2022 18:16 #238929 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

Lets focus on the last picture. I got a idea for you.

Let's consider the contour offset, produced by the Cavaliercontours library.
To check if the offset is inside the raw material shape, you can check this with the "point in polygon" function.
For this function, you can iterate trough the offset result, no order is required.
See the polygon as the raw material shape (segmented contour, for example a circle with 50 side's).

1. You pass every line or arc points into the "point in polygon" function.
2. If points are outside the "point in polygon", you know this line or arc has to be trimmed at shape intersection.

For now you can try to colorize line's or arc's inside the shape, intersecting at the shape or fully outside the shape.
Next step is to calculate the intersection, we do this in next forum post when you are ready.

I will post the "point in polygon" function as header only file within one hour.

3. To refine item 2.
  A. If firstpoint & secondpoint is inside the polygon. Keep it as it is.
  B. If firstpoint is in the polygon and second point is outside the polygon or visa versa,
       we are intersecting the raw material shape. Later on we will do the trim for this.
  C. If firstpoint & secondpoint is outside the polygon, delete this line or arc from the produced contour.



 
Last edit: 31 Mar 2022 18:16 by Grotius.

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

More
31 Mar 2022 20:18 - 31 Mar 2022 20:33 #238935 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

Attached a PointInPolygon header file. This can be used to determine wich primitives (arc's, lines) are inside the
raw material shape, or completely outside the raw material shape.

If one point of primitive is inside and one point of primitive is outside, you have intersection with raw material.

The implementation is of this algo is done in a 2d xy plane. For 3d we need a different approach.

Let me know if you can use this.

Link : github.com/grotius-cnc/occt-samples-qope...ons/PointInPolygon.h
Attachments:
Last edit: 31 Mar 2022 20:33 by Grotius.

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

More
01 Apr 2022 08:45 #238971 by Reinhard
Replied by Reinhard on topic simple linux cam
Hi,

I'm a bit confused and I have to confess, that I don't understand your "PointInPolygon" at all.
In my understanding I don't have any point that I could use for your calculations.

2D-math is fine, as I don't plan to do any 3D milling ...
... but if I follow the math from opencascade docs (brep specification), than it does not make a big difference, if calculation is done in 2D or 3D space.

From opencascades brep specs I got these formulas:
line:    anyPoint(u)    = Origin + u * Dir
circle:  anyPoint(u)    = Origin + r * cos(u) * Dir{x} + sin(u) * Dir{y}
ellipse: anyPoint(u)    = Origin + r_{maj} * cos(u) * Dir{maj} + r_{min} * sin(u) * Dir_{min}
plane:   anyPoint(u, v) = Origin + u * Dir{u} + v * Dir{v}


My days in school are long ago - sometimes I think it was another life before ...
... but if I remember well, cutpoints are calculated by setting both formulas as equal.

Speeking in general, my raw material is either round or rectangle.
Iterating over all edges of the contour wire I need to perform 2 calculations on each:
  • calculate cutpoint(s) between edge and rectangle/circle from raw material. If there are cutpoints, I have to split edge into several peaces (one more for each cutpoint)
  • determine for each edge (original if no cutpoints or all edges created from cutpoints) if the edge is inside the raw material shape or outside
So I think, calculations should be possible without cutting the edge into dots and than calculate the same for each vertex.
As opencascade uses parameters for all geom objects I guess it should be possible to calculate parameters from formula and then validate the result based on the parameters.
Well, I'm only talking about an idea. Don't know, whether it is possible and I'm not able to do the required maths on my own.

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

More
01 Apr 2022 13:02 #238987 by Grotius
Replied by Grotius on topic simple linux cam
Hi Reinhard,

I have made a little example for you how it works.
We draw a circle, this is raw material shape.
We draw 3 lines. One line is inside the circle, one line intersects and one line is fully outside the circle.

The implementation below, calculates the status for each line.

Implementation :
Mainwindow line 241

Used functions :
functions

 
Attachments:

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

More
01 Apr 2022 13:04 - 01 Apr 2022 13:18 #238988 by Grotius
Replied by Grotius on topic simple linux cam
Walk trough this code :

    //! 0. Draw the raw material.
    Handle(AIS_Shape) myShape=CirlceShape({50,50,0},{0,50,0}).ShapeTopPlane();
    occt_viewer->show_shape(myShape);


    //! 1. Draw a contour offset line.
    myShape=LineShape({50,10,0},{80,50,0}).Shape();
    occt_viewer->show_shape(myShape);

    //! 2. Draw a contour offset line.
    myShape=LineShape({80,50,0},{200,50,0}).Shape();
    occt_viewer->show_shape(myShape);

    //! 3. Draw a contour offset line.
    myShape=LineShape({200,50,0},{200,200,0}).Shape();
    occt_viewer->show_shape(myShape);


    //! Check if 1 is inside the circle, checking startpoint.
    int InPolygon=0;
    PointInPolygon({50,10,0}).TubeShape({50,50,0},50,InPolygon);
    std::cout<<"Item 1 startpoint: InPolygon: "<<InPolygon<<std::endl;

    //! Check if 1 is inside the circle, checking endpoint.
    InPolygon=0;
    PointInPolygon({80,50,0}).TubeShape({50,50,0},50,InPolygon);
    std::cout<<"Item 1 endpoint: InPolygon: "<<InPolygon<<std::endl;


    //! Check if 2 is inside the circle, checking startpoint.
    InPolygon=0;
    PointInPolygon({80,50,0}).TubeShape({50,50,0},50,InPolygon);
    std::cout<<"Item 2 startpoint: InPolygon: "<<InPolygon<<std::endl;

    //! Check if 2 is inside the circle, checking endpoint.
    InPolygon=0;
    PointInPolygon({200,50,0}).TubeShape({50,50,0},50,InPolygon);
    std::cout<<"Item 2 endpoint: InPolygon: "<<InPolygon<<std::endl;


    //! Check if 3 is inside the circle, checking startpoint.
    InPolygon=0;
    PointInPolygon({200,50,0}).TubeShape({50,50,0},50,InPolygon);
    std::cout<<"Item 3 startpoint: InPolygon: "<<InPolygon<<std::endl;

    //! Check if 3 is inside the circle, checking endpoint.
    InPolygon=0;
    PointInPolygon({200,200,0}).TubeShape({50,50,0},50,InPolygon);
    std::cout<<"Item 3 endpoint: InPolygon: "<<InPolygon<<std::endl;

Program output
Item 1 startpoint: InPolygon: 1
Item 1 endpoint: InPolygon: 1
Item 2 startpoint: InPolygon: 1
Item 2 endpoint: InPolygon: 0
Item 3 startpoint: InPolygon: 0
Item 3 endpoint: InPolygon: 0
Last edit: 01 Apr 2022 13:18 by Grotius.

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

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