# Path: lasercut/helper.py
# def biggest_area_faces(freecad_shape):
#     sorted_list = sort_area_shape_faces(freecad_shape)
#     biggest_area_face = sorted_list[-1]
# #       contains : 0:normal, 1:area mm2, 2; list of faces
#     return biggest_area_face


from FreeCAD import Gui
from lasercut.helper import biggest_area_faces
import FreeCAD
import FreeCADGui
import os
import math
import Draft
# *   This module is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
# *   Lesser General Public License for more details.                       *
# *                                                                         *
# *   You should have received a copy of the GNU Lesser General Public      *
# *   License along with this library; if not, write to the Free Software   *
# *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            *
# *   MA  02110-1301  USA                                                   *
# *                                                                         *
# ***************************************************************************


__dir__ = os.path.dirname(__file__)
iconPath = os.path.join(__dir__, 'icons')


def get_freecad_object():
    if len(FreeCADGui.Selection.getSelectionEx()) < 1:
            raise ValueError("No selection")

    obj_list = []
    for selection in FreeCADGui.Selection.getSelectionEx():
        obj_list.append(selection.Object)
    return obj_list


def transform_shape(part_feature, new_part_feature, freecad_document):
    new_part_feature.Shape = part_feature.Shape.removeSplitter()
    freecad_document.recompute()

# Path: lasercut/helper.py
# def biggest_area_faces(freecad_shape):
#     sorted_list = sort_area_shape_faces(freecad_shape)
#     biggest_area_face = sorted_list[-1]
# #       contains : 0:normal, 1:area mm2, 2; list of faces
#     return biggest_area_face


# Path: ExportPanel.py
from FreeCAD import Gui
from lasercut.helper import biggest_area_faces
import FreeCAD
import FreeCADGui
import os
import math
import Draft

# *   This module is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
# *   Lesser General Public License for more details.                       *
# *                                                                         *
# *   You should have received a copy of the GNU Lesser General Public      *
# *   License along with this library; if not, write to the Free Software   *
# *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            *
# *   MA  02110-1301  USA                                                   *
# *                                                                         *
# ***************************************************************************


__dir__ = os.path.dirname(__file__)
iconPath = os.path.join(__dir__, 'icons')


def get_freecad_object():
    if len(FreeCADGui.Selection.getSelectionEx()) < 1:
            raise ValueError("No selection")

    obj_list = []
    for selection in FreeCADGui.Selection.getSelectionEx():
        obj_list.append(selection.Object)
    return obj_list


def transform_shape(part_feature, new_part_feature, freecad_document):
    new_part_feature.Shape = part_feature.Shape.removeSplitter()
    freecad_document.recompute()

    normal_face_prop = biggest_area_faces(part_feature.Shape)