import uuid

collision_squares_labels = []


class MeshGeometryCoordinateModel(object):
    # Получение геометрии мешей
    def __init__(
        self,
        x,
        y,
        z,
        label,
    ):
        self.x = x
        self.y = y
        self.z = z
        self.label = label
        self.cadLabel = ""

    def initializePrimitivesByCoordinate(self, detailSquares):
        import FreeCAD as App

        uuidDoc = str(uuid.uuid1())
        App.ActiveDocument.addObject("Part::Box", "Box")
        App.ActiveDocument.ActiveObject.Label = uuidDoc
        App.ActiveDocument.recompute()
        part = App.ActiveDocument.getObjectsByLabel(uuidDoc)[0]
        collision_squares_labels.append(uuidDoc)
        part.Width = 2
        part.Height = 2
        part.Length = 2
        part.Placement = App.Placement(
            App.Vector(self.x - 1, self.y - 1, self.z - 1),
            App.Rotation(App.Vector(0.00, 0.00, 1.00), 0.00),
        )
        if detailSquares.get(self.label) is None:
            detailSquares[self.label] = []
        detailSquares[self.label].append(self)
        self.cadLabel = uuidDoc
        App.ActiveDocument.recompute()
