
    ^j                    |    d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZmZmZmZmZ  G d dee         Zy	)
a  
BuildPart

name: build_part.py
by:   Gumyr
date: July 12th 2022

desc:
    This python module is a library used to build 3D parts.

TODO:
- add TwistExtrude, ProjectText

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)Builderlogger)Mode)LocationPlane)EdgeFaceJointPartSolidWirec                       e Zd ZdZd ZdZeZeZ	e
j                  d	 	 	 d fdZedd       Zej                  dd       Zedd       Zej                  dd       Zedd	       Zedd
       ZddddZd Z xZS )	BuildPartaH  BuildPart

    The BuildPart class is another subclass of Builder for building parts
    (objects with the property of volume) from sketches or 3D objects.
    It has an _obj property that returns the current part being built, and
    several pending lists for storing faces, edges, and planes that will be
    integrated into the final part later. The class overrides the _add_to_pending
    method of Builder.

    Args:
        workplanes (Plane, optional): initial plane to work on. Defaults to Plane.XY.
        mode (Mode, optional): combination mode. Defaults to Mode.ADD.
    part)modec               x    i | _         d | _        g | _        g | _        g | _        g | _        t        |   |d|i y )Nr   )joints_partpending_facespending_face_planespending_planespending_edgessuper__init__)selfr   
workplanes	__class__s      M/opt/ringagent/.cad-venv/lib/python3.12/site-packages/build123d/build_part.pyr   zBuildPart.__init__<   sE    
 )+"&
)+02 +-)+*040    c                    | j                   S )zGet the current partr   r   s    r   r   zBuildPart.partI        zzr    c                    || _         yzSet the current partNr"   r   values     r   r   zBuildPart.partN        
r    c                    | j                   S )zAlias _obj to partr"   r#   s    r   _objzBuildPart._objS   r$   r    c                    || _         yr&   r"   r'   s     r   r+   zBuildPart._objX   r)   r    c                F    t        j                  | j                        d   S )z1Return a wire representation of the pending edgesr   )r   combiner   r#   s    r   pending_edges_as_wirezBuildPart.pending_edges_as_wire]   s     ||D../22r    c                Z    | j                   | j                   j                  S t               S )zBuilder's location)r   locationr   r#   s    r   r1   zBuildPart.locationb   s$     &*YY%:tyy!!J
Jr    N)
face_planec                  |D cg c]  }t        |t              s| }}|D ]\  }t        j                  d|j                  |       | j
                  j                  |       |B| j                  j                  |       ^ |D cg c]  }t        |t              s| }}|D ]=  }t        j                  d|j                         | j                  j                  |       ? yc c}w c c}w )zAdd objects to BuildPart pending lists

        Args:
            objects (Union[Edge, Face]): sequence of objects to add
        z;Adding Face to pending_faces at %s on pending_face_plane %sNz"Adding Edge to pending_edges at %s)

isinstancer
   r   debugr1   r   appendr   r	   r   )r   r2   objectso	new_facesface	new_edgesedges           r   _add_to_pendingzBuildPart._add_to_pendingg   s     !(?1:a+>Q?	? 	<DLLM
 %%d+%((//
;	< !(?1:a+>Q?	? 	,DLL4 %%d+	, @ @s   C%C%C*C*c                    | j                   rV| j                   | j                  _         | j                  j                   j                         D ]  }| j                  |_         yy)zTransfer joints on exitN)r   r   valuesparent)r   joints     r   _exit_extraszBuildPart._exit_extras   sK    ;;#{{DII))002 )#yy) r    )r   zFace | Plane | Locationr   r   )returnzPart | None)r(   r   rC   None)rC   r   )rC   zLocation | None)r7   zEdge | Facer2   zPlane | None)__name__
__module____qualname____doc___tag	_obj_namer   _shaper   
_sub_classr   ADDr   propertyr   setterr+   r/   r1   r=   rB   __classcell__)r   s   @r   r   r   (   s     DIFJ
 XX1,1 1   
[[    
[[  3 3 K K QU ,2)r    r   N)rH   
__future__r   build123d.build_commonr   r   build123d.build_enumsr   build123d.geometryr   r   build123d.topologyr	   r
   r   r   r   r   r    r    r   <module>rW      s0   > # 2 & . C C]) ])r    