A re-implementation of "Automatic Machine Knitting of 3D Meshes". Does not match the code used in the paper exactly, but is close in most regards.
The latest version of this code is available at https://github.com/textiles-lab/autoknit .
This code is placed in the public domain.
This code is automatically built using Github Actions; check for releases at https://github.com/textiles-lab/autoknit/releases . However, it is also reasonably straightforward to build on your own using the steps below.
You will need Perforce's Jam/MR tool to build, along with the SDL2 library (opengl + mouse handling), the glm math library, and the Eigen linear algebra library.
#clone repository: git clone email@example.com:textiles-lab/autoknit cd autoknit git submodule init git submodule update #install prerequisite libraries and build tool: brew install ftjam sdl2 glm eigen libpng
#clone repository: git clone firstname.lastname@example.org:textiles-lab/autoknit cd autoknit git submodule init git submodule update #install prerequisite libraries and build tool: sudo apt-get install ftjam libglm-dev libpng-dev libsdl2-dev libeigen3-dev
First, install ftjam somewhere in your
%path% so you can run it from a command prompt. (Also make sure that git is installed in such a way that it can be run from a command prompt.)
Then, from a
Visual Studio 2017 > x64 Native Tools Command Prompt for VS 2017 do:
#clone repository: git clone email@example.com:textiles-lab/autoknit cd autoknit git submodule init git submodule update #install pre-built versions of sdl2 and glm libraries: git clone firstname.lastname@example.org:ixchow/kit-libs-win #get a copy of the Eigen headers: git clone email@example.com:eigenteam/eigen-git-mirror eigen
cd autoknit jam -j8
-j8 parameter means to run up to 8 compilation jobs in parallel. You may wish to adjust this for your particular machine.
Launch the interface, telling it to load from
misc-cactus.obj and to save constraints to
cd dist ./interface obj:misc-cactus.obj constraints:misc-cactus.cons
(Note that the
interface executable is built in the
dist/ subdirectory, so you will need to change to that directory before running it.)
You will see a 3D view of the loaded model:
The point on the surface your mouse is over will be highlighted with a grey sphere (the red, green, and blue spheres show the location of the corners of the triangle:
Pressing the c key while hovering over a constraint will add a connected constraint point, which you can press left mouse button to place:
You can click and drag constraint points to move them:
Before you can proceed to the next step, you will need to create constraints for (at least) all of the boundaries of the cactus:
You can also place constraints elsewhere on the model to control the knitting direction, and use the R key to cut out a region around a constraint (useful for starting/ending on meshes without boundaries).
Now that constraints are specified, the rest of the steps proceed automatically. However, the interface can provide visualization tools to show you what is happening.
Load the cactus object and the constraints into the interface. The
obj-scale parameter tells the interface how much to scale the object, while the
stitch-height parameters give the stitch size relative to the scaled object. The
save-traced: parameter tells the interface where to save its traced stitches.
./interface obj:misc-cactus.obj load-constraints:misc-cactus.cons obj-scale:10.0 stitch-width:3.66 stitch-height:1.73 save-traced:misc-cactus.st
During peeling, you can use the g key to show or hide the portions of the row-column graph created so far, and the s key to toggle whether the original model, interpolated value, or current slice model are being shown:
If you don't want to press p a whole lot, you can just pass the
peel-step:N option to do
N steps of peeling.
peel-step:-1 will peel until the mesh is finished.
./interface obj:misc-cactus.obj load-constraints:misc-cactus.cons obj-scale:10.0 stitch-width:3.66 stitch-height:1.73 save-traced:misc-cactus.st peel-step:-1
Now that the traced stitches have been created, they need to be assigned knitting machine needles. We call this step scheduling, and it has its own executable, called
The only parameters used by schedule are
st: which gives an input stitches file and
./schedule st:misc-cactus.st js:misc-cactus.js
schedule will create knitout instructions, ready for use on your machine:
NODE_PATH=.. node misc-cactus.js out:misc-cactus.k
schedule uses some helper functions defined in the
node_modules/autoknit.js file to do things like cast on tubes, bring in/out yarns, and perform transfers. You may want to customize
autoknit.js for your machine.
Status By Pipeline Step
This implementation is mostly complete, but is not fully working.
- Interface/wrapper - working.
- Model (obj) loading - working.
- Constraint specification - working.
- Peeling - mostly working.
- Could be improved to handle ending with short rows.
- Could be improved to deal with orphaned chains.
- Linking (including split/merge cases) - working.
- Tracing - mostly working.
- Could be improved with more extensive ancestor traversal when tucking at the ends of short rows.
- Sometimes generates short yarns; next-stitch-picking heuristic could be improved.
- Might want to add a lazy vs eager switch for moving to the next row after splits. (Currently, the behavior is eager).
- Scheduling - working for small cases only.
- Need to add a greedy version (currently only optimal is used).
- Knitting instructions -- mostly working.
- Need a better yarn-in function for split tubes that tucks on front/back and then drops later.
- Should add the option to use separate yarn for starting tubes
- Should add the option to tuck yarn in from the edge of the beds