I have five DXF files with various geometric figures.
Are squares with a different geometric shape in each DXF file...
Four DXF files have a square with a different geometric shape on one side while one DXF file on each side have a different geometric shape, as shown above.
- It is possible join these 5 files?
Some files are in the wrong position to be mounted. It is possible to rotate them?
It is possible to create a code that can recognize these geometries and make some assembly like this? The animation is only illustrative. It was created only to facilitate understanding

An attempt was made to convert the files above into 2D BoundaryMeshRegions, and these can be imported via:
meshes = << "http://pastebin.com/raw/zNxS87RP"
Answer
Assuming polygons follow the same (clockwise or counterclockwise) vertex order, find all good quality two line segment rigid mappings between polygons without overlap with each other (at least much overlap, that is). Construct a graph of these mappings and apply appropriate transforms to polygons by finding transform paths from one polygon to all others. (In this case, these paths are pretty simple).
ReplaceList[MeshPrimitives[#, 2] & /@ meshes, {___,
{a : Polygon[{___, ap : Repeated[_, {3}], ___}]}, ___,
{b : Polygon[{___, bp : Repeated[_, {3}], ___}]}, ___} :>
Module[{err, trans},
{err, trans} =
Chop[FindGeometricTransform[{ap}, Reverse@{bp},
TransformationClass -> "Rigid", Method -> "Linear"], 0.001];
{Property[a \[DirectedEdge] b, "trans" -> trans],
Property[b \[DirectedEdge] a, "trans" -> InverseFunction@trans]} /;
err < 1 &&
Quiet@Area[
RegionIntersection[BoundaryDiscretizeRegion@a,
BoundaryDiscretizeRegion@TransformedRegion[b, trans]]] < 1]] //
With[{g = Graph@Flatten@#},
Graphics[{FaceForm[], EdgeForm@Thick, First@VertexList@g,
GeometricTransformation[#,
Composition @@ (PropertyValue[{g, DirectedEdge @@ #}, "trans"] & /@
Partition[FindShortestPath[g, First@VertexList@g, #], 2, 1])] & /@
Rest@VertexList@g}]] &



Comments
Post a Comment