Complex Sections
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Complex Sections
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.
If you want to take a look, see the branch here: https://github.com/WandererFan/FreeCAD/ ... lexSection
Re: Complex Sections
Wow,
This is definitely a welcome addition!
This is definitely a welcome addition!
Re: Complex Sections
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.
Re: Complex Sections
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!
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.
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;
Re: 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.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Complex Sections
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.
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.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.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Complex Sections
After a little more coffee, I noticed that I used the first example instead of the second...
Re: Complex Sections
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.
Re: Complex Sections
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.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.
Re: Complex Sections
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.