I am hoping to 3D print some simple
cardioid pictures, like the following:
myplot2[k_: 2, n_: 60] := With[ {a = Exp[2 Pi*I*Range@n/n]}, Graphics[ GraphicsComplex[ Dynamic@ ReIm[I*Join[a, a^k]], {Line@Transpose@Partition[Range[2 n], n], Thick, Circle[]}]] ];
test = myplot2[2, 60 ]
extrudeImage[image_] := Block[{res, img},img = DeleteSmallComponents[Binarize[image, 0.7], 500]; res = ImageMesh[ColorNegate[img]]; RegionProduct[res, Line[{{0.}, {50.}}]]];
testfor3d = extrudeImage[test]
Printout3D[testfor3d]
This seem like a bad output.
Using the solution here,
img = test;
g = MorphologicalGraph[img // MorphologicalBinarize,
VertexCoordinates -> Automatic, EdgeWeight -> Automatic];
edges = EdgeList[g];
vertices = Thread[Rule[VertexList[g], PropertyValue[g, VertexCoordinates]]]; lines = ((edges /. vertices) /. UndirectedEdge[a_, b_] :> Line[{a, b}]);
Graphics[lines]
Graphics3D[ Tube[#] & /@ (lines /. {x_?NumericQ, y_?NumericQ} :> {x, 0, y})]
This then looks like just had a plastic surgery.
Any good workaround?
Dynamic@
from the first argument of theGraphicsComplex
inmyPlot
. That was included for theManipulate
in the other post. (Won't fix the problem.) $\endgroup$Dynamic@
, does this work for you?:Graphics3D[First@test /. GraphicsComplex[p_, g_, o___] :> GraphicsComplex[PadRight[p, {Automatic, 3}], g /. {Line -> Tube, c_Circle -> Tube[Range@60 ~Append~ 1]}]]
-- I'm not real sure what works on a 3D printer or if you require each line to become a cuboid instead of a tube. $\endgroup$