Ë
    JÿiAl  ã                  ó$  — d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZ ddlmZmZmZ ddlmZ ddlmZ ddlmZmZmZmZmZ dd	lmZ dd
lmZ ddlm Z!m"Z" ddl#m$Z$ ddlm%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z>m?Z?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZFmGZGmHZH ddlImJZJmKZK ddlLmMZMmNZN ddlOmPZPmQZQmRZRmSZS ddlTmUZU  G d„ deJeBe)   «      ZV G d„ deV«      ZW G d„ deV«      ZX G d „ d!eV«      ZYy)"aÕ  
build123d topology

name: composite.py
by:   Gumyr
date: January 07, 2025

desc:

This module defines advanced composite geometric entities for the build123d CAD system. It
introduces the `Compound` class as a central concept for managing groups of shapes, alongside
specialized subclasses such as `Curve`, `Sketch`, and `Part` for 1D, 2D, and 3D objects,
respectively. These classes streamline the construction and manipulation of complex geometric
assemblies.

Key Features:
- **Compound Class**:
  - Represents a collection of geometric shapes (e.g., vertices, edges, faces, solids) grouped
    hierarchically.
  - Supports operations like adding, removing, and combining shapes, as well as querying volumes,
    centers, and intersections.
  - Provides utility methods for unwrapping nested compounds and generating 3D text or coordinate
    system triads.

- **Specialized Subclasses**:
  - `Curve`: Handles 1D objects like edges and wires.
  - `Sketch`: Focused on 2D objects, such as faces.
  - `Part`: Manages 3D solids and assemblies.

- **Advanced Features**:
  - Includes Boolean operations, hierarchy traversal, and bounding box-based intersection detection.
  - Supports transformations, child-parent relationships, and dynamic updates.

This module leverages OpenCascade for robust geometric operations while offering a Pythonic
interface for efficient and extensible CAD modeling workflows.

license:

    Copyright 2025 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.

é    )ÚannotationsN)Úcombinations)ÚTypeÚUnion)ÚIterableÚIteratorÚSequence)ÚBRepAlgoAPI_Fuse)ÚFont_FA_BoldÚFont_FA_ItalicÚFont_FA_RegularÚFont_FontMgrÚFont_SystemFont)ÚGProp_GProps)ÚNCollection_Utf8String)ÚStdPrs_BRepTextBuilderÚStdPrs_BRepFont)ÚTCollection_AsciiString)ÚTopAbs_ShapeEnum)ÚTopoDSÚTopoDS_BuilderÚTopoDS_CompoundÚTopoDS_IteratorÚTopoDS_Shape)ÚPreOrderIter)ÚAlignÚCenterOfÚ	FontStyle)Ú	TOLERANCEÚAxisÚColorÚLocationÚPlaneÚVectorÚ
VectorLikeÚlogger)ÚSelfé   )ÚEdgeÚWireÚMixin1D)ÚShapeÚ	ShapeListÚ	SkipCleanÚJointÚdowncastÚ	shapetypeÚ
topods_dim)ÚMixin3DÚSolid)ÚFaceÚShell)Ú_extrude_topods_shapeÚ!_make_topods_compound_from_shapesÚtuplifyÚunwrapped_shapetype)ÚVertexc                  ó  ‡ — e Zd ZdZdZej                  Z	 	 	 	 	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 	 	 d"ˆ fd„Zed#d„«       Z	ed$d„«       Z
e	 	 	 	 d%d„«       Zed&d„«       Zed	dej                  ej"                  ej"                  fd
df	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'd„«       Zed(d„«       Zd)d„Zd*d„Zd+d„Zd,d„Zd-d„Zd„ Zd)d„Zej8                  fd.d„Zd/d„Zd0d„Z	 d1	 	 	 	 	 d2d„Z 	 	 	 	 d3d„Z!d4d5d„Z"d6d„Z#d7d„Z$d6d„Z%d„ Z&d6d„Z'd„ Z(d8d „Z)ˆ xZ*S )9ÚCompoundal  A Compound in build123d is a topological entity representing a collection of
    geometric shapes grouped together within a single structure. It serves as a
    container for organizing diverse shapes like edges, faces, or solids. This
    hierarchical arrangement facilitates the construction of complex models by
    combining simpler shapes. Compound plays a pivotal role in managing the
    composition and structure of intricate 3D models in computer-aided design
    (CAD) applications, allowing engineers and designers to work with assemblies
    of shapes as unified entities for efficient modeling and analysis.g      @Nc                óð   •— t        |t        «      r$t        |D �cg c]  }|j                  ‘Œ c}«      }	n|}	t        ‰
| �  |	|||¬«       |€dn|| _        |€i n|| _        |€g | _        y|| _        yc c}w )a7  Build a Compound from Shapes

        Args:
            obj (TopoDS_Compound | Iterable[Shape], optional): OCCT Compound or shapes
            label (str, optional): Defaults to ''.
            color (Color, optional): Defaults to None.
            material (str, optional): tag for external tools. Defaults to ''.
            joints (dict[str, Joint], optional): names joints. Defaults to None.
            parent (Compound, optional): assembly parent. Defaults to None.
            children (Sequence[Shape], optional): assembly children. Defaults to None.
        )ÚobjÚlabelÚcolorÚparentNÚ )	Ú
isinstancer   r8   ÚwrappedÚsuperÚ__init__ÚmaterialÚjointsÚchildren)Úselfr?   r@   rA   rH   rI   rB   rJ   ÚsÚtopods_compoundÚ	__class__s             €úm/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/build123d/topology/composite.pyrG   zCompound.__init__‰   sˆ   ø€ ô, �cœ8Ô$Ü?Ù$'Ó(¡C˜q�—“ CÑ(ó‰Oð "ˆOä‰ÑØØØØð	 	ô 	
ð 'Ð.™°HˆŒØ"˜N‘b°ˆŒØ&Ð.˜ˆ�°Hˆ�ùò )s   ›A3c                ó,   — t        | j                  «      S )zFThe dimension of the shapes within the Compound - None if inconsistent)r2   rE   ©rK   s    rO   Ú_dimzCompound._dim²   s   € ô ˜$Ÿ,™,Ó'Ð'ó    c                óz   — t        d„ g | j                  t        «      ¢| j                  t        «      ¢D «       «      S )z$volume - the volume of this Compoundc              3  ó4   K  — | ]  }|j                   –— Œ y ­w©N)Úvolume)Ú.0Úis     rO   Ú	<genexpr>z"Compound.volume.<locals>.<genexpr>»   s   è ø€ ÐTÑ%S �1—8•8Ñ%Sùs   ‚)ÚsumÚget_typer4   r6   rQ   s    rO   rW   zCompound.volume·   s2   € ô ÑTÐ%S t§}¡}´UÓ';Ð%S¸d¿m¹mÌEÓ>RÑ%SÓTÓTÐTrS   c                ó\  — t         j                  t        t         j                  t        t         j
                  t        t         j                  t        t         j                  t        t         j                  t        t         j                  t        i}t        |«      } ||   t!        |«      «      S )z6Returns the right type of wrapper, given a OCCT object)ÚtaÚTopAbs_VERTEXr;   ÚTopAbs_EDGEr)   ÚTopAbs_WIREr*   ÚTopAbs_FACEr5   ÚTopAbs_SHELLr6   ÚTopAbs_SOLIDr4   ÚTopAbs_COMPOUNDr=   r1   r0   )Úclsr?   Úconstructor_lutÚ
shape_types       rO   ÚcastzCompound.cast¿   so   € ô ×ÑœfÜ�N‰NœDÜ�N‰NœDÜ�N‰NœDÜ�O‰OœUÜ�O‰OœUÜ×Ñ¤ð
ˆô ˜s“^ˆ
à*ˆ˜zÑ*¬8°C«=Ó9Ð9rS   c                óf   — t        t        j                  t        |j                  |«      «      «      S )a3  extrude

        Extrude a Shell into a Compound.

        Args:
            direction (VectorLike): direction and magnitude of extrusion

        Raises:
            ValueError: Unsupported class
            RuntimeError: Generated invalid result

        Returns:
            Edge: extruded shape
        )r=   r   Ú
Compound_sr7   rE   )rf   r?   Ú	directions      rO   ÚextrudezCompound.extrudeÔ   s+   € ô  Ü×ÑÔ3°C·K±KÀÓKÓLó
ð 	
rS   ÚArialç        c	                óÐ  ‡‡‡— d
ˆˆˆfd„}	t         j                  j                  d«      r&dt        j                  d<   dt        j                  d<   t
        j                  t        t
        j                  t        t
        j                  t        i|   }
t        j                  «       }|rj|j                  t        |«      j!                  «       «      rBt#        t        |«      «      }|j%                  |
t        |«      «       |j'                  |d«       n|j)                  t        |«      |
«      }t+        j,                  d|j/                  «       j!                  «       |j1                  |
«      j!                  «       «       t3        «       }t5        t7        |j/                  «       j!                  «       «      |
t9        |«      «      }t;        |j=                  |t7        |«      «      «      }t?        |d	«      }|jA                  tC        |jE                  «       jG                  |«      Ž «      }‰�9‰jH                  Št;        |jK                  «       D �cg c]
  } |	|«      ‘Œ c}«      }|S c c}w )ar  2D Text that optionally follows a path.

        The text that is created can be combined as with other sketch features by specifying
        a mode or rotated by the given angle.  In addition, edges have been previously created
        with arc or segment, the text will follow the path defined by these edges. The start
        parameter can be used to shift the text along the path to achieve precise positioning.

        Args:
            txt: text to be rendered
            font_size: size of the font in model units
            font: font name
            font_path: path to font file
            font_style: text style. Defaults to FontStyle.REGULAR.
            align (Union[Align, tuple[Align, Align]], optional): align min, center, or max
                of object. Defaults to (Align.CENTER, Align.CENTER).
            position_on_path: the relative location on path to position the text,
                between 0.0 and 1.0. Defaults to 0.0.
            text_path: a path for the text to follows. Defaults to None - linear text.

        Returns:
            a Compound object containing multiple Faces representing the text

        Examples::

            fox = Compound.make_text(
                txt="The quick brown fox jumped over the lazy dog",
                font_size=10,
                position_on_path=0.1,
                text_path=jump_edge,
            )

        c                ó   •— ‰	€J ‚| j                  «       }t        |j                  j                  |j                  j                  z   dz  dd«      }‰|j                  ‰z  z   }‰	j                  |«      }t        ddd«      j                  |«      }‰	j                  |«      }| j                  ||z
  «      j                  t        |d«      | «      S )zÙ
            Reposition a face to the provided path

            Local coordinates are used to calculate the position of the face
            relative to the path. Global coordinates to position the face.
            é   r   r(   )r   r   r(   )Úbounding_boxr$   ÚminÚXÚmaxÚ
tangent_atÚget_signed_angleÚposition_atÚ	translateÚrotater    )
Ú	orig_faceÚbboxÚface_bottom_centerÚrelative_position_on_wireÚwire_tangentÚ
wire_angleÚwire_positionÚpath_lengthÚposition_on_pathÚ	text_paths
          €€€rO   Úposition_facez)Compound.make_text.<locals>.position_face  sÐ   ø€ ð Ð(Ð(Ð(Ø×)Ñ)Ó+ˆDÜ!'¨¯©¯©°d·h±h·j±jÑ)@ÀAÑ(EÀqÈ!Ó!LÐà Ð#5×#7Ñ#7¸+Ñ#EÑEð &ð %×/Ñ/Ð0IÓJˆLÜ  1 a›×9Ñ9¸,ÓGˆJØ%×1Ñ1Ð2KÓLˆMà×&Ñ& }Ð7IÑ'IÓJ×QÑQÜ�] IÓ.Ø�óð rS   Úlinuxz/etc/fonts/fonts.confÚFONTCONFIG_FILEz/etc/fonts/ÚFONTCONFIG_PATHTz(Creating text with font %s located at %srr   )r|   r5   Úreturnr5   )&ÚsysÚplatformÚ
startswithÚosÚenvironr   ÚREGULARr   ÚBOLDr   ÚITALICr   r   ÚGetInstance_sÚ	CheckFontr   Ú	ToCStringr   ÚSetFontPathÚRegisterFontÚFindFontr&   ÚinfoÚFontNameÚFontPathÚFont_BRepTextBuilderr   r   Úfloatr=   ÚPerformr9   rz   r$   rs   Úto_align_offsetÚlengthÚfaces)rf   ÚtxtÚ	font_sizeÚfontÚ	font_pathÚ
font_styleÚalignr„   r…   r†   Ú	font_kindÚmgrÚfont_tÚbuilderÚfont_iÚ	text_flatÚ
align_textÚfrƒ   s          ``         @rO   Ú	make_textzCompound.make_textè   só  ú€ ÷\	ô, �<‰<×"Ñ" 7Ô+Ø,CŒB�J‰JÐ(Ñ)Ø,9ŒB�J‰JÐ(Ñ)ô ×ÑœÜ�N‰NœLÜ×Ñœnð
ð ñ	ˆ	ô ×(Ñ(Ó*ˆá˜Ÿ™Ô'>¸yÓ'I×'SÑ'SÓ'UÔVÜ$Ô%<¸YÓ%GÓHˆFØ×Ñ˜yÔ*AÀ)Ó*LÔMØ×Ñ˜V TÕ*ð —\‘\Ô"9¸$Ó"?ÀÓKˆFä�‰Ø6Ø�O‰OÓ×'Ñ'Ó)Ø�O‰O˜IÓ&×0Ñ0Ó2ô	
ô 'Ó(ˆÜ Ü" 6§?¡?Ó#4×#>Ñ#>Ó#@ÓAØÜ�)Óó
ˆô
 ˜WŸ_™_¨VÔ5KÈCÓ5PÓQÓRˆ	ô ˜U AÓ&ˆ
Ø×'Ñ'Ü�I×*Ñ*Ó,×<Ñ<¸ZÓHÐIó
ˆ	ð Ð Ø#×*Ñ*ˆKÜ ¸I¿O¹OÔ<MÓ!NÑ<M°q¡-°Õ"2Ð<MÑ!NÓOˆIàÐùò "Os   ÉI#c                ó¦  — t        j                  d|ddf«      }t        j                  dd|df«      }t        j                  ddd|f«      }t        j                  d| dz  |dz  dfgddg«      }t        |t	        j                  |«      j                  t        j                  «      g«      }t        j                  d|dz  t        j                  t        j                  f¬	«      j                  t        |d
z  «      «      j                  «       }t        j                  d|dz  t        j                  t        j                  f¬	«      j!                  t"        j$                  d«      j                  t        |d
z  «      «      j                  «       }t        j                  d|dz  t        j                  t        j                  f¬	«      j!                  t"        j&                  d«      j!                  t"        j(                  d«      j                  t        |d
z  «      «      j                  «       }	t+        ||||j-                  t        |d
z  «      «      |j!                  t"        j$                  d«      j-                  t        |d
z  «      «      |j!                  t"        j&                  d«      j-                  t        |d
z  «      «      g|¢|¢|	¢«      }
|
S )z*The coordinate system triad (X, Y, Z axes))r   r   r   r   é   é   )éÿÿÿÿr   r   )r´   g      ø?r   ru   é   )r£   r§   r(   ÚYéZ   ÚZi¦ÿÿÿ)r)   Ú	make_lineÚmake_spliner*   ÚcopyÚmirrorr#   ÚXZr=   r°   r   ÚMINÚCENTERÚmover"   Úedgesr{   r    r¸   r¶   ru   ÚCurveÚmoved)rf   Ú
axes_scaleÚx_axisÚy_axisÚz_axisÚ	arrow_arcÚarrowÚx_labelÚy_labelÚz_labelÚtriads              rO   Ú
make_triadzCompound.make_triadZ  s\  € ô —‘ 	¨J¸¸1Ð+=Ó>ˆÜ—‘ 	¨A¨z¸1Ð+=Ó>ˆÜ—‘ 	¨A¨q°*Ð+=Ó>ˆÜ×$Ñ$Ø˜*˜ rÑ)¨:¸©?¸AÐ>Ð?Ø˜Ð&ó
ˆ	ô �i¤§¡¨9Ó!5×!<Ñ!<¼U¿X¹XÓ!FÐGÓHˆä×ÑØ˜z¨A™~´e·i±iÄÇÁÐ5Nð ó ÷ ‰T”(˜6 A™:Ó&Ó'ß‰U‹Wð 	ô ×ÑØ˜z¨A™~´e·i±iÄÇÁÐ5Nð ó ÷ ‰V”D—F‘F˜BÓß‰T”(˜6 A™:Ó&Ó'ß‰U‹Wð 	ô ×ÑØ˜z¨A™~´e·l±lÄEÇIÁIÐ5Nð ó ÷ ‰V”D—F‘F˜BÓß‰V”D—F‘F˜BÓß‰T”(˜6 A™:Ó&Ó'ß‰U‹Wð 	ô àØØØ—‘œH V¨a¡ZÓ0Ó1Ø—‘œTŸV™V RÓ(×.Ñ.¬x¸À¹
Ó/CÓDØ—‘œTŸV™V SÓ)×/Ñ/´¸À!¹Ó0DÓEð
ð ð
ð ð
ð ð
ó
ˆð ˆrS   c                óÚ  — | j                   dk(  rD| j                  €
t        «       nt        | j                  «      }| j                  |ddg«       ||z   S |€t	        «       }n%t	        d„ t        |t        «      r|gn|D «       «      }|s| S t	        d„ | j                  «       |z   D «       «      }t        |«      dk  rt        |dd «      }n�t        «       }|j                  t        «       | j                  |d   ddg«       | j                  |dd |dd |«      }t        |t        «      r t        |«      }| j                  |ddg«       n|}t        j                   r|j!                  «       }|S )z¤Combine other to self `+` operator

        Note that if all of the objects are connected Edges/Wires the result
        will be a Wire, otherwise a Shape.
        r(   NrE   Ú_NodeMixin__childrenc              3  óN   K  — | ]  }|�|j                  «       D ]  }|–— Œ Œ y ­wrV   )Úget_top_level_shapes)rX   ÚoÚshapes      rO   rZ   z#Compound.__add__.<locals>.<genexpr>ž  s5   è ø€ ð !áH�AØ�=Ø×3Ñ3Ö5�Eô ð 6ð ÙHùs   ‚#%c              3  ó&   K  — | ]	  }|€Œ|–— Œ y ­wrV   © )rX   rL   s     rO   rZ   z#Compound.__add__.<locals>.<genexpr>¨  s   è ø€ ð 
Ù=�!ÀÁŒAÑ=ùs   ‚Šr   )rR   rE   rÂ   Úcopy_attributes_tor-   rD   r,   rÒ   Úlenr=   r
   ÚSetFuzzyValuer   Ú_bool_opÚlistr.   Úclean)rK   ÚotherÚcurveÚsummandsÚresultÚfuse_opÚbool_results          rO   Ú__add__zCompound.__add__�  s`  € ð �9‰9˜Š>Ø#Ÿ|™|Ð3”E”G¼¸t¿|¹|Ó9LˆEØ×#Ñ# E¨IÐ7MÐ+NÔOØ˜5‘=Ð ð ˆ=Ü “{‰Hä ñ !ä%/°´uÔ%=˜5™'À5ÐHó!ó ˆHñ ØˆKäñ 
Ø×0Ñ0Ó2°XÒ=ó
ó 
ˆô
 ˆx‹=˜AÒÜ$ X¨a° ]Ó3‰Fä&Ó(ˆGØ×!Ñ!¤)Ô,Ø×#Ñ# H¨Q¡K°)Ð=SÐ1TÔUØŸ-™-¨°°!¨°h¸q¸r°lÀGÓLˆKÜ˜+¤tÔ,Ü! +Ó.�Ø×'Ñ'¨°Ð<RÐ0SÕTà$�ä�?Š?Ø—\‘\“^ˆFàˆrS   c                ó–   — t        j                  | |«      }t        t        |t        «      r|n|g«      }| j                  |ddg«       |S )z$Intersect other to self `&` operatorrE   rÐ   )r,   Ú__and__r=   rD   rÛ   r×   )rK   rÝ   Úintersections      rO   rå   zCompound.__and__¿  sJ   € ä—}‘} T¨5Ó1ˆÜÜ& |´TÔ:‰LÀÀó
ˆð 	×Ñ ¨yÐ:PÐ.QÔRØÐrS   c                óH   — t        | j                  «      j                  «       S )z!
        Check if empty.
        )r   rE   ÚMorerQ   s    rO   Ú__bool__zCompound.__bool__È  s   € ô
 ˜tŸ|™|Ó,×1Ñ1Ó3Ð3rS   c              #  óä   K  — t        | j                  «      }|j                  «       rGt        j	                  |j                  «       «      –— |j                  «        |j                  «       rŒFyy­w)z*
        Iterate over subshapes.

        N)r   rE   rè   r=   ri   ÚValueÚNext)rK   Úiterators     rO   Ú__iter__zCompound.__iter__Ï  sI   è ø€ ô # 4§<¡<Ó0ˆà�m‰mŒoÜ—-‘- §¡Ó 0Ó1Ò1Ø�M‰MŒOð �m‰m�oùs   ‚A+A0Á.A0c                ó:   — d}| j                   �| D ]  }|dz  }Œ	 |S )zReturn the number of subshapesr   r(   )rE   )rK   ÚcountÚ_s      rO   Ú__len__zCompound.__len__Û  s)   € àˆØ�<‰<Ð#Û�Ø˜‘
‘ð àˆrS   c                ó  — t        | d«      r[t        | d«      rO| j                  j                  › dt        | «      d›d| j                  › d�dt        | j                  «      › d�z   }|S | j                  j                  › dt        | «      d›�}|S )	zReturn Compound info as stringr@   rJ   z at z#xz, label(z), z
#children(Ú))ÚhasattrrN   Ú__name__Úidr@   rØ   rJ   )rK   rà   s     rO   Ú__repr__zCompound.__repr__ã  s�   € ä�4˜Ô!¤g¨d°JÔ&?à—>‘>×*Ñ*Ð+¨4´°4³¸¨}¸HÀTÇZÁZÀLÐPSÐTØœs 4§=¡=Ó1Ð2°!Ð4ñ5ð ð ˆð Ÿ™×/Ñ/Ð0°´R¸³X¸b°MÐBˆFØˆrS   c                ó–   — t        j                  | |«      }t        t        |t        «      r|n|g«      }| j                  |ddg«       |S )zCut other to self `-` operatorrE   rÐ   )r,   Ú__sub__r=   rD   rÛ   r×   )rK   rÝ   Ú
differences      rO   rú   zCompound.__sub__î  sJ   € ä—]‘] 4¨Ó/ˆ
ÜÜ$ Z´Ô6‰J¸Z¸Ló
ˆ
ð 	×Ñ 
¨YÐ8NÐ,OÔPàÐrS   c                ó‚  — |t         j                  k(  rt        d«      ‚|t         j                  k(  r\t	        «       }t
        j                  t        | «         }|r. || j                  |«       t        |j                  «       «      }|S t        ‚|t         j                  k(  r| j                  «       j                  «       }S )a�  Return center of object

        Find center of object

        Args:
            center_of (CenterOf, optional): center option. Defaults to CenterOf.MASS.

        Raises:
            ValueError: Center of GEOMETRY is not supported for this object
            NotImplementedError: Unable to calculate center of mass of this object

        Returns:
            Vector: center
        z3Center of GEOMETRY is not supported for this object)r   ÚGEOMETRYÚ
ValueErrorÚMASSr   r,   Úshape_properties_LUTr:   rE   r$   ÚCentreOfMassÚNotImplementedErrorÚBOUNDING_BOXrs   Úcenter)rK   Ú	center_ofÚ
propertiesÚcalc_functionÚmiddles        rO   r  zCompound.centerø  s¤   € ð œ×)Ñ)Ò)ÜÐRÓSÐSØœŸ™Ò%Ü%›ˆJÜ!×6Ñ6Ô7JÈ4Ó7PÑQˆMÙÙ˜dŸl™l¨JÔ7Ü 
× 7Ñ 7Ó 9Ó:�ð
 ˆô *Ð)Øœ(×/Ñ/Ò/Ø×&Ñ&Ó(×/Ñ/Ó1ˆFØˆrS   c                óŠ   — | j                  «       }t        |«      }|dk7  rt        j                  d|› d�d¬«       |r|d   S dS )zReturn the Compoundr(   zFound z compounds, returning firstrr   )Ú
stacklevelr   N)Ú	compoundsrØ   ÚwarningsÚwarn)rK   Ú
shape_listÚentity_counts      rO   ÚcompoundzCompound.compound  sN   € à—^‘^Ó%ˆ
Ü˜:“ˆØ˜1ÒÜ�M‰MØ˜˜Ð&AÐBØõñ !+ˆz˜!‰}Ð4°Ð4rS   c                ó  — | j                   €
t        «       S t        | j                   t        «      rF| D �cg c]  }t        |j                   t        «      sŒ|‘Œ! }}|j	                  | «       t        |«      S g }t        |«      S c c}w )z+compounds - all the compounds in this Shape)rE   r-   rD   r   Úappend)rK   ÚcÚsub_compoundss      rO   r  zCompound.compounds   sv   € à�<‰<ÐÜ“;ÐÜ�d—l‘l¤OÔ4á(,ÓW© 1´
¸1¿9¹9ÄoÕ0VšQ¨ˆMÐWØ× Ñ  Ô&ô ˜Ó'Ð'ð ˆMÜ˜Ó'Ð'ùò	 Xs   µBÁBc           	     óZ  — t        t        | «      «      }|s|j                  d«       |D �cg c]%  }t        j                  |j                  «       «      ‘Œ' }}t        t        t        t        |«      «      «      d«      D �cg c]  }t        t        t        |«      «      ‘Œ }}|D ]z  }||d      j                  ||d      «      }	|	€Œ#||d      j                  ||d      «      }
|
€ŒCt        |
t         «      rdn|
j                  }||kD  sŒgd||d      ||d      f|fc S  yc c}w c c}w )aC  Do Children Intersect

        Determine if any of the child objects within a Compound/assembly intersect by
        intersecting each of the shapes with each other and checking for
        a common volume.

        Args:
            include_parent (bool, optional): check parent for intersections. Defaults to False.
            tolerance (float, optional): maximum allowable volume difference. Defaults to 1e-5.

        Returns:
            tuple[bool, tuple[Shape, Shape], float]:
                do the object intersect, intersecting objects, volume of intersection
        r   rr   r(   ro   T)F)NNro   )rÛ   r   Úpopr4   Úfrom_bounding_boxrs   r   ÚrangerØ   ÚtupleÚmapÚintÚ	intersectrD   rW   )rK   Úinclude_parentÚ	tolerancerJ   ÚchildÚchildren_bboxÚcombÚchild_index_pairsÚchild_index_pairÚbbox_intersectionÚobj_intersectionÚcommon_volumes               rO   Údo_children_intersectzCompound.do_children_intersect,  sw  € ô" !%¤\°$Ó%7Ó 8ˆÙØ�L‰L˜ŒOñ HPó
ÙGO¸eŒE×#Ñ# E×$6Ñ$6Ó$8Õ9Àxð 	ð 
ô
 %¤T¬%´°H³Ó*>Ó%?ÀÔCó
áC�ô ”#”c˜4“.Õ!ØCð 	ð 
ó !2Ðð !.Ð.>¸qÑ.AÑ B× LÑ LØÐ.¨qÑ1Ñ2ó!Ðð !Ñ,Ø#+Ð,<¸QÑ,?Ñ#@×#JÑ#JØÐ-¨aÑ0Ñ1ó$Ð ð $Ñ/ô &Ð&6¼Ô=ñ à-×4Ñ4ð "ð
 % yÓ0à à (Ð)9¸!Ñ)<Ñ =Ø (Ð)9¸!Ñ)<Ñ =ðð *ð ò ð# !2ð2 *ùòA
ùò
s   ¬*D#Â D(c                óŠ  — t         t        j                  t        t        j                  t
        t        j                  t        t        j                  t        t        j                  t        t        j                  t        t        j                  i}g }| j                  «       D ]Ÿ  }t!        «       }|j#                  |j$                  «       |j'                  «       sŒ9|j)                  «       }|j+                  «       ||   k(  r |j-                   |t/        |«      «      «       |j1                  «        |j'                  «       rŒgŒ¡ |S )a  get_type

        Extract the objects of the given type from a Compound. Note that this
        isn't the same as Faces() etc. which will extract Faces from Solids.

        Args:
            obj_type (Union[Vertex, Edge, Face, Shell, Solid, Wire]): Object types to extract

        Returns:
            list[Union[Vertex, Edge, Face, Shell, Solid, Wire]]: Extracted objects
        )r;   r   r_   r)   r`   r5   rb   r6   rc   r4   rd   r*   ra   r=   re   r  r   Ú
InitializerE   rè   rë   Ú	ShapeTyper  r0   rì   )rK   Úobj_typeÚtype_mapÚresultsÚcomprí   r  s          rO   r\   zCompound.get_typec  sê   € ô0 Ô$×2Ñ2ÜÔ"×.Ñ.ÜÔ"×.Ñ.ÜÔ#×0Ñ0ÜÔ#×0Ñ0ÜÔ"×.Ñ.ÜÔ&×6Ñ6ð
ˆð ˆØ—N‘NÖ$ˆDÜ&Ó(ˆHØ×Ñ §¡Ô-Ø—-‘-•/Ø Ÿ™Ó(�Ø—?‘?Ó$¨°Ñ(:Ò:Ø—N‘N¡8¬H°U«OÓ#<Ô=Ø—‘”ð	 —-‘-–/ð %ð ˆrS   c                ó&  — t        | «      dk(  r‚t        t        | «      «      }| j                  |ddg«       t	        |t
        «      rD|j                  |«      }|s t        | «      |j                  «      }| j                  |ddg«       |S |r|S | S | S )a  Strip unnecessary Compound wrappers

        Args:
            fully (bool, optional): return base shape without any Compound
                wrappers (otherwise one Compound is left). Defaults to True.

        Returns:
            Union[Self, Shape]: base shape
        r(   rE   rÐ   )	rØ   ÚnextÚiterr×   rD   r=   ÚunwrapÚtyperE   )rK   ÚfullyÚsingle_elementÚ	unwrappeds       rO   r2  zCompound.unwrap�  s˜   € ô ˆt‹9˜Š>Ü!¤$ t£*Ó-ˆNØ×#Ñ# N°YÐ@VÐ4WÔXô ˜.¬(Ô3à*×1Ñ1°%Ó8�	ÙØ *¤ T£
¨9×+<Ñ+<Ó =�IØ×'Ñ'¨	°IÐ?UÐ3VÔWØ Ð á%*�>Ð4°Ð4ð ˆrS   c                óÈ   — t        j                  d| j                  |j                  «       t        |j                  D �cg c]  }|j
                  ‘Œ c}«      |_        yc c}w )z(Method call after attaching to `parent`.zUpdated parent of %s to %sN)r&   Údebugr@   r8   rJ   rE   ©rK   rB   r  s      rO   Ú_post_attachzCompound._post_attach«  sD   € ä�‰Ð1°4·:±:¸v¿|¹|ÔLÜ:Ø &§¢Ó0¡˜1ˆQ�Y‹Y Ñ0ó
ˆ�ùÚ0s   ¿Ac                ó  — |r}dj                  |D �cg c]  }|j                  ‘Œ c}«      }t        j                  d|| j                  «       t	        | j
                  D �cg c]  }|j                  ‘Œ c}«      | _        yyc c}w c c}w )z'Method call after attaching `children`.Ú,zAdding children %s to %sN©Újoinr@   r&   r8  r8   rJ   rE   ©rK   rJ   r  Úkidsr  s        rO   Ú_post_attach_childrenzCompound._post_attach_children²  sn   € áØ—8‘8±hÓ?±h¨U˜UŸ[›[°hÑ?Ó@ˆDÜ�L‰LÐ3°T¸4¿:¹:ÔFÜ<Ø$(§M¢MÓ2¡M˜q�—“ MÑ2óˆD�Lð ùÚ?ùò 3ó   ’BÁ Bc                óð   — t        j                  d| j                  |j                  «       |j                  r3t	        |j                  D �cg c]  }|j
                  ‘Œ c}«      |_        yd|_        yc c}w )z*Method call after detaching from `parent`.zRemoving parent of %s (%s)N)r&   r8  r@   rJ   r8   rE   r9  s      rO   Ú_post_detachzCompound._post_detach½  sV   € ä�‰Ð1°4·:±:¸v¿|¹|ÔLØ�?Š?Ü>Ø$*§O¢OÓ4¡O˜q�—“ OÑ4óˆF�Nð "ˆF�Nùò 5s   ÁA3c                ó  — |r}dj                  |D �cg c]  }|j                  ‘Œ c}«      }t        j                  d|| j                  «       t	        | j
                  D �cg c]  }|j                  ‘Œ c}«      | _        yyc c}w c c}w )z(Method call before detaching `children`.r<  zRemoving children %s from %sNr=  r?  s        rO   Ú_post_detach_childrenzCompound._post_detach_childrenÇ  sn   € áØ—8‘8±hÓ?±h¨U˜UŸ[›[°hÑ?Ó@ˆDÜ�L‰LÐ7¸¸t¿z¹zÔJÜ<Ø$(§M¢MÓ2¡M˜q�—“ MÑ2óˆD�Lð ùÚ?ùò 3rB  c                ó:   — t        |t        «      st        d«      ‚y)z)Method call before attaching to `parent`.z!`parent` must be of type CompoundN)rD   r=   rþ   )rK   rB   s     rO   Ú_pre_attachzCompound._pre_attachÒ  s   € ä˜&¤(Ô+ÜÐ@ÓAÐAð ,rS   c                ó>   — t        d„ |D «       «      st        d«      ‚y)z(Method call before attaching `children`.c              3  ó<   K  — | ]  }t        |t        «      –— Œ y ­wrV   )rD   r,   )rX   r  s     rO   rZ   z0Compound._pre_attach_children.<locals>.<genexpr>Ù  s   è ø€ ÐB¹°”:˜e¤U×+¹ùs   ‚z Each child must be of type ShapeN)Úallrþ   )rK   rJ   s     rO   Ú_pre_attach_childrenzCompound._pre_attach_children×  s"   € äÑB¹ÓBÔBÜÐ?Ó@Ð@ð CrS   c                óf   — t        «       }|j                  | j                  |j                  «       | S )z]Return self with the specified shape removed.

        Args:
          shape: Shape:
        )r   ÚRemoverE   )rK   rÔ   Úcomp_builders      rO   Ú_removezCompound._removeÜ  s)   € ô &Ó'ˆØ×Ñ˜DŸL™L¨%¯-©-Ô8ØˆrS   )NrC   NrC   NNN)r?   z(TopoDS_Compound | Iterable[Shape] | Noner@   ÚstrrA   zColor | NonerH   rQ  rI   zdict[str, Joint] | NonerB   úCompound | NonerJ   zSequence[Shape] | None)rŠ   z
int | None)rŠ   r�   )r?   r   rŠ   z6Vertex | Edge | Wire | Face | Shell | Solid | Compound)r?   r6   rl   r%   rŠ   r=   )r¢   rQ  r£   r�   r¤   rQ  r¥   z
str | Noner¦   r   r§   z"Align | tuple[Align, Align] | Noner„   r�   r…   zEdge | Wire | NonerŠ   r=   )rÄ   r�   rŠ   r=   )rÝ   zNone | Shape | Iterable[Shape]rŠ   r=   )rÝ   zShape | Iterable[Shape]rŠ   r=   )rŠ   Úbool)rŠ   zIterator[Shape]©rŠ   r  )r  r   rŠ   r$   )rŠ   rR  )rŠ   zShapeList[Compound])Fgñhãˆµøä>)r  rS  r  r�   rŠ   z5tuple[bool, tuple[Shape | None, Shape | None], float])r+  zOtype[Vertex] | type[Edge] | type[Face] | type[Shell] | type[Solid] | type[Wire]rŠ   z1list[Vertex | Edge | Face | Shell | Solid | Wire])T)r4  rS  rŠ   zSelf | Shape)rB   r=   )rJ   zIterable[Shape])rÔ   r,   rŠ   r=   )+rö   Ú
__module__Ú__qualname__Ú__doc__Úorderr+   Úproject_to_viewportrG   ÚpropertyrR   rW   Úclassmethodri   rm   r   r�   r   r¿   r°   rÎ   rã   rå   ré   rî   rò   rø   rú   r   rÿ   r  r  r  r'  r\   r2  r:  rA  rD  rF  rH  rL  rP  Ú__classcell__)rN   s   @rO   r=   r=   z   s8  ø„ ñJð €Eà!×5Ñ5Ðð
 9=ØØ"ØØ*.Ø"&Ø+/ð%=à5ð%=ð ð%=ð ð	%=ð
 ð%=ð (ð%=ð  ð%=ð )õ%=ðR ò(ó ð(ð òUó ðUð ð:Øð:à	?ò:ó ð:ð( ò
ó ð
ð& ð
 Ø $Ø )× 1Ñ 1Ø5:·\±\À5Ç<Á<Ð4PØ"%Ø(,ðoàðoð ðoð ð	oð
 ðoð ðoð 2ðoð  ðoð &ðoð 
òoó ðoðb ò0ó ð0óh.ó`ó4ó
óò	óð ,4¯=©=ô ó:	5ó
(ð @Dð5*Ø"ð5*Ø7<ð5*à	>ó5*ðn*ðð*ð 
;ó*ôXó8
óó"òóBò
A÷
rS   r=   c                  óZ   — e Zd ZdZej
                  Zedd„«       Zd	d„Zd	d„Z	d
d„Z
dd„Zy)rÂ   z,A Compound containing 1D objects - aka Edgesc                 ó   — y)Nr(   rÖ   rQ   s    rO   rR   z
Curve._dimí  ó   € àrS   c                óR   — t        | j                  «       «      j                  |«      S )z7Position on curve operator @ - only works if continuous)r*   rÁ   ry   ©rK   Úpositions     rO   Ú
__matmul__zCurve.__matmul__ó  ó   € ä�D—J‘J“LÓ!×-Ñ-¨hÓ7Ð7rS   c                óR   — t        | j                  «       «      j                  |«      S )z5Tangent on wire operator % - only works if continuous)r*   rÁ   rw   ra  s     rO   Ú__mod__zCurve.__mod__÷  s   € ä�D—J‘J“LÓ!×,Ñ,¨XÓ6Ð6rS   c                óR   — t        | j                  «       «      j                  |«      S )z6Location on wire operator ^ - only works if continuous)r*   rÁ   Úlocation_atra  s     rO   Ú__xor__zCurve.__xor__û  rd  rS   c                óH   — t        j                  | j                  «       «      S )z&A list of wires created from the edges)r*   ÚcombinerÁ   rQ   s    rO   ÚwireszCurve.wiresÿ  s   € ä�|‰|˜DŸJ™J›LÓ)Ð)rS   NrT  )rb  r�   rŠ   r$   )rb  r�   rŠ   r"   )rŠ   zShapeList[Wire])rö   rU  rV  rW  r+   rã   rZ  rR   rc  rf  ri  rl  rÖ   rS   rO   rÂ   rÂ   ç  s6   „ Ù6à�o‰o€Gð òó ðó
8ó7ó8ô*rS   rÂ   c                  ó"   — e Zd ZdZedd„«       Zy)ÚSketchz,A Compound containing 2D objects - aka Facesc                 ó   — y)Nrr   rÖ   rQ   s    rO   rR   zSketch._dim	  r_  rS   NrT  ©rö   rU  rV  rW  rZ  rR   rÖ   rS   rO   rn  rn    s   „ Ù6ð òó ñrS   rn  c                  ó"   — e Zd ZdZedd„«       Zy)ÚPartz-A Compound containing 3D objects - aka Solidsc                 ó   — y)Né   rÖ   rQ   s    rO   rR   z	Part._dim  r_  rS   NrT  rp  rÖ   rS   rO   rr  rr    s   „ Ù7ð òó ñrS   rr  )ZrW  Ú
__future__r   r»   rŽ   r‹   r  Ú	itertoolsr   Útypingr   r   Úcollections.abcr   r   r	   Ú
OCP.TopAbsÚTopAbsr^   ÚOCP.BRepAlgoAPIr
   ÚOCP.Fontr   r   r   r   r   Ú	OCP.GPropr   ÚOCP.NCollectionr   Ú
OCP.StdPrsr   rœ   r   ÚOCP.TCollectionr   r   Ú
OCP.TopoDSr   r   r   r   r   Úanytreer   Úbuild123d.build_enumsr   r   r   Úbuild123d.geometryr   r    r!   r"   r#   r$   r%   r&   Útyping_extensionsr'   Úone_dr)   r*   r+   Ú
shape_corer,   r-   r.   r/   r0   r1   r2   Úthree_dr3   r4   Útwo_dr5   r6   Úutilsr7   r8   r9   r:   Úzero_dr;   r=   rÂ   rn  rr  rÖ   rS   rO   Ú<module>rŒ     sØ   ðñ4õl #ã Û 	Û 
Û Ý "ß ç 8Ñ 8å Ý ,÷õ õ #Ý 2ß VÝ 3Ý '÷õ õ !ß <Ñ <÷	÷ 	ó 	õ #ç &Ñ &÷÷ ñ ÷ $ß ÷ó õ ôj	ˆw˜˜oÑ.ô j	ôZ*ˆHô *ô:ˆXô ôˆ8õ rS   