# 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
                               FreeCAD.Vector(0., side_length / 2.0, 0.))
        current_angle = rel_angle * face_index
        translation = helper.rotate_vector_z(FreeCAD.Vector(radius, 0., 0), current_angle)
        transformed_seg_a = seg_a.rotate_z(current_angle).add(translation)
        transformed_seg_b = seg_b.rotate_z(current_angle).add(translation)

        polygon_segment.append([transformed_seg_a, transformed_seg_b])


    return polygon_segment


# Split a list into roughly equal-sized pieces :
# http://stackoverflow.com/questions/2130016/splitting-a-list-of-arbitrary-size-into-only-roughly-n-equal-parts
def chunkIt(seq, num):
    if num == 0:
        return []
    avg = len(seq) / float(num)
    out = []
    last = 0.0

    while last < len(seq):
        out.append(seq[int(last):int(last + avg)])
        last += avg

    return out


def create_sides(polygon_segment, height, nb_cut):
    part_list = []

# 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

                               FreeCAD.Vector(0., side_length / 2.0, 0.))
        current_angle = rel_angle * face_index
        translation = helper.rotate_vector_z(FreeCAD.Vector(radius, 0., 0), current_angle)
        transformed_seg_a = seg_a.rotate_z(current_angle).add(translation)
        transformed_seg_b = seg_b.rotate_z(current_angle).add(translation)

        polygon_segment.append([transformed_seg_a, transformed_seg_b])


    return polygon_segment


# Split a list into roughly equal-sized pieces :
# http://stackoverflow.com/questions/2130016/splitting-a-list-of-arbitrary-size-into-only-roughly-n-equal-parts
def chunkIt(seq, num):
    if num == 0:
        return []
    avg = len(seq) / float(num)
    out = []
    last = 0.0

    while last < len(seq):
        out.append(seq[int(last):int(last + avg)])
        last += avg

    return out


def create_sides(polygon_segment, height, nb_cut):
    part_list = []

    index = 0