Complex Sections

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Complex Sections

Post by wandererfan »

I've been looking into "complex sections". This is related to issue #6309. The premise is that the user generates a "cutting profile" using Sketcher or Draft, anything that will create a wire or edge. This profile is extruded into a cutting tool that is used to remove material from a source shape. You can make a stand alone ComplexSection feature, or one based on an existing view.
complexSectionProto_draftSpline.png
complexSectionProto_draftSpline.png (172.25 KiB) Viewed 5059 times
complexSection_sketchProfile.png
complexSection_sketchProfile.png (166.94 KiB) Viewed 5059 times
If you want to take a look, see the branch here: https://github.com/WandererFan/FreeCAD/ ... lexSection
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: Complex Sections

Post by aapo »

Wow,

This is definitely a welcome addition! :shock:
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Re: Complex Sections

Post by NewJoker »

Great, this would be a game-changer. Advanced section cuts are in my opinion the most missing feature and their addition could make TechDraw almost as powerful as similar modules in commercial CAD software.
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: Complex Sections

Post by aapo »

Is the following part of your code the actual interesting part of the code, which uses OCC magic to actually project the cut 3D-wires onto the TechDraw paper plane? I presume BRepAlgo_NormalProjection is pretty much battle-tested part of OCC. I glanzed through the code, and the algorithm you invented looks bullet-proof to me, at least. Great idea, thanks for this addition to FreeCAD! :D

The only downside is that if I read the code correctly, it seems to me that BRepAlgo_NormalProjection projects the whole section wire onto the paper plane along the same (section) normal direction. If I've understood correctly, the piecewise polyline projections (e.g. your 2nd example) should be done by first projecting the pieces separately into their respective normal directions, and only after that joining the projections. This could be achieved by "flattening" the 3C cut face wire, instead of projecting it, but I'm afraid that flattening the face is more difficult than projecting. I hope there's an OCC function for that, but for future enhancement we'd need two modes to select from: projection or flattening.

Code: Select all

    BaseGeomPtrVector result;
    Base::Vector3d stdOrg(0.0, 0.0, 0.0);

    TopoDS_Face paper = BRepBuilderAPI_MakeFace(gp_Pln(getProjectionCS(stdOrg)));
    BRepAlgo_NormalProjection projector(paper);
    projector.Add(inWire);
    projector.Build();
    TopExp_Explorer expShape(projector.Projection(), TopAbs_EDGE);
    for (; expShape.More(); expShape.Next()) {
        BaseGeomPtr edge = BaseGeom::baseFactory(TopoDS::Edge(expShape.Current()));
        result.push_back(edge);
    }
    return result;
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: Complex Sections

Post by chrisb »

wandererfan wrote: Wed Sep 21, 2022 12:47 am I've been looking into "complex sections".
I never needed it until now, but it looks like a good thing on the way to make TechDraw perfect!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Complex Sections

Post by wandererfan »

aapo wrote: Wed Sep 21, 2022 6:43 am The only downside is that if I read the code correctly, it seems to me that BRepAlgo_NormalProjection projects the whole section wire onto the paper plane along the same (section) normal direction.
DrawComplexSection only uses DrawViewPart::projectWire() to create the section line on the BaseView. We are projecting the cutting profile onto the BaseView's paper plane, so section normal doesn't enter into it.
aapo wrote: Wed Sep 21, 2022 6:43 am If I've understood correctly, the piecewise polyline projections (e.g. your 2nd example) should be done by first projecting the pieces separately into their respective normal directions, and only after that joining the projections. This could be achieved by "flattening" the 3C cut face wire, instead of projecting it, but I'm afraid that flattening the face is more difficult than projecting. I hope there's an OCC function for that, but for future enhancement we'd need two modes to select from: projection or flattening.
Not sure I'm following this. The profile is extruded in an "up" direction determined by the BaseView's Direction, or, for a standalone ComplexSection, by the ComplexSection's projection CS. I've envisioned the profile as being planar, but I don't think it makes a difference as the extrusion operation will eliminate any vertical variation in the profile.
complexSectionProfile.png
complexSectionProfile.png (35.03 KiB) Viewed 4895 times
complexSection_toolFace.png
complexSection_toolFace.png (24.81 KiB) Viewed 4895 times
complexSection_cuttingTool.png
complexSection_cuttingTool.png (24.84 KiB) Viewed 4895 times
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Complex Sections

Post by wandererfan »

After a little more coffee, I noticed that I used the first example instead of the second...
complexSection_profileSketch.png
complexSection_profileSketch.png (44.2 KiB) Viewed 4878 times
complexSection_cuttingToolFromSketch.png
complexSection_cuttingToolFromSketch.png (22.62 KiB) Viewed 4878 times
0mer0
Posts: 71
Joined: Mon Feb 08, 2021 8:46 pm

Re: Complex Sections

Post by 0mer0 »

I have never seen section cuts of orthogonal views with cut lines that are not straight (I am not saying that they do not exist). But they are welcome for section cuts of perspective views, where they are widely used.
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: Complex Sections

Post by aapo »

wandererfan wrote: Wed Sep 21, 2022 1:08 pm Not sure I'm following this. The profile is extruded in an "up" direction determined by the BaseView's Direction, or, for a standalone ComplexSection, by the ComplexSection's projection CS. I've envisioned the profile as being planar, but I don't think it makes a difference as the extrusion operation will eliminate any vertical variation in the profile.
What I mean is that your current code seems to project the view along the direction of the red lines in the following crude drawing. The standard convention is (or at least I believe it to be) to project the two sides, green and blue, separately into two different normal directions, and then join the two projections into the same drawing as if they would be in the same plane. So, it's kind of a pseudo-planar projection. If I read your code correctly, I think it calculates the red projection. I could be wrong, as I haven't yet had the time to actually test the code. Note that the red picture and green+blue picture are completely different, but there's a use case for both modes in different situations.
20220921 TD section projections p01.png
20220921 TD section projections p01.png (32.51 KiB) Viewed 4864 times
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Re: Complex Sections

Post by NewJoker »

0mer0 wrote: Wed Sep 21, 2022 1:28 pm I have never seen section cuts of orthogonal views with cut lines that are not straight (I am not saying that they do not exist).
The first post in this thread shows some examples of advanced section cuts: https://www.forum.freecadweb.org/viewto ... 35&t=65321

Indeed, lines forming the cut are usually straight (but composed of multiple segments with different orientations) but broken out sections are an exception. Curved lines could be also useful for broken (interrupted) views of long objects: https://forum.freecadweb.org/viewtopic. ... 35&t=67912

But this would require a separate tool.
Post Reply