I think, if you use arrays, and objects made up of tilemaps, you can achieve this.
I can't tell how to code it but the idea I have in mind is... Lets make it by your example. You will make shapes by using tilemap objects, and you will represent your "hole" with an array. Imagine below
Array:
1 1 1 1 1 1 1 1 1 1
1 1 0 0 0 0 0 0 1 1
1 1 0 0 0 0 0 0 1 1
1 1 0 0 0 0 0 0 1 1
1 1 0 0 0 0 0 0 1 1
1 1 0 0 0 0 0 0 1 1
1 1 1 1 1 1 1 1 1 1
then you have shapes made up of tilemaps, and also represented by arrays as well. Imagine a triangle shape which is represented by:
1 1 1 1 1 1
1 1 1 1 1 0
1 1 1 1 0 0
1 1 1 0 0 0
1 1 0 0 0 0
1 0 0 0 0 0
When you place it, you get the coordinates, translate them into array adresses, and add each adress over the first one. If anywhere it becomes a 2, it means the shape is not passing through the hole.
If not, object is placed. Then you place the second object which is also triangle, but you can rotate it. You will have to go into matrix coding or sth like that to rotate the arrays, probably by writing functions to do so. Same applies for the second object, place it, adress it on the array, chech for 2's. If not, second shape also fits. After all shapes placed, check for any remaining 0's inthe main array to see if the hole was closed completely.
I don't know if I could describe it, but it just what came on top of my head.
Hope it helps.