
    ^jp                       d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlZddlmZmZmZ dd	lmZmZmZmZ dd
lmZ ddlmZmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-  G d de)      Z. G d de.      Z/ G d de.      Z0 G d de.      Z1 G d de.      Z2 G d de.      Z3 G d de.      Z4 G d de.      Z5 G d de.      Z6 G d d e.      Z7 G d! d"e.      Z8 G d# d$e.      Z9 G d% d&e.      Z: G d' d(e.      Z;y))a  
Sketch Objects

name: objects_sketch.py
by:   Gumyr
date: March 22nd 2023

desc:
    This python module contains objects (classes) that create 2D Sketches.

license:

    Copyright 2022 Gumyr

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    )annotations)Iterable)cosdegreespiradianssintan)PathLike)castN)LocationListflatten_sequencevalidate_inputs)Align	FontStyleMode	TextAlign)BuildSketch)	TOLERANCEAxisLocationRotationVector
VectorLiketo_align_offset)	CompoundEdgeFace	ShapeListSketchVertexWiretopo_explore_common_vertextuplifyc                  h     e Zd ZdZej
                  gZddej                  f	 	 	 	 	 	 	 d fdZ	 xZ
S )BaseSketchObjectay  BaseSketchObject

    Base class for all BuildSketch objects

    Args:
        face (Face): face to create
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to None
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   Nc                l   |Ct        |d      }|j                  t        |j                         j	                  |                   t        j                  | d      }|@|dk7  r*|j                  t        dd|            j                         n|j                         }ns|| _
        || _        |dk7  r|j                  t        dd|            n|}t        d |j                         D              }t        |t
              r |j                  |d|i t        | A  t#        |      j$                         y )N   F)logr   c              3     K   | ]G  }t        j                         j                  D ]$  }|t               k7  r|j	                  |      n| & I y wN)r   _get_contextlocal_locationsr   moved).0facelocations      Q/opt/ringagent/.cad-venv/lib/python3.12/site-packages/build123d/objects_sketch.py	<genexpr>z,BaseSketchObject.__init__.<locals>.<genexpr>g   sS      " , 9 9 ; K K"  )1HJ(>

8$DH"H"s   AAmode)r$   mover   bounding_boxr   r   r,   r.   r   facesrotationr4   r   
isinstance_add_to_contextsuper__init__r   wrapped)selfobjr8   alignr4   context	new_faces	__class__s          r2   r<   zBaseSketchObject.__init__N   s    E1%EHHXc..0@@GHI&1&>&>t&O? q= 		(1a2399;YY[  %DMDI9AQ#))HQ845CC! "IIK" I
 ';/'''>>),445    )r?   zCompound | Facer8   floatr@   "Align | tuple[Align, Align] | Noner4   r   __name__
__module____qualname____doc__r   _tag_applies_tor   ADDr<   __classcell__rC   s   @r2   r&   r&   ?   sW    
 ##$K
 48XX!6!6 !6 2	!6
 !6 !6rD   r&   c                       e Zd ZdZej
                  gZdej                  ej                  fe	j                  f	 	 	 	 	 	 	 d fdZ xZS )Circlea  Sketch Object: Circle

    Create a circle defined by radius.

    Args:
        radius (float): circle radius
        arc_size (float, optional): angular size of sector. Defaults to 360.
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.CENTER, Align.CENTER)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
         v@c                z   t        j                  |       }t        ||        || _        || _        t        |d      | _        |dk(  rt        t        j                  |            n:t        j                  t        j                  |dfd      |t        j                        }t        | A  |d| j                  |       y )Nr(   rS   r   r   r   )r   r,   r   radiusarc_sizer$   r@   r   r"   make_circlerevolver   	make_liner   Zr;   r<   )r>   rV   rW   r@   r4   rA   r0   rC   s          r2   r<   zCircle.__init__   s     '2&>&>t&D& UA&
 5  !!&)*dnnfa[&A8TVVT 	
 	q$**d3rD   )rV   rE   rW   rE   r@   rF   r4   r   rH   rI   rJ   rK   r   rL   rM   r   CENTERr   rN   r<   rO   rP   s   @r2   rR   rR   r   sd    
 ##$K
  5:\\5<<4PXX44 4 2	4
 4 4rD   rR   c                       e Zd ZdZej
                  gZdej                  ej                  fe	j                  f	 	 	 	 	 	 	 	 	 d fdZ xZS )Ellipsea  Sketch Object: Ellipse

    Create an ellipse defined by x- and y- radii.

    Args:
        x_radius (float): x radius of the ellipse (along the x-axis of plane)
        y_radius (float): y radius of the ellipse (along the y-axis of plane)
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.CENTER, Align.CENTER)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   c                    t        j                  |       }t        ||        || _        || _        t        |d      | _        t        t        j                  ||            }t        | -  ||| j                  |       y Nr(   )r   r,   r   x_radiusy_radiusr$   r@   r   r"   make_ellipser;   r<   )	r>   rb   rc   r8   r@   r4   rA   r0   rC   s	           r2   r<   zEllipse.__init__   si     '2&>&>t&D&  UA&
D%%h9:xT:rD   )
rb   rE   rc   rE   r8   rE   r@   rF   r4   r   r\   rP   s   @r2   r_   r_      sn     ##$K 5:\\5<<4PXX;; ; 	;
 2; ; ;rD   r_   c                       e Zd ZdZej
                  gZdej                  ej                  fe	j                  d	 	 	 	 	 	 	 d fdZ xZS )Polygona  Sketch Object: Polygon

    Create a polygon defined by given sequence of points.

    Note: the order of the points defines the resulting normal of the Face in Algebra
    mode, where counter-clockwise order creates an upward normal while clockwise order
    a downward normal. In Builder mode, the Face is added with an upward normal.

    Args:
        pts (VectorLike | Iterable[VectorLike]): sequence of points defining the
            vertices of the polygon
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.NONE, Align.NONE)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   r8   r@   r4   c               J   t        j                  |       }t        ||        t        | }|| _        t        |d      | _        | j                  D cg c]  }t        |       }}t        t        j                  |            }	t        
| 1  |	|| j                  |       y c c}w ra   )r   r,   r   r   ptsr$   r@   r   r   r"   make_polygonr;   r<   )r>   r8   r@   r4   ri   rA   flattened_ptsppoly_ptsr0   rC   s             r2   r<   zPolygon.__init__   s     '2&>&>t&D&(#. UA&
'+xx0!F1I00D%%h/0xT: 1s   B )ri   z!VectorLike | Iterable[VectorLike]r8   rE   r@   rF   r4   r   )rH   rI   rJ   rK   r   rL   rM   r   NONEr   rN   r<   rO   rP   s   @r2   rf   rf      sd    " ##$K
 5:ZZ4LXX;/; ; 2	;
 ; ;rD   rf   c                       e Zd ZdZej
                  gZdej                  ej                  fe	j                  f	 	 	 	 	 	 	 	 	 d fdZ xZS )	Rectanglea  Sketch Object: Rectangle

    Create a rectangle defined by width and height.

    Args:
        width (float): rectangle width
        height (float): rectangle height
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.CENTER, Align.CENTER)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   c                    t        j                  |       }t        ||        || _        || _        t        |d      | _        t        j                  ||      }t        | )  ||| j                  |       y ra   )r   r,   r   widthrectangle_heightr$   r@   r   	make_rectr;   r<   	r>   rr   heightr8   r@   r4   rA   r0   rC   s	           r2   r<   zRectangle.__init__   sc     '2&>&>t&D&
 &UA&
~~eV,xT:rD   
rr   rE   rv   rE   r8   rE   r@   rF   r4   r   r\   rP   s   @r2   rp   rp      sn     ##$K 5:\\5<<4PXX;; ; 	;
 2; ; ;rD   rp   c                       e Zd ZdZej
                  gZdej                  ej                  fe	j                  f	 	 	 	 	 	 	 	 	 	 	 d fdZ xZS )RectangleRoundeda  Sketch Object: Rectangle Rounded

    Create a rectangle defined by width and height with filleted corners.

    Args:
        width (float): rectangle width
        height (float): rectangle height
        radius (float): fillet radius
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.CENTER, Align.CENTER)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   c                Z   t        j                  |       }t        ||        |d|z  k  s|d|z  k  rt        d      || _        || _        || _        t        |d      | _        t        j                  ||      }|j                  ||j                               }t        	| 9  ||||       y )Nr(   z#width and height must be > 2*radius)r   r,   r   
ValueErrorrr   rs   rV   r$   r@   r   rt   	fillet_2dverticesr;   r<   )
r>   rr   rv   rV   r8   r@   r4   rA   r0   rC   s
            r2   r<   zRectangleRounded.__init__  s     '2&>&>t&D&AJ&AJ"6BCC
 &UA&
~~eV,~~fdmmo6x5rD   )rr   rE   rv   rE   rV   rE   r8   rE   r@   rF   r4   r   r\   rP   s   @r2   ry   ry     sx     ##$K 5:\\5<<4PXX66 6 	6
 6 26 6 6rD   ry   c                       e Zd ZdZej
                  gZddej                  ej                  fe	j                  f	 	 	 	 	 	 	 	 	 	 	 d fdZ xZS )RegularPolygona  Sketch Object: Regular Polygon

    Create a regular polygon defined by radius and side count. Use major_radius to define whether
    the polygon circumscribes (along the vertices) or inscribes (along the sides) the radius circle.

    Args:
        radius (float): construction radius
        side_count (int): number of sides
        major_radius (bool): If True the radius is the major radius (circumscribed circle),
            else the radius is the minor radius (inscribed circle). Defaults to True
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.CENTER, Align.CENTER)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    Tr   c                   t        j                  |       }t        ||        |dk  rt        d|       |r|}n|t	        t
        |z        z  }|| _        |t	        t
        |z        z  | _        || _        || _	        t        t        |dz         D 	cg c]X  }	t        |t	        |	dz  t
        z  |z  t        |      z         z  |t        |	dz  t
        z  |z  t        |      z         z        Z c}	      }
|
j                  t         j"                        |
j                  t         j$                        g}|d   d   j"                  |d   d   j$                  g}|d   d   j"                  |d   d   j$                  g}t'        |||d      }|
D cg c]  }||z   	 }}t)        t+        j,                  |            }t.        | a  |dd |	       y c c}	w c c}w )
N   z3RegularPolygon must have at least three sides, not    r(   r   rU   )centerrg   )r   r,   r   r{   r   r   rV   apothem
side_countr@   r   ranger   r   r	   sort_byr   XYr   r   r"   rj   r;   r<   )r>   rV   r   major_radiusr8   r@   r4   rA   radiri   
pts_sortedminsmaxsalign_offsetpointpts_aor0   rC   s                     r2   r<   zRegularPolygon.__init__@  s    '2&>&>t&D&>Ej\R  C3rJ//C !CO%
 
 %
 zA~.
 	 #a!ebj:58IIJJ#a!ebj:58IIJJ
 kk$&&)3;;tvv+>?
 1a ""JqM!$4$6$671b!##Z]2%6%8%89&tT5H4785%,&88D%%f-.DA% 9s   AGG)rV   rE   r   intr   boolr8   rE   r@   ztuple[Align, Align]r4   r   r\   rP   s   @r2   r   r   -  s      ##$K "&+llELL%AXX2B2B 2B 	2B
 2B #2B 2B 2BrD   r   c                  f     e Zd ZdZej
                  gZdej                  f	 	 	 	 	 	 	 d fdZ	 xZ
S )SlotArcan  Sketch Object: Slot Arc

    Create a slot defined by a line and height. May be an arc, stright line, spline, etc.

    Args:
        arc (Edge | Wire): center line of slot
        height (float): diameter of end arcs
        rotation (float, optional): angle to rotate object. Defaults to 0
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   c                    t        j                  |       }t        ||        || _        || _        t        |t              r|nt        |g      }t        |j                  |dz              }t        | )  ||d |       y ra   )r   r,   r   arcslot_heightr9   r"   r   	offset_2dr;   r<   )r>   r   rv   r8   r4   rA   r0   rC   s          r2   r<   zSlotArc.__init__  sn     '2&>&>t&D&!T*ccUCMM&1*-.xt4rD   )r   zEdge | Wirerv   rE   r8   rE   r4   r   rG   rP   s   @r2   r   r   u  sT    	 ##$K XX55 5 	5
 5 5rD   r   c                  j     e Zd ZdZej
                  gZdej                  f	 	 	 	 	 	 	 	 	 d fdZ	 xZ
S )SlotCenterPointa  Sketch Object: Slot Center Point

    Create a slot defined by the center of the slot and the center of one end arc.
    The slot will be symmetric about the center point.

    Args:
        center (VectorLike): center point
        point (VectorLike): center of arc point
        height (float): diameter of end arcs
        rotation (float, optional): angle to rotate object. Defaults to 0
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   c                   t        j                  |       }t        ||        t        |      }t        |      }|| _        || _        || _        ||z
  }	|	j                  dk  rt        d|	j                   d      t        j                  t        j                  ||      t        j                  |||	z
        g      }
t        |
d   j                  |dz              }t        | A  ||d |       y )Nr   zIDistance between center and point must be greater than 0 Got: distance = z (computed)r(   )r   r,   r   r   slot_centerr   r   lengthr{   r"   combiner   rZ   r   r   r;   r<   )r>   r   r   rv   r8   r4   rA   center_vpoint_v	half_line
slot_wiresr0   rC   s               r2   r<   zSlotCenterPoint.__init__  s     '2&>&>t&D&&>-#
!h&	q ##,#3#3"4KA 
 \\w1xI)=>

 JqM++FQJ78xt4rD   )
r   r   r   r   rv   rE   r8   rE   r4   r   rG   rP   s   @r2   r   r     s^     ##$K XX 5 5  5 	 5
  5  5  5rD   r   c                  f     e Zd ZdZej
                  gZdej                  f	 	 	 	 	 	 	 d fdZ	 xZ
S )SlotCenterToCentera  Sketch Object: Slot Center To Center

    Create a slot defined by the distance between the centers of the two end arcs.

    Args:
        center_separation (float): distance between arc centers
        height (float): diameter of end arcs
        rotation (float, optional): angle to rotate object. Defaults to 0
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   c                   |dk  rt        d|      t        j                  |       }t        ||        || _        || _        |dkD  rt        t        t        j                  t        | dz  dd      t                     t        j                  t               t        |dz  dd            g      j                  |dz              }n,t        t        t        |dz  |      j                               }t        | A  ||d |       y )Nr   z7Requires center_separation > 0. Got: center_separation=r(   r4   )r{   r   r,   r   center_separationr   r   r"   r   rZ   r   r   r   rR   r0   r;   r<   )r>   r   rv   r8   r4   rA   r0   rC   s          r2   r<   zSlotCenterToCenter.__init__  s     q J8I7KL  '2&>&>t&D&!2!q v/@.@1.Da'KVXVvx9J8JQ8NPQST1UV
 )FQJ'D fVaZd;@@BCDxt4rD   )r   rE   rv   rE   r8   rE   r4   r   rG   rP   s   @r2   r   r     sT    	 ##$K XX5 5 5 	5
 5 5rD   r   c                       e Zd ZdZej
                  gZdej                  ej                  fe	j                  f	 	 	 	 	 	 	 	 	 d fdZ xZS )SlotOveralla  Sketch Object: Slot Overall

    Create a slot defined by the overall width and height.

    Args:
        width (float): overall width of slot
        height (float): diameter of end arcs
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.CENTER, Align.CENTER)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    r   c                ,   ||k  rt        d|d|      t        j                  |       }t        ||        || _        || _        ||kD  rt        t        t        j                  t        | dz  |dz  z   dd      t                     t        j                  t               t        |dz  |dz  z
  dd            g      j                  |dz              }n,t        t        t        |dz  |      j                               }t        | A  ||||       y )Nz.Slot requires that width > height. Got: width=z	, height=r(   r   r   )r{   r   r,   r   rr   r   r   r"   r   rZ   r   r   r   rR   r0   r;   r<   ru   s	           r2   r<   zSlotOverall.__init__  s	    6>A5(*VIN  '2&>&>t&D&
!6>vufqj6A:.Eq!'LfhWvx
VaZ8OQRTU1VW
 )FQJ'D fUQYT:??ABDx5rD   rw   r\   rP   s   @r2   r   r     sn     ##$K 5:\\5<<4PXX66 6 	6
 26 6 6rD   r   c            
           e Zd ZdZej
                  gZddej                  e	j                  e	j                  fdddddej                  f
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZ xZS )Textaw  Sketch Object: Text

    Create text defined by text string and font size.

    Fonts installed to the system can be specified by name and FontStyle. Fonts with
    subfamilies not in FontStyle should be specified with the subfamily name, e.g.
    "Arial Black". Alternatively, a specific font file can be specified with font_path.

    Use `available_fonts()` to list available font names for `font` and FontStyles.
    Note: on Windows, fonts must be installed with "Install for all users" to be found
    by name.

    Not all fonts have every FontStyle available, however ITALIC and BOLDITALIC will
    still italicize the font if the respective font file is not available.

    text_align specifies alignment of text inside the bounding box, while align the
    aligns the bounding box itself.

    Optionally, the Text can be positioned on a non-linear edge or wire with a path and
    position_on_path.

    Args:
        txt (str): text to render
        font_size (float): size of the font in model units
        font (str, optional): font name. Defaults to "Arial"
        font_path (PathLike | str, optional): system path to font file. Defaults to None
        font_style (Font_Style, optional): font style, REGULAR, BOLD, BOLDITALIC, or
            ITALIC. Defaults to Font_Style.REGULAR
        text_align (tuple[TextAlign, TextAlign], optional): horizontal text align
            LEFT, CENTER, or RIGHT. Vertical text align BOTTOM, CENTER, TOP, or
            TOPFIRSTLINE. Defaults to (TextAlign.CENTER, TextAlign.CENTER)
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of
            object. Defaults to None
        path (Edge | Wire, optional): path for text to follow. Defaults to None
        position_on_path (float, optional): the relative location on path to position
            the text, values must be between 0.0 and 1.0. Defaults to 0.0
        single_line_width (float, optional): width of outlined single line font.
            Defaults to 4% of font_size
        rotation (float, optional): angle to rotate object. Defaults to 0
        mode (Mode, optional): combination mode. Defaults to Mode.ADD
    ArialN        c                   t        j                  |       }t        ||        |
d|z  }
n|
dk  rt        d|
 d      || _        || _        || _        || _        || _        || _	        || _
        || _        |	| _        |
| _        || _        || _        t!        j"                  ||||||||	||

      }t$        | M  ||d |       y )Ng{Gz?r   zsingle_line_width (z) must be greater than 0)
txt	font_sizefont	font_path
font_style
text_alignr@   position_on_path	text_pathsingle_line_width)r   r,   r   r{   r   r   r   r   r   r   r@   r   r   r   r8   r4   r   	make_textr;   r<   )r>   r   r   r   r   r   r   r@   pathr   r   r8   r4   rA   text_stringrC   s                  r2   r<   zText.__init__[  s     '2&>&>t&D&$ !%y 0#%%&7%88PQ  "	"$$
 0!2 	((!!-/
 	hd;rD   )r   strr   rE   r   r   r   zPathLike[str] | str | Noner   r   r   ztuple[TextAlign, TextAlign]r@   rF   r   zEdge | Wire | Noner   rE   r   float | Noner8   rE   r4   r   )rH   rI   rJ   rK   r   rL   rM   r   REGULARr   r]   r   rN   r<   rO   rP   s   @r2   r   r   )  s    (V ##$K 04 ) 1 13<3C3CYEUEU2V48#'"%*.XX4<4< 4< 	4<
 .4< 4< 04< 24< !4<  4< (4< 4< 4< 4<rD   r   c                       e Zd ZdZej
                  gZddej                  ej                  fe	j                  f	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZ xZS )	Trapezoida  Sketch Object: Trapezoid

    Create a trapezoid defined by major width, height, and interior angle(s).

    Args:
        width (float): trapezoid major width
        height (float): trapezoid height
        left_side_angle (float): bottom left interior angle
        right_side_angle (float, optional): bottom right interior angle. If not provided,
            the trapezoid will be symmetric. Defaults to None
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to (Align.CENTER, Align.CENTER)
        mode (Mode, optional): combination mode. Defaults to Mode.ADD

    Raises:
        ValueError: Give angles result in an invalid trapezoid
    Nr   c                r   t        j                  |       }t        ||        |s|n|}|| _        || _        || _        || _        t        |d      | _        |dk(  rdn|t        t        |            z  }	|dk(  rdn|t        t        |            z  }
|dz  }|dz  }|dz  }|dz  }|	dkD  r||	z  }n||	z  }|
dkD  r||
z  }n||
z  }||z   dk  rt        d      ||z   dk  rt        d      g }|j                  t        | | dz               |j                  t        || dz               |j                  t        ||dz               |j                  t        | |dz               |j                  |d          t        t        j                   |            }t"        | I  ||| j                  |       y )Nr(   Z   r   z(Trapezoid bottom invalid - change anglesz%Trapezoid top invalid - change angles)r   r,   r   rr   trapezoid_heightleft_side_angleright_side_angler$   r@   r
   r   r{   appendr   r   r"   rj   r;   r<   )r>   rr   rv   r   r   r8   r@   r4   rA   reduction_leftreduction_righttop_width_lefttop_width_rightbot_width_leftbot_width_rightri   r0   rC   s                    r2   r<   zTrapezoid.__init__  s    '2&>&>t&D&2B?HX
 &. 0UA&
 !B&AFS9Q5R,R 	 "R'AVc'BR:S6T-T 	 !)!)An,Nn,NQ.O.O_,1GHH_,1DEE

6>/F7Q;78

6/F7Q;78

6/6A:67

6>/6A:67

3q6D%%c*+xT:rD   )rr   rE   rv   rE   r   rE   r   r   r8   rE   r@   rF   r4   r   r\   rP   s   @r2   r   r     s    & ##$K *.5:\\5<<4PXX8;8; 8; 	8;
 '8; 8; 28; 8; 8;rD   r   c            
           e Zd ZdZej
                  gZddddddddej                  d		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZ	 xZ
S )Trianglea9  Sketch Object: Triangle

    Create a triangle defined by one side length and any of two other side lengths or interior
    angles. The interior angles are opposite the side with the same designation
    (i.e. side 'a' is opposite angle 'A'). Side 'a' is the bottom side, followed by 'b'
    on the right, going counter-clockwise.

    Args:
        a (float, optional): side 'a' length. Defaults to None
        b (float, optional): side 'b' length. Defaults to None
        c (float, optional): side 'c' length. Defaults to None
        A (float, optional): interior angle 'A'. Defaults to None
        B (float, optional): interior angle 'B'. Defaults to None
        C (float, optional): interior angle 'C'. Defaults to None
        rotation (float, optional): angle to rotate object. Defaults to 0
        align (Align | tuple[Align, Align], optional): align MIN, CENTER, or MAX of object.
            Defaults to None
        mode (Mode, optional): combination mode. Defaults to Mode.ADD

    Raises:
        ValueError: One length and two other values were not provided
    Nr   )	abcABCr@   r8   r4   c       	   
         t        j                         }
t        |
        |||fD cg c]  }|d u  c}j                  d      dk(  s*||||||fD cg c]  }|d u  c}j                  d      dk7  rt	        d      d |||fD        \  }}}t        j                  ||||||      \  }}}} _         _        | _	        t        |       _        t        |       _        t        |       _        t        t        j                   t#        dd      t#        d      t#        |d      j%                  t&        j(                   j                        g            }t+        d |j-                         D        t#        ddd            dz  }|j/                  t1        |              |d nt3        |d      }t4         m  ||||	        j9                         j;                  fd	      d    _         j9                         j;                   fd
      d    _         j9                         j;                   fd      d    _         tC         j>                   j@                         _"        tG         jD                  tH              sJ   jD                  _%        tC         j<                   j@                         _&        tG         jL                  tH              sJ   jL                  _%        tC         j<                   j>                         _'        tG         jN                  tH              sJ   jN                  _%        y c c}w c c}w )NTr   z0One length and two other values must be providedc              3  :   K   | ]  }|t        |      nd   y wr+   )r   )r/   angles     r2   r3   z$Triangle.__init__.<locals>.<genexpr>  s     XUU%675>D@Xs   r   c              3  2   K   | ]  }t        |        y wr+   )r   )r/   vs     r2   r3   z$Triangle.__init__.<locals>.<genexpr>#  s     8q8s   r(   )r?   r8   r@   r4   c                B    t        | j                  z
        t        k  S r+   )absr   r   )ears    r2   <lambda>z#Triangle.__init__.<locals>.<lambda>(  s    s188b=7II7U rD   c                d    t        | j                  z
        t        k  xr | j                  fvS r+   )r   r   r   edge_a)r   brr>   s    r2   r   z#Triangle.__init__.<locals>.<lambda>,  s)    c!((R-(94O4;;-9O rD   c                8    | j                   j                  fvS r+   )r   edge_b)r   r>   s    r2   r   z#Triangle.__init__.<locals>.<lambda>1  s    aT[[99 rD   )(r   r,   r   countr{   trianglesolversolver   r   r   r   r   r   r   r   r"   rj   r   rotater   r[   sumr}   r5   r   r$   r;   r<   edges	filter_byr   r   edge_cr#   vertex_Ar9   r!   topo_parentvertex_Bvertex_C)r>   r   r   r   r   r   r   r@   r8   r4   rA   r   crArBrCrtrianglecenter_of_geometry	alignmentr   r   rC   s   `                  @@r2   r<   zTriangle.__init__   s    '2&>&>t&D& !1ay)!AI)//5: !1aAq1?
AI?

%+? OPPXqRSUViX1a!/!5!5aAq!Q!GBBB1vb!}fRm.B.B466466.RS
 8H$5$5$78&Aq/JQN 	 	h 2234!MDwua/@	X	PTUjjl,,-UV
 jjl,,O
 

 jjl,,9
 

 3KK
 $--000$(!2KK
 $--000$(!2KK
 $--000$(!g * ?
s   MM)r   r   r   r   r   r   r   r   r   r   r   r   r@   rF   r8   rE   r4   r   rG   rP   s   @r2   r   r     s    . ##$K 48XXC) C) 	C)
 C) C) C) C) 2C) C) C) C)rD   r   )<rK   
__future__r   collections.abcr   mathr   r   r   r   r	   r
   osr   typingr   r   build123d.build_commonr   r   r   build123d.build_enumsr   r   r   r   build123d.build_sketchr   build123d.geometryr   r   r   r   r   r   r   build123d.topologyr   r   r   r   r    r!   r"   r#   r$   r&   rR   r_   rf   rp   ry   r   r   r   r   r   r   r   r    rD   r2   <module>r     s  8 # $ 4 4    R R C C .  
 
 
06v 06f"4 "4J ;  ;F$; $;N ;   ;F&6' &6REB% EBP5 5@05& 05f,5) ,5^/6" /6df< f<RN;  N;b`) `)rD   