Posts

Showing posts from August, 2025

Part contour simplification, with a twist

Image
 Many vector graphic algorithms have a cost proportional to the number of segments of the shapes involved. Thus, many different polygon simplification algorithms have been developed over the years. The main idea is to represent the original shape, but reduce the total number of edges of the shape's contour.  A favourite of mine is the Douglas-Peucker algorithm. It uses an error parameter that allows the user to tune the acceptable error introduced by the simplification. That works well in many scenarios, but as you may guess, it does not work well for some of my needs. Free form 2D nesting packs groups of parts inside bins, in my case, those bins are rectangles. The rules are that any two parts cannot overlap. Nesting libraries will determine where to place each part inside a bin and what rotation to apply to the part. The number of parts and the number of edges per part have a big influence on the time required to perform the nesting operation. So, being able to simplify the...

One step forward, one step backward

Image
 While it was nice to be able to get a faster 2D nesting code, its efficiency was far from perfect. So, looking at the nesting results, you could see how it could have been done much better in certain cases.  And what we usually do when we overcome a hurdle is to look for the next one. In my case, I realized one of the heuristics of the code was to place small parts inside the unused space of the bounding box of the larger parts. That is ok, but what could be better is to use all the free space of a bin once the first placement of large parts is over.  This time, I leaned on another Chinese AI tool, called GLM-4.5 from the  z.AI company.  I explained the above idea in the chat, and I waited for the magic to happen. I used Roo Code within Visual Studio Code, accessing GLM-4.5 API. A few minutes later, I had a newer version of the library. I was pleasantly surprised when I saw a significant improvement in its packing ability, proving that the new heuristic was a ...