gbSTL
gbSTL is a viewer for STL (stereolithography) files. It can read both Ascii and Binary
STL file types. The user can select the colors used to display the image (including gradient colors),
rotate the image (including automated rotation), move the image, and select the level of detail in the
image (points/lines/surfaces).
The data in the image file may be viewed, as may the current position image of the points
and triangles which make up the image.
For programmers, the STL image generation is available in a DLL which may be used in other
applications that need STL imaging. Exported file functions are discussion in a section below.
To install, just unzip the contents of the distribution file into a folder of its own!
Feature List
gbSTL provides a wide variety of features whic can be accomplished
by keyboard or mouse.
- View STL files
- Binary and Ascii file formats supported (auto-detection of type)
- Built-in Cube and Sphere models
- Drag and drop file onto gbSTL
- Browse model library (Next/Previous commands)
- Background image selection (BMP, GIF, PNG, JPG)
- Rotate image (including automated rotation) by dragging mouse
- Resize image using mousewheel
- Move image up/down/left/right (user-specified move distances)
- Selectively rotate on any axis (user-specified step angle)
- Select point, line and surface colors
- Use built-in gradient colors (any of 6 directions)
- View original file data (including color data)
- View current point position data (including color data)
- Back face culling and depth sorting (image display settings)
- Orthographic projection
- Online Help
Toolbar
The toolbar provides access to all features of gbSTL
- Open - select/open an STL image file (Ascii or Binary)
- Reset - restore image to default position and resized to fit dialog
- Copy - copy image to the clipboard
- Spin - automatically spin the image about the selected XYZ axes
- X - allow X axis rotation
- Y - allow Y axis rotation
- Z - allow Z axis rotation
- Points - show only points in the image
- Lines - show only lines in the image
- Surface - show surfaces in the image (lines are optional)
- Data - toggle display of model point/triangle data
- BG Image - toggle display of background image
- Gradient - generate gradient colors (vs user-defined colors)
- Settings - display settings summary
- Help - open this online Help page
Keyboard Shortcuts
The following key combinations are available to the user to access gbSTL features:
- F1 - Help
- Left Arrow - Move object towards the left side of the screen
- Right Arrow - Move object towards the right side of the screen
- Up Arrow - Move object up the screen
- Down Arrow - Move object down the scree
- Ctrl+G - Cycle through 6 gradient directions
- Ctrl+N - Display Next STL model
- Ctrl+P - Display Previous STL model
- Ctrl+T - Show render time in dialog caption
Settings
The toolbar Settings button provides the following dropdown menu options:
- Cube - create/display a cube
- Sphere - create/display a sphere
- File - display the STL image found in the currently selected file
- Backface Culling - do not draw surfaces facing away from the user
- Depth Sort - sort images on how far away they are from the user (sets drawing order)
- Surface Lines - show/hide lines when surfaces are drawn
- Markers (Points Only) - enlarge of farthest/closest points (visual aide)
- Current Position Data - determines what model data is dislayed (current or default)
- Stetch BG Image - size background image to fit stl image area
- Select BG Image - select image to display in background
- BG Color - select background color
- Point Color - select color used to display points
- Line Color - select color used to display lines
- Surface - select color used to display surfaces
- Reset Color - restore default colors
- Use Current Colors as Default - uses currently selected colors as default colors
- Point Size - select point size
- Move Distance - select distance to move up/down/left/right
- Rotation Angle - specify angle for each rotation step (radians)
- Rotation Interval - specify timer interval for spinning (milliseconds)
gbSTL DLL (Programmer Information)
STL image generation is provided by a custom DLL that programmers my freely use in the
own applications. The parent application supplies a DC to which the DLL will copy the
image on demand. Additionally, the parent application passes about a dozen settings
which affect the returned image.
Declarations
The needed Declare statement are found in the "gbSTLDemo.bas" source code file.
Types
Three UDT declaration are required - "PointX", "TriangleX", "STLData". They are
found in the "gbSTLDemo.bas" source code file .
Exported Procedures and Arguments
This section discusses each of the exported procedures and their arguments.
stl_Render
This is where settings are passed to the DLL:
- hParent - handle to the parent main dialog
- hParentDC - DC of parent window where STL image is displayed (copied using BltBlt)
- CFN - STL file name
- Details - 1:Points, 2:Lines, 3:Triangles
- Shape - 1:Cube, 2:Sphere, 3:File
- Gradient - 0/1 - turns gradient features on/off
- PointColor - color used to draw points
- LineColor - color used to draw lines
- TriangleColor - color used to draw interior of triangles (see SurfaceLines variable)
- BGColor - background color of image canvas
- BackFaceCull - 0/1 - when on, does not draw surfaces facing away from the user
- DepthSort - 0/1 - determines order in which surfaces are drawn
- Orthographic - 0/1 - not used at this time
- PointSize - size (pixels) used to draw points when Details=1
- MoveDistance - distance (pixels) moved with MoveUp/MoveDown/MoveLeft/MoveRight
- ShowMarkers - 0/1 - enlarges two points with highest/lowest z value (viewing aide)
- SurfaceLines - 0/1 -when details=3 (triangles),
- GradientDir - 1-6 - direction in which to apply gradients
- ShowBGImage - 0/1 - show background image
- BGImageFit - 0/1 - fit the background image to the model display area
stl_ResizeImage
- w - image width
- h - image height
stl_RotateAboutXAxis
- Angle - angle to rotate (radians) about the X axis
stl_RotateAboutYAxis
- Angle - angle to rotate (radians) about the Y axis
stl_RotateAboutZAxis
- Angle - angle to rotate (radians) about the Z axis
stl_LoadObjectFromFile
- CFN - file name (Ascii *.stla or Binary *.stlb)
stl_LoadBGIimage
- FileName - image file name
stl_ChangeSize
- ScaleFactor - grows/shrinks the mode (value 0-1)
stl_GetDataPointers
- pPTR - pointer to P() array
- pDims() - UBound of P() array
- tPTR - pointer to T() array
- tDims() - UBound of T() array
stl_ScaleToFit - scales the STL model to fit within the display area
stl_SetPointHighLow - determine maximum dimensions of STL model for resizing
stl_CenterModele - centers the model in the display area
stl_CreateCube - no arguments. creates/displays a cube
stl_CreateSphere - no arguments. creates/displays a sphere
stl_GetPointCount - no arguments. returns number of points in the model
stl_GetTriangleCount - no arguments. returns number of triangles in the model
stl_MoveLeft - no arguments. moves left by MoveDistance (pixels)
stl_MoveRight - no arguments. moves right by MoveDistance (pixels)
stl_MoveUp - no arguments. moves up by MoveDistance (pixels)
stl_MoveDown - no arguments. move down by MoveDistance (pixels)
stl_Reset - resets all position to those read from file (does not reload the file)
Other Comments
Comments and suggestions are welcome!