I've been trying to code this idea in lots of different approaches but I've reached a wall here. Mathematica isn't my strong suit and I've been unable to find a solution to the RegionMeasure error.

The program takes an input of an arbitrary shape (in my case I'm using clothing patterns) and cuts it into triangles, finds the area of the shape from the area of the triangles, then packs the triangles into a rectangle of the same area without any overlaps or gaps.

The code is as follows:

(*Import the RegionMeasure function from the Region \

(*Import the vector image of the clothing pattern*)
pattern = Import["/Users/jonathanvardy/triangle pattern filled.png"];

(*Cut the pattern into triangles*)
triangles = Tessellate[pattern];

(*Convert the triangles into regios using the Polygon function*)
triangleRegions = Polygon /@ triangles;

(*Compute the total area of the triangles*)
triangleArea = Total[RegionMeasure /@ triangles];

(*Compute the side length of the rectangle that has the same area as \
the triangles*)
rectSideLength = Sqrt[triangleArea];

(*Pack the triangles into the rectangle without gaps*)
packedTriangles = 
  Graphics[{EdgeForm[Black], FaceForm[White], triangles}, 
   ImageSize -> {rectSideLength, rectSideLength}];

(*Print the final result*)

enter image description here


1 Answer 1


You mean like this:


Unfortunately, I did not have a better resolution of your sewing pattern

enter image description here

mr = ImageMesh[ColorNegate[input]];
triMesh = ToElementMesh[mr];
mesh = ToQuadMesh[triMesh];

enter image description here


This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .