An open-source reimplementation of autoknit (3D mesh -> machine knitting pattern).
Switch branches/tags
Nothing to show
Clone or download
Vidya Narayanan Vidya Narayanan
Latest commit efe16ca Sep 6, 2018
Permalink
Failed to load latest commit information.
kit @ 7d04158 builds on windows Aug 26, 2018
libgeodesic
node_modules autoknit moved to node_modules folder Sep 2, 2018
usage missed one image scaling Sep 2, 2018
.gitignore
.gitmodules in the midst of a messy refactoring and addition Mar 20, 2018
EmbeddedMesh.hpp
EmbeddedPlanarMap.hpp
Interface.cpp
Interface.hpp
Jamfile builds on windows Aug 26, 2018
Jamrules in the midst of a messy refactoring and addition Mar 20, 2018
Makefile.results
README.md Update README.md Sep 5, 2018
ScheduleCost.cpp scheduling computes lots of options Sep 25, 2017
ScheduleCost.hpp
Shape.hpp shape is now behaving more correctly, and has some test code to demon… Aug 10, 2018
Stitch.cpp starting a fresh implementation of the scheduling code Sep 17, 2017
Stitch.hpp
TODO.txt more work to be done for knitting output, but the end may -- at least… Aug 6, 2018
TaggedArguments.hpp
ak-build_next_active_chains.cpp accept on boundaries Aug 5, 2018
ak-embed_constraints.cpp doing more-right sorts of things Jul 7, 2018
ak-embedded_path.cpp embedded_path with pre-trimming seems faster Jul 6, 2018
ak-extract_level_chains.cpp trying geodesics in heat for distance extraction Jun 29, 2018
ak-find_first_active_chains.cpp
ak-interpolate_values.cpp interpolation was broken because of a sign flip Jun 7, 2018
ak-link_chains.cpp compile on osx Aug 6, 2018
ak-load_constraints.cpp
ak-peel_chains-libgeodesic.cpp
ak-peel_slice-euclidean.cpp accept on boundaries Aug 5, 2018
ak-sample_chain.cpp sampled chains with peeling left-of selection; started thinking about… Jun 30, 2018
ak-trace_graph.cpp
ak-trim_model.cpp
embed_DAG.cpp builds on windows Aug 26, 2018
embed_DAG.hpp
graph-color-concept.svg
init.cpp
load_obj.cpp
pipeline.hpp
plan_transfers-best_collapse.cpp builds on windows Aug 26, 2018
plan_transfers-best_expand.cpp builds on windows Aug 26, 2018
plan_transfers-best_shift.cpp linux warning fixes, add 'stress' mode to run test cases forever, che… Jan 10, 2018
plan_transfers-draw_beds.cpp builds on windows Aug 26, 2018
plan_transfers-helpers.hpp more bug-hunting. It seems like the current collapse/expand won't alw… Jan 9, 2018
plan_transfers-minimize_winding.cpp more bug-hunting. It seems like the current collapse/expand won't alw… Jan 9, 2018
plan_transfers-run_transfers.cpp compile on osx Jun 28, 2018
plan_transfers.cpp linux warning fixes, add 'stress' mode to run test cases forever, che… Jan 10, 2018
plan_transfers.hpp
schedule.cpp [compile macosx] minor getting rid of compilation warning->errors Sep 5, 2018
test_flatten.cpp
test_plan_transfers.cpp
test_shape.cpp builds on windows Aug 26, 2018
typeset.hpp scheduling computes lots of options Sep 25, 2017

README.md

Autoknit

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.

License

This code is placed in the public domain.

Building

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.

MacOS setup

#clone repository:
git clone git@github.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

Linux setup

TBD

Window setup

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 git@github.com:textiles-lab/autoknit
cd autoknit
git submodule init
git submodule update

#install pre-built versions of sdl2 and glm libraries:
git clone git@github.com:ixchow/kit-libs-win
#get a copy of the Eigen headers:
git clone git@github.com:eigenteam/eigen-git-mirror eigen

Linux/Windows/MacOS build

cd autoknit
jam -j8

The -j8 parameter means to run up to 8 compilation jobs in parallel. You may wish to adjust this for your particular machine.

Usage

Step-by-step instructions for creating knitting machine instructions for the misc-cactus.obj model from the autoknit-tests repository.

Step 1: Constraints

Launch the interface, telling it to load from misc-cactus.obj and to save constraints to misc-cactus.cons:

./interface obj:misc-cactus.obj constraints:misc-cactus.cons

You will see a 3D view of the loaded model:

You can rotate this model with the right mouse button, zoom with the mouse wheel, and pan with shift + right mouse button.

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 will add a constraint:

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:

Pressing the + key while hovering over a constraint will move it later in time (redder) while pressing the - key will move it earlier in time (bluer):

Pressing the X key while hovering over a constraint will delete it:

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).

Step 2: Peeling/Linking

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.

Manual method:

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-width and 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

Press the p key to step through peeling:

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:

Once the peeling has finished, you can press t to create and save the traced path:

Automatic method:

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

Step 3: Scheduling

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 schedule. The only parameters used by schedule are st: which gives an input stitches file and js: which gives an output javascript file:

./schedule st:misc-cactus.st js:misc-cactus.js

Schedule doesn't have an UI; it just does a relatively large combinatorial search and then dumps its output into a javascript file.

Step 4: Knitout

Running the javascript file created by schedule will create knitout instructions, ready for use on your machine:

NODE_PATH=.. node misc-cactus.js out:misc-cactus.k

Note that the javascript file created by 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