Skip to content

Commit

Permalink
Adapt GoSlice struct to be fully exported. This allows easy usage as …
Browse files Browse the repository at this point in the history
…lib.
  • Loading branch information
aligator committed Mar 25, 2021
1 parent d07f4bd commit a5ffdc6
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 259 deletions.
64 changes: 61 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

# GoSlice

This is a very experimental slicer for 3d printing. It is currently in a very early stage but it can already slice models:
This is a very experimental slicer for 3d printing. It is currently in a very early stage, but it can already slice models:

Supported features:
__Supported features:__
* perimeters
* simple linear infill
* rotated infill
Expand All @@ -18,11 +18,18 @@ Supported features:
* simple support generation
* brim and skirt

__For users - Use CLI:__
Provides a basic command line interface. Just run with `--help` and see the description bellow.

__For developers - Use as Go library:__
You can use GoSlice as slicing lib, with support to inject custom slicing logic at any stage.
See __"Use as lib"__ bellow.

Example:
<img width="200" alt="sliced Gopher logo" src="https://raw.githubusercontent.com/aligator/GoSlice/master/docs/GoSlice-print.png">

## Try it out - for users
Download latest release matching your platform from here:
Download the latest release matching your platform from here:
https://github.com/aligator/GoSlice/releases

Unpack the executable and run it in the commandline.
Expand All @@ -41,6 +48,9 @@ If you need the usage of all possible flags, run it with the `--help` flag:
./goslice --help
```

Note that some flags exist as --initial-... also which applies to the first layer only.
The non-initial apply to all other layers, but not the first one.

## Try it out - for developers
Just running GoSlice:
```
Expand All @@ -65,6 +75,54 @@ go build -ldflags "-X=main.Version=$(git describe --tags) -X=main.Build=$(git re
## How does it work
[see here](docs/README.md)

## Use as lib
You want to
* Create a slicer but do not want to do everything of it?
* Extend GoSlice functionality? (Please consider Pull Requests if you created a nice addition :-)
* Create a new, user-friendly frontend?

-> Then you can do it with GoSlice!

To do this you can copy the `goslice/slicer.go/NewGoSlice` function and just pass to GoSlice what you want.
You can add new logic by implementing one of the various handler interfaces used by it.
If you need even more control, you can even copy and modify the whole `goslice/slicer.go` file which allows you to
control how the steps are called after each other.

### Handler Interfaces
Here some brief explanation of the interfaces. For more detailed information just look into the code...
(And take a look at [the docs](docs/README.md) where I explained some aspects a bit deeper.)
* Reader handler.ModelReader
Is used to read a mesh file. GoSlice provides an implementation for stl files.

* Optimizer handler.ModelOptimizer
Is responsible for
1. checking the model
2. optimizing it by e.g. removing doubles
3. calculating some additional information,
like the touching vertices etc. which is needed for the next step.
The implementation of GoSlice is very currently basic and may have problems with some models.

* Slicer handler.ModelSlicer
Creates the slices (e.g. layers) out of the model.
It then tries to combine all lines to several polygons per each layer.
The implementation of GoSlice is again very basic, but it works.

* Modifiers []handler.LayerModifier
This is the most interesting part: Modifiers are called after each other and
Calculate things like perimeters, infill, support, ...
They add this information as "Attributes" which is basically just a map of interface{}.
GoSlice already provides several basic modifiers.

* Generator handler.GCodeGenerator
The generator then generates the final gcode based on the data the modifiers added.
The implementation of GoSlice is basically a collection of `Renderer` which often just match one modifier.
You can provide your own, additional Renderers or even replace existing ones.

* Writer handler.GCodeWriter
This is the last part, and it basically just writes the gcode to somewhere.
You could for example provide a writer which directly sends the gcode to OctoPrint.
The default implementation just writes it to a gcode file.

## Contribution
You are welcome to help.
[Just look for open issues](https://github.com/aligator/GoSlice/issues) and pick one, create new issues or create new pull requests.
Expand Down
3 changes: 2 additions & 1 deletion cmd/goslice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"GoSlice/data"
"GoSlice/goslice"
"fmt"
"io"
"os"
Expand All @@ -25,7 +26,7 @@ func main() {
os.Exit(1)
}

p := NewGoSlice(o)
p := goslice.NewGoSlice(o)
err := p.Process()

if err != nil {
Expand Down
180 changes: 0 additions & 180 deletions cmd/goslice/slicer.go

This file was deleted.

51 changes: 0 additions & 51 deletions cmd/goslice/slicer_test.go

This file was deleted.

Loading

0 comments on commit a5ffdc6

Please sign in to comment.