# Arbitrary shape cut into triangles and packed into rectangle of the same area [duplicate]

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 \
package*)Needs["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*)
packedTriangles



You mean like this:

ResourceFunction["FEMAddOnsInstall"][];
Needs["FEMAddOns"]


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

mr = ImageMesh[ColorNegate[input]];
triMesh = ToElementMesh[mr];
`