[Solved] PartDesign: Pad Up to Face with Custom direction

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: PartDesign: Pad Up to Face with Custom direction

Post by uwestoehr »

flachyjoe wrote: Sat Dec 03, 2022 3:28 pm I'm not sure: in the case I described the distance is null but the pad can be done.
Yes, but this is luck then and depends on the computer. When the length of a pad is below the OCC precision we cannot be sure the result is valid, especially when the pad is later used for further features.

Many thanks for your fix, I took it and only changed the variable names and the wording: https://github.com/FreeCAD/FreeCAD/pull/7943
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: PartDesign: Pad Up to Face with Custom direction

Post by uwestoehr »

adrianinsaval wrote: Sat Dec 03, 2022 7:25 pm Can you maybe add a comment in the code or even better a test script so that this isn't changed in the future by someone else? I can see how one can easily think this option doesn't make sense there.
Thanks. Yes, the case of a circular face s not obvious. I added ad note in this PR: https://github.com/FreeCAD/FreeCAD/pull/7944
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: [Solved] PartDesign: Pad Up to Face with Custom direction

Post by flachyjoe »

uwestoehr wrote: Sun Dec 04, 2022 4:22 am but this is luck then and depends on the computer
Can you please give a failing case ? With your commit my file is invalid again. We must look further.
- Flachy Joe -
Image
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [Solved] PartDesign: Pad Up to Face with Custom direction

Post by uwestoehr »

flachyjoe wrote: Sun Dec 04, 2022 5:39 pm Can you please give a failing case ? With your commit my file is invalid again. We must look further.
Can you please give me an example file that fails. here is my test file I played with:
BrokenPad.FCStd
(23.82 KiB) Downloaded 23 times
With the merged PR thew UpTo feature works for me now also when using a non-normal direction.
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: [Solved] PartDesign: Pad Up to Face with Custom direction

Post by flachyjoe »

Hi @uwestoehr,
The file I sent in my first message fails. A sketch edge is included in the UpToFace surface so distance is null and Pad fails with "UpToFace is too close".
I can't see any reason to disallow such behavior unless there is another case which results in an OCC failure. So I asked you for this.

Can restricting the distance check to parallel case be the solution :?:

NB : English is not my natural language, I apologize if I was rough and offended you. I certainly appreciate your work on this problem.
- Flachy Joe -
Image
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [Solved] PartDesign: Pad Up to Face with Custom direction

Post by uwestoehr »

flachyjoe wrote: Mon Dec 05, 2022 5:16 pm Hi @uwestoehr,
The file I sent in my first message fails. A sketch edge is included in the UpToFace surface so distance is null and Pad fails with "UpToFace is too close".
I can't see any reason to disallow such behavior unless there is another case which results in an OCC failure. So I asked you for this.
As I wrote, when the distance between the sketch plane and the found plane is too low, OCC behaves unpredictable. It could sometimes create the pad, sometimes not. And even when it could create it, it might fail when you add later e.g. a fillet to the pad.

I can't see a problem with your file. When I take your file and use e.g. the "To last" mode, I get correctly get the error that the sketch is too close to the found face: The next face is Face3 (top face of the box). This face is coincident to the bottom line of the sketch.
You can test by yourself: disable the check

Code: Select all

if (distSS.Value() < Precision::Confusion())
and you will see that OCC cannot create the pad.
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: [Solved] PartDesign: Pad Up to Face with Custom direction

Post by flachyjoe »

@uwestoehr I tweak the check in this manner:

Code: Select all

    BRepAdaptor_Surface upToFaceSurface(TopoDS::Face(upToFace));

    // We must measure from sketchshape, not supportface, here
    BRepExtrema_DistShapeShape distSS(sketchshape, upToFace);

    if (upToFaceSurface.GetType() == GeomAbs_Plane) {
        // Check that the upToFace is not parallel to the extrusion direction
        if (dir.IsNormal(upToFaceSurface.Plane().Axis().Direction(), Precision::Confusion()))
            throw Base::ValueError("SketchBased: The UpTo-Face must not be parallel to the extrusion direction!");

        // Check the distance if the upToFace is normal to the extrusion direction
        if (dir.IsParallel(upToFaceSurface.Plane().Axis().Direction(), Precision::Confusion()))
            if (distSS.Value() < Precision::Confusion())
                throw Base::ValueError("SketchBased: The UpTo-Face is too close to the sketch");

    }
My tests run well
Capture d’écran_2022-12-07_21-36-02.png
Capture d’écran_2022-12-07_21-36-02.png (25.69 KiB) Viewed 917 times
UtFCheck.FCStd
(65.91 KiB) Downloaded 22 times
Generated faces are full usable as support.
Capture d’écran_2022-12-07_21-37-29.png
Capture d’écran_2022-12-07_21-37-29.png (15.97 KiB) Viewed 917 times
I'm agree fillet can fail but it always fails on cylinder/triangle interface. There the fillet is created faulty when the error is caught in normal cases.
Capture d’écran_2022-12-07_22-09-00.png
Capture d’écran_2022-12-07_22-09-00.png (21.28 KiB) Viewed 917 times
UtFCheckFillet.FCStd
(131.95 KiB) Downloaded 31 times
- Flachy Joe -
Image
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: PartDesign: Pad Up to Face with Custom direction

Post by flachyjoe »

@uwestoehr Ping ?
What do you think about this solution ? I still can check the fillet code to catch these errors too. :geek:
- Flachy Joe -
Image
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [Solved] PartDesign: Pad Up to Face with Custom direction

Post by uwestoehr »

flachyjoe wrote: Wed Dec 07, 2022 9:13 pm @uwestoehr I tweak the check in this manner:
My tests run well
In your example file UtFCheck.FCStd the pad in the body "ParallelToClose" fails correctly since you pad to a face that is coincident with the sketch plane. As I wrote, this case must be prevented.

The other cases look good. So if the UpToFace is not normal to the sketch plane, we must skip the check for the distance.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [Solved] PartDesign: Pad Up to Face with Custom direction

Post by uwestoehr »

uwestoehr wrote: Mon Dec 12, 2022 3:37 am The other cases look good. So if the UpToFace is not normal to the sketch plane, we must skip the check for the distance.
I took your code and made this PR:
https://github.com/FreeCAD/FreeCAD/pull/8026

Unfortunately I can currently not make any Pad in master. Either I screwed my build system or I screwed up Sketch with my today's header removal.
Post Reply