Saturday, 16 February 2013

Drawing Module: Section Views

This past week has been a tremendously busy one at University, but in the few bits of time I do have available, I have been looking at incorporating section views into my experiments on the Drawing Module. For those unfamiliar what a 'Section' views, below is an example. These are highly important in mechanical design and allow complex features to be seen and also annotated

Sectional View Along Axis A-A
Yorik, already did some work within his arch module purely using the python capabilities within FreeCAD. This can be used in the latest release of 0.13. His solution is simple but works well. Below is a representation of the sectioning algorithm (I am currently waiting for a download to finish so found the time to draw it)

  1. The user defines a 3D plane. The 3D Plane is then checked to see if it intersects with the object
  2. The bounding box for the FreeCAD part is then projected onto the cutting plane - there are 8 points.
  3. The maximum size of each projection on the principal axes of the plane are found. These are then turned into an extruded box prism and a boolean cut operation leaves the remaining part.
  4. The remaining sectioned part remains. The faces are then projected and if they are coincident with the cutting plane it will be sectioned face.
Interestingly enough I decided to mimic such behavior in the Sectioned View of this. Although relatively simple, in c++ requires finding the correct modeling algorithms in OpenCascade. After some mind boggling, I eventually got something crude to work.

The functionality I am aiming towards is something similar to the functionality in other commercial CAD packages (namely Solidworks). My view is that using a 3D plane to section an object can be slightly tedious and awkward - atleast until we get a plane feature with the arrival on the Assembly Module. Instead I think it is more practical to create a section in the 2D Drawing User Interface.



 The user can create both 3D and Orthographic projections of the object and the user will 'draw' a section line AA in 2D. Upon completion this will create a new 'Section' View to the side that can be freely positioned.

The section plane is calculated simply by taking the cross product of the current view normal and the line, which produces the new normal of the plane.

This would hopefully cover most cases, but it should also allow an arbitrary plane to be set to create more flexibility when sectioning. 

The one complication that arises is that references will be lost because of the boolean operation. This will be of concern atleast until we get the more robust naming mechanism.

Hatching:

Any sectioned faces or even chosen ones should be fillable with a hatch pattern. This can be detected automatically if the face is coincident on the plane. I haven't yet decided the approach for storing hatching information but should be relatively straight forward.

I am hoping to get some more of this done tonight or tomorrow and have something to show but that all depends on University work... 

3 comments:

  1. Amazing! Can't wait to see more! The big problem I had with section views is the complex depth-based face sorting system (called painter's algorithm) I used to sort faces after projecting them on the section plane, because I wanted fillable faces as output (the current OCC algorithm in FreeCAD only projects edges). It fails a lot and is very slow...

    Your idea to place a section plane in 2D is indeed much easier to use than my current 3D plane. And indeed it will cover 99% of the cases... Now I guess we'll really need to put some work in the Drawing module!

    ReplyDelete
  2. I got the sectioning to work very crudely this afternoon, but is currently not at the correct angle.

    What I am really hoping is that OpenCascade will allow me to sort through each projected face - I am pretty sure that these are projected just like the edges but aren't exposed in the BREPHLR sort algorithm. Hopefully we can take this further and make coloured vectors drawings like you have done already :)

    I think other CAD packages also allow you to set hatches for faces even if it's a section view.

    So yes, should be an exciting result if this works!

    ReplyDelete
  3. Hatching in SVG is pretty easy once you have a fillable, closed path (but doesn't work on the qtsvg viewer, you'll definitely need to surrender to webkit ;) ), basically you define a hatch pattern, which is a small, tileable svg fragment, then simply use its name as fill value: http://www.carto.net/svg/samples/patterns.shtml And the pattern definition can come anywhere inside the svg, so each freecad view could carry its own or have controls to tweak it...

    If OCC is able to sort the projected faces, then definitely our major problem would be solved. Where did you find about that?

    ReplyDelete