# Path: lasercut/roundedboxproperties.py
# class RoundedBoxProperties(ObjectProperties):
# 
#     _allowed = ('nb_face', 'inradius', 'height', 'side_length', 'max_side_length', 'thickness', 'cut')
# 
#     def __init__(self, **kwargs):
#         super(RoundedBoxProperties, self).__init__(**kwargs)
#         if not hasattr(self, 'nb_face'):
#             self.nb_face = int(5)
#         if not hasattr(self, 'inradius'):
#             self.inradius = 50.
#         if not hasattr(self, 'height'):
#             self.height = 30.
#         if not hasattr(self, 'thickness'):
#             self.thickness = 3.
#         if not hasattr(self, 'cut_nb'):
#             self.cut = int(0)
# 
#         self.side_length = 0.
#         self.max_side_length = 0.
#         self.compute_information(True)
# 
#     def compute_information(self, update_side_length = False):
#         circumradius =  self.inradius / math.cos(math.pi / float(self.nb_face))
#         self.max_side_length = 2 * circumradius * math.sin(math.pi / float(self.nb_face))
#         self.max_side_length = round(self.max_side_length - 0.01, 2)
# 
#         if update_side_length is True or self.side_length >= self.max_side_length :
#             self.side_length = math.floor(self.max_side_length * 0.75)
# 
#         if self.cut > self.nb_face:
#             self.cut = int(self.nb_face)
# 
# class TopBottomRoundedProperties(ObjectProperties):
#     _allowed = ('position', 'height_shift', 'radius_outside')
# 
#     POSITION_OUTSIDE = "Outside"
#     POSITION_INSIDE = "Inside"
# 
#     def __init__(self, **kwargs):
#         super(TopBottomRoundedProperties, self).__init__(**kwargs)
#         if not hasattr(self, 'position'):
#             self.position = self.POSITION_INSIDE
#         if not hasattr(self, 'height_shift'):
#             self.height_shift = 0.
#         if not hasattr(self, 'radius_outside'):
#             self.radius_outside = 0.
# 
# Path: lasercut/makehinges.py
# def do_intersection(seg1, seg2):
#     da = seg1.B - seg1.A
#     db = seg2.B - seg2.A
#     dc = seg2.A - seg1.A
# 
#     coplanar_val = dc.dot(da.cross(db))
#     if not compare_value(coplanar_val, 0.):
#         raise ValueError("Not coplanar (seg1: %s, seg2: %s) => res: %s" %(str(seg1), str(seg2), str(coplanar_val)))
# 
#     a = dc.cross(db).dot(da.cross(db))
#     s = dc.cross(db).dot(da.cross(db)) / da.cross(db).dot(da.cross(db))
#     if s >= 10e-6:
#         da.scale(s, s, s)
#         ip = seg1.A.add(da)
#         return ip
#     else:
#         raise ValueError("Wrong scale")


from FreeCAD import Gui
from lasercut.roundedboxproperties import RoundedBoxProperties, TopBottomRoundedProperties
from lasercut.makehinges import do_intersection
import FreeCAD
import FreeCADGui
import Part
import math
import lasercut.helper as helper
        inner_arc_point = dir_mid_point * inner_arc_radius
        inner_arc_point = inner_arc_point.add(intersection_point)
        outer_arc_point = dir_mid_point * outer_arc_radius
        outer_arc_point = outer_arc_point.add(intersection_point)
        arcs_segment_list.append(helper.Segment(outer_arc_point, inner_arc_point))

    #FreeCAD.Console.PrintMessage("Computed arc radius : inner = %f, outer = %f" % (inner_arc_radius, outer_arc_radius))
    return arcs_segment_list


def get_contours_with_arc(edge, arcs_segment_list):
    nb_face = len(edge)

    outer_contours = []
    inner_contours = []
    for index in range(nb_face):
        first_segment = edge[index][0]
        second_segment = edge[index][1]
        last_segment = edge[(index + 1) % nb_face][0]

        outer_contours.append(Part.makeLine(first_segment.A, second_segment.A))
        inner_contours.append(Part.makeLine(first_segment.B, second_segment.B))

        outer_contours.append(Part.Arc(second_segment.A, arcs_segment_list[index].A, last_segment.A).toShape())
        inner_contours.append(Part.Arc(second_segment.B, arcs_segment_list[index].B, last_segment.B).toShape())

    return inner_contours, outer_contours


def create_plane_part(dimension_properties, plane_properties):

# Path: lasercut/roundedboxproperties.py
# class RoundedBoxProperties(ObjectProperties):
# 
#     _allowed = ('nb_face', 'inradius', 'height', 'side_length', 'max_side_length', 'thickness', 'cut')
# 
#     def __init__(self, **kwargs):
#         super(RoundedBoxProperties, self).__init__(**kwargs)
#         if not hasattr(self, 'nb_face'):
#             self.nb_face = int(5)
#         if not hasattr(self, 'inradius'):
#             self.inradius = 50.
#         if not hasattr(self, 'height'):
#             self.height = 30.
#         if not hasattr(self, 'thickness'):
#             self.thickness = 3.
#         if not hasattr(self, 'cut_nb'):
#             self.cut = int(0)
# 
#         self.side_length = 0.
#         self.max_side_length = 0.
#         self.compute_information(True)
# 
#     def compute_information(self, update_side_length = False):
#         circumradius =  self.inradius / math.cos(math.pi / float(self.nb_face))
#         self.max_side_length = 2 * circumradius * math.sin(math.pi / float(self.nb_face))
#         self.max_side_length = round(self.max_side_length - 0.01, 2)
# 
#         if update_side_length is True or self.side_length >= self.max_side_length :
#             self.side_length = math.floor(self.max_side_length * 0.75)
# 
#         if self.cut > self.nb_face:
#             self.cut = int(self.nb_face)
# 
# class TopBottomRoundedProperties(ObjectProperties):
#     _allowed = ('position', 'height_shift', 'radius_outside')
# 
#     POSITION_OUTSIDE = "Outside"
#     POSITION_INSIDE = "Inside"
# 
#     def __init__(self, **kwargs):
#         super(TopBottomRoundedProperties, self).__init__(**kwargs)
#         if not hasattr(self, 'position'):
#             self.position = self.POSITION_INSIDE
#         if not hasattr(self, 'height_shift'):
#             self.height_shift = 0.
#         if not hasattr(self, 'radius_outside'):
#             self.radius_outside = 0.
# 
# Path: lasercut/makehinges.py
# def do_intersection(seg1, seg2):
#     da = seg1.B - seg1.A
#     db = seg2.B - seg2.A
#     dc = seg2.A - seg1.A
# 
#     coplanar_val = dc.dot(da.cross(db))
#     if not compare_value(coplanar_val, 0.):
#         raise ValueError("Not coplanar (seg1: %s, seg2: %s) => res: %s" %(str(seg1), str(seg2), str(coplanar_val)))
# 
#     a = dc.cross(db).dot(da.cross(db))
#     s = dc.cross(db).dot(da.cross(db)) / da.cross(db).dot(da.cross(db))
#     if s >= 10e-6:
#         da.scale(s, s, s)
#         ip = seg1.A.add(da)
#         return ip
#     else:
#         raise ValueError("Wrong scale")


# Path: lasercut/makeroundedbox.py
from FreeCAD import Gui
from lasercut.roundedboxproperties import RoundedBoxProperties, TopBottomRoundedProperties
from lasercut.makehinges import do_intersection
import FreeCAD
import FreeCADGui
import Part
import math
import lasercut.helper as helper

        inner_arc_point = dir_mid_point * inner_arc_radius
        inner_arc_point = inner_arc_point.add(intersection_point)
        outer_arc_point = dir_mid_point * outer_arc_radius
        outer_arc_point = outer_arc_point.add(intersection_point)
        arcs_segment_list.append(helper.Segment(outer_arc_point, inner_arc_point))

    #FreeCAD.Console.PrintMessage("Computed arc radius : inner = %f, outer = %f" % (inner_arc_radius, outer_arc_radius))
    return arcs_segment_list


def get_contours_with_arc(edge, arcs_segment_list):
    nb_face = len(edge)

    outer_contours = []
    inner_contours = []
    for index in range(nb_face):
        first_segment = edge[index][0]
        second_segment = edge[index][1]
        last_segment = edge[(index + 1) % nb_face][0]

        outer_contours.append(Part.makeLine(first_segment.A, second_segment.A))
        inner_contours.append(Part.makeLine(first_segment.B, second_segment.B))

        outer_contours.append(Part.Arc(second_segment.A, arcs_segment_list[index].A, last_segment.A).toShape())
        inner_contours.append(Part.Arc(second_segment.B, arcs_segment_list[index].B, last_segment.B).toShape())

    return inner_contours, outer_contours


def create_plane_part(dimension_properties, plane_properties):

    if plane_properties.position == TopBottomRoundedProperties.POSITION_INSIDE: