Code covered by the BSD License  

Highlights from
surf2solid - make a solid volume from a surface for 3D printing

5.0

5.0 | 2 ratings Rate this file 30 Downloads (last 30 days) File Size: 4.96 KB File ID: #42876
image thumbnail

surf2solid - make a solid volume from a surface for 3D printing

by Sven

 

29 Jul 2013 (Updated 31 Jul 2013)

Turns thin surfaces into closed solids by adding a flat base or offsetting by a given thickness.

| Watch this File

File Information
Description

SURF2SOLID Convert a thin surface to a closed triangulated solid volume.

  SOLID_FV = SURF2SOLID(FV, OPTIONS...) takes in a triangulated patch
  defined by FV (a structure with fields 'vertices' and 'faces'), and
  returns a solid patch SOLID_FV closed by options described below.

  SOLID_FV = SURF2SOLID(F, V, ...) takes faces and vertices separately.

  [F, V] = SURF2SOLID(...) returns solid faces and vertices separately.

  SURF2SOLID(...) with no output argument plots the 3 components
  (orig-surface, side-walls, under-surface) to the current figure.

  SURF2SOLID(X, Y, Z, ...) reads in surface data in X, Y, and Z, and
  triangulates this gridded data into a triangulated surface using
  triangulation options specified below. X, Y and Z can be
  two-dimensional arrays with the same size. If X and Y are vectors with
  length equal to SIZE(Z,2) and SIZE(Z,1), respectively, they are passed
  through MESHGRID to create gridded data. If X or Y are scalar values,
  they are used to specify the X and Y spacing between grid points.

  SURF2SOLID(...,'PropertyName',VALUE,...) makes a solid volume from thin
  surface using any of the following property/value options:

  ELEVATION - Extends the surface down to a flat base at the given
                  (Z) elevation value. Useful for turning a thin
                  elevation map into a solid block with a flat base. The
                  ELEVATION value should be below the lowest (or above
                  the highest) data point. If no other options are given,
                  ELEVATION defaults to MIN(Z)-0.1*(MAX(Z)-MIN(Z)).

  THICKNESS - Value to offset the given thin surface to make a
                  thickened solid slab. Each node on the surface will be
                  projected along its normal direction by thickness. When
                  negative thickness is given, offset will be away from
                  face normal direction. An N-by-1 array of thicknesses
                  may be given to offset the surface by variable
                  thicknesses (N must equal the number of vertices in the
                  thin surface, and currently cannot be used when
                  triangulation of X,Y,Z data was provided)

  TRIANGULATION - When used with gridded data, TRIANGULATION is either:
                   'delaunay' - (default) Delaunay triangulation of X, Y
                   'f' - Forward slash division of grid quads
                   'b' - Back slash division of quadrilaterals
                   'x' - Cross division of quadrilaterals
                  Note that 'f', 'b', or 't' triangulations use an
                  inbuilt version of FEX entry 28327, "mesh2tri".

  Note: SURF2SOLID currently outputs faces on the side-walls that may
  have opposite normal directions to the input surface. Future versions
  will ensure continuity between face normal directions of the wall and
  underside faces with the original faces.

  Example (shows both THICKNESS and ELEVATION forms):
    n = 50;
    [X,Y] = meshgrid(linspace(0,1,2*n+1));
    L = (40/51/0.9)*membrane(1,n);
    figure, subplot(2,2,[1 3]), title 'Thin surface'
    surf(X,Y,L,'EdgeColor','none'); colormap pink; axis image; camlight
    subplot(2,2,2), title 'Block elevation'
    surf2solid(X,Y,L,'elevation',min(L(:))-0.05); axis image; camlight; camlight
    subplot(2,2,4), title 'Thickness'
    surf2solid(X,Y,L,'thickness',-0.1); axis image; camlight;

  Original idea adapted from Paul Kassebaum's blog post
  http://blogs.mathworks.com/community/2013/06/20/paul-prints-the-l-shaped-membrane/

Acknowledgements

Mesh2tri inspired this file.

Required Products MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File  
Everyone's Tags
3d, 3d printing, mesh, offset, patch, solid, stl, surface, triangulated
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
30 Jul 2013 Paul Kassebaum

Love it!

30 Jul 2013 mathgirl

The function is amazing. It works fast and efficiently, and is very easy to use. The resulting stl has high resolution and reasonable size.

Thank you Sven!
Really appreciate your work.

Updates
31 Jul 2013

Set other-faces as opposite norm direction to input faces
Ensured optional per-node thickness input is accepted

Contact us