
    ,j                        d dl mZmZmZmZmZmZmZmZm	Z	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mZ d dlmZmZ ddlmZmZmZmZmZm Z  ddl!m"Z"m#Z#m$Z$m%Z% d	d
l&m'Z'm(Z( d	dl)m*Z*m+Z+m,Z, d dl-m.Z.m/Z/  e.j0                    1                                D ]Z2e23                    e/j4                   d dl5m6Z7 d dl8m9Z: d dl;m<Z< d dl=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZI d dlJmKZKmLZLmMZMmNZN d dlJmOZO d dlPmQZQ d dlPmRZR d dlSmTZTmUZUmVZV d dlWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZe d dlfmgZg d dlhmiZimjZj d dlkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZs d dltmuZu d dlvmwZw d dlxmyZymzZz d dl{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZmZmZ d dlmZmZ d dlmZ d dlmZmZ d d lmZmZmZmZmZ d d!lmZ d d"lmZmZmZmZmZmZ d d#lmZmZmZmZmZmZmZ d d$lmZ d d%lmZ d d&lmZmZ d d'lmZmZmZmZ d d(lmZmZmZ d d)lmZmZmZmZ d d*lmZmZmZ d d+lmZmZ d d,lmZ d d-lmZ d d.lmZ d d/lmZmZmZ d d0lmZ d d1lmZ d d2lmZmZmZmZmZ d d3lmZmZ d d4lmZmZmZmZmZmZ d d5lmZ d d6lmZ d d7lmZmZ d d8lmZ d d9lmZ d d:l8mZmZmZmZmZmZmZmZ d d;lmZ d d<lmZmZ d d=lmZmZmZmZmZmZ d d>l mZ d d?l5mZmZ d d@lmZmZmZmZ d dAlm	Z	 d dBl
mZmZmZ d dClmZmZmZ d dDlmZ d dElmZ d dFlmZmZ d dGlmZ d dHlmZmZ d dIlmZ d dJl m!Z! d dKl"m#Z# d dLl$m%Z% d dMl&m'Z'm(Z( d dNl)m*Z*m+Z+ d dOl,m-Z- d dPl.m/Z/ d dQl0m1Z1 d dRl2m3Z3 d dSl4m5Z5 d dTl6m7Z7m8Z8 d dUl9m:Z: d dVl;m<Z< d dWl=m>Z>m?Z?m@Z@mAZAmBZB d dlCZCd	dXl)mDZD eeEeFf         ZGedY         ZHdZZIe7jJ        d[e7jK        d\e7jL        d]e7jM        d^e7jN        d_e7jO        d`e7jP        dae7jQ        dbiZRe7jJ        de7jK        ejjS        e7jL        ejjS        e7jM        ejjT        e7jN        ejjT        e7jO        ejjU        e7jQ        ejjU        iZVdc eRW                                D             ZXe7jJ        e|jY        e7jK        e|jZ        e7jL        e|j[        e7jM        e|j\        e7jN        e|j]        e7jO        e|j^        e7jP        e|j_        e7jQ        e|j`        iZae7jJ        d[e7jK        eTe7jL        d]e7jM        eVe7jN        d_e7jO        d`e7jO        dae7jQ        dbiZbe7jK        e7jL        e7jM        e7jN        e7jO        ddZc ededfg          Zddhe}diefdjZedhe}die}fdkZfdhe}die}fdlZg G dm dfeh          Zi G dn doe          Zj G dp d[ei          Zkedq         Zledr         Zm G ds dteje          Zn edueng          Zo G dv dweh          Zp G dx d\eiep          Zq G dy d]eiep          Zr G dz d^ei          Zs G d{ d_ei          Zt ed|ejg          Zu G d} d~eh          Zv G d d`eiev          Zw G d daeiev          Zx G d dbeiev          Zydeer         dieeer                  fdZzdeer         diees         fdZ{d<deeq         deEdieer         fdZ|deidee$ee$df         f         dieei         fdZ}deidee$ee$df         f         dieifdZ~deidierfdZdeidieei         fdZdeidieei         fdZdeei         dieeeerekf                           fdZdeei         dieeer                  fdZdeei         dieeeesekf                           fdZdeei         dieees                  fdZdeidieifdZdee}ee}         f         dieifdZdee         dieKfdZdeeeGeGf                  dieNfdZdeeE         dieRfdZdeei         diefdZdedieei         fdZ eej        ej        ej        ej        ej        ej        ej                  ZdediefdZ ee1j        e1j        e1j                  Zdedie1fdZde8deEdeEdiefdZeeeief         eif         Ze+	 	 d=deideeeGeGf                  dedeEdieif
d            Ze+dZdddeideideideEdeFdieifd            Zd>deideidieifdZe+deidieifd            Ze+deei         dieifd            Ze+deidieifd            Ze+deei         dieifd            ZdZdddeideidieifdZde]dees         dee         fdZe+dZdddddeideEdedeeei         eiz           dee         dieifdÄ            Ze+	 	 	 	 d?deei         deEdedeeei         eiz           dee         dieifdĄ            Ze+dZddŜdƐeidǐeideEdee         dieif
dȄ            Ze+	 	 	 d@deei         deeei                  deEdee         dieif
dʄ            Ze*deidieifd˄            Ze*deei         eeiddf         z  dieifd̄            Ze*d͐eGdΐeGdϐeGdieifdЄ            Ze*defd҄            ZdededieifdӄZdedieifdԄZdedieifdՄZdeEd֐eEdieifdׄZe*dZdd؜dedeEdedieifdل            Ze*	 	 	 	 	 dAdee         deee                  deeeE                  deEdedܐedieifd݄            ZdސeEdieifd߄ZdeEdeEdieifdZe*deGdeGdieifd            Ze*dieifd            ZdeEdeEd֐eEdieifdZdeEd֐eEdieifdZdeEdieifdZdeEdeEdieifdZe+deGd֐eGdieifd            Ze+deGdeGd֐eGdieifd            Ze*	 	 	 	 	 dBdedeGdedee         ded         ded         ded         dieifd            Ze*	 	 	 	 	 	 dCdedeGdeidededee         ded         ded         ded         dieifd            Ze*	 	 	 	 	 dBdedeGdeideidedee         ded         ded         ded         dieifd             Z	 	 dDdƐeideideeef         deEdef
dZdedeHfdZdedeEfdZdeFfd	Zddd
dƐeideideideEdeHdieifdZdEdƐeideideEdeHdieif
dZ	 dEdƐeideideEdeHdieif
dZdFdƐeideideEdieifdZdddddeideEdeHdee         dieif
dZdeidieifdZdGdeideeeief                  dieifdZ	 dGdeideideeeief                  dieifdZdeideidސeEdieifdZdeideideEdieifdZdeidedieifdZÐdHdeidededeEfdZ	 dIdeideEdedeEdieif
d Ze*	 dJdeideid!eei         d"edieif
d#            Ze*	 dJdeei         deid!eei         d"edieif
d$            Ze*	 	 	 	 	 	 	 	 dKdeei         d"ed)ed*ed+         d,ed         d-eFd.ed/ed0eeEeEeEf         dieifd1            Ze*ddd%d&d'ddd(d2deid"ed)ed*ed+         d,ed         d-eFd.ed/ed0eeEeEeEf         dieifd3            Z	 	 	 	 dLdeideid*ed+         d-eFd6eFdeEfd7Z	 	 dMdeid8eeeeei         e	f                           deeE         diefd9ZdƐeideidiefd:ZdƐeideidieeef         fd;ZdS (N      )OptionalTupleUnionIterableListSequenceIteratorDictAnyoverloadTypeVarcastLiteralProtocol	Generator)Self)BytesIO)vtkPolyData)vtkTriangleFiltervtkPolyDataNormals   )Vector
VectorLikeBoundBoxPlaneLocationMatrix)geom_LUT_FACEgeom_LUT_EDGEShapesGeoms   )SelectorStringSyntaxSelector)multimethodmultidispatchmypyclassmethod)MessageMessage_GravityN)	Precision)gp_Vecgp_Pntgp_Ax1gp_Ax2gp_Ax3gp_Dirgp_Circgp_Trsfgp_Plngp_Pnt2dgp_Dir2dgp_Elips)TColgp_HArray1OfPntTColgp_HArray2OfPntTColgp_Array1OfPntTColgp_HArray1OfPnt2d)TColgp_Array1OfVec)TColStd_HArray1OfBoolean)TColStd_HArray1OfReal)BRepAdaptor_CurveBRepAdaptor_CompCurveBRepAdaptor_Surface)BRepBuilderAPI_MakeVertexBRepBuilderAPI_MakeEdgeBRepBuilderAPI_MakeFaceBRepBuilderAPI_MakePolygonBRepBuilderAPI_MakeWireBRepBuilderAPI_SewingBRepBuilderAPI_CopyBRepBuilderAPI_GTransformBRepBuilderAPI_TransformBRepBuilderAPI_TransformedBRepBuilderAPI_RightCornerBRepBuilderAPI_RoundCornerBRepBuilderAPI_MakeSolidBRepBuilderAPI_NurbsConvert)GProp_GProps)BRepGProp_Face	BRepGProp)BRepPrimAPI_MakeBoxBRepPrimAPI_MakeConeBRepPrimAPI_MakeCylinderBRepPrimAPI_MakeTorusBRepPrimAPI_MakeWedgeBRepPrimAPI_MakePrismBRepPrimAPI_MakeRevolBRepPrimAPI_MakeSphere)BRepIntCurveSurface_Inter)TopExp)	BRep_ToolBRep_Builder)TopoDSTopoDS_ShapeTopoDS_BuilderTopoDS_CompoundTopoDS_IteratorTopoDS_WireTopoDS_FaceTopoDS_EdgeTopoDS_VertexTopoDS_SolidTopoDS_ShellTopoDS_CompSolid)GC_MakeArcOfCircleGC_MakeArcOfEllipse)GCE2d_MakeSegment)gce_MakeLingce_MakeDir)GeomAPI_InterpolateGeomAPI_ProjectPointOnSurfGeomAPI_ProjectPointOnCurveGeomAPI_PointsToBSplineGeomAPI_PointsToBSplineSurface)BRepFill)BRepAlgoAPI_CommonBRepAlgoAPI_FuseBRepAlgoAPI_CutBRepAlgoAPI_BooleanOperationBRepAlgoAPI_SplitterBRepAlgoAPI_Check)Geom_BezierCurveGeom_ConicalSurfaceGeom_CylindricalSurfaceGeom_Surface
Geom_PlaneGeom_BSplineCurve
Geom_Curve)Geom2d_Line)Geom2dAPI_Interpolate)BRepLibBRepLib_FindSurface)BRepOffsetAPI_ThruSectionsBRepOffsetAPI_MakePipeShellBRepOffsetAPI_MakeThickSolidBRepOffsetAPI_MakeOffset)BRepFilletAPI_MakeChamferBRepFilletAPI_MakeFilletBRepFilletAPI_MakeFillet2d))TopTools_IndexedDataMapOfShapeListOfShapeTopTools_ListOfShapeTopTools_MapOfShapeTopTools_IndexedMapOfShape)ShapeFix_ShapeShapeFix_SolidShapeFix_Face)STEPControl_WriterSTEPControl_AsIs)BRepMesh_IncrementalMesh)StlAPI_Writer)ShapeUpgrade_UnifySameDomain)	BRepToolsBRepTools_WireExplorerBRepTools_ReShape)LocOpe_DPrism)BRepCheck_Analyzer)Font_FontMgrFont_FA_RegularFont_FA_ItalicFont_FA_BoldFont_SystemFont)StdPrs_BRepFontStdPrs_BRepTextBuilder)Graphic3d_HTA_LEFTGraphic3d_HTA_CENTERGraphic3d_HTA_RIGHTGraphic3d_VTA_BOTTOMGraphic3d_VTA_CENTERGraphic3d_VTA_TOP)NCollection_Utf8String)BRepFeat_MakeDPrism)BRepClass3d_SolidClassifierBRepClass3d)TCollection_AsciiString)TopLoc_Location)GeomAbs_Shape
GeomAbs_C0
GeomAbs_G2
GeomAbs_C2GeomAbs_IntersectionGeomAbs_JoinTypeGeomAbs_IsoTypeGeomAbs_CurveType)BRepOffsetAPI_MakeFilling)BRepOffset_MakeOffsetBRepOffset_Mode)BOPAlgo_GlueEnumBOPAlgo_BuilderBOPAlgo_BOPBOPAlgo_FUSEBOPAlgo_CUTBOPAlgo_COMMON)IFSelect_ReturnStatus)TopAbs_ShapeEnumTopAbs_Orientation)ShapeAnalysis_FreeBoundsShapeAnalysis_EdgeShapeAnalysis_WireShapeAnalysis_Surface)TopTools_HSequenceOfShape)GCPnts_AbscissaPointGCPnts_QuasiUniformAbscissaGCPnts_QuasiUniformDeflection)GeomFill_FrenetGeomFill_CorrectedFrenetGeomFill_TrihedronLaw)BRepProj_Projection)BRepExtrema_DistShapeShape)IVtkOCC_ShapeIVtkOCC_ShapeMesher)IVtkVTK_ShapeData)Standard_NoSuchObjectStandard_Failure)Prs3d_IsoAspect)Quantity_Color)Aspect_TOL_SOLID)Interface_Static)ShapeCustom!ShapeCustom_RestrictionParameters)BRepAlgoBRepAlgo_NormalProjection)ChFi2d_FilletAPI)GeomConvert_ApproxCurve)Approx_ParametrizationType)LProp3d_CLProps)BinTools)Adaptor3d_IsoCurveAdaptor3d_Curve)GeomAdaptor_Surface)OSD_ThreadPool)pisqrtinfradianscos)	deprecate)partialfullNư>VertexEdgeWireFaceShellSolid	CompSolidCompoundc                     i | ]\  }}||	S  r   ).0kvs      R/DATA/AppData/hermes/venv/lib/python3.11/site-packages/cadquery/occ_impl/shapes.py
<dictcomp>r   e  s    888daQ888    )r   r   r   r   r   TShape)boundobjreturnc                 p    |                                  rt          d          |                                 S )NzNull TopoDS_Shape object)IsNull
ValueError	ShapeTyper  s    r   	shapetyper    s/    
zz|| 53444==??r   c                 P    t           t          |                    } ||           }|S )z@
    Downcasts a TopoDS object to suitable specialized type
    )downcast_LUTr  )r  
f_downcastrvs      r   downcastr    s&    
 #9S>>2J	CBIr   c                     t          |           }|                                 t          |                                          S )z:
    Fix a TopoDS object to suitable specialized type
    )r   Performr  r  )r  sfs     r   fixr    s4    
 
		BJJLLLBHHJJr   c                      e Zd ZU dZeed<   eed<   defdZdedefdZ	dedefd	Z
eddededd fd            Z	 	 	 	 	 ddededededededefdZdedefdZdeeef         defdZedeeef         dd fd            Zdeeef         defdZedeeef         dd fd            ZdefdZdefdZdefdZdd defd Zdd defd!Zdefd"Z	 dde e         de!fd$Z"	 	 dd'ee#d(         e$f         d)e$dd fd*Z%e&d+d de'fd,            Z(e&dd de)e)e                  fd-            Z*de'fd.Z+dde e         de'fd/Z,e&d0e-d          de'fd1            Z.e&dd de/fd2            Z0e&ddd d3e e         defd4            Z1e&dd de'fd5            Z2e&d0e)d          de'fd6            Z3defd7Z4de5fd8Z6d9e5de-e         fd:Z7d;e5d<e5de8d e)d          f         fd=Z9de)d>         fd?Z:de)d@         fdAZ;de)dB         fdCZ<de)dD         fdEZ=de)dF         fdGZ>de)dH         fdIZ?de)dJ         fdKZ@de)dL         fdMZAdNe eeBef                  dOe-d          dd fdPZCddNe eeBef                  dd fdQZDddNe eeBef                  dd fdRZEddNe eeBef                  dd fdSZFddNe eeBef                  dd fdTZGddNe eeBef                  dd fdUZHddNe eeBef                  dd fdVZIdefdWZJdd3e e         defdXZKdedYeLdefdZZMded[e$d\e$d]edef
d^ZNded_e$defd`ZOdaedd fdbZPddedcedefddZQdeeRdd fdfZSdeeRdd fdgZTdeUfdhZVdedieUdefdjZWdedieUdefdkZXeYdedieUdefdl            ZZeY	 	 	 	 	 	 ddedne[doe[dpe[dqe[dre[dse[defdt            ZZeYdedie$defdu            ZZeYdedieUdefdv            Z\eYdedweUdxeUdyeUdd f
dz            Z\eYdedye]eU         dd fd{            Z\eY	 	 	 	 	 	 ddedne[doe[dpe[dqe[dre[dse[defd|            Z\eYdedie$defd}            Z\eYdedwe$dxe$dye$dd f
d~            Z\eYdedie]e$         dd fd            Z\defdZ^defdZ_	 dde-d          de-d          dee`eaf         dedd f
dZbd#ddd d3e e         dd fdZcd
d#ddd ded3e e         dd fdZdd#ddd d3e e         dd fdZe	 	 dde$de$d3ede e#d                  fdZfddZgdd defdZhdd deie         fdZjddedefdZk	 ddededele)e'         e)eleeef                  f         fdZm	 ddededededef
dZndedefdZo	 	 	 dde e         de e         dedepfdZqd Zrdeid          fdZsd+d de5ddBfdZtdd+d de5deddBfdZuddZvddZwddZxddZy	 	 	 ddedededede e8ee/f                  f
dZzdeleef         fdZ{deleef         fdZ|dd dd de}fdZ~dd de}fdZd#S )r  z?
    Represents a shape in the system. Wraps TopoDS_Shape.
    wrappedforConstructionr  c                 J    t          |          | _        d| _        d| _        d S )NF )r  r  r  label)selfr  s     r   __init__zShape.__init__  s"    }}$


r   r  r  c                     t          | j        ddd          }|                    d           |                                 |                     |                                          S )z%Experimental clean using ShapeUpgradeTF)r   r  AllowInternalEdgesBuild	__class__r  )r  upgraders     r   cleanzShape.clean  sY     0dD$OO##E***~~hnn..///r   c                     |                                  s)t          | j                  }|                     |          S | S )zTry to fix shape if not valid)isValidr  r  r   )r  fixeds     r   r  z	Shape.fix  s8    ||~~ 	)%%E>>%(((r   Fc                    d}t           j        t          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 objectN)taTopAbs_VERTEXr   TopAbs_EDGEr   TopAbs_WIREr   TopAbs_FACEr   TopAbs_SHELLr   TopAbs_SOLIDr   TopAbs_COMPSOLIDr   TopAbs_COMPOUNDr   r  r  r  )clsr  r  trconstructor_LUTts         r   r   z
Shape.cast  s      fNDNDNDOUOU	
 cNN_Q..,	r   MbP?皙?TfileName	toleranceangularToleranceasciirelativeparallelc                     t          | j        ||||           t                      }||_        |                    | j        |          S )aX  
        Exports a shape to a specified STL file.

        :param fileName: The path and file name to write the STL output to.
        :param tolerance: A linear deflection setting which limits the distance between a curve and its tessellation.
            Setting this value too low will result in large meshes that can consume computing resources.
            Setting the value too high can result in meshes with a level of detail that is too low.
            Default is 1e-3, which is a good starting point for a range of cases.
        :param angularTolerance: Angular deflection setting which limits the angle between subsequent segments in a polyline. Default is 0.1.
        :param ascii: Export the file as ASCII (True) or binary (False) STL format.  Default is binary.
        :param relative: If True, tolerance will be scaled by the size of the edge being meshed. Default is True.
            Setting this value to True may cause large features to become faceted, or small features dense.
        :param parallel: If True, OCCT will use parallel processing to mesh the shape. Default is True.
        )r   r  r   	ASCIIModeWrite)r  r6  r7  r8  r9  r:  r;  writers           r   	exportStlzShape.exportStl  sM    0 	!L)X/?	
 	
 	
  ||DL(333r   c                    d}d|v r
|d         sd}d|v r|d         nd}t                      }t          j        d|           t          j        d|           |                    | j        t
                     |                    |          S )au  
        Export this shape to a STEP file.

        kwargs is used to provide optional keyword arguments to configure the exporter.

        :param fileName: Path and filename for writing.
        :param write_pcurves: Enable or disable writing parametric curves to the STEP file. Default True.

            If False, writes STEP file without pcurves. This decreases the size of the resulting STEP file.
        :type write_pcurves: bool
        :param precision_mode: Controls the uncertainty value for STEP entities. Specify -1, 0, or 1. Default 0.
            See OCCT documentation.
        :type precision_mode: int
        r   write_pcurvesr   precision_modezwrite.surfacecurve.modezwrite.precision.mode)r   r   	SetIVal_sTransferr  r   r>  )r  r6  kwargspcurvesrC  r?  s         r   
exportStepzShape.exportStep  s    " f$$VO-D$G5E5O5O 011UV#%%"#<gFFF"#9>JJJ&6777||H%%%r   fc                 B    t          j        | j        |          }|dn|S )z2
        Export this shape to a BREP file
        NT)r   Write_sr  r  rI  r  s      r   
exportBrepzShape.exportBrep  s&    
 t|Q//zttr)r   c                     t                      }t                      }t          j        |||           |                                rt          d|           |                     |          S )z/
        Import shape from a BREP file
        zCould not import )r_   r]   r   Read_sr  r  r   )r0  rI  sbuilders       r   
importBrepzShape.importBrep'  sb    
 NN..Aw'''88:: 	6444555xx{{r   c                 B    t          j        | j        |          }|dn|S )z:
        Export this shape to a binary BREP file.
        NT)r   rK  r  rL  s      r   	exportBinzShape.exportBin6  s&    
 dlA..zttr)r   c                 r    t                      }t          j        ||           |                     |          S )z7
        Import shape from a binary BREP file.
        )r_   r   rO  r   )r0  rI  rP  s      r   	importBinzShape.importBin?  s/    
 NN1xx{{r   c                 b   t           t          | j                           }t          |t                    r|}nd|t
          u r.t           || j                                                           }n-t           || j                                                           }t          t          |          S )aR  
        Gets the underlying geometry type.

        Implementations can return any values desired, but the values the user
        uses in type filters should correspond to these.

        As an example, if a user does::

            CQ(object).faces("%mytype")

        The expectation is that the geomType attribute will return 'mytype'

        The return values depend on the type of the shape:

        | Vertex:  always 'Vertex'
        | Edge:   LINE, CIRCLE, ELLIPSE, HYPERBOLA, PARABOLA, BEZIER,
        |         BSPLINE, OFFSET, OTHER
        | Face:   PLANE, CYLINDER, CONE, SPHERE, TORUS, BEZIER, BSPLINE,
        |         REVOLUTION, EXTRUSION, OFFSET, OTHER
        | Solid:  'Solid'
        | Shell:  'Shell'
        | Compound: 'Compound'
        | Wire:   'Wire'

        :returns: A string according to the geometry type
        )geom_LUTr  r  
isinstancestrr>   r   GetTyper   tcastr!   )r  r1  r  s      r   geomTypezShape.geomTypeJ  s    8 9T\223b# 	;BB$$$rr$,//7799:BBrr$,//7799:BUBr   c                 *    t          | j                  S )z
        Returns a hashed value denoting this shape. It is computed from the
        TShape and the Location. The Orientation is not used.
        )hashr  r  s    r   hashCodezShape.hashCodeq  s    
 DL!!!r   c                 4    | j                                         S )z
        Returns true if this shape is null. In other words, it references no
        underlying shape with the potential to be given a location and an
        orientation.
        )r  r  r`  s    r   isNullzShape.isNullx  s     |""$$$r   otherc                 @    | j                             |j                   S )z
        Returns True if other and this shape are same, i.e. if they share the
        same TShape with the same Locations. Orientations may differ. Also see
        :py:meth:`isEqual`
        )r  IsSamer  rd  s     r   isSamezShape.isSame  s     |""5=111r   c                 @    | j                             |j                   S )z
        Returns True if two shapes are equal, i.e. if they share the same
        TShape with the same Locations and Orientations. Also see
        :py:meth:`isSame`.
        )r  IsEqualrg  s     r   isEqualzShape.isEqual  s     |##EM222r   c                 N    t          | j                                                  S )z
        Returns True if no defect is detected on the shape S or any of its
        subshapes. See the OCCT docs on BRepCheck_Analyzer::IsValid for a full
        description of what is checked.
        )r   r  IsValidr`  s    r   r$  zShape.isValid  s      "$,//77999r   Nc                 8    t          j        | j        |          S )z
        Create a bounding box for this Shape.

        :param tolerance: Tolerance value passed to :class:`BoundBox`
        :returns: A :class:`BoundBox` object for this Shape
        tol)r   _fromTopoDSr  r  r7  s     r   BoundingBoxzShape.BoundingBox  s     #DLi@@@@r   XYr   r   r   mirrorPlane)rt  YXXZZXYZZYbasePointVectorc                 v   t          |t                    rZ|dk    s|dk    rt          ddd          }n|dk    s|dk    rt          ddd          }nf|dk    s|dk    rt          ddd          }nHt          |t                    r
t          | }n)t          |t                    r|                                }t          |t                    rt	          |          }t                      }|                    t          t          |
                                 |                     |                     |          S )	aL  
        Applies a mirror transform to this Shape. Does not duplicate objects
        about the plane.

        :param mirrorPlane: The direction of the plane to mirror about - one of
            'XY', 'XZ' or 'YZ'
        :param basePointVector: The origin of the plane to mirror about
        :returns: The mirrored shape
        rt  rw  r   r   rx  ry  rz  r{  )rY  rZ  r0   tupler   toDirr2   	SetMirrorr.   r,   toTuple_apply_transform)r  rv  r|  mirrorPlaneNormalVectorr  s        r   mirrorzShape.mirror  s:     k3'' 	>d""kT&9&9*0Aq//''$$t(;(;*0Aq//''$$t(;(;*0Aq//'+u-- >*0+*>''K00 >*5*;*;*=*='ou-- 	6$_55OII	F6?#:#:#<#<=?VWWXXX$$Q'''r   shapec                     t                      }t          j        | j        |           t	          |                                          S N)rO   rQ   VolumeProperties_sr  r   CentreOfMass)r  
Propertiess     r   _center_of_masszShape._center_of_mass  s<     "^^
$U]J???j--//000r   c                     t                      }t          t          | j                           }|rA || j        |           |                                fdt          dd          D             S t          )z
        Calculates the matrix of inertia of an object.
        Since the part's density is unknown, this result is inertia/density with units of [1/length].
        :param obj: Compute the matrix of inertia of this object
        c                 L    g | ]fd t          dd          D              S )c                 <    g | ]}                     |          S r   Value)r   jimois     r   
<listcomp>z4Shape.matrixOfInertia.<locals>.<listcomp>.<listcomp>  s%    :::SYYq!__:::r   r      )range)r   r  r  s    @r   r  z)Shape.matrixOfInertia.<locals>.<listcomp>  s:    PPPq:::::eAqkk:::PPPr   r   r  )rO   shape_properties_LUTr  r  MatrixOfInertiar  NotImplementedError)r  r  calc_functionr  s      @r   matrixOfInertiazShape.matrixOfInertia  sx     "^^
,Ys{-C-CD 	QM#+z222,,..CPPPPE!QKKPPPP!!r   c                 6    t                               |           S )zI
        :returns: The point of the center of mass of this Shape
        )r  centerOfMassr`  s    r   CenterzShape.Center  s    
 !!$'''r   c                 8    |                      |          j        S )z
        :param tolerance: Tolerance passed to the :py:meth:`BoundingBox` method
        :returns: Center of the bounding box of this shape
        )r7  )rs  centerrr  s     r   CenterOfBoundBoxzShape.CenterOfBoundBox  s    
 )44;;r   objectsc                     t          d | D                       }d | D             }|d         }|dd         D ]}|                    |          }t          |                    d|z                      S )zy
        Calculates the center of mass of multiple objects.

        :param objects: A list of objects with mass
        c              3   J   K   | ]}t                               |          V  d S r  r  computeMassr   os     r   	<genexpr>z'Shape.CombinedCenter.<locals>.<genexpr>  s0      ??!**1--??????r   c                     g | ]G}t                               |                              t                               |                    HS r   )r  r  multiplyr  r  s     r   r  z(Shape.CombinedCenter.<locals>.<listcomp>  sO     
 
 
EFEq!!**5+<+<Q+?+?@@
 
 
r   r   r   N      ?)sumaddr   r  )r  
total_massweighted_centerssum_wcwcs        r   CombinedCenterzShape.CombinedCenter  s     ??w?????

 
JQ
 
 
 "!$"122& 	$ 	$BZZ^^FFfoocJ&677888r   c                 z   t          | j                  }|t          j        k    r| r}t	          t          |                     }|                                dk    r4t	          t          |                    }|                                dk    4t          |j                  }nt          j        }t          |         S )zf
        Helper to find the correct mass calculation function with special compound handling.
        r   )	r  r  r'  r/  nextiterr	  r-  r  )r  type_childs      r   _mass_calc_functionzShape._mass_calc_function  s     #+&& B&&&  (T#YY oo'':55 e--E oo'':55 "%-00  $E**r   rp  c                     t                      }t                              |           } || j        |g|r|fndR   |                                S )z
        Calculates the 'mass' of an object.

        :param obj: Compute the mass of this object
        :param tol: Numerical integration tolerance (optional).
        r   )rO   r  r  r  Mass)r  rp  r  r  s       r   r  zShape.computeMass  sW     "^^
11#66ck:H31F#BHHHH   r   c                     t                      }t                              |           } || j        |           t	          |                                          S )z~
        Calculates the center of 'mass' of an object.

        :param obj: Compute the center of mass of this object
        )rO   r  r  r  r   r  )r  r  r  s      r   r  zShape.centerOfMass-  sN     "^^
11#66ck:...j--//000r   c                 .   t          |           }g }| D ]3}|                    t          j        |j                  j                   4|d         }|dd         D ]}|                    |          }t          |                    d|z                      S )zy
        Calculates the center of a bounding box of multiple objects.

        :param objects: A list of objects
        r   r   Nr  )	lenappendr   rq  r  r  r  r   r  )r  r  r  r  r  r  s         r   CombinedCenterOfBoundBoxzShape.CombinedCenterOfBoundBox;  s     \\
 	L 	LA##H$8$C$C$JKKKK!!$"122& 	$ 	$BZZ^^FFfoocJ&677888r   c                 4    | j                                         S )z/
        :returns: The closedness flag
        )r  Closedr`  s    r   r  zShape.ClosedN  s     |""$$$r   c                 f    t          t          t          t          | j                                     S r  )r\  r    	shape_LUTr  r  r`  s    r   r	  zShape.ShapeTypeT  s!    VYy'>'>?@@@r   	topo_typec                     t                      }t          j        | j        t          |         |           t          t          t                   |          S r  )r   r[   MapShapes_sr  inverse_shape_LUTr\  r   r_   )r  r  	shape_sets      r   	_entitieszShape._entitiesW  s?    .00	4<):9)EyQQQXl+Y777r   
child_typeparent_typec                 t   t                      }t          j        | j        t          |         t          |         |           i }t          d|                                dz             D ]O}d |                    |          D             |t          	                    |
                    |                    <   P|S )Nr   c                 B    g | ]}t                               |          S r   r  r   r   els     r   r  z'Shape._entitiesFrom.<locals>.<listcomp>m  s/     / / /#%

2/ / /r   )r   r[   MapShapesAndAncestors_sr  r  r  ExtentFindFromIndexr  r   FindKey)r  r  r  resoutr  s         r   _entitiesFromzShape._entitiesFrom^  s     899&Lj)k*		
 	
 	
 )+q#**,,*++ 	 	A/ /),):):1)=)=/ / /C

3;;q>>**++ 
r   r   c                 @    d |                      d          D             S )z:
        :returns: All the vertices in this Shape
        c                 ,    g | ]}t          |          S r   )r   r   r  s     r   r  z"Shape.Vertices.<locals>.<listcomp>x  s    <<<aq		<<<r   r   r  r`  s    r   VerticeszShape.Verticess  s$    
 =<4>>(#;#;<<<<r   r   c                 @    d |                      d          D             S )z7
        :returns: All the edges in this Shape
        c                 x    g | ]7}t          j        t          j        |                    (t	          |          8S r   )r\   Degenerated_sr^   Edge_sr   r  s     r   r  zShape.Edges.<locals>.<listcomp>  sI     
 
 
*6=+;+;<<
GG
 
 
r   r   r  r`  s    r   EdgeszShape.Edgesz  s/    

 
^^F++
 
 
 	
r   r   c                 @    d |                      d          D             S )z;
        :returns: All the compounds in this Shape
        c                 ,    g | ]}t          |          S r   )r   r  s     r   r  z#Shape.Compounds.<locals>.<listcomp>  s    @@@@@@r   r   r  r`  s    r   	CompoundszShape.Compounds  s%    
 A@T^^J%?%?@@@@r   r   c                 @    d |                      d          D             S )z7
        :returns: All the wires in this Shape
        c                 ,    g | ]}t          |          S r   r   r  s     r   r  zShape.Wires.<locals>.<listcomp>      888AQ888r   r   r  r`  s    r   WireszShape.Wires  $    
 98!7!78888r   r   c                 @    d |                      d          D             S )z7
        :returns: All the faces in this Shape
        c                 ,    g | ]}t          |          S r   r   r  s     r   r  zShape.Faces.<locals>.<listcomp>  r  r   r   r  r`  s    r   FaceszShape.Faces  r  r   r   c                 @    d |                      d          D             S )z8
        :returns: All the shells in this Shape
        c                 ,    g | ]}t          |          S r   )r   r  s     r   r  z Shape.Shells.<locals>.<listcomp>      :::Qa:::r   r   r  r`  s    r   ShellszShape.Shells  $    
 ;:$.."9"9::::r   r   c                 @    d |                      d          D             S )z8
        :returns: All the solids in this Shape
        c                 ,    g | ]}t          |          S r   )r   r  s     r   r  z Shape.Solids.<locals>.<listcomp>  r  r   r   r  r`  s    r   SolidszShape.Solids  r  r   r   c                 @    d |                      d          D             S )z<
        :returns: All the compsolids in this Shape
        c                 ,    g | ]}t          |          S r   )r   r  s     r   r  z$Shape.CompSolids.<locals>.<listcomp>  s    BBB	!BBBr   r   r  r`  s    r   
CompSolidszShape.CompSolids  s%    
 CBdnn[&A&ABBBBr   selectorobjsc                 (   |rJt          |t                    rt          |          }n|}|                    t	          |                    }nt	          |          }t          |          dk    r	|d         }nt                              |          }|S )Nr   r   )rY  rZ  r$   filterlistr  r   makeCompound)r  r  r  selectorObjselectedr  s         r   _filterzShape._filter  s    
  	"(C(( '28<<&"))$t**55HHDzzHx==A!BB&&x00B	r   c           	          |                      |t          t          j        |                     d                              S )z"
        Select vertices.
        r   r  mapr  r   r  r  r  s     r   verticeszShape.vertices  s0    
 ||Hc%*dnnX6N6N&O&OPPPr   c           	          |                      |t          t          j        |                     d                              S )z
        Select edges.
        r   r  r  s     r   edgeszShape.edges  0    
 ||Hc%*dnnV6L6L&M&MNNNr   c           	          |                      |t          t          j        |                     d                              S )z
        Select wires.
        r   r  r  s     r   wireszShape.wires  r  r   c           	          |                      |t          t          j        |                     d                              S )z
        Select faces.
        r   r  r  s     r   faceszShape.faces  r  r   c           	          |                      |t          t          j        |                     d                              S )z 
        Select shells.
        r   r  r  s     r   shellszShape.shells  0    
 ||Hc%*dnnW6M6M&N&NOOOr   c           	          |                      |t          t          j        |                     d                              S )z 
        Select solids.
        r   r  r  s     r   solidszShape.solids  r  r   c                 z    t                      }t          j        | j        |           |                                S )zG
        :returns: The surface area of all faces in this Shape
        )rO   rQ   SurfaceProperties_sr  r  r  r  s     r   Areaz
Shape.Area  s2     "^^
%dlJ???   r   c                 8    t                               | |          S )z4
        :returns: The volume of this Shape
        r  )r  rp  s     r   VolumezShape.Volume  s    
   s+++r   Trc                 x    |                      t          | j        |d                                                    S NT)r   rI   r  r  )r  r  s     r   r  zShape._apply_transform  s/    ~~6t|RNNTTVVWWWr   startVector	endVectorangleDegreesc           	         t          |          t          k    rt          |          }t          |          t          k    rt          |          }t                      }|                    t          t          |                                          t          |          t          |          z
                                            t          |                     | 	                    |          S )aw  
        Rotates a shape around an axis.

        :param startVector: start point of rotation axis
        :type startVector: either a 3-tuple or a Vector
        :param endVector: end point of rotation axis
        :type endVector: either a 3-tuple or a Vector
        :param angleDegrees:  angle to rotate, in degrees
        :returns: a copy of the shape, rotated
        )
typer~  r   r2   SetRotationr-   toPntr  r   r  )r  r  r  r   r  s        r   rotatezShape.rotate  s     %% --K	??e##y))IYY
{##))++	""VK%8%88??AA  L!!	
 	
 	
 $$R(((r   vectorc                     t                      }|                    t          |          j                   |                     |          S )zA
        Translates this shape through a transformation.
        )r2   SetTranslationr   r  r  )r  r&  r  s      r   	translatezShape.translate   s>    
 II	/000$$Q'''r   factorc                     t                      }|                    t                      |           |                     |          S )z=
        Scales this shape through a transformation.
        )r2   SetScaler,   r  )r  r*  r  s      r   scalezShape.scale*  s9    
 II	

688V$$$$$Q'''r   meshc                 x    |                      t          | j        d|                                                    S )z
        Creates a new object that is a copy of this object.

        :param mesh: should I copy the triangulation too (default: False)
        :returns: a copy of the object
        T)r   rG   r  r  )r  r.  s     r   copyz
Shape.copy4  s1     ~~1$,dKKQQSSTTTr   tMatrixc                     t                               t          | j        |j                                                                                             }| j        |_        |S )a	  
        Transforms this Shape by tMatrix. Also see :py:meth:`transformGeometry`.

        :param tMatrix: The transformation matrix
        :returns: a copy of the object, transformed by the provided matrix,
            with all objects keeping their type
        )r  r   rI   r  Trsfr  r  r1  rs      r   transformShapezShape.transformShape>  sR     JJ$T\7?3G3G3I3IJJPPRR
 
 !0r   c                     t                               t          | j        |j        d                                                     }| j        |_        |S )ag  
        Transforms this shape by tMatrix.

        WARNING: transformGeometry will sometimes convert lines and circles to
        splines, but it also has the ability to handle skew and stretching
        transformations.

        If your transformation is only translation and rotation, it is safer to
        use :py:meth:`transformShape`, which doesn't change the underlying type
        of the geometry, but cannot handle skew transformations.

        :param tMatrix: The transformation matrix
        :returns: a copy of the object, but with geometry transformed instead
            of just rotated.
        T)r  r   rH   r  r  r4  s      r   transformGeometryzShape.transformGeometryN  sH      JJ%dlGOTJJPPRR
 
 !0r   c                 N    t          | j                                                   S )z-
        Return the current location
        )r   r  r`  s    r   locationzShape.locatione  s     
 --//000r   locc                 D    | j                             |j                    | S )z=
        Apply a location in absolute sense to self.
        )r  r   r  r;  s     r   locatezShape.locatel  s!    
 	ck***r   c                     |                      | j                            |j                            }| j        |_        |S )zG
        Apply a location in absolute sense to a copy of self.
        )r   r  Locatedr  r  r;  r5  s      r   locatedzShape.locatedu  s7    
 NN4<//<<== 0r   c                 D    | j                             |j                    | S )z\
        Apply a location in relative sense (i.e. update current location) to self.
        )r  Mover=  s     r   movez
Shape.move  s!     	#+&&&r   r   xyzrxryrzc           
      h    | j                             t          ||||||          j                    | S )zj
        Apply translation and rotation in relative sense (i.e. update current location) to self.
        r  rD  r   r  rF  rG  rH  rI  rJ  rK  s          r   rE  z
Shape.move  s4     	(1aBB77?@@@r   c                 ^    | j                             t          |          j                    | S )z^
        Apply a VectorLike in relative sense (i.e. update current location) to self.
        rM  r=  s     r   rE  z
Shape.move  s(     	(3--/000r   c                     |                      | j                            |j                            }| j        |_        |S )zf
        Apply a location in relative sense (i.e. update current location) to a copy of self.
        )r   r  Movedr  rA  s      r   movedzShape.moved  s7     NN4<--ck::;; 0r   loc1loc2locsc                 6    |                      ||f|z             S z+
        Apply multiple locations.
        )rR  r  rS  rT  rU  s       r   rR  zShape.moved  s     zz4,-...r   c                     g }|D ]4}|                     | j                            |j                             5t          |          S rW  )r  r  rQ  _compound_or_shape)r  rU  r  ls       r   rR  zShape.moved  sM      	5 	5AIIdl((334444!"%%%r   c           
      P    |                      t          ||||||                    S )zU
        Apply translation and rotation in relative sense to a copy of self.
        rR  r   rN  s          r   rR  zShape.moved  s(     zz(1aBB77888r   c                 F    |                      t          |                    S )zI
        Apply a VectorLike in relative sense to a copy of self.
        r]  r=  s     r   rR  zShape.moved  s     zz(3--(((r   c                     |                      t          |          t          |          ft          d |D                       z             S )Q
        Apply multiple VectorLikes in relative sense to a copy of self.
        c              3   4   K   | ]}t          |          V  d S r  r   )r   r;  s     r   r  zShape.moved.<locals>.<genexpr>  s(      4S4SsXc]]4S4S4S4S4S4Sr   )rR  r   r~  rX  s       r   rR  zShape.moved  sJ     zzd^^Xd^^,u4S4Sd4S4S4S/S/SS
 
 	
r   c                 Z    |                      t          d |D                                 S )r`  c              3   4   K   | ]}t          |          V  d S r  rb  )r   r[  s     r   r  zShape.moved.<locals>.<genexpr>  s(      99999999r   )rR  r~  r=  s     r   rR  zShape.moved  s-     zz%99S99999:::r   c                 *    |                                  S r  )ra  r`  s    r   __hash__zShape.__hash__      }}r   c                 Z    t          |t                    r|                     |          ndS NF)rY  r  rh  rg  s     r   __eq__zShape.__eq__  s(    %/u%=%=Ht{{5!!!5Hr   argstoolsopc                    t                      }|D ]}|                    |j                   t                      }|D ]}|                    |j                   |                    |           |                    |           |                    |           |                                 t                              |                                          S )z
        Generic boolean operation

        :param parallel: Sets the SetRunParallel flag, which enables parallel execution of boolean operations in OCC kernel
        )	r   Appendr  SetArgumentsSetToolsSetRunParallelr  r  r   )r  rk  rl  rm  r;  argr  tools           r   _bool_opzShape._bool_op  s     #$$ 	$ 	$CJJs{#####%% 	% 	%CKK$$$$

D
(###



zz"((**%%%r   ro  toCutc                |    t                      }|r|                    |           |                     | f||          S zl
        Remove the positional arguments from this Shape.

        :param tol: Fuzzy mode tolerance
        )rw   SetFuzzyValueru  r  rp  rv  cut_ops       r   cutz	Shape.cut  sC     !"" 	&  %%%}}dWeV444r   gluerp  toFuser~  c                    t                      }|r|                    t          j                   |r|                    |           |                     | f||          }|S )z
        Fuse the positional arguments with this Shape.

        :param glue: Sets the glue option for the algorithm, which allows
            increasing performance of the intersection of the input shapes
        :param tol: Fuzzy mode tolerance
        )rv   SetGluer   BOPAlgo_GlueShiftry  ru  )r  r~  rp  r  fuse_opr  s         r   fusez
Shape.fuse$  sf     #$$ 	@OO,>??? 	'!!#&&&]]D7FG44	r   toIntersectc                |    t                      }|r|                    |           |                     | f||          S zt
        Intersection of the positional arguments and this Shape.

        :param tol: Fuzzy mode tolerance
        )ru   ry  ru  r  rp  r  intersect_ops       r   	intersectzShape.intersect9  sC     *++ 	,&&s+++}}dWk<@@@r   -C6?pointaxis	direction)	AlongAxisOppositec                    t          |t                    rt          |                                 nt          | }t          |t                    s!t	          t          |          j                  nt	          |j                  }t          ||                                          }| j        }t                      }	|		                    |||           g }
|	
                                rq|	                                }t          ||          }|                    |          }|                                r|                                }nd}|dk    rH|E|                    ||          s/||k    r)|
                    |	                                |f           n|dk    rH|E|                    ||          r/||k    r)|
                    |	                                |f           nH|7|
                    |	                                t%          |          f           nt'          d          |	                                 |	
                                q|
                    d            d |
D             }d |D             S )	a   
        Computes the intersections between the provided line and the faces of this Shape

        :param point: Base point for defining a line
        :param axis: Axis on which the line rests
        :param tol: Intersection tolerance
        :param direction: Valid values: "AlongAxis", "Opposite";
            If specified, will ignore all faces that are not in the specified direction
            including the face where the point lies if it is the case
        :returns: A list of intersected faces sorted by distance from point
        Nr  r  zTInvalid direction specification.
Valid specification are 'AlongAxis' and 'Opposite'.c                     | d         S )Nr   r   )rF  s    r   <lambda>z.Shape.facesIntersectedByLine.<locals>.<lambda>  s
    ad r   )keyc                     g | ]
}|d          S r   r   r   faces     r   r  z0Shape.facesIntersectedByLine.<locals>.<listcomp>  s    000Ta000r   c                 ,    g | ]}t          |          S r   r  r  s     r   r  z0Shape.facesIntersectedByLine.<locals>.<listcomp>  s    ---tT

---r   )rY  r   r,   r  r0   r  rm   r  rZ   InitMorePntrn   SquareDistanceIsDone
IsOppositer  r   absr  Nextsort)r  r  r  rp  r  oc_pointoc_axisliner  intersectMaker
faces_distinterPt
interDirMkdistanceinterDirr  s                   r   facesIntersectedByLinezShape.facesIntersectedByLineG  s   ( )35&(A(AUFEMMOO$$vu~ 	
 dF++&F6$<<'(((%% 	 8W--3355244E4---
!!## %	"$((**G$Xw77J..w77H   ""   * 0 0 2 2K''($//== ) 3%%~':':'<'<h&GHHHj((( ++GS99 ) 3%%~':':'<'<h&GHHH"!!#((**CMM:    !k   !!!K !!## %	"N 	NN+++00Z000--u----r   	splittersc                 N    t                      }|                     | f||          S )zA
        Split this shape with the positional arguments.
        )ry   ru  )r  r  split_ops      r   splitzShape.split  s'    
 ())}}dWi:::r   c                     t          | j        |j                  }|                    d           |                                S )z5
        Minimal distance between two shapes
        T)r   r  SetMultiThreadr  )r  rd  	dist_calcs      r   r  zShape.distance  s;    
 /t|U]KK	  &&&   r   othersc              '     K   t                      }|                    d           |                    | j                   |D ]F}|                    |j                   |                                 |                                V  GdS )zD
        Minimal distances to between self and other shapes
        TN)r   r  LoadS1r  LoadS2r  r  )r  r  r  rP  s       r   	distanceszShape.distances  s      
 /00	  &&&&&& 	$ 	$AQY'''//######		$ 	$r   c                 l    t          j        | j        |          st          | j        |d|           dS dS )z8
        Generate triangulation if none exists.
        TN)r   Triangulation_sr  r   )r  r7  r8  s      r   r.  z
Shape.mesh  sE    
 (yAA 	V$T\9dDTUUUUU	V 	Vr   c           	      @  	
 |                      ||           g }g }d|                                 D ]}t                      }t          j        |j        |          		-|                                |j                                        t          j	        k    rdnd
|d 	fdt          d	                                dz             D             D             z  }|
fd	                                D             z  }	                                z  ||fS )Nr   TFc                     g | ]I}t          |                                |                                |                                          JS r   )r   XYZr   r   s     r   r  z$Shape.tessellate.<locals>.<listcomp>  sL        qssuuacceeQSSUU++  r   c              3   h   K   | ],}                     |                                        V  -d S r  )NodeTransformed)r   r  r3  polys     r   r  z#Shape.tessellate.<locals>.<genexpr>  sL        78DIIaLL,,T22     r   r   c                 T   g | ]}rP|                     d           z   d z
  |                     d          z   d z
  |                     d          z   d z
  fnO|                     d           z   d z
  |                     d          z   d z
  |                     d          z   d z
  fS )r      r"   r  )r   r3  offsetreverses     r   r  z$Shape.tessellate.<locals>.<listcomp>  s         
GGAJJ'!+GGAJJ'!+GGAJJ'!+  GGAJJ'!+GGAJJ'!+GGAJJ'!+  r   )r.  r  r   r\   r  r  TransformationOrientationr   TopAbs_REVERSEDr  NbNodes	Triangles)r  r7  r8  r  	trianglesrI  r;  r3  r  r  r  s          @@@@r   
tessellatezShape.tessellate  su    			)-...!#02	 %	% %	%A!##C,QY<<D|%%''D 9((**.@.PPP         <A!T\\^^VWEW<X<X     H       ))   I dllnn$FF""r   r  degreenurbsc                     t                      }t          j        | j        |||dt          j        t          j        d| |
  
        }|                     |          S )z
        Approximate shape with b-splines of the specified degree.

        :param degree: Maximum degree.
        :param tolerance: Approximation tolerance.
        :param nurbs: Use rational splines.
        r   T)r   r   BSplineRestriction_sr  gar   r   )r  r  r7  r  paramsresults         r   	toSplineszShape.toSplines  s[     3441LMMI
 
 ~~f%%%r   c                 |    t          | j        d          }|                     |                                          S )zA
        Return a NURBS representation of a given shape.
        T)Copy)rN   r  r   r  )r  bldrs     r   toNURBSzShape.toNURBS  s2    
 +4<dCCC~~djjll+++r   normalsc                    t          | j                  }t                      }t                      }|                                }|                    t          t                      t          dd                     |	                    t          t                      t          dd                     |r|
                    |           |r|                    |           |                    ||           |                                }t                      }	|	                    |           |	                                 |	                                }|rt%                      }
|
                    d           |
                    d           |
                    d           |
                    |           |
                                 |
                                }|S )z.
        Convert shape to vtkPolyData
        r   r   Th  )r   r  r   r   
AttributesSetUIsoAspectr   r   r   SetVIsoAspectSetDeviationCoefficientSetDeviationAngler  getVtkPolyDatar   SetInputDataUpdate	GetOutputr   SetComputePointNormalsSetComputeCellNormalsSetFeatureAngle)r  r7  r8  r  	vtk_shape
shape_datashape_mesherdrawerr  t_filtern_filters              r   toVtkPolyDatazShape.toVtkPolyData  s    "$,//	&((
*,,%%''_^-=-=?OQRTUVVWWW_^-=-=?OQRTUVVWWW 	6**9555 	7$$%56669j111&&(( %&&b!!!!!  	&)++H++D111**4000$$S)))!!"%%%OO##%%B	r   c                 H    ddl m}  ||                                           S )z3
        Jupyter 3D representation support
        r   )display)jupyter_toolsr  _repr_javascript_)r  r  s     r   r  zShape._repr_javascript_I  s0    
 	+*****wt}}..000r   c              #   
  K   t          | j                  }|                                rXt                              |                                          V  |                                 |                                VdS dS )z*
        Iterate over subshapes.

        N)rb   r  r  r  r   r  r  )r  its     r   __iter__zShape.__iter__R  sz       T\**ggii 	**RXXZZ(((((GGIII ggii 	 	 	 	 	r   kindc                    t                      }t          j        |j        t	          | j                  t
          |         |           t                              d |                    | j                  D                       S )zc
        Iterate over ancestors, i.e. shapes of same kind within shape that contain self.

        c              3   J   K   | ]}t                               |          V  d S r  r  r   rP  s     r   r  z"Shape.ancestors.<locals>.<genexpr>j  s=       %
 %
EJJqMM%
 %
 %
 %
 %
 %
r   )	r   r[   r  r  r  r  r   r   FindFromKey)r  r  r  	shape_maps       r   	ancestorszShape.ancestors^  s     >??	&M9T\224Ed4KY	
 	
 	
 $$ %
 %
#,#8#8#F#F%
 %
 %
 
 
 	
r   r   levelc                    t                      t          j        |j        t                   t          | j                             t                      fdt                               | g|                    S )zj
        Iterate over siblings, i.e. shapes within shape that share subshapes of kind with self.

        c                     t                      }| D ]}                    |j                   | D ]7}|                    fd|                              D                        8|dk    r|n ||dz
            S )Nc              3      K   | ]K}                     |          D ]3}                    |          t                              |          V  4Ld S r  r  Containsr  r   r   r  r  excluder  s      r   r  z4Shape.siblings.<locals>._siblings.<locals>.<genexpr>  z        '33E::  "++B//	JJrNN      r   r   setAddr  updater  shapesr   r  rP  	_siblingsr  r  r  s       r   r  z!Shape.siblings.<locals>._siblingsz  s    B ' 'AI&&&&  		     !"T!2!2       !222uqy)A)AAr   )	r   r[   r  r  r  r  r   r   r   )r  r  r  r   r  r  r  s     ` @@@r   siblingszShape.siblingsn  s     >??	&M,T2Idl4K4KY	
 	
 	
 &''	B 	B 	B 	B 	B 	B 	B 	B$ $$YYvu%=%=>>>r   c                 "    t          | |          S )z&
        Fuse self and other.
        )r  rg  s     r   __add__zShape.__add__  s    
 D%   r   c                 "    t          | |          S )z+
        Subtract other from self.
        )r|  rg  s     r   __sub__zShape.__sub__  s    
 4r   c                 "    t          | |          S )z+
        Intersect self and other.
        )r  rg  s     r   __mul__zShape.__mul__  s    
 u%%%r   c                 "    t          | |          S )z(
        Split self with other.
        )r  rg  s     r   __truediv__zShape.__truediv__  s    
 T5!!!r   fnameoptc                 2    ddl m}  || ||||           dS )z'
        Export Shape to file.
        r   )export)r7  r8  r  N)	exportersr  )r  r  r7  r8  r  r  s         r   r  zShape.export  sF     	&%%%%%%9?OUX	
 	
 	
 	
 	
 	
r   c                     t                      }t          j        | j        |           |                    d           || j        fS )Nr   )r   r   rK  r  seekr  )r  datas     r   __getstate__zShape.__getstate__  s=    yyt,,,		!d*++r   r   c                     t                      }t          j        ||d                    || _        |d         | _        d S )Nr   r   )r_   r   rO  r  r  )r  r   r  s      r   __setstate__zShape.__setstate__  s:    ..a)))#Awr   oldnewc                 d   g }|D ]B}t          |t                    r|                    |           -|                    |           Ct	                      }|                    |j        t          |          j                   |                    | j                  }| 	                    |          S )z:
        Replace old subshape with new subshapes.
        )
rY  r   extendr  r   Replacer  compoundApplyr   )r  r$  r%  rl  r  r  r  s          r   replacezShape.replace  s    
   	! 	!B"h'' !R    R     ""S[(5//"9:::ZZ%%~~b!!!r   subshapec                     t                      }|D ]}|                    |j                   |                    | j                  }|                     |          S )z#
        Remove subshapes.
        )r   Remover  r*  r   )r  r,  r  r  r  s        r   removezShape.remove  sZ    
 !"" 	$ 	$BKK
####ZZ%%~~b!!!r   F)r4  r5  FTTr  )rt  ru  )r   r   r   r   r   r   T)r  N)r  r  r  r  )r5  )r  r4  F)NNFr   )rd  r  r  r  )r5  r5  N)__name__
__module____qualname____doc__r_   __annotations__boolr  r  r"  r  classmethodr   rZ  floatr@  r   rH  r   r   rM  rR  rT  rV  r!   r]  intra  rc  rh  rk  r$  r   r   rs  r   r   r  staticmethodr   r  r   r  r  r  r   r  r   r  r  r  r  r  r    r	  r  r
   r  r  r  r  r  r  r  r  r  r#   r  r  r
  r  r  r  r  r  r  r2   r  r%  r)  r-  r0  r   r6  r8  r   r:  r>  rB  r%   rE  RealrR  r   rf  rj  rx   ry   ru  r|  r  r  r  r  r  r	   r  r.  r   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r!  r#  r   r+  r/  r   r   r   r  r    sI          L    0A 0! 0 0 0 0!       | d w    [6  "%4 44 4  	4
 4 4 4 
4 4 4 4B&3 &5J & & & &:*E#w,/ *D * * * * 5g. 7    [*5g. *4 * * * * %W- '    [% % %  %  %  % N"# " " " "% % % % %2G 2 2 2 2 23W 3 3 3 3 3: : : : : ,0	A 	A!%	A		A 	A 	A 	A &/#( #(67C
#(
 $#( 
#( #( #( #(J 1w 16 1 1 1 \1 "W "d5k): " " " \" ( ( ( ( (< <(5/ <V < < < < 9 1 9f 9 9 9 \9" + +S + + + \+8 ! ! !x !% ! ! ! \! 1' 1f 1 1 1 \1 9$w- 9F 9 9 9 \9$% % % % %A6 A A A A86 8h|.D 8 8 8 8 /5	gtG}$	%   *=$x. = = = =	
tF| 	
 	
 	
 	
A4
+ A A A A9tF| 9 9 9 99tF| 9 9 9 9;W ; ; ; ;;W ; ; ; ;CD- C C C C x}!56>Fw>O	   *Q Q%#*>!? Q7 Q Q Q QO OhuXs]';< O O O O OO OhuXs]';< O O O O OO OhuXs]';< O O O O OP Pxhm(<= P P P P PP Pxhm(<= P P P P P!e ! ! ! !, ,(5/ ,U , , , ,Xq Xg X! X X X X))()5?)OT)	
) ) ) )<( (: (! ( ( ( ((E (g ( ( ( (U U1 UD UQ U U U Uf       G    .1( 1 1 1 1Q X !    a h 1     1 8     [     	
    
   [" 1 : !    [ A H     [ /A /X /X /h /7 / / / [/ 
&A 
&Xh/ 
&G 
& 
& 
& [
&  9 999 9 	9
 9 9 9 
9 9 9 [9 )A )J )1 ) ) ) [) 	
	
!	
)3	
<F	
		
 	
 	
 [	
 ;A ;HZ0 ;W ; ; ; [;#    It I I I I & &w&  & .0DDE	&
 & 
& & & &: ;? 5 5 5' 5 57 5 5 5 5 .34  &*9A%	   * GK A A Ag AHUO Aw A A A A$ @DM. M.M. M. 	M.
 G$;<=M. M. M. M.^; ; ; ;!g !% ! ! ! !$ $Xe_ $ $ $ $ V Ve Vu V V V V ;>1# 1#1#271#	tF|T%S#"677	81# 1# 1# 1#h JO& &&&-2&BF&	
& & & &8,a ,Q , , , , &*,0	. .E?. #5/. 	.
 
. . . .`1 1 1
(7+ 
 
 
 

w 
f 
 
 
 
 
 ? ?g ?V ?C ?
 ? ? ? ?@! ! ! !       & & & &" " " " "%(,
 


 
  	

 d38n%
 
 
 
",eGTM2 , , , ,'w}!5 ' ' ' '"7 "' "d " " " "(" "D " " " " " "r   c                   ^    e Zd Zedefd            ZdeddfdZded         fdZde	fdZ
dS )	ShapeProtocolr  c                     d S r  r   r`  s    r   r  zShapeProtocol.wrapped  s    r   r  Nc                     d S r  r   )r  r  s     r   r  zShapeProtocol.__init__      r   r   c                     d S r  r   r`  s    r   r  zShapeProtocol.Faces  rB  r   c                     d S r  r   r`  s    r   r]  zShapeProtocol.geomType  rB  r   )r3  r4  r5  propertyr_   r  r  r   r  r!   r]  r   r   r   r?  r?    s            X     tF|    %      r   r?  c            	            e Zd ZU dZeed<   ddedef fdZde	e
e
e
f         fdZdefd	Zed
e
de
de
dd fd            Z xZS )r   z!
    A Single Point in Space
    r  Fr  r  c                     t          t          |                               |           || _        |                                 \  | _        | _        | _        dS )z!
        Create a vertex
        N)superr   r  r  r  r  r  r  )r  r  r  r   s      r   r  zVertex.__init__  sI     	fd$$S))).!%r   r  c                     t          j        | j                  }|                                |                                |                                fS r  )r\   Pnt_sr  r  r  r  )r  
geom_points     r   r  zVertex.toTuple  s8    _T\22


??r   c                 D    t          |                                           S )z3
        The center of a vertex is itself!
        )r   r  r`  s    r   r  zVertex.Center  s     dllnn%%%r   rF  rG  rH  c           	      t     | t          t          |||                                                              S r  )rA   r,   r   )r0  rF  rG  rH  s       r   
makeVertexzVertex.makeVertex  s3     s,VAq!__==DDFFGGGr   r0  )r3  r4  r5  r6  rf   r7  r_   r8  r  r   r:  r  r   r  r9  rN  __classcell__)r   s   @r   r   r     s           0 0L 04 0 0 0 0 0 0@ueU23 @ @ @ @
& & & & & H5 HU Hu H H H H [H H H H Hr   )length	parameter)frenet	correctedc                       e Zd ZdefdZdefdZdeee	f         fdZ
dededeeee	f         ef         fdZdeeef         fdZdedefd	ZddededefdZ	 	 	 ddededededef
dZ	 ddedededefdZdee         dee         fdZdS )Mixin1DProtocolr  c                     d S r  r   r`  s    r   _approxCurvezMixin1DProtocol._approxCurve%  rB  r   c                     d S r  r   r`  s    r   _curvezMixin1DProtocol._curve(  rB  r   c                     d S r  r   r`  s    r   _geomAdaptorzMixin1DProtocol._geomAdaptor+  rB  r   dmodec                     d S r  r   r  r\  r]  s      r   _curve_and_paramz Mixin1DProtocol._curve_and_param.  	     	r   c                     d S r  r   r`  s    r   boundszMixin1DProtocol.bounds3  rB  r   c                     d S r  r   )r  r\  s     r   paramAtzMixin1DProtocol.paramAt6  rB  r   rP  c                     d S r  r   r_  s      r   
positionAtzMixin1DProtocol.positionAt9  rB  r   rR  Fframeplanarc                     d S r  r   )r  r\  r]  rh  ri  s        r   
locationAtzMixin1DProtocol.locationAt<  s	     	r   r   
resolutionc                     d S r  r   )r  r\  r]  rl  s       r   curvatureAtzMixin1DProtocol.curvatureAtE  ra  r   	locationsc                     d S r  r   )r  ro  s     r   paramsLengthzMixin1DProtocol.paramsLengthJ  rB  r   NrP  rP  rR  FrP  r   )r3  r4  r5  r   rW  r   rY  r   r>   r?   r[  r:  	ParamModer   r`  rc  re  r   rg  	FrameModer8  r   rk  rn  r   r   rq  r   r   r   rU  rU  $  s       /    
    e$57L$LM    '	u&(==>E	F   
eUl+     5     E  6     ##   	
  
    IM '@E	   
huo $u+      r   rU  T1Dc                      e Zd Zdedeeef         fdZdedeeef         fdZdedefdZ	dedefdZ
dedefdZdedefdZded	eeef         defd
Zd0dedee         dee         fdZdedee         dee         fdZ	 d1dedededefdZ	 d2dedee         dedee         fdZdedefdZdedefdZdedefdZdedefdZdedefdZded	ededeeee f         ef         fdZ!	 d2ded	ededefdZ"	 d2dedee         dedee         fdZ#dedee$ef         deee         ee         f         fd Z%	 	 	 d3ded	eded#e&d$ede'fd%Z(	 	 	 d3dedee         ded#e&d$edee'         fd&Z)	 d4de*d(d)d	e+d*edee*ee*         f         f
d+Z,	 	 d5ded	eded,edef
d-Z-	 	 d5dedee         ded,edee         f
d.Z.d/S )6Mixin1Dr  r  c                 *    |                                  S r  )rc  r`  s    r   _boundszMixin1D._boundsR  s    {{}}r   c                 z    |                                  }|                                |                                fS )z1
        Parametric bounds of the curve.
        )r[  FirstParameterLastParameter)r  curves     r   rc  zMixin1D.boundsV  s8    
 !!####%%u':':'<'<<<r   c                     |                                  }|                                }t          |                    |                    S )z

        :return: a vector representing the start point of this edge

        Note, circles may have the start and end points the same
        )r[  r}  r   r  )r  r  umins      r   
startPointzMixin1D.startPoint^  s@     !!####%%ekk$''(((r   c                     |                                  }|                                }t          |                    |                    S )z

        :return: a vector representing the end point of this edge.

        Note, circles may have the start and end points the same
        )r[  r~  r   r  )r  r  umaxs      r   endPointzMixin1D.endPointk  s@     !!##""$$ekk$''(((r   c                     t          |                                 t          t          dd                                          }|S )zv
        Approximate curve adaptor into a real b-spline. Meant for handling of
        BRepAdaptor_CompCurve.
        d   r  )MaxSegments	MaxDegree)r   r[  	TOLERANCEr   Curver  r  s     r   rW  zMixin1D._approxCurvex  sC     %JCST
 
 

%'' 	 	r   c                     |                                  }t          |t                    r'|                                                                }n|                                 }|S )z.
        Return the underlying curve.
        )r[  rY  r>   r  rW  )r  r  r  s      r   rY  zMixin1D._curve  sY    
 !!##e.// 	%$$&&BB""$$B	r   r\  c                    |                                  }t          |t                    ro|                                 }t	          |                                ||                                |                                                                          }nLt          j
        |          }t          |||z  |                                                                          }|S )z
        Compute parameter value at the specified normalized distance or a point.

        :param d: normalized distance [0, 1] or a point
        :return: parameter value
        )r[  rY  r   rY  rq   r$  r}  r~  LowerDistanceParameterr   Length_s	Parameter)r  r\  r  curve_r  r[  s         r   re  zMixin1D.paramAt  s     !!##a   		X[[]]F,		65#7#7#9#95;N;N;P;P $$&& B
 %-e44A%eQUE4H4H4J4JKKUUWWB	r   r   ptsc                 *   g }|                                  }|                                 }|                                }|                                }t	          |          }t          |          }	t          |	                                |||          }
|
                                }|	                    |           |D ]R}	|

                    |	                                           |
                                }|	                    |           S|S )z
        Computes u values closest to given vectors.

        :param pts: the points to compute the parameters at.
        :return: list of u values.
        )r[  rY  r}  r~  r  r  rq   r$  r  r  r  )r  r  rp  usr  r  r  r  r  ptprojus               r   r  zMixin1D.params  s     !!####%%""$$ #YY"XX*288::vtTJJ''))
		! 	 	BLL$$$++--AIIaLLLL	r   ro  c                     g }|                                  }t          j        |          }|D ]O}t          |||z  |                                                                          }|                    |           P|S )z
        Computes u values at given relative lengths.

        :param locations: list of distances.
        :returns: list of u values.
        :param pts: the points to compute the parameters at.
        )r[  r   r  r}  r  r  )r  ro  r  r  Lr\  r  s          r   rq  zMixin1D.paramsLength  s|     !!## )%00 	 	A$UAE53G3G3I3IJJTTVVAIIaLLLL	r         ?rP  locationParamr]  c                    |                                  }t                      }t                      }|dk    r|                     |          }n|}|                    |||           t          t          |                    S )z
        Compute tangent vector at the specified location.

        :param locationParam: distance or parameter value (default: 0.5)
        :param mode: position calculation mode (default: length)
        :return: tangent vector
        rP  )r[  r,   r+   re  D1r   r0   )r  r  r]  r  tmpr  params          r   	tangentAtzMixin1D.tangentAt  st     !!##hhhh8LL//EE!ES!!!fSkk"""r   c                 <   |                                  }|dk    r|                     |          }n|}g }t                      }t                      }|D ]H}|                    |||           |                    t          t          |                               I|S )z
        Compute tangent vectors at the specified locations.

        :param locations: list of distances or parameters.
        :param mode: position calculation mode (default: length).
        :return: list of tangent vectors
        rP  )r[  rq  r,   r+   r  r  r   r0   )	r  ro  r]  r  r  r  r  r  r  s	            r   tangentszMixin1D.tangents  s     !!## 8&&y11FFFhhhh 	+ 	+EHHUC%%%IIfVC[[))****	r   c                    |                                  }|                                 }|dk    rH|                                }t          |                                                                          }n|dk    rH|                                }t          |                                                                          }nt          | j        d          }|	                                }t          |t                    rH|                                }t          |                                                                          }nt          d          |S )zo
        Calculate the normal Vector. Only possible for planar curves.

        :return: normal vector
        CIRCLEELLIPSET	OnlyPlanezNormal not defined)r[  r]  Circler   Axis	DirectionEllipser   r  SurfacerY  r   Plnr  )	r  r  gtypecircr  ellfssurfplns	            r   normalzMixin1D.normal  s    !!##H<<>>D		--//00BBi--//C

,,..//BB$T\TBBBB::<<D$
++ 7hhjjCHHJJ002233 !5666	r   c                     t                      }t          j        | j        |           t	          |                                          S r  )rO   rQ   LinearProperties_sr  r   r  r  s     r   r  zMixin1D.Center0  s:    !^^
$T\:>>>j--//000r   c                 N    t          j        |                                           S r  )r   r  r[  r`  s    r   LengthzMixin1D.Length7  s    #,T->->-@-@AAAr   c                     |                                  }	 |                                }n)# t          t          f$ r}t	          d          |d}~ww xY w|                                S )z
        Calculate the radius.

        Note that when applied to a Wire, the radius is simply the radius of the first edge.

        :return: radius
        :raises ValueError: if kernel can not reduce the shape to a circular edge
        z&Shape could not be reduced to a circleN)r[  r  r   r   r  Radius)r  geomr  es       r   radiuszMixin1D.radius;  sr       ""	N;;==DD%'78 	N 	N 	NEFFAM	N{{}}s   + AAAc                 4    t          j        | j                  S r  )r\   
IsClosed_sr  r`  s    r   IsClosedzMixin1D.IsClosedK  s    #DL111r   c                 n    |                                  }|dk    r|                     |          }n|}||fS )z:
        Helper that reurns the curve and u value
        rP  )r[  re  r  r\  r]  r  r  s        r   r`  zMixin1D._curve_and_paramO  s@     !!##8LLOOEEEe|r   c                 x    |                      ||          \  }}t          |                    |                    S )a  
        Generate a position along the underlying curve.

        :param d: distance or parameter value
        :param mode: position calculation mode (default: length)
        :return: A Vector on the underlying curve located at the specified d value.
        )r`  r   r  r  s        r   rg  zMixin1D.positionAt_  s7     ,,Q55uekk%(()))r   dsc                 $      fd|D             S )z
        Generate positions along the underlying curve.

        :param ds: distance or parameter values
        :param mode: position calculation mode (default: length)
        :return: A list of Vector objects.
        c                 <    g | ]}                     |          S r   )rg  )r   r\  r]  r  s     r   r  z%Mixin1D.positions.<locals>.<listcomp>y  s'    555Q4((555r   r   )r  r  r]  s   ` `r   	positionszMixin1D.positionsn  s#     65555"5555r   nc                    t          |t                    r>|                                 t                                          r|dz   n|          n$|                                 t          |                                          }fdt          d                                r|n|dz             D             }fd|D             }||fS )z
        Sample a curve based on a number of points or deflection.

        :param n: Number of positions or deflection
        :return: A list of Vectors and a list of parameters.
        r   c                 :    g | ]}                     |          S r   )r  )r   r  gcpntss     r   r  z"Mixin1D.sample.<locals>.<listcomp>  s7     
 
 
 Q
 
 
r   c                 T    g | ]$}t                              |                    %S r   )r   r  )r   pcrvs     r   r  z"Mixin1D.sample.<locals>.<listcomp>  s+    555syy||$$555r   )rY  r;  r[  r   r  r   NbPointsr  )r  r  N_ptsr  pntsr  r  s        @@r   samplezMixin1D.sample{  s     a 	;##%%C0s||~~6Ta!eeSTUUFF##%%C23::F!!
 
 
 
1s||~~Dee519EE
 
 
 6555f555V|r   rR  Frh  ri  c                    |                      ||          \  }}|dk    rt                      }nt                      }|                    |           t	                      t	                      t	                      }
}	}|                    |||	|
           |                    |          }t                      }|r|                    t          |t          ddd          t          t          ddd                              t          |                                                    j                            t                                 no|                    t          |t          |                                          t          |	                                                    t                                 t!          t#          |                    S )a  
        Generate a location along the underlying curve.

        :param d: distance or parameter value
        :param mode: position calculation mode (default: length)
        :param frame: moving frame calculation method (default: frenet)
        :param planar: planar mode
        :return: A Location object representing local coordinate system at the specified distance.
        rR  r   r   )r`  r   r   SetCurver+   D0r  r2   SetTransformationr/   r0   r   cross
normalizedr  XYZr   r   )r  r\  r]  rh  ri  r  r  lawtangentr  binormalpntr  s                r   rk  zMixin1D.locationAt  s   " ,,Q55u H!##CC*,,CU$*HHfhhugvx000kk%  II 	1aOO6!Q??00AALLNNVWW 
     sF7;;==116&**,,3G3GHH&((   **+++r   c                 ,      fd|D             S )a  
        Generate locations along the curve.

        :param ds: distance or parameter values
        :param mode: position calculation mode (default: length)
        :param frame: moving frame calculation method (default: frenet)
        :param planar: planar mode
        :return: A list of Location objects representing local coordinate systems at the specified distances.
        c                 @    g | ]}                     |          S r   )rk  )r   r\  rh  r]  ri  r  s     r   r  z%Mixin1D.locations.<locals>.<listcomp>  s+    DDDA477DDDr   r   )r  r  r]  rh  ri  s   ` ```r   ro  zMixin1D.locations  s,    " EDDDDDDDDDDr   Tr  r   closestc                     t          | j        |j        t          |                                                    }t	          |                                          }|rt                      }|                    | j                   t          }|D ]a}|	                    |j                   |
                                 |                                }	|	|k     r|	}t          t          |          }
bnd |D             }
|
S )zD
        Project onto a face along the specified direction.
        c                 8    g | ]}t          t          |          S r   )r\  rw  r  s     r   r  z#Mixin1D.project.<locals>.<listcomp>  s     222R%R..222r   )r   r  r   r  r   r  r   r  r   r  r  r  r\  rw  )r  r  r\  r  r  r  r  min_distr  distr  s              r   projectzMixin1D.project  s     #4<vayy?P?PQQ$**,,'' 	3244IT\***H ( (  ,,,!!### (((??#HsBB( 326222B	r   rl  c                     |                      ||          \  }}t          ||d|          }|                                S )a?  
        Calculate mean curvature along the underlying curve.

        :param d: distance or parameter value
        :param mode: position calculation mode (default: length)
        :param resolution: resolution of the calculation (default: 1e-6)
        :return: mean curvature value at the specified d value.
        r"   )r`  r   	Curvature)r  r\  r]  rl  r  r  propss          r   rn  zMixin1D.curvatureAt  s@     ,,Q55uua<<   r   c                 (      fd|D             S )aA  
        Calculate mean curvatures along the underlying curve.

        :param d: distance or parameter values
        :param mode: position calculation mode (default: length)
        :param resolution: resolution of the calculation (default: 1e-6)
        :return: mean curvature value at the specified d value.
        c                 >    g | ]}                     |          S r   )rn  )r   r\  r]  rl  r  s     r   r  z&Mixin1D.curvatures.<locals>.<listcomp>"	  s+    BBB!  D*55BBBr   r   )r  r  r]  rl  s   ` ``r   
curvatureszMixin1D.curvatures	  s(     CBBBBBrBBBBr   Nr   )r  rP  rr  rs  r1  rt  )/r3  r4  r5  rU  r   r:  r{  rc  r   r  r  r   rW  r   rY  r   r=  re  r   r   r  rq  ru  r  r  r  r  r  r  r8  r  r>   r?   r`  rg  r  r;  r  rv  r   rk  ro  rw  r   r  rn  r  r   r   r   ry  ry  Q  s       o %u*=    =_ =ue|)< = = = =) )V ) ) ) )) )6 ) ) ) )
? 
/@ 
 
 
 
_     o %f*= %    . _ 8F+; $u+    @? x 4PU;    , NV# ##.3#AJ#	# # # #4 NV *25/AJ	f   :_     81_ 1 1 1 1 1B_ B B B B B_      2 24 2 2 2 2"'/8	u&(==>E	F   " <D* **"'*/8*	* * * *  GO6 66#+E?6:C6	f6 6 6 6"'U
"3	tF|T%[(	)   @ ##/, /,/,/, /, 	/,
 /, 
/, /, /, /,h ##E EEUOE E 	E
 E 
hE E E E( AE     $. 9= 	sDI~	       J # 	! !!! ! 	!
 
! ! ! !0 # 	C CCUOC C 	C
 
eC C C C C Cr   ry  c                      e Zd ZU dZeed<   defdZded         fdZ	de
fdZded	edd fd
ZdddefdZe e
ddd           e
ddd          dddfdedededededd fd            Ze e
ddd           e
ddd           e
ddd          dddfdedededededededed         dd fd            Ze	 	 	 	 	 d7d"ee
         d#eee
                  d$ed%eee                  d&ed'edd fd(            Ze	 	 	 	 d8d"ee
         d'ed+eeeeef                  d,ed-edd fd.            Zed/ed0ed1edd fd2            Zed/ed0ed1edd fd3            Zed/ed0edd fd4            Zed5ee
         dd fd6            Z dS )9r   z>
    A trimmed curve that represents the border of a face
    r  r  c                 *    t          | j                  S z0
        Return the underlying geometry
        )r>   r  r`  s    r   r[  zEdge._geomAdaptor,	  s    
 !...r   )r   r   c                     |                                  s.t                              | f                                          }n| }|S )z
        Close an Edge
        )r  r   assembleEdgescloser  s     r   r  z
Edge.close3	  sA     }} 	##TG,,2244BBB	r   c                    |                                  }|                                 }|dk    rFt          |                                                                                                          }n^|dk    rFt          |                                                                                                          }nt          | d          |S )zE
        Center of an underlying circle or ellipse geometry.
        r  r  z has no arc center)r]  r[  r   r  Positionr   r  r  )r  gar  s       r   	arcCenterzEdge.arcCenter@	  s    
 MMOO==

++--668899BB)^^		,,..7799::BB555666	r   u0u1c                     t          |                                                                                                 ||          }|                     |                                          S )z~
        Trim the edge in the parametric space to (u0, u1).

        NB: this operation is done on the base geometry.
        )rB   r[  r  r   r  )r  r  r  r  s       r   trimz	Edge.trimQ	  sT     't'8'8':':'@'@'B'B'H'H'J'JBPRSS~~djjll+++r   rI  r   c                 Z    t                                          | j        |j                  S )z:
        Check if self has a pcurve defined on f.
        )r   	HasPCurver  )r  rI  s     r   	hasPCurvezEdge.hasPCurve\	  s$    
 "##--dlAIFFFr   r   r        v@r  Tr  r  dirangle1angle2c                    t          |          }t          |          }t          t          |                                |                                          |          }||k    r* | t          |                                                    S t          |t          |          t          |          |          	                                } | t          |                                                    S r  )
r   r1   r.   r$  r  rB   r   rj   r   r  )	r0  r  r  r  r  r  orientation	circle_gpcircle_geoms	            r   
makeCirclezEdge.makeCirclec	  s     SkkSkkF399;;		<<fEE	V3.y99>>@@AAA,76??GFOO[ egg  3.{;;@@BBCCCr   x_radiusy_radiusxdirsense)r   c	                    t          |                                          }	t          |                                          }
t          |                                          }t          |	|
          }t	          |	|
|          }||k    r5t          d          }t          |||                              ||          }nd}t          |||          }||k    r+ | t          |          	                                          }nrt          |t          |          |z
  t          |          |z
  |dk                                              } | t          |          	                                          }|S )a  
        Makes an Ellipse centered at the provided point, having normal in the provided direction.

        :param cls:
        :param x_radius: x radius of the ellipse (along the x-axis of plane the ellipse should lie in)
        :param y_radius: y radius of the ellipse (along the y-axis of plane the ellipse should lie in)
        :param pnt: vector representing the center of the ellipse
        :param dir: vector representing the direction of the plane the ellipse should lie in
        :param angle1: start angle of arc
        :param angle2: end angle of arc (angle2 == angle1 return closed ellipse = default)
        :param sense: clockwise (-1) or counter clockwise (1)
        :return: an Edge
             V@        r   )r   r$  r  r-   r.   r   r6   RotatedrB   r   rk   r  )r0  r	  r
  r  r  r  r  r  r  pnt_pdir_dxdir_dax1ax2correction_angle
ellipse_gpellipseellipse_geoms                     r   makeEllipsezEdge.makeEllipsez	  se   4 s!!##s!!####%%UE""UE6**h&t}}!#x::BB% JJ  #!#x::JVc1*==BBDDEEGG /"22"22
	 
 egg  c1,??DDFFGGGr   NFr   listOfVectorr  periodic
parametersr-  rp  c                    t          dt          |                    }t          |          D ]0\  }}	|                    |dz   |	                                           1|t          |||          }
nt          |          t          |          |z   k    r/t          dt          |           dt          |                     t          dt          |                    }t          |          D ]\  }}|                    |dz   |           t          ||||          }
|rNt          |          dk    r;t          |          dk    r(|\  }}|
                    |j	        |j	        |           n t          |          t          |          k    r/t          dt          |           dt          |                     t          dt          |                    }t          dt          |                    }t          |          D ]P\  }}|                    |dz   |du           ||nt                      }|                    |dz   |j	                   Q|
                    |||           |
                                 |
                                st          d          |
                                } | t!          |                                                    S )a  
        Interpolate a spline through the provided points.

        :param listOfVector: a list of Vectors that represent the points
        :param tangents: tuple of Vectors specifying start and finish tangent
        :param periodic: creation of periodic curves
        :param parameters: the value of the parameter at each interpolation point. (The interpolated
          curve is represented as a vector-valued function of a scalar parameter.) If periodic ==
          True, then len(parameters) must be len(intepolation points) + 1, otherwise len(parameters)
          must be equal to len(interpolation points).
        :param scale: whether to scale the specified tangent vectors before interpolating. Each
          tangent is scaled, so it's length is equal to the derivative of the Lagrange interpolated
          curve. I.e., set this to True, if you want to use only the direction of the tangent
          vectors specified by ``tangents``, but not their magnitude.
        :param tol: tolerance of the algorithm (consult OCC documentation). Used to check that the
          specified points are not too close to each other, and that tangent vectors are not too
          short. (In either case interpolation may fail.)
        :return: an Edge
        r   NzuThere must be one parameter for each interpolation point (plus one if periodic), or none specified. Parameter count: z, point count: r"   zgThere must be one tangent for each interpolation point, or just two end point tangents. Tangent count: zB-spline interpolation failed)r7   r  	enumerateSetValuer$  ro   r  r=   Loadr  r;   r<   r   r  r  r  rB   r   )r0  r  r  r  r  r-  rp  r  ixr   spline_builderparameters_arrayp_indexp_valuet1t2tangents_arraytangent_enabled_arrayt_indext_valuetangent_vecspline_geoms                         r   
makeSplinezEdge.makeSpline	  s   : #1c,&7&788|,, 	- 	-EBMM"q&!'')),,,,0xEENN:3|#4#4x#?@@ K:K K7:<7H7HK K  
  5QJHH$-j$9$9 @ @  ))'A+w????07GSVWWN 	R8}}!!c,&7&71&<&<!B##BJ
EBBBBx==C$5$555$Mx==M M9<\9J9JM M   "4As8}}!E!E(@CMM(R(R%(1((;(; N N$GW)227Q;t@STTT-4-@''fhhK"++GaK9LMMMM##N4I5QQQ   $$&& 	><===$**,,s*;77<<>>???r   r4     	smoothingminDegmaxDegc                    t          dt          |                    }t          |          D ]0\  }}|                    |dz   |                                           1|rt          |g|R ||d}	nt          ||||          }	|	                                st          d          |	                                }
 | t          |
          
                                          S )a  
        Approximate a spline through the provided points.

        :param listOfVector: a list of Vectors that represent the points
        :param tol: tolerance of the algorithm (consult OCC documentation).
        :param smoothing: optional tuple of 3 weights use for variational smoothing (default: None)
        :param minDeg: minimum spline degree. Enforced only when smothing is None (default: 1)
        :param maxDeg: maximum spline degree (default: 6)
        :return: an Edge
        r   DegMaxTol3DDegMinr7  r8  B-spline approximation failed)r7   r  r   r!  r$  rr   r  r  r  rB   r   )r0  r  rp  r2  r3  r4  r  r#  r   r$  r/  s              r   makeSplineApproxzEdge.makeSplineApprox
  s   & #1c,&7&788|,, 	- 	-EBMM"q&!'')),,,, 	4  )/s  NN 5VF#  N $$&& 	><===$**,,s*;77<<>>???r   v1v2v3c                 V   t          t          |                                          t          |                                          t          |                                                                                    } | t	          |                                                    S )z
        Makes a three point arc through the provided points

        :param cls:
        :param v1: start vector
        :param v2: middle vector
        :param v3: end vector
        :return: an edge object through the three points
        )rj   r   r$  r  rB   r   r0  r=  r>  r?  r  s        r   makeThreePointArczEdge.makeThreePointArc)
  s     )2JJr

 0 0 2 2F2JJ4D4D4F4F
 

%'' 	 s*;77<<>>???r   c                 <   t          t          |                                          t          |          j        t          |                                                                                    } | t          |                                                    S )z
        Makes a tangent arc from point v1, in the direction of v2 and ends at v3.

        :param cls:
        :param v1: start vector
        :param v2: tangent vector
        :param v3: end vector
        :return: an edge
        )rj   r   r$  r  r  rB   r   rA  s        r   makeTangentArczEdge.makeTangentArc<
  sz     )2JJr

 2F2JJ4D4D4F4F
 

%'' 	 s*;77<<>>???r   c                      | t          t          |                                          t          |                                                                                              S )z
        Create a line between two points

        :param v1: Vector that represents the first point
        :param v2: Vector that represents the second point
        :return: A linear edge between the two provided points
        )rB   r   r$  r   )r0  r=  r>  s      r   makeLinezEdge.makeLineM
  sU     s#F2JJ$4$4$6$6r

8H8H8J8JKKPPRR
 
 	
r   pointsc                 H   t          dt          |                    }t          |          D ]=\  }}|                    |dz   t	          |                                                     >t          |          } | t          |                                                    S )u  
        Create a cubic Bézier Curve from the points.

        :param points: a list of Vectors that represent the points.
            The edge will pass through the first and the last point,
            and the inner points are Bézier control points.
        :return: An edge
        r   )	r9   r  r   r!  r   r$  r{   rB   r   )r0  rG  arrr  r   bezs         r   
makeBezierzEdge.makeBezierZ
  s     !CKK00f%% 	3 	3DAqLLQq		 1 12222s##s*3//4466777r   )NFNTr   )r4  Nr   r1  )!r3  r4  r5  r6  re   r7  r>   r[  r   r  r   r  r=  r  r8  r  r9  r:  r   r  r   r  r   r   r   r0  r   r;  r<  rB  rD  rF  rK  r   r   r   r   r   %	  sN          // / / / /u^,    6    "	,t 	, 	,& 	, 	, 	, 	,G6 Gd G G G G  !&Aq// &Aq//D DD D 	D
 D D 
D D D [D, 
 !&Aq// &Aq//!6!Q?? !6 66 6 	6
 6 6 6 6 u~6 
6 6 6 [6p  0404L@ L@6lL@ 8F+,L@ 	L@
 Xe_-L@ L@ L@ 
L@ L@ L@ [L@\  :>$@ $@6l$@ $@ E%"567	$@
 $@ $@ 
$@ $@ $@ [$@L @@!+@1;@	@ @ @ [@$ @
 @
 @
 @v @ @ @ [@  

* 

* 

 

 

 

 [

 8V 8 8 8 8 [8 8 8r   c                      e Zd ZU dZeed<   defdZdee	e
f         fdZd7dZe	 d8deed ef                  d	eded          fd
            Zedee         dd fd            Zededededd fd            Ze	 	 	 	 d9dedededededededededd fd            Ze	 	 d:dee         dededd fd             Ze ed!d!d!           ed!d!d"          ddfd#ed$ededed%ed&ed'edd fd(            Zd;d*Z	 d<d,ed-ed.         ded          fd/Zded0ee         dd fd1Zd,ed0ee         dd fd2Z 	 d=ded0e!ee                  dd fd4Z"dee         fd5Z#de$e         fd6Z%d3S )>r   zL
    A series of connected, ordered Edges, that typically bounds a Face
    r  r  c                 z    t                      }|                    | j                   |                                S )z"
        Number of edges.
        )r   r"  r  NbEdges)r  sas     r   _nbEdgeszWire._nbEdgesv
  s1    
  !!
zz||r   c                     |                                  dk    r-|                                 d                                         }nt          | j                  }|S )z1
        Return the underlying geometry.
        r   r  )rP  r  r[  r?   r  r  s     r   r[  zWire._geomAdaptor
  sK     ==??ab!..00BB&t|44B	r   c                     |                                  sbt                              |                                 |                                           }t
                              | |f          d         }n| }|S )z
        Close a Wire
        r   )r  r   rF  r  r  r   combine)r  r  r  s      r   r  z
Wire.close
  s_    
 }} 	dmmoot/@/@AAAtQi((+BBB	r   &.>listOfWiresrp  c                     t                      }t                      }t                              |                                          D ]}|                    |j                   t          j        ||d|            fd|D             S )z
        Attempt to combine a list of wires and edges into a new wire.

        :param cls:
        :param listOfWires:
        :param tol: default 1e-9
        :return: List[Wire]
        Fc                 &    g | ]} |          S r   r   )r   r  r0  s     r   r  z Wire.combine.<locals>.<listcomp>
  s!    ,,,BB,,,r   )r   r   r   r  ro  r  r   ConnectEdgesToWires_s)r0  rU  rp  edges_in	wires_outr  s   `     r   rS  zWire.combine
  s     -..-//	&&{3399;; 	' 	'AOOAI&&&& 6xeYWWW,,,,),,,,r   listOfEdgesc                    t                      }t                      }|D ]}|                    |j                   |                    |           |                                 |                                s8dt          |                                          z   }t          j
        |            | |                                          S )a  
        Attempts to build a wire that consists of the edges in the provided list

        :param cls:
        :param listOfEdges: a list of Edge objects. The edges are not to be consecutive.
        :return: a wire with the edges assembled

        BRepBuilderAPI_MakeWire::Error() values:

        * BRepBuilderAPI_WireDone = 0
        * BRepBuilderAPI_EmptyWire = 1
        * BRepBuilderAPI_DisconnectedWire = 2
        * BRepBuilderAPI_NonManifoldWire = 3
        zBRepBuilderAPI_MakeWire::Error(): returns the construction status. BRepBuilderAPI_WireDone if the wire is built, or another value of the BRepBuilderAPI_WireError enumeration indicating why the construction failed = )rE   r   ro  r  r  r  r  rZ  Errorwarningswarnr   )r0  r[  wire_builderocc_edges_listr  ws         r   r  zWire.assembleEdges
  s      /00-// 	- 	-A!!!),,,,(((""$$ 	 jl((**++,  M!s<$$&&'''r   r  r  r  c                 j    t                               |||          }|                     |g          }|S )aT  
        Makes a Circle centered at the provided point, having normal in the provided direction

        :param radius: floating point radius of the circle, must be > 0
        :param center: vector representing the center of the circle
        :param normal: vector representing the direction of the plane the circle should lie in
        )r   r  r  )r0  r  r  r  circle_edgerb  s         r   r  zWire.makeCircle
  s3     oofff=={m,,r   r   r  Tr	  r
  xDirr  r  rotation_angleclosedc
           	         t                               |||||||          }
||k    rY|	rWt                               |
                                |
                                          }|                     |
|g          }n|                     |
g          }|dk    r4|                    |t          |          t          |          z   |          }|S )a]  
        Makes an Ellipse centered at the provided point, having normal in the provided direction

        :param x_radius: floating point major radius of the ellipse (x-axis), must be > 0
        :param y_radius: floating point minor radius of the ellipse (y-axis), must be > 0
        :param center: vector representing the center of the circle
        :param normal: vector representing the direction of the plane the circle should lie in
        :param angle1: start angle of arc
        :param angle2: end angle of arc
        :param rotation_angle: angle to rotate the created ellipse / arc
        r  )r   r  rF  r  r  r  r%  r   )r0  r	  r
  r  r  re  r  r  rf  rg  ellipse_edger  rb  s                r   r  zWire.makeEllipse
  s    2 ''hff
 
 V==!6!6!8!8,:Q:Q:S:STTD!!<"677AA!!<.11AS  &..!@.QQAr   FlistOfVerticesr  r  c                    t                      }|D ]6}|                    t          |                                                     7|r|                                  | |                                          }||_        |S )z9
        Construct a polygonal wire from points.
        )rD   r  r   r$  Closer   r  )r0  rj  r  r  r`  r   rb  s          r   makePolygonzWire.makePolygon  s     233 	0 	0AVAYY__..//// 	!   C!!##$$+r   r   r   pitchheightr  anglelefthandc                     |dk    r]t          t          t          |                                          t          |                                                    |          }njt          t          t          |                                          t          |                                                    t          |          |          }|r5t          t          dd          t          dt          z  |                    }	n4t          t          dd          t          dt          z  |                    }	||z  }
|	                    d          }|	                    |
t          dt          z  dz  |dz  z             z            }t          ||                                          }t          ||                                          }t!          |                                          }t%          j        |dd            | |          S )z
        Make a helix with a given pitch, height and radius
        By default a cylindrical surface is used to create the helix. If
        the fourth parameter is set (the apex given in degree) a conical surface is used instead'
        r   r  r"   r   i  )
MaxSegment)r}   r/   r   r$  r  r|   r   r   r4   r5   r   r  r   rl   rB   r   rE   r   r   BuildCurves3d_s)r0  rn  ro  r  r  r  rp  rq  	geom_surf	geom_linen_turnsu_startu_stopgeom_segr  rb  s                   r   	makeHelixzWire.makeHelix$  s   $ E>>&=vf~~++--vc{{/@/@/B/BCCV' 'II ,vf~~++--vc{{/@/@/B/BCC I  	Q#HS#$6$6b%8P8PQQII#HS#$6$6R8O8OPPI 5.//#&&4RA
0J+K+K!KLL$Wf55;;==#Hi88==?? $A&&++--4D9999s1vvr   rd  c                 D   t                      }|                    t          j        | j                             |                    t          j        |j                             |                                 |                     |                                          S )zAttempt to stitch wires)rE   r  r^   Wire_sr  r  r   r   )r  rd  r`  s      r   stitchzWire.stitchU  s     /00t|44555u}55666~~l//11222r   arcr\  r  r  intersectionr  c                     t           j        t           j        t           j        d}t	                      }|                    ||                    |                     j                   |                    |           t          |
                                          }t          |t                    r fdt          |          D             }n                     |          g}|S )zOffsets a planar wirer  c                 D    g | ]}                     |j                  S r   )r   r  )r   r  r  s     r   r  z!Wire.offset2D.<locals>.<listcomp>r  s'    EEE$..,,EEEr   )r   GeomAbs_Arcr   GeomAbs_Tangentr   r  AddWirer  r  r  r  rY  ra   r   r   )r  r\  r  	kind_dictr  r  r  s   `      r   offset2DzWire.offset2D_  s     $/,A'7
 
	 *++IdO$$$t|$$$qv||~~&&c?++ 	'EEEEx}}EEEBB..%%&B	r   r  c                     t                               |           }|                    ||                                          S )z+
        Apply 2D fillet to a wire
        )r   makeFromWiresfillet2D	outerWire)r  r  r  rI  s       r   r  zWire.fillet2Dx  s7    
 t$$zz&(++55777r   c                     t                               |           }|                    ||                                          S )z,
        Apply 2D chamfer to a wire
        )r   r  	chamfer2Dr  )r  r\  r  rI  s       r   r  zWire.chamfer2D  s7    
 t$${{1h''11333r   Nc                 6   t          |           }|                                 }t          |          }t          |          }g }|d         }|rt          |          nt                      }	t	          |          D ]}
|
|dz
  k    r|                                 s n||
dz   |z           }|                    d          }|                    d          }|                    |          }|j        dk    s||
dz   |z           |	vr't          |	          r|
                    |           |}|                                                                }t          ||                                          }t          |j        |j        |          }|                    |          }|st%          d|
dz    d          t'          t)          |                                                                                    }|                    ||j        |j                  }|
                    |           |
                    t-          |                     |}|                                 s|
                    |           t.                              |          S )a>  
        Apply 2D or 3D fillet to a wire

        :param radius: the radius of the fillet, must be > zero
        :param vertices: the vertices to delete (where the fillet will be applied).  By default
          all vertices are deleted except ends of open wires.
        :return: A wire with filleted corners
        r   r   zFailed fillet at vertex !)r  r  r  r
  r  r  r  r  r  r8  r  r  r$  r3   r  r   r  r  r  r  r  Resultr   r   r  )r  r  r  r
  all_verticesn_edges
n_verticesnewEdgescurrentEdgeverticesSetr  nextEdge
currentDirnextDir	normalDirpointInPlanecornerPlanefilletMakerokthePointres_arcs                        r   filletzWire.fillet  s~    T

}}e**&&
Ah'/:c(mmmSUUw *	# *	#AGaKa!ew./H %..q11J((++G"((11I
 1$$a!ez12+EE%% F ,,,& '--//5577L y/@/@AAK*#X%5{ K $$V,,B D !BAaC!B!B!BCCC DNN++2244::<<H!((+-x/? G OOK(((OODMM***"KK
 }} 	)OOK(((!!(+++r   c                    g }t          | j                  }|                    t          |                                                     |                                r\|                                 |                    t          |                                                     |                                \|                                 r
|dd         }|S )z7
        Ordered list of vertices of the wire.
        Nr  )r   r  r  r   CurrentVertexr  r  r  )r  r  exps      r   r  zWire.Vertices  s    
 $T\22
		&**,,--...hhjj 	3HHJJJIIfS..0011222 hhjj 	3
 ==?? 	CRCB	r   c              #      K   t          | j                  }|                                rMt          |                                          V  |                                 |                                KdS dS )z8
        Iterate over edges in an ordered way.

        N)r   r  Currentr   r  )r  r  s     r   r  zWire.__iter__  sv       %T\22kkmm 	s{{}}%%%%%HHJJJ kkmm 	 	 	 	 	r   )r  r   rT  )r   r   r  T)FF)rd  r   r  r   )r  r  )&r3  r4  r5  r6  rc   r7  r;  rP  r   r>   r?   r[  r  r9  r   r   r:  r   rS  r  r   r  r8  r  rm  r   r|  r  r   r  r   r  r  r   r  r  r	   r  r   r   r   r   r   o
  s          #    e$57L$LM        FJ- -"5#67->C-	f- - - [-, ( (6 ( ( ( [(B $.8B	   [   #% %% % 	%
 % % % % % % 
% % % [%N  !&	  ,  	
 
   [.  $VAq!__ &Aq//. .. . 	.
 . . . . 
. . . [.`3 3 3 3 KP %&FG	f   28u 80@ 8V 8 8 8 845 4HV,< 4 4 4 4 4 EIH, H,H,'/0@'AH,	H, H, H, H,T$v,    (
(4. 
 
 
 
 
 
r   c                      e Zd ZU dZeed<   defdZdee	e	e	e	f         fdZ
dee	e	e	e	f         fdZdedee	e	f         fdZ	 dsd
ee         de	deee	         ee	         f         fdZdededefdZdeeeef                  dee         fdZedtdee         defd            Zedededeeef         fd            Zdee         dee         deee         ee         f         fdZdefdZdefdZdee         fdZeeddddd d!d"d#d$d%fd&eee ef                  d'eee eee!f                  d(e"d)e#d*e#d+e#d,e$d-e	d.e	d/e	d0e	d1e#d2e#dd fd3            Z%e	 	 	 	 dud6ee	         d7ee	         d8ed9edd f
d:            Z&e'ed;e d<e dd fd=                        Z(e'ed;ed<edd fd>                        Z(ed?             Z(eg fd@edAee         dd fdB            Z)e	 	 	 	 dvdDeee                  de	dEeee	e	e	f                  dFe#d1e#dd fdG            Z*dHe	dIee+         dd fdJZ,dKe	dIee+         dd fdLZ-de.fdMZ/dNe	ddOfdPZ0edwdU            Z1dVd dKedd fdWZ2dxdYe	dd fdZZ3edyd\ed]ed^ed_edede4fd`            Z5edaeeef         dbeeef         dceeef         d
eeef         dd f
dd            Z5edRedTede4fde            Z5dzdfedge6dh         de fdiZ7	 dzdjee         dge6dh         dee          fdkZ8	 	 	 	 d{dKe	dme$dne$doe$dpe$dd fdqZ9dTee z  de4fdrZ:dS )|r   zK
    a bounded surface that represents part of the boundary of a solid
    r  r  c                 4    t          j        | j                  S r  )r\   	Surface_sr  r`  s    r   r[  zFace._geomAdaptor  s     "4<000r   c                 *    |                                  S r  )uvBoundsr`  s    r   	_uvBoundszFace._uvBounds  rg  r   c                 4    t          j        | j                  S )zA
        Parametric bounds (u_min, u_max, v_min, v_max).
        )r   
UVBounds_sr  r`  s    r   r  zFace.uvBounds  s    
 #DL111r   r  c                     |                                  }t          t          |                                          |          }|                                \  }}||fS )z
        Computes the (u,v) pair closest to a given vector.

        :returns: (u, v) tuple
        :param pt: the location to compute the normal at.
        :type pt: a vector that lies on or close to the surface.
        )r[  rp   r   r$  LowerDistanceParameters)r  r  surface	projectorr  r   s         r   re  zFace.paramAt  sV     ##%% /vbzz/?/?/A/A7KK	00221!tr   rT  r  rp  c                    g }g }|                                  }t          |          }t          |          }t          |          }|                    t          |                                          |          }	|                    |	                                           |                    |		                                           |D ]}|
                    |	t          |                                          |          }	|                    |	                                           |                    |		                                           ||fS )z
        Computes (u,v) pairs closest to given vectors.

        :returns: list of (u, v) tuples
        :param pts: the points to compute the normals at.
        :type pts: a list of vectors that lie on the surface.
        )r[  r   r  r  	ValueOfUVr   r$  r  r  r  NextValueOfUV)
r  r  rp  r  vsr  r  r  r  uvs
             r   r  zFace.params  s     ##%% *'22	 #YY"XX  !1!1!3!3S99
		"$$&&
		"$$&& 	 	B((VBZZ-=-=-?-?EEBIIbddffIIbddff2vr   r  r   c                     t                      }t                      }t          | j                                      ||||           t          |          S )a$  
        Computes the position vector at the desired location in the u,v parameter space.

        :returns: a vector representing the position
        :param u: the u parametric location to compute the normal at.
        :param v: the v parametric location to compute the normal at.
        )r,   r+   rP   r  Normalr   r  r  r   r  vns        r   rg  zFace.positionAtB  sF     HHXXt|$$++Aq!R888ayyr   uvsc                     t                      }t                      }g }|D ]Q\  }}t          | j                                      ||||           |                    t          |                     R|S )z
        Computes position vectors at the desired locations in the u,v parameter space.

        :returns: list of vectors corresponding to the requested u,v positions
        :param uvs: iterable of u,v pairs.
        )r,   r+   rP   r  r  r  r   )r  r  r  r  r  r  r   s          r   r  zFace.positionsP  sr     HHXX 	! 	!DAq4<((//1a<<<IIfQii    	r   NlocationVectorc                    |                                  }|*|                                 \  }}}}d||z   z  }d||z   z  }nFt          t          |                                          |          }	|	                                \  }}t                      }
t                      }t          | j	                  
                    |||
|           t          |                                          S )a8  
        Computes the normal vector at the desired location on the face.

        :returns: a vector representing the direction
        :param locationVector: the location to compute the normal at. If none, the center of the face is used.
        :type locationVector: a vector that lies on the surface.
        Nr  )r[  r  rp   r   r$  r  r,   r+   rP   r  r  r  )r  r  r  r  r  v0r=  r  r   r  r  r  s               r   normalAtzFace.normalAta  s     ##%%!!^^--NBBrBwArBwAA 3~&&,,.. I 4466DAqHHXXt|$$++Aq!R888bzz$$&&&r   c                     t                      }t                      }t          | j                                      ||||           t          |                                          t          |          fS )a;  
        Computes the normal vector at the desired location in the u,v parameter space.

        :returns: a vector representing the normal direction and the position
        :param u: the u parametric location to compute the normal at.
        :param v: the v parametric location to compute the normal at.
        )r,   r+   rP   r  r  r   r  r  s        r   r  zFace.normalAt  s]     HHXXt|$$++Aq!R888bzz$$&&q		11r   r  r  c                 z   g }g }t                      }t                      }t          | j                  }t	          ||          D ]s\  }}	|                    ||	||           |                    t          |                                                     |                    t          |                     t||fS )aU  
        Computes the normal vectors at the desired locations in the u,v parameter space.

        :returns: a tuple of list of vectors representing the normal directions and the positions
        :param us: the u parametric locations to compute the normal at.
        :param vs: the v parametric locations to compute the normal at.
        )	r,   r+   rP   r  zipr  r  r   r  )
r  r  r  rv_nrv_pr  r  BGPr  r   s
             r   r  zFace.normals  s     HHXXT\**BKK 	# 	#DAqJJq!Q###KKr

--//000KKq		""""Tzr   c                     t                      }t          j        | j        |           t	          |                                          S r  )rO   rQ   r  r  r   r  r  s     r   r  zFace.Center  s:    !^^
%dlJ???j--//000r   c                 N    t          t          j        | j                            S r  )r   r   OuterWire_sr  r`  s    r   r  zFace.outerWire  s    I)$,77888r   c                 l    |                                  fd|                                 D             S )Nc                 >    g | ]}|                               |S r   rh  )r   rb  outers     r   r  z#Face.innerWires.<locals>.<listcomp>  s(    ???aqxx????r   )r  r  r  r  s    @r   
innerWireszFace.innerWires  s4      ????4::<<????r   r     r"   Fgh㈵>r  {Gz?r5     	   r
  constraints
continuityr  
nbPtsOnCurnbIter
anisotropytol2dtol3dtolAngtolCurvr4  maxSegmentsc                 2   t          ||||||	|
|||
  
        }|D ]e}t          |t                    r|                    |j        |           3|                                D ]}|                    |j        |           f|D ]K}t          |t                    r|                    |           .t          |t                    r(|                    |                                           kt          |t                    r5|                    t          |                                                     t          |t                    r"|                    |j        t          d           t          |t                    r:|                                D ]#}|                    |j        t          d           $;t          d|           |                                 |                                }t          |                                          S )a  
        Returns a surface enclosed by a closed polygon defined by 'edges' and 'constraints'.

        :param edges: edges
        :type edges: list of edges or wires
        :param constraints: constraints
        :type constraints: list of points or edges
        :param continuity: OCC.Core.GeomAbs continuity condition
        :param degree: >=2
        :param nbPtsOnCur: number of points on curve >= 15
        :param nbIter: number of iterations >= 2
        :param anisotropy: bool Anisotropy
        :param tol2d: 2D tolerance >0
        :param tol3d: 3D tolerance >0
        :param tolAng: angular tolerance
        :param tolCurv: tolerance for curvature >0
        :param maxDeg: highest polynomial degree >= 2
        :param maxSegments: greatest number of segments >= 2
        FzInvalid constraint )r   rY  r   r  r  r  r,   r   r$  r~  r   r   r  r  r  r   r  )r0  r
  r  r  r  r  r  r  r  r  r  r  r4  r  n_sidedr  el_edgecr  r  s                       r   makeNSidedSurfacezFace.makeNSidedSurface  s   J ,
 
  	= 	=B"d## =BJ
3333!xxzz = =GKK<<<<=  	< 	<A!V$$ <AAv&& 
<AGGII&&&&Au%% <F1IIOO--....At$$ <AIz59999At$$ < > >AKK	:u====> !!:q!:!:;;; 	}}Dzz~~r   ru  r   r   r   rP  widthbasePntr  c                 n   t          |          }t          |          }t          |                                |                                          }|r6|r4t	          || dz  |dz  | dz  |dz                                            }n!t	          |                                          } | |          S )Nr  )r   r3   r$  r  rC   r   )r0  rP  r  r  r  pln_geom	pln_shapes          r   	makePlanezFace.makePlane  s     //Skk'--//399;;77 	Ae 	A/5&3,fWs]FSL dff I 099>>@@Is9~~r   edgeOrWire1edgeOrWire2c                     d S r  r   r0  r  r  s      r   makeRuledSurfacezFace.makeRuledSurface!  ra  r   c                     d S r  r   r  s      r   r  zFace.makeRuledSurface&  ra  r   c                     t          |t                    r2|                     t          j        |j        |j                            S |                     t          j        |j        |j                            S )z
        makeRuledSurface(Edge|Wire,Edge|Wire) -- Make a ruled surface
        Create a ruled surface out of two edges or wires. If wires are used then
        these must have the same number of edges
        )rY  r   r   rt   Shell_sr  Face_sr  s      r   r  zFace.makeRuledSurface+  s`     k4(( 	W88H,[-@+BUVVWWW88HOK,?ATUUVVVr   r  r  c                    |r#|                                 st          d          t                              |g|z             }t	          |j        d                                          st          d          t          |j                  }|                                 t          j
        |                                          }t          |d          }|D ]?}|                                 st          d          |                    |j                   @|                                 |                                s$t          d|                                           |                                }t%          |          }	|	                                 |	                                  | |	                                          S )z<
        Makes a planar face from one or more wires
        z.Cannot build face(s): outer wire is not closedTr  z&Cannot build face(s): wires not planarz.Cannot build face(s): inner wire is not closedzCannot build face(s): )r  r  r   r   r   r  Foundr   r  r^   r~  r  rC   r  r  r  r]  r   r   FixOrientationr  )
r0  r  r  wssf_swoface_builderrb  r  sf_fs
             r   r  zFace.makeFromWires8  s     	Oi0022 	OMNNN ""I;#;<<"2:>>>DDFF 	GEFFF i/00]4::<<((.r488 	( 	(A::<< S !QRRRQY''''""$$ 	NLl6H6H6J6JLLMMM  ""T""s4;;==!!!r   r   rG  r2  r3  c           	      L   t          dt          |          dt          |d                             }t          |          D ]I\  }}t          |          D ]4\  }	}
|                    |dz   |	dz   |
                                           5J|rt          |g|R ||d}nt          ||||          }|                                st          d          |                                } | t          |t          j                                                                        S )a  
        Approximate a spline surface through the provided points.

        :param points: a 2D list of Vectors that represent the points
        :param tol: tolerance of the algorithm (consult OCC documentation).
        :param smoothing: optional tuple of 3 weights use for variational smoothing (default: None)
        :param minDeg: minimum spline degree. Enforced only when smothing is None (default: 1)
        :param maxDeg: maximum spline degree (default: 6)
        r   r   r6  r9  r;  )r8   r  r   r!  r$  rs   r  r  r  rC   r*   Confusion_sr   )r0  rG  rp  r2  r3  r4  points_r  vir  r   r$  r/  s                r   r<  zFace.makeSplineApprox_  sJ   $ &aVaVAYHHv&& 	: 	:EAr!" : :1  QAqwwyy9999:  	;# ,2#  NN <vS  N $$&& 	><===$,,..s*;	8M8O8OPPUUWWXXXr   r  r  c                     t          | j                  }|D ]}|                    |j        |           |                                 |                     |                                          S )z+
        Apply 2D fillet to a face
        )r   r  	AddFilletr  r   r  )r  r  r  fillet_builderr   s        r   r  zFace.fillet2D  sm    
 4DLAA 	8 	8A$$QY7777~~n2244555r   r\  c                    t          | j                  }|                     dd          }|D ]w}||         }t          |          dk     rt	          d          |\  }}|                    t          j        |j                  t          j        |j                  ||           x|                                 | 	                    |
                                                                          S )z,
        Apply 2D chamfer to a face
        r   r   r"   zCannot chamfer at this location)r   r  r  r  r  
AddChamferr^   r  r  r   r  r  )	r  r\  r  chamfer_builderedge_mapr   r
  e1e2s	            r   r  zFace.chamfer2D  s    
 5T\BB%%h77 		 		AQKE5zzA~~ !BCCCFB&&bj))6=+D+Da    	~~o335566::<<<r   c                 R    t          | j                  }|                                S )z
        Convert this face to a gp_Pln.

        Note the Location of the resulting plane may not equal the center of this face,
        however the resulting plane will still contain the center of this face.
        )r@   r  r   )r  adaptors     r   toPlnz
Face.toPln  s!     &dl33}}r   	thicknessr   c           
          t                      }|                    | j        |dt          j        ddt
          d           |                                 t          |                                          S )z)
        Return a thickened face
        r   FT)	r   
Initializer  r   BRepOffset_Skinr   MakeOffsetShaper   r  )r  r  rQ  s      r   thickenzFace.thicken  sn    
 ())L+ 		
 		
 		
 	!!!W]]__%%%r   rI  r  r   innerc                      |j         |g|R  S r  )r  )r0  rI  r  r  s       r   constructOnzFace.constructOn  s     qve$e$$$$r   rd  c                     t          t          |                                                                         }fd|                                 D             } | j        |g|R  S )Nc              3   j   K   | ]-}t          t          |                                        V  .d S r  )r\  r   r  )r   rb  r\  rd  s     r   r  zFace.project.<locals>.<genexpr>  s;      OO5qyy2233OOOOOOr   )r\  r   r  r  r  r  )r  rd  r\  outer_pinner_ps    ``  r   r  zFace.project  sp    dnn..66ua@@AAOOOOOT__=N=NOOOtw99999r   r4  r7  c                 \    |                      t          j        | j        |                    S )z
        Approximate planar face with arcs and straight line segments.

        :param tolerance: Approximation tolerance.
        )r   r   ConvertFace_sr  rr  s     r   toArcszFace.toArcs  s%     ~~h4T\9MMNNNr   r   r  r  r  r=  c                     t          |                                 |||||          }|                     |                                          S )z
        Trim the face in the (u,v) space to (u0, u1)x(v1, v2).

        NB: this operation is done on the base geometry.
        )rC   r[  r   r  )r  r  r  r  r=  rp  r  s          r   r  z	Face.trim  sA     't'8'8':':BBCPP~~djjll+++r   pt1pt2pt3c           	         g }|                                  }t          |||g|R ||g||R           D ]H\  }}|                    t          t	          | t	          |                                                      Ig }	|D ]7}
|	                    t          |
|                                                     8t                      }t                      }|	D ]}|
                    |           |                    |           |                                }t          j        |           |                     | t          |                    S )zL
        Trim the face using a polyline defined in the (u,v) space.
        )r[  r  r  rl   r4   r  rB   r   rE   r   ro  r  r   r   ru  r  )r  r   r!  r"  r  segs_uvr  el1el2r
  segrQ  r  edgerb  s                  r   r  z	Face.trim  s^      "" S#s1S11C3Hs3HC3H3HII 	V 	VHCNN,Xs^Xs^LLRRTTUUUU  	D 	DCLL0d;;@@BBCCCC *++"$$ 	 	DJJtCLLNN""" d1gg...r   c                 $   t          |                                 |j                  }|D ].}|                    t	          j        |j                             /|                     |                                                                          S )zU
        Trim using wires. The provided wires need to have a pcurve on self.
        )	rC   r[  r  r  r^   r~  r   r   r  )r  r  r  r  rb  s        r   r  z	Face.trim  sw     't'8'8':':EMJJ 	/ 	/AHHV]19--....~~diikk**..000r   r  r  )r  r   c                    |                                  \  }}}}|dk    rt          j        }||}	}nt          j        }||}	}t	          t          |                                           ||          }
t          t          |
||	                    S )z'
        Construct an isoline.
        r  )	r  r   GeomAbs_IsoUGeomAbs_IsoVr   r   r[  r   _adaptor_curve_to_edge)r  r  r  r  u2r=  r>  isop1p2r  s              r   isolinezFace.isoline#  s    
 ))BB!.CBB!.CB$ 1 1 3 344c5
 
 *7B;;<<<r   r  c                 $      fd|D             S )z.
        Construct multiple isolines.
        c                 <    g | ]}                     |          S r   )r2  )r   r  r  r  s     r   r  z!Face.isolines.<locals>.<listcomp>>  s'    ;;;qQ	**;;;r   r   )r  r  r  s   ` `r   isolineszFace.isolines7  s#     <;;;;F;;;;r   Tr  r  vminvmaxc           	          |                                  dk    r|                                 n| }t                      }t          j        |j        ||||||           |                     |          S )aO  
        Extend a face. Does not work well in periodic directions.
        
        :param d: length of the extension.
        :param umin: extend along the umin isoline.
        :param umax: extend along the umax isoline.
        :param vmin: extend along the vmin isoline.
        :param vmax: extend along the vmax isoline.
        BSPLINE)r]  r  rd   r   ExtendFace_sr  r   )r  r\  r  r  r6  r7  r  r  s           r   r'  zFace.extend@  sa    & !%9 < <dllnnn$]]S[!T4tRHHH~~b!!!r   c           	      P   t          | j                  }|D ]W}|                    t          j        t          |t                    r|j        nt          |          j                             X|                     |	                                          
                                S )z(
        Add one or more holes.
        )rC   r  r  r^   r~  rY  r   wirer   r   r  )r  r  r  rb  s       r   addHolezFace.addHoleZ  s    
 't|44 	 	AHH:a+>+>SaiiDGGOTT    ~~diikk**..000r   r  r  )NNru  r  )r  Nr   r  )rI  r   r  r   r  r   r  r   )r4  r  )r   )TTTT);r3  r4  r5  r6  rd   r7  r~   r[  r   r:  r  r  r   re  r   r   r  r=  r   rg  r  r%   r   r  r  r  r   r  r  r9  r   r   r   r,   r   r;  r8  r  r  r   r  r  r<  r   r  r  r3   r  r  r  r  r  r   r  r   r2  r5  r'  r=  r   r   r   r   r     ss          1l 1 1 1 15ue!;<    2%ueU :; 2 2 2 2* ue|)<    & 7;! !J'!.3!	tE{DK'	(! ! ! !FD T f    XeD$J&78 T&\    " ' 'x
'; 'v ' ' ' [': 2$ 24 2E&&.,A 2 2 2 [24.&.tn	tF|T&\)	*   41 1 1 1 194 9 9 9 9@DJ @ @ @ @ 
 %/ N  N dDj)*N  eD$
F$BCDN  "	N 
 N  N  N  N  N  N  N  N  N  N  
N  N  N  [N `  #'!%'#   	
  
   [* 4 d v    [ X 4 d v    [ X 
W 
W [
W EG $" $"d $"T
 $"F $" $" $" [$"L  :>%Y %YT&\"%Y %Y E%"567	%Y
 %Y %Y 
%Y %Y %Y [%YN6u 60@ 6V 6 6 6 6=5 =HV,< = = = = =.	v 	 	 	 	& &7 & & & &, % % % [%:V :
 :v : : : :O O O O O O O 	, 	,t 	, 	,4 	,T 	, 	,PT 	, 	, 	, [	, %/4:%/ 4:%/ 4:	%/
 D$J%/ 
%/ %/ %/ [%/N 
1$ 
1 
1 
1 
1 
1 [
1= =T =gh.? =$ = = = =* FI< <tn<181B<	d< < < < " "" " 	"
 " " 
" " " "41dTk 1d 1 1 1 1 1 1r   c                   J    e Zd ZU dZeed<   edee         dd fd            Z	dS )r   z)
    the outer boundary of a surface
    r  listOfFacesr  c                     t                      }|D ]}|                    |j                   |                                 |                                } | |          S )z+
        Makes a shell from faces.
        )rF   r  r  r  
SewedShape)r0  r?  shell_builderr  rP  s        r   	makeShellzShell.makeShellp  sg     .// 	, 	,Ddl++++$$&&s1vvr   N)
r3  r4  r5  r6  rh   r7  r9  r   r   rC  r   r   r   r   r   i  s^           HTN w    [  r   TSc                      e Zd Zdededee         defdZdededee         dee         def
dZ		 	 d!dedeee
                  dededed         defdZ	 d"dedededefdZe	 	 	 	 	 d#dedee
         dee         dee         dedee
         dededefd            Ze	 	 	 	 	 d#dedee
         dee
         dee         dedee
         dededefd             ZdS )$Mixin3Dr  r  edgeListr  c                     d |D             }t          | j                  }|D ]}|                    ||           |                     |                                          S )z
        Fillets the specified edges of this solid.

        :param radius: float > 0, the radius of the fillet
        :param edgeList:  a list of Edge objects, which must belong to this solid
        :return: Filleted solid
        c                     g | ]	}|j         
S r   r  r   r  s     r   r  z"Mixin3D.fillet.<locals>.<listcomp>      333Qqy333r   )r   r  r  r   r  )r  r  rG  nativeEdgesr  r  s         r   r  zMixin3D.fillet  sl     43(3331$,?? 	* 	*Avq))))~~n2244555r   rP  length2c           	         d |D             }t                      }t          j        | j        t          j        t          j        |           t          | j                  }|r|}|}n|}|}|D ]S}	|                    |	          	                                }
|
                    |||	t          j        |
                     T|                     |                                          S )ak  
        Chamfers the specified edges of this solid.

        :param length: length > 0, the length (length) of the chamfer
        :param length2: length2 > 0, optional parameter for asymmetrical chamfer. Should be `None` if not required.
        :param edgeList:  a list of Edge objects, which must belong to this solid
        :return: Chamfered solid
        c                     g | ]	}|j         
S r   rJ  rK  s     r   r  z#Mixin3D.chamfer.<locals>.<listcomp>  rL  r   )r   r[   r  r  r'  r)  r+  r   r  Firstr  r^   r  r   r  )r  rP  rN  rG  rM  edge_face_mapr  d1d2r  r  s              r   chamferzMixin3D.chamfer  s     43(333 BCC&L".".-	
 	
 	

 4DLAA 	BBBBB 	 	A ,,Q//5577DB6=..    ~~o3355666r   r  r  faceListr  r7  r  r  r  c           	          t           j        t           j        d}t                      }t	                      }|r|D ]}|                    |j                   |                    | j        |||d||                    |                                 |r(| 	                    |
                                          }	n| 	                    |
                                                                          d         j        }
|                                 d         j        }|dk    rt          |
|          }nt          ||
          }| 	                    |
                                                                          }	|	S )a  
        Make a shelled solid of self.

        :param faceList: List of faces to be removed, which must be part of the solid. Can
          be an empty list.
        :param thickness: Floating point thickness. Positive shells outwards, negative
          shells inwards.
        :param tolerance: Modelling tolerance of the method, default=0.0001.
        :return: A shelled solid.
        rW  T)IntersectionJoinr   )r   r  r   r   r   ro  r  MakeThickSolidByJoinr  r   r  r  rM   r  )r  rV  r  r7  r  r  occ_faces_listrB  rI  r  s1s2sols                r   shellzMixin3D.shell  ss   & $/,A
 
	
 .//466 	1 1 1%%ai0000**L4 	+ 	
 	
 	
 	 	3 3 3 5 566BB  3 3 5 566==??BJBq!)B 1}}.r266.r266 		,,0022B	r   r   r  c                 "   t          |t                    r|                                }t          | j                  }|                    t          | |           |                                t          j	        k    p|
                                S )a\  
        Returns whether or not the point is inside a solid or compound
        object within the specified tolerance.

        :param point: tuple or Vector representing 3D point to be tested
        :param tolerance: tolerance for inside determination, default=1.0e-6
        :return: bool indicating whether or not point is within solid
        )rY  r   r  r   r  r  r,   Stater'  	TopAbs_IN	IsOnAFace)r  r  r7  solid_classifiers       r   isInsidezMixin3D.isInside  sx     eV$$ 	$MMOOE6t|DD  ;;;%%''2<7W;K;U;U;W;WWr   Nr   TbasisprofilesdepthtaperupToFacethruAlladditivec           	      n    t          |          }d |D             }	|                     ||	|||||          S )aO  
        Make a prismatic feature (additive or subtractive)

        :param basis: face to perform the operation on
        :param profiles: list of profiles
        :param depth: depth of the cut or extrusion
        :param upToFace: a face to extrude until
        :param thruAll: cut thruAll
        :return: a Solid object
        c                 `    g | ]+}t                               |d          |dd                   ,S r   r   N)r   r  )r   r  s     r   r  z"Mixin3D.dprism.<locals>.<listcomp>  s4    JJJQ##AaD!ABB%00JJJr   )sortWiresByBuildOrderdprism)
r  rg  rh  ri  rj  rk  rl  rm  sorted_profilesr  s
             r   rr  zMixin3D.dprism  sB    , 099JJ/JJJ{{5%x(SSSr   r  c           	      x   | j         }|D ]}	t          ||	j         |r|j         nt                      t          |          |d          }
||
                    |j                    n.|s||
                                 n|
                    |           |
                                }|                     |          S ri  )r  r   rd   r   r  PerformThruAllr  r   )r  rg  r  ri  rj  rk  rl  rm  r  r  feats              r   rr  zMixin3D.dprism"  s     48< 	! 	!D&!&9KMM D #X-.... $EM##%%%%U###JJLLEE~~e$$$r   )r  r  r  )Nr   NTT)r3  r4  r5  r   r:  r   r   r  r   rU  r   r   r`  r?  r   r8  rf  r%   rD  r   r   r=  rr  r   r   r   rF  rF    s       6S 6% 68D> 6c 6 6 6 6""7"7 "7+3E?"7FNtn"7	"7 "7 "7 "7P "/48 888D>*8 8 	8
 +,8 
8 8 8 8v DJX XX$.X;@X	X X X X& 
 !%#'T TT~T t*T ~	T
 T 4.T T T 
T T T [T4 
 !%#'% %%~% Dz% ~	%
 % 4.% % % 
% % % [% % %r   rF  c                      e Zd ZU dZeed<   ededefd            Z	e
dedd fd            Ze
 eddd           eddd	          fd
edededededd fd            Ze
 eddd           eddd	          dfdededededededd fd            Ze
 eddd           eddd	          dfdedededededd fd            Ze
 eddd           eddd	          ddfdededededededd fd            Ze
dQdee         dedd fd            Ze
 eddd           eddd	          fdeded ed!ed"ed#ed$edededd fd%            Ze
 eddd           eddd	          dd&dfdededededed'edd(fd)            Ze
d*ed+ed,edefd-            Zeed.ed/ee         d0ed1ededd fd2                        Ze
ed3e d0ed1ededd f
d4                        Zee	 dRd.ed/ee         d1ed5edd f
d6                        Z!e
e	 dRd3e d1ed5edd fd7                        Z!eed.ed/ee         ded8ed9edd fd:                        Z"e
ed3e ded8ed9edd f
d;                        Z"e#e$e%d<Z&e
d=e'd>e(ee)f         d?e(eee)f         defd@            Z*edAe(e)ef         defdB            Z+ee	 	 	 	 dSd.ed/ee         d>e(ee)f         dFedGed?e(eee)dDf         dHe,d<         dd(fdI                        Z-e
e	 	 	 	 dSd3e d>e(ee)f         dFedGed?e(eee)dDf         dHe,d<         dd(fdJ                        Z-e
	 	 	 dTdKe.e(ee f                  d>e(ee)f         dFedGed?e(eee)dDf         dd fdL            Z/defdMZ0dee         fdNZ1dOe(ed f         de2fdPZ3dDS )Ur   z
    a single solid
    r  r  r  c                     t          | d          rW|                                 dk    s=|                                 dk    r't          |                                           dk    rdS dS )zH
        Returns true if the object is a solid, false otherwise
        r	  r   r   r   TF)hasattrr	  r  r  r
  s    r   isSolidzSolid.isSolidL  s`    
 3$$ 	}}')):--#cjjll2C2Ca2G2Gtur   r`  c                 `     | t                                          |j                            S )z4
        Makes a solid from a single shell.
        )r   SolidFromShellr  )r0  r`  s     r   	makeSolidzSolid.makeSolidX  s*     s>##225=AABBBr   r   r   rP  r  ro  r  r  c           
           | t          t          t          |                                          t          |                                                    |||                                                    S )z
        makeBox(length,width,height,[pnt,dir]) -- Make a box located in pnt with the dimensions (length,width,height)
        By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)
        )rR   r.   r   r$  r  r  )r0  rP  r  ro  r  r  s         r   makeBoxzSolid.makeBox`  sf     svc{{((**F3KK,=,=,?,?@@&%QW egg
 
 	
r   r  radius1radius2r   c                     | t          t          t          |                                          t          |                                                    |||t          |                                                              S )z
        Make a cone with given radii and height
        By default pnt=Vector(0,0,0),
        dir=Vector(0,0,1) and angle=360
        )rS   r.   r   r$  r  r   r  )r0  r  r  ro  r  r  r   s          r   makeConezSolid.makeCones  su     s vc{{((**F3KK,=,=,?,?@@%%  egg
 
 	
r   r  c           
          | t          t          t          |                                          t          |                                                    ||t          |                                                              S )z
        makeCylinder(radius,height,[pnt,dir,angle]) --
        Make a cylinder with a given radius and height
        By default pnt=Vector(0,0,0),dir=Vector(0,0,1) and angle=360
        )rT   r.   r   r$  r  r   r  )r0  r  ro  r  r  r   s         r   makeCylinderzSolid.makeCylinder  sr     s$vc{{((**F3KK,=,=,?,?@@%%	 
 egg
 
 	
r   angleDegrees1angleDegrees2c                 *    | t          t          t          |                                          t          |                                                    ||t          |          t          |                                                              S )z
        makeTorus(radius1,radius2,[pnt,dir,angle1,angle2,angle]) --
        Make a torus with a given radii and angles
        By default pnt=Vector(0,0,0),dir=Vector(0,0,1),angle1=0
        ,angle1=360 and angle=360
        )rU   r.   r   r$  r  r   r  )r0  r  r  r  r  r  r  s          r   	makeToruszSolid.makeTorus  s}      s!vc{{((**F3KK,=,=,?,?@@&&&&  egg
 
 	
r   F
listOfWireruledc                    t          |          dk     rt          d          t          d|          }|D ]}|                    |j                   |                                  | |                                          S )z
        makes a loft from a list of wires
        The wires will be converted into faces when possible-- it is presumed that nobody ever actually
        wants to make an infinitely thin shell for a real FreeCADPart.
        r"   zMore than one wire is requiredT)r  r  r   r  r  r  r  )r0  r  r  loft_builderrb  s        r   makeLoftzSolid.makeLoft  s     z??Q=>>>1$>> 	, 	,A  ++++s<%%''(((r   dxdydzxminzminxmaxzmaxc
                      | t          t          t          |                                          t          |	                                                    |||||||                                                    S )zh
        Make a wedge located in pnt
        By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)
        )rV   r.   r   r$  r  r   )
r0  r  r  r  r  r  r  r  r  r  s
             r   	makeWedgezSolid.makeWedge  sv    $ s!vc{{((**F3KK,=,=,?,?@@	 	 egg
 
 	
r   Z   angleDegrees3r  c                 D    | t          t          t          |                                          t          |                                                    |t          |          t          |          t          |                                                              S )z
        Make a sphere with a given radius
        By default pnt=Vector(0,0,0), dir=Vector(0,0,1), angle1=0, angle2=90 and angle3=360
        )rY   r.   r   r$  r  r   r  )r0  r  r  r  r  r  r  s          r   
makeSpherezSolid.makeSphere  s     s"vc{{((**F3KK,=,=,?,?@@&&&&&&  egg
 
 	
r   r<  spineauxSpinec                     t          |          }|                    |d           |                    |           |                                 |                                 |                                S )z?
        Helper function for extrudeLinearWithRotation
        F)r   SetModer  r  	MakeSolidr  )r0  r<  r  r  extrude_builders        r   _extrudeAuxSpinezSolid._extrudeAuxSpine  sq     6e<<%000D!!!!!###$$&&&r   r  r  	vecCenter	vecNormalc                 >    t          |          }t          |          }t                              ||                    |                    }t                              |g          d         j        d|z  |j        z  }	d}
t                              |	|j        |
||          j         	                    |j                  } fd|D             }t                              |          }  t          ||                                                    S )a  
        Creates a 'twisted prism' by extruding, while simultaneously rotating around the extrusion vector.

        Though the signature may appear to be similar enough to extrudeLinear to merit combining them, the
        construction methods used here are different enough that they should be separate.

        At a high level, the steps followed are:

        (1) accept a set of wires
        (2) create another set of wires like this one, but which are transformed and rotated
        (3) create a ruledSurface between the sets of wires
        (4) create a shell and compute the resulting object

        :param outerWire: the outermost wire
        :param innerWires: a list of inner wires
        :param vecCenter: the center point about which to rotate.  the axis of rotation is defined by
            vecNormal, located at vecCenter.
        :param vecNormal: a vector along which to extrude the wires
        :param angleDegrees: the angle to rotate through while extruding
        :return: a Solid object
        r   r   r   )r  r  c                 H    g | ]}                     |j                  S r   )r  r  )r   rb  aux_spine_wr0  straight_spine_ws     r   r  z3Solid.extrudeLinearWithRotation.<locals>.<listcomp>I  s>     
 
 
   ,<kJJ
 
 
r   )r   r   rF  r  r   rS  r  r  r|  r  r   _makeCompoundrw   r  )r0  r  r  r  r  r   
vecNormal_
vecCenter_straight_spine_ern  r  outer_solidinner_solids
inner_compr  r  s   `             @@r   extrudeLinearWithRotationzSolid.extrudeLinearWithRotation  s8   @ I&&
I&&
  ==Z^^J5O5OPP<<)9(;<<Q?G $z'88nn:$fZZ % 
 

 	
 **/
 


 
 
 
 
 

 
 
 ++L99
 s?;
;;AACCDDDr   r  c                 |    |                      |                                |                                |||          S r  )r  r  r  )r0  r  r  r  r   s        r   r  zSolid.extrudeLinearWithRotationT  s;     ,,NNdoo//I|
 
 	
r   rj  c                     |dk    rt                               ||          }nt                               |          }|                     |||          S )a  
        Attempt to extrude the list of wires into a prismatic solid in the provided direction

        :param outerWire: the outermost wire
        :param innerWires: a list of inner wires
        :param vecNormal: a vector along which to extrude the wires
        :param taper: taper angle, default=0
        :return: a Solid object

        The wires must not intersect

        Extruding wires is very non-trivial.  Nested wires imply very different geometry, and
        there are many geometries that are invalid. In general, the following conditions must be met:

        * all wires must be closed
        * there cannot be any intersecting or self-intersecting wires
        * wires must be listed from outside in
        * more than one levels of nesting is not supported reliably

        This method will attempt to sort the wires, but there is much work remaining to make this method
        reliable.
        r   )r   r  extrudeLinear)r0  r  r  r  rj  r  s         r   r  zSolid.extrudeLinearb  sP    @ A::%%i<<DD%%i00D  y%888r   c           	         t          |          }|dk    rt          |j        |j        d          }n|                                }|                    |          t          d          k     rdnd}t          |j        ||j        z  t          t          |                    z  |t          |          z            } | |	                                          S )Nr   Tr  r   r  )
r   rW   r  r  getAngler   r   r  r   r  )r0  r  r  rj  r  prism_builder
faceNormalr\  s           r   r  zSolid.extrudeLinear  s     I&&
A::!6j0$" "MM J((44wt}}DD"A *Z&&#genn*=*==GENN" M s=&&(()))r   	axisStartaxisEndc                 h    t                               ||          }|                     ||||          S )a  
        Attempt to revolve the list of wires into a solid in the provided direction

        :param outerWire: the outermost wire
        :param innerWires: a list of inner wires
        :param angleDegrees: the angle to revolve through.
        :type angleDegrees: float, anything less than 360 degrees will leave the shape open
        :param axisStart: the start point of the axis of rotation
        :param axisEnd: the end point of the axis of rotation
        :return: a Solid object

        The wires must not intersect

        * all wires must be closed
        * there cannot be any intersecting or self-intersecting wires
        * wires must be listed from outside in
        * more than one levels of nesting is not supported reliably
        * the wire(s) that you're revolving cannot be centered

        This method will attempt to sort the wires, but there is much work remaining to make this method
        reliable.
        )r   r  revolve)r0  r  r  r   r  r  r  s          r   r  zSolid.revolve  s2    @ !!)Z88{{4y'BBBr   c                 .   t          |          }t          |          }||z
  }t          |j        t          |                                |                                          t          |          d          } | |                                          S r  )r   rX   r  r-   r$  r  r   r  )r0  r  r   r  r  r=  r>  revol_builders           r   r  zSolid.revolve  s     IG__"W-L&RXXZZ88',:O:OQU
 
 s=&&(()))r   )transformedroundrightrQ  pathr]  c                    d}t          |t                    rt                      }|                    |                                                                           |                    |                                           |                    |           d}nJt          |t          t          f          r.|                    |                     |          j        d           |S )NFT)rY  r   r.   SetLocationr  r$  SetDirectionr  r  r   r   _toWirer  )r0  rQ  r  r]  r%  axs         r   _setSweepModezSolid._setSweepMode  s     dF## 	=BNN4??,,2244555OODJJLL)))OOBFFtTl++ 	=OOCKK--5t<<<r   r  c                 l    t          | t                    rt                              | g          }n| }|S r  )rY  r   r   r  )r  r  s     r   r  zSolid._toWire  s7     a 	##QD))BBB	r   TNr  r}  isFrenettransitionModec                 Z   |                      |          }g }	|g|z   D ]}
t          |j                  }d}d}|r|                     |||          }n|                    |           |                    | j        |                    |                    |
j        ||           |                                 |r|	                                 |	
                    t                              |                                                     |	d         |	dd         }}|r
 |j        | }|S )a  
        Attempt to sweep the list of wires into a prismatic solid along the provided path

        :param outerWire: the outermost wire
        :param innerWires: a list of inner wires
        :param path: The wire to sweep the face resulting from the wires over
        :param makeSolid: return Solid or Shell (default True)
        :param isFrenet: Frenet mode (default False)
        :param mode: additional sweep mode parameters
        :param transitionMode:
            handling of profile orientation at C1 path discontinuities.
            Possible values are {'transformed','round', 'right'} (default: 'right').
        :return: a Solid object
        Fr   r   N)r  r   r  r  r  SetTransitionMode_transModeDictr  r  r  r  r  r   r|  )r0  r  r  r  r}  r  r]  r  r  r  rb  rQ  r)  r%  r  inner_shapess                   r   sweepzSolid.sweep  s2   4 KKz) 	7 	7A1!)<<GIF  ***7D$??)))%%c&8&HIIIKK	9f555MMOOO $!!###MM%**W]]__556666!!9fQRRjL 	'&B	r   c           	          |                      |                                |                                |||||          S r  )r  r  r  )r0  r  r  r}  r  r]  r  s          r   r  zSolid.sweep4  sC     yyNNOO
 
 	
r   rh  c                 0   t          |t                    r!t                              |g          j        }n|j        }t          |          }d}d}	|r|                     |||          }	n|                    |           |D ]N}
t          |
t                    r|
j        n|
                                j        }|	                    |||	           O|
                                 |r|                                  | |                                          S )a(  
        Multi section sweep. Only single outer profile per section is allowed.

        :param profiles: list of profiles
        :param path: The wire to sweep the face resulting from the wires over
        :param mode: additional sweep mode parameters.
        :return: a Solid object
        F)rY  r   r   r  r  r   r  r  r  r  r  r  r  )r0  rh  r  r}  r  r]  rb  rQ  r)  r%  r  s              r   sweep_multizSolid.sweep_multiJ  s   " dD!! 	""D7++3AAA-a00	 	&&&wd;;FFOOH%%% 	. 	.A'400K		akkmm6KAKK9f---- 	 s7==??###r   c                 N    t          t          j        | j                            S )z&
        Returns outer shell.
        )r   r   OuterShell_sr  r`  s    r   
outerShellzSolid.outerShellu  s    
 [-dl;;<<<r   c                 l    |                                  fd|                                 D             S )z'
        Returns inner shells.
        c                 >    g | ]}|                               |S r   r  )r   rP  r  s     r   r  z%Solid.innerShells.<locals>.<listcomp>  s(    @@@a@@@@r   )r  r  r  s    @r   innerShellszSolid.innerShells|  s6    
 !!@@@@4;;==@@@@r   r  c                 |   t          | j                  }|D ]J}|                    t          |t                    r|j        n|                                j                   Kt          |                                          }|                                 | 	                    |                                          S )z+
        Add one or more cavities.
        )
rM   r  r  rY  r   r  r   r   r  r   )r  r  rQ  shr  s        r   	addCavityzSolid.addCavity  s    
 +4<88  	 	BKK(U33P

9P   
 GMMOO,,


~~bhhjj)))r   r0  r  )TFNr  )TFN)4r3  r4  r5  r6  rg   r7  r<  r  r8  rz  r9  r   r}  r   r:  r   r  r  r  r  r   r   r  r  r  rc   r_   r  r'   r%   r=  r  r   r  r  rJ   rL   rK   r  r   r   r   r  r  r   r  r   r  r  r  r   r  r   r   r   r   r   E  s	          	U 	t 	 	 	 \	 Ce C C C C [C  !&Aq// &Aq//
 

 
 	

 
 
 

 
 
 [
$  !&Aq// &Aq//!
 

 
 	

 
 
 
 

 
 
 [
0 
 !&Aq// &Aq//!
 

 
 	

 
 
 

 
 
 [
, 
 !&Aq// &Aq// "
 

 
 	

 
 
 
 

 
 
 [
2 ) )$t* )T )g ) ) ) [)$  !&Aq// &Aq//
 

 
 	

 
 
 
 
 
 
 

 
 
 [
<  !&Aq// &Aq// !"
 

 
 	

 
 
 
 

 
 
 [
. '''2'>I'	' ' ' [' ;E;E J;E 	;E
 ;E ;E 
;E ;E ;E [ _;Ez 



 

 	


 

 


 

 

 [ [

  #9 #9#9 J#9 	#9
 #9 
#9 #9 #9 [ _#9J >?* **$.*7;*	* * * [ [*.  C C J C 	 C
  C  C 
 C  C  C [ _ CD **'+*8B*MW*	* * * [ [* 2++ N , D$J FD$&'	
 
   [( 5t$     \  04CP6 66 J6 D$J	6
 6 6 FD$,-6   ?@6 
6 6 6 [ _6p 
 04CP
 

 D$J
 	

 
 FD$,-
   ?@
 

 
 
 [ [
( 
 04($ ($5t,-($ D$J($ 	($
 ($ FD$,-($ 
($ ($ ($ [($T=E = = = =AT%[ A A A A*ug~!6 *4 * * * * * *r   c                       e Zd ZU dZeed<   dS )r   z
    a single compsolid
    r  N)r3  r4  r5  r6  ri   r7  r   r   r   r   r     s*           r   c                      e Zd ZU dZeed<   edee         defd            Z	de
fdZedee
         dd fd            Zed	d
ddd ej                    fdededededee         ded         ded         ded         deddfd            ZdefdZd
ddddee         dd fdZd d
d!d"e
d#edee         dd fd$Zd
dd%ddee         dd fd&Zdddedd fd'Zd+ddded)edd fd*Zd
S ),r   z-
    a collection of disconnected solids
    r  listOfShapesr  c                     t                      }t                      }|                    |           | D ]}|                    ||           |S r  )ra   r`   MakeCompoundr  )r  compcomp_builderrP  s       r   r  zCompound._makeCompound  s[       %''!!$''' 	& 	&AT1%%%%r   r  c                 l    t                      }|D ]"}|                    | j        |j                   #dS )z.
        Remove the specified shapes.
        N)r`   r.  r  )r  r  r  rP  s       r   r/  zCompound.remove  sE    
 &'' 	9 	9Aai8888	9 	9r   c                 R     | |                      d |D                                 S )z;
        Create a compound out of a list of shapes
        c              3   $   K   | ]}|j         V  d S r  rJ  r  s     r   r  z(Compound.makeCompound.<locals>.<genexpr>  s$      %F%FAai%F%F%F%F%F%Fr   )r  )r0  r  s     r   r   zCompound.makeCompound  s1     s3$$%F%F%F%F%FGGHHHr   ArialNregularr  textsizero  fontfontPathr  r  bolditalichalignr  leftr  valignr  topbottompositionr  c
                    t           t          t          d|         }
t          j                    }|r|                    t          |                                                    rVt          t          |                    }|	                    |
t          |                     |
                    |d           n#|                    t          |          |
          }t                      }t          t          |                                                                          |
t!          |                    }|dk    rt"          }n|dk    rt$          }nt&          }|dk    rt(          }n|dk    rt*          }nt,          }t/          |                    |t          |          ||                    }|dk    r|                                d                                         |z  }t7          |j        |j                  } | |                                                              |	j                  }n|                    |	j                  }|S )z"
        Create a 3D text
        r  Tr  r  r  	theHAlign	theVAlignr   )r   r   r   r   GetInstance_s	CheckFontr   	ToCStringr   SetFontPathRegisterFontFindFontFont_BRepTextBuilderr   r   FontNamer:  r   r   r   r   r   r   r  r  r  r  rW   r  r6  rG)r0  r  r  ro  r  r  r  r  r  r  	font_kindmgrfont_trQ  font_ir  r  	text_flatr  text_3dr  s                        r   makeTextzCompound.makeText  s-   $ ' $
 
 		 (** 	L&=h&G&G&Q&Q&S&STT 	L$%<X%F%FGGFy*A(*K*KLLLVT**** \\"9$"?"?KKF&(( "6??#4#4#>#>#@#@AA$KK
 

 V*IIx,II+IX,IIx,II)IOO&t,,##	   
 
	 Q;;!))!,5577&@I+I,=y?PQQGW]]__%%44X[AABB))(+66B	r   c                 N    t          | j                                                  S )z!
        Check if empty.
        )rb   r  r  r`  s    r   __bool__zCompound.__bool__  s     
 t|,,11333r   ro  rv  rp  c                    t                      }|r|                    |           t          t          |                     | ||                    S rx  )rw   ry  r\  r   ru  rz  s       r   r|  zCompound.cut  sK     !"" 	&  %%%Xt}}T5&AABBBr   Fr}  r  r~  c                b   t                      }|r|                    t          j                   |r|                    |           t          |           |z   }t          |          dk    r	|d         }n'|                     |dd         |dd         |          }t          t          |          S )z&
        Fuse shapes together
        r   r   N)
rv   r  r   r  ry  r~  r  ru  r\  r   )r  r~  rp  r  r  rk  r  s          r   r  zCompound.fuse#  s     #$$ 	@OO,>??? 	'!!#&&&T{{V#t99>>QBBtBQBxabb7;;B
 Xr"""r   r  c                    t                      }|r|                    |           t          t          |                     | ||                    S r  )ru   ry  r\  r   ru  r  s       r   r  zCompound.intersect<  sK     *++ 	,&&s+++Xt}}T;MMNNNr   c                     t                      t          d | D                       }|D ])}t          j        |j        |t
          |                    *t                              fd| D                       S )zo
        Iterate over ancestors, i.e. shapes of same kind within shape that contain elements of self.

        c              3   >   K   | ]}t          |j                  V  d S r  r  r  r   chs     r   r  z%Compound.ancestors.<locals>.<genexpr>S  ,      >>22:..>>>>>>r   c              3      K   | ];}                     |j                  D ]}t                              |          V  <d S r  )r  r  r  r   )r   rP  r  r  s      r   r  z%Compound.ancestors.<locals>.<genexpr>Z  sb       %
 %
1F1Fqy1Q1Q%
 %
,-EJJqMM%
 %
 %
 %
 %
 %
 %
r   )r   r
  r[   r  r  r  r   r   )r  r  r  
shapetypesr3  r  s        @r   r  zCompound.ancestorsL  s     >??	>>>>>>>
 	 	A*q"3D"99    $$ %
 %
 %
 %
#'%
 %
 %
 
 
 	
r   r   r   c                 $   t                      t          d | D                       }|D ])}t          j        |j        t
                   |           *t                      fdt                               | |                    S )zz
        Iterate over siblings, i.e. shapes within shape that share subshapes of kind with the elements of self.

        c              3   >   K   | ]}t          |j                  V  d S r  r  r  s     r   r  z$Compound.siblings.<locals>.<genexpr>e  r  r   c                     t                      }| D ]}                    |j                   | D ]7}|                    fd|                              D                        8|dk    r|n ||dz
            S )Nc              3      K   | ]K}                     |          D ]3}                    |          t                              |          V  4Ld S r  r  r  s      r   r  z7Compound.siblings.<locals>._siblings.<locals>.<genexpr>v  r  r   r   r	  r  s       r   r  z$Compound.siblings.<locals>._siblingsn  s    B ' 'AI&&&&  		     !"T!2!2       !222uqy)A)AAr   )	r   r
  r[   r  r  r  r   r   r   )	r  r  r  r   r  r3  r  r  r  s	     `   @@@r   r  zCompound.siblings^  s     >??	>>>>>>>
 	 	A*069    &''	B 	B 	B 	B 	B 	B 	B 	B" $$YYtU%;%;<<<r   r2  )r3  r4  r5  r6  ra   r7  r<  r   r_   r  r  r/  r9  r   r   rt  rZ  r:  r   r   r
  r8  r  r|  r  r  r    r  r;  r  r   r   r   r   r     s          	H\$: 	 	 	 	 \	9U 9 9 9 9 I IJ I I I [I  "&5>5=5="%(**E EE E 	E
 E 3-E 12E 12E 12E E 
E E E [EN4$ 4 4 4 4 ;? C C C' C C: C C C C ,1# # ##$(#7?#	# # # #4 =AO O O#O*25/O	O O O O 
w 
f 
 
 
 
 
$!= !=g !=V !=C !=
 != != != != != !=r   wireListc                 0   t          |           dk     r| gS t                              | d         | dd                   }g }|                                D ]?}|                    |                                g|                                z              @|S )a  Tries to determine how wires should be combined into faces.

    Assume:
        The wires make up one or more faces, which could have 'holes'
        Outer wires are listed ahead of inner wires
        there are no wires inside wires inside wires
        ( IE, islands -- we can deal with that later on )
        none of the wires are construction wires

    Compute:
        one or more sets of wires, with the outer wire listed first, and inner
        ones

    Returns, list of lists.
    r"   r   r   N)r  r   r  r  r  r  r  )r  r  r  r  s       r   rq  rq    s    $ 8}}q
 	

 x{HQRRL99E	B ; ;
		4>>##%(9(99::::Ir   c                 x    t                               | d         | dd                                                   S )z+
    Convert wires to a list of faces.
    r   r   N)r   r  r  )r  s    r   wiresToFacesr    s2    
 hqk8ABB<88>>@@@r   r
  rp  c                     t                      }t                      }| D ]}|                    |j                   t          j        ||d|           d |D             S )z+
    Convert edges to a list of wires.
    Fc                 ,    g | ]}t          |          S r   r  r  s     r   r  z edgesToWires.<locals>.<listcomp>  s    )))DHH)))r   )r   ro  r  r   rX  )r
  rp  rY  rZ  r  s        r   edgesToWiresr"    sk    
 )**H)++I # #	""""28S%SSS))y))))r   rP  ts.c              #   >  K   t          |t                    r|}n|f}|                                 }||v r| V  dS |dk    rH| D ]C}|                                |v r|V  t          d| d|                                           dS t          d| d|           )z/
    Get desired shapes or raise an error.
    r   Required type(s): ; encountered NrY  r~  r	  r  )rP  r#  typesr3  r  s        r   _getr)    s       "e  	
AEzz	
j 	 	B||~~## NNNbllnnNN  		 	 FeFF1FFGGGr   c                 4   t          |t                    r|}n|f}|                                 }||v r| }na|dk    rF| D ]B}|                                |v r|} n't          d| d|                                           nt          d| d|           |S )z*
    Get one shape or raise an error.
    r   r%  z, encountered r&  r'  )rP  r#  r(  r3  r  r  s         r   _get_oner+    s     "e  	
AEzz	
j 	 	B||~~## NNNbllnnNN   FeFF1FFGGGIr   c                     t          | d          }t          |t                    r|S t                              |f          S )z3
    Get one wire or edge and convert to wire.
    )r   r   )r+  rY  r   r  rP  r  s     r   _get_one_wirer.    sA    
 
!%	&	&B"d )	!!2%(((r   c              #     K   |                                  }|dk    r| V  dS |dk    r2t                              t          t          |           f          V  dS |dk    r| D ]}t          |          E d{V  dS t          d|           )z(
    Get wires or wires from edges.
    r   r   r   N*Required type(s): Edge, Wire; encountered )r	  r   r  r\  r   
_get_wiresr  )rP  r3  r  s      r   r1  r1    s      
 	
AF{{	
f  %a..!23333333	
j 	& 	&B!"~~%%%%%%%%	& 	& IaIIJJJr   r  c               '     K   | D ]}|                                 }|dk    r|V  !|dk    r(t          |                                          E d{V  O|dk    r|D ]}t          |          E d{V  pt          d|           dS )z(
    Get edges or edges from wires.
    r   r   Nr   r0  )r	  
_get_edgesr
  r  )r  rP  r3  r  s       r   r3  r3    s      
  O OKKMM;;GGGG&[[!!'')),,,,,,,,,,*__ * *%b>>))))))))* M!MMNNNO Or   c                    g }t          |           dz
  }t          |           D ]\  }}|dk    rN	 d t          |          D             }n.# t          $ r! d |                                D             }Y nw xY w|s nȌZ||k    r	 t          |t          |                    D ]\  }}|                    |           # t          $ r@ t          ||                                          D ]\  }}|                    |           Y w xY wt          |t          |                    D ]\  }}|                    |           !|S )z5
    Get lists of wires for sweeping or lofting.
    r   r   c                     g | ]}|gS r   r   r   rb  s     r   r  z#_get_wire_lists.<locals>.<listcomp>8  s    :::aqc:::r   c                     g | ]}|gS r   r   r  s     r   r  z#_get_wire_lists.<locals>.<listcomp>;      999aqc999r   )r  r   r1  r  r  r  r  )rP  
wire_listsix_lastr  r  	wire_listrb  r   s           r   _get_wire_listsr<  +  s   
 35J!ffqjG1 $ $266::::b>>:::

 : : :992;;==999


:
   '\\($'
JrNN$C$C ( (LIq$$Q''''( ( ( ($'
BKKMM$B$B ( (LIq$$Q''''( ((
 !$J
2 ? ? $ $	1  ####$ s$   A(A65A68B>>ADDc                    g }t          |           dz
  }t          |           D ]a\  }}|dk    rd t          |          D             }|s n:)t          |t          |                    D ]\  }}|                    |           b|S )z*
    Get lists of wires for sweeping.
    r   r   c                     g | ]}|gS r   r   r6  s     r   r  z*_get_wire_lists_strict.<locals>.<listcomp>]  s    666!1#666r   )r  r   r1  r  r  )rP  r9  r:  r  r  r;  rb  s          r   _get_wire_lists_strictr?  Q  s    
 $&J!ffqjG1 $ $26666z"~~666J   !$J
2 ? ? $ $	1  ####$ r   c                    g }t          |           dz
  }t          |           D ]E\  }}|dk    rWd |                                D             }|s2|                                sd |                                D             }|s nc||k    r|                                }t          |          t          |          k    r,t          ||          D ]\  }}|                    |           t          ||                                          D ]\  }}|                    |           t          ||                                          D ]\  }}|                    |           Gt          d |D                       rg S |S )z[
    Get lists of faces for sweeping or lofting. First and last shape can be a vertex.
    r   r   c                     g | ]}|gS r   r   r   rI  s     r   r  z#_get_face_lists.<locals>.<listcomp>v      222!1#222r   c                     g | ]}|gS r   r   r  s     r   r  z#_get_face_lists.<locals>.<listcomp>z  r8  r   c              3      K   | ]:}t          |d          t                    ot          |d         t                    V  ;dS rp  )rY  r   r  s     r   r  z"_get_face_lists.<locals>.<genexpr>  sT        DF
2a5&!!?jA&?&?     r   )r  r   r  r
  r  r  r  any)	rP  
face_listsr:  r  r  r  	face_listrI  r   s	            r   _get_face_listsrI  j  s   
 35J!ffqjG1 $ $26622rxxzz222J  :bhhjj :992;;==999
   '\\ HHJJE5zzS__,,$'
E$:$: ( (LIq$$Q''''( %(
BKKMM$B$B ( (LIq$$Q''''( !$J

 ; ; $ $	1  ####$   JT      	r   c                 $   g }t          |           dz
  }t          |           D ]k\  }}|dk    r#d |                                D             }|s n?.t          ||                                          D ]\  }}|                    |           l|S )zC
    Get lists of faces for sweeping. No vertices are allowed.
    r   r   c                     g | ]}|gS r   r   rB  s     r   r  z*_get_face_lists_strict.<locals>.<listcomp>  rC  r   )r  r   r  r  r  )rP  rG  r:  r  r  rH  rI  s          r   _get_face_lists_strictrL    s    
 $&J!ffqjG1 $ $26622rxxzz222J   !$J

 ; ; $ $	1  ####$ r   c                 0   |                                  }| }|dk    rI|                                 }t          |          dk    r!t          j        | j                  s|d         }n0|dk    r*t          |           }t          |          dk    r|d         }|S )z}
    Apply some normalizations:
    - Shell with only one Face -> Face.
    - Compound with only one element -> element.
    r   r   r   r   )r	  r  r  r\   r  r  r  )rP  r3  r  r  r  s        r   
_normalizerN    s     	
A	
BG||		u::??9#7	#B#B?qB	
jAwwt99>>aBIr   c                 J   t          | t                    r(t          t                              |                     }net          |           dk    r.t          t                              | d                             }n$t                              d | D                       }|S )zB
    Convert a list of TopoDS_Shape to a Shape or a Compound.
    r   r   c                 \    g | ])}t          t                              |                    *S r   rN  r  r   r  s     r   r  z&_compound_or_shape.<locals>.<listcomp>  s*    #K#K#K2Juzz"~~$>$>#K#K#Kr   )rY  r_   rN  r  r   r  r   r   r-  s     r   rZ  rZ    s    
 !\"" M

1&&	Q1

1Q4(())""#K#K#K#K#KLLIr   r  c                     t          dt          |                     }t          |           D ]=\  }}|                    |dz   t	          |                                                     >|S )zJ
    Convert a sequence of Vector to a TColgp harray (OCCT specific).
    r   )r7   r  r   r!  r   r$  r  r  r  r  s       r   _pts_to_harrayrT    sb    
 
QC	)	)B# . .1
AE6!99??,,----Ir   c                     t          dt          |                     }t          |           D ]%\  }}|                    |dz   t	          |            &|S )zM
    Convert a sequence of 2d points to a TColgp harray (OCCT specific).
    r   )r:   r  r   r!  r4   rS  s       r   _pts_to_harray2DrV    sV    
 
q#c((	+	+B# ) )1
AE8Q<((((Ir   valsc                     t          dt          |                     }t          |           D ]\  }}|                    |dz   |           |S )zK
    Convert a sequence of floats to a TColstd harray (OCCT specific).
    r   )r=   r  r   r!  )rW  r  r  vals       r   _floats_to_harrayrZ    sR    
 
q#d))	,	,BD//    3
AE3Ir   c                 `    t                      }| D ]}|                    |j                   |S )zJ
    Convert an iterable of Shape to a TopTools list (OCCT specific).
    )r   ro  r  )rP  r  r  s      r   _shapes_to_toptools_listr\    s:    
 
		B  
		"*Ir   tlc                     d | D             S )z@
    Convert a TopTools list (OCCT specific) to a compound.
    c                 \    g | ])}t          t                              |                    *S r   rQ  r  s     r   r  z,_toptools_list_to_shapes.<locals>.<listcomp>  s*    4442Juzz"~~&&444r   r   )r]  s    r   _toptools_list_to_shapesr`    s    
 544444r   )C0C1C2C3CNG1G2namec                 @    t           |                                          S )zB
    Convert a literal to GeomAbs_Shape enum (OCCT specific).
    )_geomabsshape_dictupperrh  s    r   _to_geomabshaperm    s    
 djjll++r   )uniformchordalcentripetalc                 @    t           |                                          S )zO
    Convert a literal to Approx_ParametrizationType enum (OCCT specific).
    )_parametrization_dictlowerrl  s    r   _to_parametrizationrt  -  s    
 !..r   r  r0  r1  c                 r   t           }|                                 }||j        k    r%t          |                                 ||          }nY||j        k    r%t          |                                 ||          }n)||j        k    r$t          |                                 ||          }n||j	        k    r$t          | 
                                ||          }n||j        k    r$t          |                                 ||          }n||j        k    r$t          |                                 ||          }nm||j        k    r$t          |                                 ||          }n>||j        k    r$t          |                                 ||          }nt'          d          |                                S )Nz!{t} is not a supported curve type)r   r[  GeomAbs_BSplineCurverB   BSplineGeomAbs_BezierCurveBezierGeomAbs_Circler  GeomAbs_LineLineGeomAbs_Ellipser  GeomAbs_Hyperbola	HyperbolaGeomAbs_ParabolaParabolaGeomAbs_OffsetCurveOffsetCurver  r   )r  r0  r1  GCTr3  r  s         r   r-  r-  5  s{   
CAC$$$&s{{}}b"==	
c%	%	%&szz||R<<	
c 	 	 &szz||R<<	
c		&sxxzz2r::	
c!	!	!&s{{}}b"==	
c#	#	#&s}}B??	
c"	"	"&s||~~r2>>	
c%	%	%&s'8'8"bAA=>>>99;;r   Fbaser  c                 X   t          | d          }t          t          |          ||          }|                                 t	          |                                |                                                                          }t          j	        |           t          |          S )z=
    Build an edge on a face from points in (u,v) space.
    r   )r+  r   rV  r  rB   r  r[  r   r   ru  rZ  )r  r  r  rp  rI  spline_bldrr  s          r   edgeOnr  V  s     	vA ((8(=(=xMMK 
!!2!2!4!4ann6F6F	G	G	L	L	N	NBBb!!!r      rp  Nfbaseedgedgsr  c                   t          | d          }g }t          |g|R  D ]}|                    |          \  }}	d |D             }
|                                \  }}|                                }d}|                                rA|                                r-d}|	                    ||                                z              nD|                                r0|
                    |
d                    |	                    |           t          t          |
          t          |	          ||          }|                                 t          |                                |                                                                          }t!          j        |           |                    |           t%          |          S )zB
    Map one or more edges onto a base face in the u,v space.
    r   c                 *    g | ]}|j         |j        fS r   )rF  rG  r  s     r   r  zedgeOn.<locals>.<listcomp>  s     ,,,bd|,,,r   FTr   )r+  r3  r  r{  r[  
IsPeriodicr  r  Periodr   rV  rZ  r  rB   r  r   r   ru  rZ  )r  r  rp  r  r  rI  rvsr  pts3Dr  r  t0r(  el_crvr  r  r  s                    r   r  r  n  s    	A C$t$$$ " " 		!v -,e,,, B""  	6??#4#4 	HMM"v}}.//// __ 	JJs1vMM" ,S!!#4V#<#<h
 
 	 %[%6%6%8%8!..:J:JKKPPRR###

2c"""r   rb  c                 j      fd|                                 D             }t          |          S )z7
    Map a wire onto a base face in the u,v space.
    c                 6    g | ]}t          |           S )r  )r  )r   r  r  r  rp  s     r   r  zwireOn.<locals>.<listcomp>  s*    
<
<
<Q6$sa(((
<
<
<r   )r  r<  )r  rb  rp  r  r  s   ` `` r   wireOnr    s:    
 =
<
<
<
<
<!''))
<
<
<C99r   c                      t                      }t          d | D                       }|                    |           t          |                                          S )z 
    Build wire from edges.
    c              3   >   K   | ]}t          |          D ]}|V  d S r  )r3  )r   r  r  s      r   r  zwire.<locals>.<genexpr>  s5      $K$K2JrNN$K$KqQ$K$K$K$K$K$K$Kr   )rE   r\  r  rZ  r  )rP  rQ  r
  s      r   r<  r<    sS     &''G$$K$K$K$K$KKKEKKgmmoo...r   c                     t          |  S r  )r<  rP  s    r   r<  r<    s     8Or   c                     ddl m} t                              d | D                       j        }t                      }|                    ||          }|st          d          t          t          |          d          S )z)
    Build face from edges or wires.
    r   )BOPAlgo_Toolsc              3   >   K   | ]}t          |          D ]}|V  d S r  )r1  )r   r  rb  s      r   r  zface.<locals>.<genexpr>  s5      EERjnnEEqEEEEEEEr   zFace construction failedr   )
OCP.BOPAlgor  r   r   r  ra   WiresToFaces_sr  r+  rZ  )rP  r  r  r  statuss        r   r  r    s     *)))))			EE1EEE	E	E	MB			B))"b11F 53444&r**F333r   c                     t          |  S )z7
    Build face from a sequence of edges or wires.
    )r  r  s    r   r  r    s     8Or   fcsc                   g }t          | d          |D ]}|                                D ]y}|                     j        t	          t
          t          |                                                    gfd|                                D             R             zt          |          dk    r	|d         }nt          |          }|S )zW
    Build face(s) on base by mapping planar face(s) onto the (u,v) space of base.
    r   r  c           
   3   d   K   | ]*}t          t          t          |                     V  +dS )r  N)r\  r   r  )r   rb  r  r  rp  s     r   r  zfaceOn.<locals>.<genexpr>  sR         dF5!$B$B$BCC     r   r   r   )r+  r  r  r  r\  r   r  r  r  r  r)  )	r  rp  r  r  r  r  fcr  r  s	    ``     @r   faceOnr    s
    C T6""E   ((** 
	 
	BJJ
$ubllnn# K K KLL     !#       
	 3xx1}}Vc]]Ir   rQ  r  historyc                    ||                                 D ]D\  }}t          |t                    r*t          |                     |j                            ||<   E|D ].}t          |                     |j                            ||<   -dS dS )z8
    Reusable helper for processing sewing history.
    N)itemsrY  rZ  r   Modifiedr  )rQ  r  r  r   r   rI  s         r   _process_sewing_historyr    s     MMOO 	? 	?DAq!S!! ?!'"2"219"="=>>
  	; 	;Ag..qy99::GAJJ 	; 	;r   Trp  manifoldctxr  r  r  c                    t          | |           }|rWt          |t                    r|                    |j                   n'|                    t          |          j                   g }|D ]D}t          |d          D ]1}|                    |j                   |                    |           2E|	                                 |
                                }	t          |||           |	                                t          j        k    rHt                      }
t!                      }|                    |
           |                    |
|	           n|	}
t%          |
          S )zQ
    Build shell from faces. If ctx is specified, local sewing is performed.
    )option4r   )rF   rY  r  r"  r  r)  r)  r  r  r  rA  r  r	  r   r+  rh   r`   	MakeShellrZ  )rp  r  r  r  rP  rQ  r  r  rI  sewedr  builder_topos               r   r`  r`    sa    $CX>>>G
 0c5!! 	0LL%%%%LL#.///E  b&!! 	 	AKK	"""LLOOOO	 OO  EGUG444
 ,888^^%''r"""U#### b!!!r   c                      t          | ||||dS )z_
    Build shell from a sequence of faces. If ctx is specified, local sewing is performed.
    r  )r`  )rP  rp  r  r  r  s        r   r`  r`  =  s     !xS'JJJJr   rp  r  r]  snc          	         	 t                      	| g|}d |D             }d |D             }|s2d |D             }t          t          t          |||dj                  g}	fd|D             }t          |          S )z+
    Build solid from faces or shells.
    c                 8    g | ]}t          |d           D ]}|S ))r   r   )r)  )r   r  rI  s      r   r  zsolid.<locals>.<listcomp>X  s0    GGG"44E+F+FGGaAGGGGr   c                 F    g | ]}t          |t                    |j        S r   )rY  r   r  r  s     r   r  zsolid.<locals>.<listcomp>[  s)    IIIR:b%3H3HIbjIIIr   c                 <    g | ]}t          |t                    |S r   )rY  r   r  s     r   r  zsolid.<locals>.<listcomp>]  s'    CCCjT.B.BCCCCr   r  c                 :    g | ]}                     |          S r   )r|  )r   r  rQ  s     r   r  zsolid.<locals>.<listcomp>`  s'    
7
7
7"7!!"%%
7
7
7r   )r   r\  rh   r`  r  rZ  )
r]  rp  r  r  rP  shells_facesr  r  r  rQ  s
            @r   solidr  L  s     G 
	b	AGGGGGL JI<IIIF XCClCCCeUW&M&M&M&UVVW
7
7
7
7
7
7
7Cc"""r   r  c           
         t                      }|                    t          t          | ||dd          j                   |r8t          t          |||dd          D ]}|                    |j                   t          |                                          }|                                 t          |                                          S )z/
    Build solid from a sequence of faces.
    r  r   )
rM   r  r+  r`  r  r)  r   r   r  rZ  )rP  r  rp  r  rQ  r  r  s          r   r  r  e  s     '((GKKsG<<<gFFNOOO $ueg>>>HH 	$ 	$BKK
#### 
	(	(BJJLLLbhhjj)))r   c                      t                      }t                      }|                    |           | D ]}|                    ||j                   t          |          S )z%
    Build compound from shapes.
    )ra   r`   r  r  r  r   )rP  r  rQ  r  s       r   r)  r)  ~  sb     
		BG $ $B
####B<<r   c                     t          |  S )z3
    Build compound from a sequence of shapes.
    )r)  r  s    r   r)  r)    s     Q<r   rF  rG  rH  c           	      |    t          t          t          | ||                                                              S )z.
    Construct a vertex from coordinates.
    )rZ  rA   r,   r   )rF  rG  rH  s      r   vertexr    s1     7q!QHHOOQQRRRr   r  c                     t          t          t          |                                                                                               S )z-
    Construct a vertex from VectorLike.
    )rZ  rA   r   r$  r   )r  s    r   r  r    s7     7q		8I8IJJQQSSTTTr   c                     t          t          t          |                                           t          |                                                                                              S )z.
    Construct a segment from two points.
    )rZ  rB   r   r$  r   )r0  r1  s     r   segmentr    sS    
 r

 0 0 2 2F2JJ4D4D4F4FGGLLNN  r   c                      t                      }| D ]6}|                    t          |                                                     7t	          |                                          S )z+
    Construct a polyline from points.
    )rD   r  r   r$  rZ  r   r  rQ  r  s      r   polyliner    sY    
 )**G ' 'F1IIOO%%&&&&gllnn---r   c                      t                      }| D ]6}|                    t          |                                                     7|                                 t          |                                          S )z<
    Construct a polygon (closed polyline) from points.
    )rD   r  r   r$  rl  rZ  r   r  s      r   polygonr    sf    
 )**G ' 'F1IIOO%%&&&&MMOOOgllnn---r   hc                 v    t          |  dz  | dz  df| dz  | dz  df| dz  |dz  df|  dz  |dz  df          S )z 
    Construct a rectangle.
    r"   r   )r  )rb  r  s     r   rectr    se    
 
a!aa!eaR!VQ/!a%Q1BaR!VQQRUTUDV  r   )rp  r  c                     t          |          }t          |||           }|                                 t          t	          |                                                                                    S )z)
    Construct a spline from points.
    )rT  ro   r  rZ  rB   r  r   )rp  r  r  r   rQ  s        r   spliner    s]     #D!$#66GOO5gmmooFFKKMMNNNr   tgtsr  r-  c                    t          |           }| t          |t          |          ||          }nt          |||          }|G|                    t	          |d                   j        t	          |d                   j        |           |                                 t          t          |	                                          
                                          S )z4
    Construct a spline from a sequence points.
    Nr   r   )rT  ro   rZ  r"  r   r  r  rZ  rB   r  r   )r  r  r  rp  r  r-  r   rQ  s           r   r  r    s     #D%d,=f,E,ExQTUU%dHc::VDG__,fT!Woo.EuMMMOO5gmmooFFKKMMNNNr   r5  c                    t          t          t          t          t	                                                      t	          ddd                                                    |                                                               S )z
    Construct a circle.
    r   r   )rZ  rB   r1   r.   r   r$  r  r   )r5  s    r   circler    sg    
 F688>>++VAq!__-B-B-D-DEEqII	
 	

$&&  r   r1r2c                    t          t          t          t          t	                                                      t	          ddd                                                    | |                                                              S )z
    Construct an ellipse.
    r   r   )rZ  rB   r6   r.   r   r$  r  r   )r  r  s     r   r  r    si    
 VFHHNN,,fQ1oo.C.C.E.EFFBOO	
 	

$&&  r   r[  c           
      &   t          t          ddd                                          t          ddd                                                    }t	          t          ||  dz  | dz  | dz  |dz                                                      S )z)
    Construct a finite planar face.
    r   r   r"   r3   r   r$  r  rZ  rC   r   )rb  r[  r  s      r   planer    s     fQ1oo++--vaA/D/D/F/FGGH1"q&!a%!aQGGLLNN  r   c            	         d} t          t          ddd                                          t          ddd                                                    }t	          t          ||  | |  |                                                     S )z
    Construct an infinite planar face.

    This is a crude approximation. Truly infinite faces in OCCT do not work as
    expected in all contexts.
    gDcLr   r   r  )INFr  s     r   r  r  ,  sy     CfQ1oo++--vaA/D/D/F/FGGH3$cT3??DDFF  r   c                    t          t          t          t          |  dz  | dz  d                                          t          ddd                                                    | ||                                                    S )z 
    Construct a solid box.
    r"   r   r   )rZ  rR   r.   r   r$  r  r  )rb  r[  r  s      r   boxr  >  s|    
 61"q&1"q&!,,2244fQ1oo6K6K6M6MNNPQSTVW	
 	

%''  r   r\  c                    t          t          t          t          ddd                                          t          ddd                                                    | dz  |dt          z                                                      S )z%
    Construct a solid cylinder.
    r   r   r"   )rZ  rT   r.   r   r$  r  r   r  r\  r  s     r   cylinderr  J  sv    
  6!Q??((**F1aOO,A,A,C,CDDa!eQPQTVPV	
 	

%''  r   c                    t          t          t          t          ddd                                          t          ddd                                                    | dz                                                      S )z#
    Construct a solid sphere.
    r   r   r"   )rZ  rY   r.   r   r$  r  r  )r\  s    r   spherer  V  sk    
 6!Q??((**F1aOO,A,A,C,CDDa!e	
 	

%''  r   rS  rT  c                 "   t          t          t          t          ddd                                          t          ddd                                                    | dz  |dz  ddt          z                                                      S )z"
    Construct a solid torus.
    r   r   r"   )rZ  rU   r.   r   r$  r  r   r  )rS  rT  s     r   torusr  b  s    
 6!Q??((**F1aOO,A,A,C,CDDFFF	
 	
 %''  r   c                 $    t          | d|          S )z&
    Construct a full solid cone.
    r  )coner  s     r   r  r  r  s     3??r   c                 "   t          t          t          t          ddd                                          t          ddd                                                    | dz  |dz  |dt          z                                                      S )z)
    Construct a partial solid cone.
    r   r   r"   )rZ  rS   r.   r   r$  r  r   r  )rS  rT  r  s      r   r  r  {  s     6!Q??((**F1aOO,A,A,C,CDDFFF	
 	
 %''  r   r  r  r  txtr  r  r  r  r  r  r  r  r  c                    t                      }t          t          t          d|         }t	          j                    }	|r|	                    t          |                                                    rVt          t          |                    }
|

                    |t          |                     |	                    |
d           n#|	                    t          |          |          }
t          t          |
                                                                          |t!          |                    }|dk    rt"          }n|dk    rt$          }nt&          }|dk    rt(          }n|dk    rt*          }nt,          }|                    |t          |           ||          }t1          t3          t5          |                                                                                              S )z
    Create a flat text.
    r  Tr  r  r  r  )r  r   r   r   r   r  r  r   r  r   r  r  r   r   r   r  r:  r   r   r   r   r   r   r  r"  r)  rZ  r  r  )r  r  r  r  r  r  r  rQ  r  r  r  r  r  r  r  s                  r   r  r    s    #$$G #   	I 
$
&
&C H5d;;EEGGHH H !8!>!>??9&=d&C&CDDD&&&& 5d;;YGGv00::<<==y%PT++ F &			8		(		'	(			8		(		%		&s++yI 
 
 
B ,R00668899>>@@AAAr   r  ri  c	           	         t          |          }|                                }	g }
t          | ||||||                                          D ]}|                                j        j        }|
                    |                    |                               |rdndd                              |	                    ||	z                                 t          t          |
                    S )z#
    Create a text on a spine.
    ir   )rI  rJ  )r.  r  r  r  rs  r  rF  r  rR  rk  rN  r)  )r  r  r  ri  r  r  r  r  r  r  r  r  poss                r   r  r    s      %  EA	B3dD$??EEGG 
 
nn%' 			HHcTNNUV*ccsU33U5##C!G,,--	
 	
 	
 	
 hrll###r   c	                 0   t          |d          }t          | ||d|||||	  	        }	g }
|	                                D ]=}|
                    |                    ||                                                     >t          t          |
                    S )z6
    Create a text on a spine and a base surface.
    r   F)r+  r  r  r  r  r  rN  r)  )r  r  r  r  r  r  r  r  r  r  r  rI  s               r   r  r    s      D&!!D
sD%dD&&
I
IC	BYY[[ 1 1
		!))D!**,,//0000hrll###r   r  r^  r;  c                    t                      }|                    | j                   t                      }|                    |j                   |                    |           |                    |           |                    |           |                    d           |r|                    |           |                                 d S r  )	r   ro  r  rp  rq  rr  	SetUseOBBry  r  )r]  r^  rQ  rp  r;  rs  rt  s          r   ru  ru    s     
 
 CJJrz!!DKK
T8$$$d
 #c"""MMOOOOOr   r~  c                 p    |r3|                      |dk    rt          j        nt          j                   d S d S )Nr   )r  r   BOPAlgo_GlueFullr  )rQ  r~  s     r   	_set_gluer    sN     
v~~ --!3	
 	
 	
 	
 	

 
r   c                     |                      d           |                     d           |                     d           |r|                     |           d S d S r  )rr  r  SetNonDestructivery  )rQ  rp  s     r   _set_builder_optionsr  (  sj    4   dd###
 #c"""""# #r   r  c                 V    t          j                    }|                    |            dS )zA
    Set number of threads to be used by boolean operations.
    N)r   DefaultPool_sr  )r  pools     r   
setThreadsr  2  s%    
 '))DIIaLLLLLr   )rp  r~  c                   t                      }|                    t                     t          ||           t	          ||           |                    | j                   |                    |j                   |D ]}|                    |j                   |                                 t          |
                                          S )z#
    Fuse at least two shapes.
    )r   SetOperationr   r  r  AddArgumentr  AddToolr  rZ  r  )r]  r^  rp  r~  r  rQ  rP  s          r   r  r  ;  s     mmG&&&gt#&&&
###OOBJ # #	""""OOgmmoo...r   c                 d   t                      }|                    t                     t          ||           t	          ||           |                    | j                   |                    |j                   |                                 t          |
                                          S )z
    Subtract two shapes.
    )r   r  r   r  r  r  r  r  r  rZ  r  r]  r^  rp  r~  rQ  s        r   r|  r|  S  s    
 mmG%%%gt#&&&
###OOBJOOgmmoo...r   c                 d   t                      }|                    t                     t          ||           t	          ||           |                    | j                   |                    |j                   |                                 t          |
                                          S )z
    Intersect two shapes.
    )r   r  r   r  r  r  r  r  r  rZ  r  r  s        r   r  r  f  s     mmG(((gt#&&&
###OOBJOOgmmoo...r   c                     t                      }t          | |||           t          |                                          S )z'
    Split one shape with another.
    )ry   ru  rZ  r  )r]  r^  rp  rQ  s       r   r  r  {  s9    
 #$$GRWc"""gmmoo...r   r   )rp  r~  r  c                    t                      }t          ||           t          ||            |D ]}|                    |j                   |                                 ||                                }|                                D ]c\  }}t          |t                    rI	 t          t          |                    |j                                      ||<   S# t          $ r Y _w xY wd|D ]J}	 t          t          |                    |j                                      ||<   ;# t          $ r Y Gw xY wt          |                                          S )z-
    Imprint arbitrary number of shapes.
    )r   r  r  r  r  r  Imagesr  rY  rZ  rZ  r  Findr   r  )	rp  r~  r  r  rQ  rP  imagesr   r   s	            r   imprintr    sw    Ggt#&&& ' 'AI&&&&OO !! MMOO 	 	DAq!S!! !3DQY9O9O4P4P!Q!QGAJJ,   D  	 	A/V[[5K5K0L0LMM

(    gmmoo...s$   '7C
C,+C,57D--
D:9D:c                     t          | j        ddd          }|                    d           |                                 t	          |                                          S )z,
    Clean superfluous edges and faces.
    TF)r   r  r  r  rZ  r  )rP  rQ  s     r   r"  r"    sP    
 +19dD$GGGu%%%MMOOOgmmoo...r   r   r  c                    t                      }t          |           D ]"}|                    |j        t                     #|D ]}t          |t                    r4t          |          D ]#}|                    |j        t          d           $K|                    t          |                                                     |	                                 t          |                                          S )z7
    Fill edges/wire possibly obeying constraints.
    F)r   r3  r  r  r   rY  r  r   r$  r  rZ  )rP  r  rQ  r  r  s        r   fillr    s    
 ())G]] + +AIz**** + +a 	+]] : :AIz59999: KKq		))****MMOOOgmmoo...r   c                 t   t                      }|                    ddd           t          |           D ]M}t          |                    |d          d          }|                    |j        |j        t          d           N|D ]}t          |t                    r4t          |          D ]#}|                    |j        t          d           $K|                    t          |                                                     |                                 t          |	                                          S )zh
    Fill edges/wire possibly obeying constraints and try to connect smoothly to the context shape.
    r"   r     r   TF)r   SetResolParamr3  r+  r  r  r  r   rY  r  r   r   r$  r  rZ  )rP  r  r  rQ  r  rI  r  s          r   capr    s    ())G!R###]] < <Q[[f--v66AIqy*d;;;; + +a 	+]] : :AIz59999: KKq		))****MMOOOgmmoo...r   r  c                 .   t          t          | d          j                  }t          |                                          D ]}|                    ||j                   |                                 t          |                                          S )z:
    Fillet selected edges in a given shell or solid.
    r   r   )	r   r+  r  r3  r
  r  r  rZ  r  )rP  r  r5  rQ  r  s        r   r  r    sz    
 'x3E'F'F'NPPG## # #Arz""""MMOOOgmmoo...r   c                 .   t          t          | d          j                  }t          |                                          D ]}|                    ||j                   |                                 t          |                                          S )z;
    Chamfer selected edges in a given shell or solid.
    r  )	r   r+  r  r3  r
  r  r  rZ  r  )rP  r  r\  rQ  r  s        r   rU  rU    sz    
 (4F(G(G(OQQG## # #Arz""""MMOOOgmmoo...r   c                    g }t          | d          D ]d}t          |j        t          |          j                  }|                                 |                    |                                           et          |          S )z
    Extrude a shape.
    r   r   r   r   )r)  rW   r  r   r  r  r  rZ  )rP  r\  resultsr  rQ  s        r   extruder  
  su    
 G1899 ( ('
F1II4EFFw}}''''g&&&r   r  r  c                    g }t          t          |                                          t          |                                                    }t	          | d          D ]`}t          |j        |t          |                    }|                                 |	                    |
                                           at          |          S )z
    Revolve a shape.
    r  )r-   r   r$  r  r)  rX   r  r   r  r  r  rZ  )rP  r  r\  r  r  r  r  rQ  s           r   r  r    s    
 G	q		!!6!99??#4#4	5	5B1899 ( ('
B

CCw}}''''g&&&r   r3  bothc                 "     fd}|rh ||          } ||           }d t          ||          D             }t          |          dk    r	|d         }	n5t                              |          }	n ||          }
t	          |
          }	|	S )z,
    Offset or thicken faces or shells.
    c                 $   g }t          d          D ]{}t                      }|                    |j        | t          j        ddt                     |                                 |                    |	                                           ||S )N)r   r   F)
r)  r   r  r  r   r  r   r  r  r  )r3  r  r  rQ  r  rP  rp  s       r   _offsetzoffset.<locals>._offset4  s    q+,, 	, 	,B+--G
/$	 	 	 ##%%%NN7==??++++r   c                 R    g | ]$\  }}t          |          t          |          z   %S r   )r  )r   r%  r&  s      r   r  zoffset.<locals>.<listcomp>Q  s:     
 
 
(0SE#JJs#
 
 
r   r   r   )r  r  r   r   rZ  )rP  r3  r  r  rp  r  results_posresults_negresults_bothr  r  s   ` ` `      r   r  r  -  s          2  )gajjgqbkk
 
47[4Q4Q
 
 
 |!!aBB&&|44BB '!**((Ir   auxr  c                    t          |          g }fd}|                                 }|r||D ]x}t          |                                |d          }|                                }	|	r"|t          t          |	          |d          z  }|                    |j                   ynt          |           D ]y}
 |            }|	                    |
j        dd           |
                                 |r|                                 |                    |                                           zt          |          S )zt
    Sweep edge, wire or face along a path. For faces cap has no effect.
    Do not mix faces with other types.
    c                      t          j                  } r)|                     t                    j        d           n|                     d           | S NTFr   r  r  r.  r  r   r  s    r   _make_builderzsweep.<locals>._make_buildern  sS    (77 	JJ}S))148888JJu	r   TF)r.  r  r  r  r  r)  r  r  r1  r  r  r  r  rZ  )rP  r  r   r  r  r&  r  rI  r  inner_wiresrb  rQ  r  s     `         @r   r  r  a  sY    $EG      GGIIE  , 	( 	(AtS$77C ,,..K EuXk22D#tDDDNN3;''''	( A 		, 		,A#mooGKK	5%000MMOOO $!!###NN7==??++++g&&&r   c                    t          |          g }fd}t          |           D ]} |            }|D ]0}|                    |                                j        dd           1|                                 |                                 g }	|d                                         D ]=}
 |            }|                    |
j        dd           |	                    |           >|dd         D ]F}t          |	|                                          D ]!\  }}
|                    |
j        dd           "Gg }|	D ]^}|                                 |                                 |                    t          |
                                                     _|                    t          |
                                          t          |          z
  j                   |st          |           D ]~} |            }|D ]}
|                    |
j        dd           |                                 |r|                                 |                    |
                                           t          |          S )z
    Sweep edges, wires or faces along a path, multiple sections are supported.
    For faces cap has no effect. Do not mix faces with other types.
    c                      t          j                  } r)|                     t                    j        d           n|                     d           | S r#  r$  r%  s    r   r&  zsweep.<locals>._make_builder  sS    (77 	JJ}S))148888JJu	r   Fr   r   N)r.  rL  r  r  r  r  r  r  r  r  r  r)  r?  rZ  )rP  r  r   r  r  r&  r  rQ  rI  builders_innerrb  builder_innerinner_partsr&  r  s     `           @r   r  r    s    $EG	 	 	 	 	 	 %Q''  Q  Q-// 	= 	=AKK-ue<<<<  A!!## 	1 	1A)MOOMai666!!-0000 ABB 	; 	;A$'$G$G ; ; q!!!)UE::::; + 	= 	=M!!!##%%%u]%8%8%:%:;;<<<<gmmoo..+1F1FFOPPPP  ,)!,, 	, 	,C#mooG 5 5AIue4444MMOOO $!!###NN7==??++++g&&&r   rc  rn  r  r   r   r   r  r  )rb  rc  rd  parametrizationr  compatr2  weightsc	           	         g }	fd}
t          |           D ]} |
d          }d}|D ]`}t          |t                    r-|                    |                                j                   D|                    |j                   d}a|                                 |                                 g }|st          t          |d                   
                                D ]<} |
d          }|                    |j                   |                    |           =|dd         D ]W}t          |t          t          |          
                                          D ]\  }}|                    |j                    Xg }|D ]^}|                                 |                                 |                    t          |                                                     _|	                    t          |                                          t          |          z
  j                   |	st          |           D ]} |
|          }|D ]L}t          |t                     r|                    |j                   2|                    |j                   M|                                 |                                 |	                    |                                           t#          |	          S )ze
    Loft edges, wires or faces. For faces cap has no effect. Do not mix faces with other types.
    c                 B   t          |           }|                               |                               |                    t	                               |                    t                               |                                |j          |S r  )	r   SetMaxDegreeCheckCompatibilitySetContinuityrm  
SetParTypert  SetSmoothingSetCriteriumWeight)	r  r  r/  r  r  r.  r  r2  r0  s	     r   r&  zloft.<locals>._make_builder  s    'U33

f%%%
44555
)/::;;;
	"""w''	r   TFr   r   N)rI  rY  r   r  r  r  	AddVertexr  Checkr\  r  r  r  r  r)  r<  r   rZ  )rP  r  r  r  r.  r  r/  r2  r0  r  r&  r  rQ  
has_vertexrI  r*  rb  r+  r,  r&  w2s     ```````            r   loftr=    s4     G	 	 	 	 	 	 	 	 	 	 	 a   +Q +Q-%% 
 	" 	"A!T"" " 56666!!!),,,!

  	54A''2244 5 5 -d 3 3%%ai000%%m4444 V 5 5(+"E$NN$=$=$?$?) ) 5 5$M1 "))!)44445 + 	= 	=M!!!!!!u]%8%8%:%:;;<<<<gmmoo..+1F1FFOPPPP  ,"1%% 	, 	,C#mC((G 2 2b$'' 2OOBJ////%%bj1111MMOOOMMOOONN7==??++++g&&&r   )r  r  r  r.  r  r/  r2  r0  c           	      ,    t          || |||||          S )z!
    Variadic loft overload.
    )r=  )	r  r  r  r.  r  r/  r2  r0  rP  s	            r   r=  r=  C  s      3z?FFKKKr      r  maxsegc                 >   t          |j                  }|                    ||dz  t          |          ||           t	          |           D ]}|                    | j                   |                                 t          |                                          S )z6
    Project s onto base using normal projection.
    gUUUUUU?)	r   r  	SetParamsrm  r3  r  r  rZ  
Projection)rP  r  r  r  r@  rp  r  r  s           r   r  r  V  s     %T\22DNN3
(C(CVVTTTmm  JJLLLdoo//000r   r  c                    t          | j                  }|                    d           |                    d           |                                 |                                }|r|                    |           |s|                                 |                                D ]J}|	                    t          |                                          |                                f           K|S )z$
    Check if a shape is valid.
    T)rz   r  rr  r  r  rm  ry  clearr  r  r`  GetFaultyShapes1GetCheckStatus)rP  r  rp  analyzerr  r5  s         r   checkrI  p  s     !++HD!!!t					B
 $s### "" 	 	ANN)!*<*<*>*>??AQAQASAST    Ir   c                     t                      }t          j        |j        t	          | j                  t
          |                                         |           |                    | j                  S )z*
    Check if s1 is a subshape of s2.
    )r   r[   r  r  r  r  r	  r  )r]  r^  r  s      r   
isSubshaperK    s_    
 :;;I
"

Ibj))+<R\\^^+Li   bj)))r   c                 d   t                      }|                    d           |                    | j                   |                    |j                   |                                sJ t          |                    d                    t          |                    d                    fS )z,
    Closest points between two shapes.
    Tr   )	r   r  r  r  r  r  r   PointOnShape1PointOnShape2)r]  r^  exts      r   r  r    s    
 %
&
&Ct JJrzJJrz ;;===###A&&''0A0A!0D0D)E)EEEr   r  )Fr   )r   r  )r   TNN)Nr   N)NNr   FT)r  Nr  r  r  )Fr  Nr  r  r  )r  T)r  N)r  )r   )r  )TFr   ri  )FFrc  rn  r  TFr-  )rc  r  r?  r  )NN(  typingr   r   r   r   r   r   r	   r
   r   r   r   r   r\  r   r   r   typing_extensionsr   ior   vtkmodules.vtkCommonDataModelr   vtkmodules.vtkFiltersCorer   r   r  r   r   r   r   r   r   shape_protocolsr   r   r    r!   	selectorsr#   r$   utilsr%   r&   r'   OCP.Messager(   r)   DefaultMessenger_sPrintersprinterSetTraceLevelMessage_Fail
OCP.TopAbsTopAbsr'  OCP.GeomAbsGeomAbsr  OCP.Precisionr*   OCP.gpr+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   
OCP.TColgpr7   r8   r9   r:   r;   OCP.TColStdr<   r=   OCP.BRepAdaptorr>   r?   r@   OCP.BRepBuilderAPIrA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   	OCP.GProprO   OCP.BRepGProprP   rQ   OCP.BRepPrimAPIrR   rS   rT   rU   rV   rW   rX   rY   OCP.BRepIntCurveSurfacerZ   
OCP.TopExpr[   OCP.BRepr\   r]   
OCP.TopoDSr^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   OCP.GCrj   rk   	OCP.GCE2drl   OCP.gcerm   rn   OCP.GeomAPIro   rp   rq   rr   rs   OCP.BRepFillrt   OCP.BRepAlgoAPIru   rv   rw   rx   ry   rz   OCP.Geomr{   r|   r}   r~   r   r   r   
OCP.Geom2dr   OCP.Geom2dAPIr   OCP.BRepLibr   r   OCP.BRepOffsetAPIr   r   r   r   OCP.BRepFilletAPIr   r   r   OCP.TopToolsr   r   r   r   OCP.ShapeFixr   r   r   OCP.STEPControlr   r   OCP.BRepMeshr   
OCP.StlAPIr   OCP.ShapeUpgrader   OCP.BRepToolsr   r   r   
OCP.LocOper   OCP.BRepCheckr   OCP.Fontr   r   r   r   r   
OCP.StdPrsr   r   r  OCP.Graphic3dr   r   r   r   r   r   OCP.NCollectionr   OCP.BRepFeatr   OCP.BRepClass3dr   r   OCP.TCollectionr   
OCP.TopLocr   r   r   r   r   r   r   r   r   r   OCP.BRepOffsetr   r   r  r   r   r   r   r   r   OCP.IFSelectr   r   r   OCP.ShapeAnalysisr   r   r   r   r   
OCP.GCPntsr   r   r   OCP.GeomFillr   r   r   OCP.BRepProjr   OCP.BRepExtremar   OCP.IVtkOCCr   r   OCP.IVtkVTKr   OCP.Standardr   r   	OCP.Prs3dr   OCP.Quantityr   
OCP.Aspectr   OCP.Interfacer   OCP.ShapeCustomr   r   OCP.BRepAlgor   r   
OCP.ChFi2dr   OCP.GeomConvertr   
OCP.Approxr   OCP.LProp3dr   OCP.BinToolsr   OCP.Adaptor3dr   r   OCP.GeomAdaptorr   OCP.OSDr   mathr   r   r   r   r   r^  r   r:  r;  r=  GlueLiteralr  r(  r)  r*  r+  r,  r-  r.  r/  r  r  r  r  r  r  r  Vertex_sr  r~  r  r  Solid_sCompSolid_s
Compound_sr  rX  ancestors_LUTr  r  r  r  objectr  r?  r   ru  rv  rU  rw  ry  r   r   r   r   rD  rF  r   r   r   rq  r  r"  r)  r+  r.  r1  r3  r<  r?  rI  rL  rN  rZ  rT  rV  rZ  r\  r`  dict
GeomAbs_C1
GeomAbs_C3
GeomAbs_CN
GeomAbs_G1rj  rZ  rm  Approx_IsoParametricApprox_ChordLengthApprox_Centripetalrr  rt  r-  ShapeHistoryr8  r  r  r<  r  r  r  r`  r  r)  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  ru  r  r  r  r  r|  r  r  r  r"  r  r  r  rU  r  r  r  r  r=  r  rI  rK  r  r   r   r   <module>r     s'                                   $ # " " " " "       6 5 5 5 5 5 K K K K K K K K G G G G G G G G G G G G G G G G H H H H H H H H H H H H       
 @ ? ? ? ? ? ? ? ? ? 1 0 0 0 0 0 0 0)w)++4466 8 8G/67777             # # # # # #                                        * ) ) ) ) ) 1 0 0 0 0 0 . - - - - -                                        $ # " " " " " 3 3 3 3 3 3 3 3	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 > = = = = =       - , , , , , , ,                            ; : : : : : : : ' ' ' ' ' ' , , , , , , , ,              " ! ! ! ! !                                 # " " " " " / / / / / / 4 4 4 4 4 4 4 4                                G F F F F F F F F F @ @ @ @ @ @ @ @ 1 1 1 1 1 1 $ $ $ $ $ $ 9 9 9 9 9 9          % $ $ $ $ $ , , , , , ,              W V V V V V V V                3 2 2 2 2 2 , , , , , , D D D D D D D D 3 3 3 3 3 3 & & & & & &	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 8 7 7 7 7 7 A A A A A A A A                / . . . . . ; ; ; ; ; ; ; ;            3 2 2 2 2 2                   - , , , , , 6 6 6 6 6 6 : : : : : : : : ) ) ) ) ) ) A @ @ @ @ @ @ @ % % % % % % ' ' ' ' ' ' ' ' ' ' ' ' * * * * * * J J J J J J J J < < < < < < < < ' ' ' ' ' ' 3 3 3 3 3 3 1 1 1 1 1 1 ' ' ' ' ' ' ! ! ! ! ! ! = = = = = = = = / / / / / / " " " " " " , , , , , , , , , , , , , ,       UCZ-.	 hNFNFNFOWOW
		 dNI0NI0NI1OY2OY1	4  98ioo&7&7888  foNFMNFMNFMOV^OV^+)	 hN%NFN'OWOWO[
	 nNNO_  GCw< $4    , <     \  l        G" G" G" G" G"F G" G" G"T*    H   H H H H HU H H HB )*	)*	' ' ' ' 'mX ' ' 'T ge?+++QC QC QC QC QCf QC QC QChG8 G8 G8 G8 G85' G8 G8 G8T
C C C C C5' C C CLq	1 q	1 q	1 q	1 q	15 q	1 q	1 q	1h    E   0 WT'''~% ~% ~% ~% ~%f ~% ~% ~%BQ	* Q	* Q	* Q	* Q	*E7 Q	* Q	* Q	*h    w   ^= ^= ^= ^= ^=ug ^= ^= ^=BDJ 4T
3C    BA4: A$t* A A A A* * *U *d4j * * * *&HE HuVU63;%778 HXe_ H H H H8 5vs{);!;<     >
)U 
)t 
) 
) 
) 
)K% KHUO K K K K$O O(5/ O O O O&#x #4U4<5H0I+J # # # #Lhuo $tDz2B    2,x ,4U4<5H0I+J , , , ,^huo $tDz2B    2% E    ,%h|.D DE %    
, 
1D 
 
 
 

(5t#45 
:O 
 
 
 

HUO 
0E 
 
 
 

 
4H 
 
 
 
5!5 5$u+ 5 5 5 5 T   ,# ,- , , , , &;&9*=   /c /&@ / / / / U  +    < E%*%u,-  	" "
"	%d
#	$" " 
	"
 " " " ". 9=/# /# /#/#/#%*/#16/#BE/#
/# /# /# /#d  5 U     
/U 
/u 
/ 
/ 
/ 
/ HUO     
 4U 4u 4 4 4 4$ HUO      *.    e     B;";+/:;@H@V; ; ; ;&  -1&**" *" *"*"	*" *" 
(5/E)	*	*"
 l#*" *" *" *" *"Z  -1&*K KK	K K 
(5/E)	*	K
 l#K K K K K (,PT# # ### %#7?7M#
# # # #0  (,&*	* **HUO$* 
* l#	*
 * * * *0  5      )E4,=">> 5     Sd St S S S S S S Uj U U U U
 
 u    
.: 
.% 
. 
. 
. 
..* . . . . .E e      *. 
O 
O 
O 
O% 
O$ 
O5 
O 
O 
O 
O  ,0(,O O	*	O
8J'
(O Xe_%O 
	O
 O O O O O O6	e 	 	 	 	 		 	5 	U 	 	 	 	 	T 	d 	u 	 	 	 	 u    "	5 	U 	u 	 	 	 	 		 	% 	E 	 	 	 		e 	 	 	 	 	e  5      D T e     T t         1:19195B 5B	5B
5B 5B 3-	5B
 -
.5B -.5B -.5B 5B 5B 5B 5Bp 
 1:1919$ $	$
$ $ 	$
 $ 3-$ -
.$ -.$ -.$ $ $ $ $@  1:1919$ $	$
$ $ 	$
 $ 3-$ -
.$ -.$ -.$ $ $ $ $B   /1EEF 
	
    4
 
k 
 
 
 
#/ # # # # ##     8;PT/ / ///#(//4/BM/
/ / / /0/ /E /u /5 /k /U / / / /( AE/ ///$/2=/
/ / / /*/ /e / /U /U / / / / &*	'/ '/ '/'/	'/ '/ l#	'/
 '/ '/ '/ '/T	/U 	/u 	/ 	/ 	/ 	// /E /uj/@)A B /E / / / /. MO/ ///'/eZ6G0H'I/
/ / / /4/e / /% /E / / / //u / /5 /U / / / /'u ' ' ' ' ' '"' 'u ' '
 'u ' ' ' '& DH1 111(,1;@1
1 1 1 1h DI2' 2'2'2' (2'=A2'
2' 2' 2' 2'j NSJ' J'J'#J'*25/J'GKJ'
J' J' J' J'Z  ,0DM*3Z' Z'Z'	Z' Z' ()	Z'
 @AZ' Z' Z' Z' 5%&'Z' Z' Z' Z' Z'z  ,0DM*3L L LL	L L ()	L
 @AL L L L 5%&'L L L L L* -11 11
1 ()1 	1
 1 
1 1 1 18 8< d5ec!1234 
% 
	   @*5 *e * * * * *"F F5 FU66>%: F F F F F Fr   