
    hZ                    R   % S SK Jr  S SKJrJrJrJrJrJrJ	r	  S SK
JrJr  S SKrS SKrS SKJr  S SKJr  S SKJrJrJrJrJrJr  S SKJrJrJrJr  S S	KJ r J!r!  S S
K"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0  SSK1J2r2J3r3J4r4  SSK5J6r6J7r7  SSK8J9r9  SSKJ:r:  \(       a  S SK;J<r<J=r=  S SK>J?r?  S SKJ@r@  S/rA\" S\" SS S9\" SS\R                  S9\" S\R                  SS9\" S\R                  SS9\" S\R                  S S9\" S!S"S#S$9\" S%S"S#S$9\" S&S"S#S$9\" S'\R                  S#\R                  S(9\" S)\R                  S#\R                  S(9\" S*\R                  \'S#\R                  \S+9S,.5      rF\" \F5      rG " S- S.5      rH1 S/krI\\\J      rKS0\LS1'   \9 " S2 S\65      5       rMg)3    )annotations)TYPE_CHECKINGListIterableSequencecastIteratorOptional)	TypeAliasSelfN)
AuditError)	validator)DXFAttrDXFAttributesDefSubclassXTypeRETURN_DEFAULTgroup_code_mapping)SUBCLASS_MARKERDXF2000DXFValueErrorDXFStructureError)VertexArrayTags)Vec3UVecMatrix44ConstructionEllipseZ_AXISNULLVECOCSuniform_knot_vectoropen_uniform_knot_vectorBSplinerequired_knot_valuesrequired_fit_pointsrequired_control_pointsfit_points_to_cad_cv   )
base_classSubclassProcessor	DXFEntity)
DXFGraphicacdb_entity)register_entity)default_copy)DXFNamespaceEllipse)AbstractTagWriter)AuditorSpline
AcDbSplineF   )defaultG      )r8   r   H   
knot_count)xtypegetterI   control_point_countJ   fit_point_count*   g|=T)r8   optional+   ,      )r=   rD   r         )r=   r8   rD   r   fixer)flagsdegreen_knotsn_control_pointsn_fit_pointsknot_tolerancecontrol_point_tolerancefit_tolerancestart_tangentend_tangent	extrusionc                      \ rS rSrSS jrSrg)
SplineData   c                    UR                   U l         UR                  U l        UR                  U l        UR                  U l        g N)
fit_pointscontrol_pointsknotsweights)selfsplines     G/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/spline.py__init__SplineData.__init__   s3     ++$33\\
~~    )r\   r[   r]   r^   N)r`   r5   )__name__
__module____qualname____firstlineno__rb   __static_attributes__ rd   ra   rW   rW      s    &rd   rW   >   
      (   )   r;   r?   rA   r   Verticesc                    ^  \ rS rSrSrSr\" \\\	5      r
\rSrSrSrSrSrU 4S	 jr\4S,S
 jjr S-   S.U 4S jjjrS/S jrS0U 4S jjrS1S jr\S2S j5       r\R6                  S3S j5       r\S4S j5       r\R6                  S5S j5       rS6S jr\S4S j5       r\R6                  S5S j5       r\S7S j5       r\R6                  S8S j5       rS6S jr \S7S j5       r!\!R6                  S8S j5       r!S6S jr"S9S jr#S:S jr$S;S<S jjr%\&S=S j5       r'S>S?S  jjr(S>S?S! jjr)S>S@S" jjr* S>       SAS# jjr+ S>       SAS$ jjr, S>       SAS% jjr-SBS& jr.SCU 4S' jjr/SDS( jr0SDS) jr1SES* jr2S+r3U =r4$ )Fr5      zDXF SPLINE entitySPLINEr)               c                z   > [         TU ]  5         [        5       U l        [        5       U l        / U l        / U l        g rZ   )superrb   r   r[   r\   r]   r^   )r_   	__class__s    ra   rb   Spline.__init__   s/    %-)m
rd   c                Z   [        U[        5      (       d   e[        R                  " U R                  5      Ul        [        R                  " U R
                  5      Ul        [        R                  " U R                  5      Ul        [        R                  " U R                  5      Ul        g)z<Copy data: control_points, fit_points, weights, knot_values.N)
isinstancer5   copydeepcopy_control_points_fit_points_knots_weights)r_   entitycopy_strategys      ra   	copy_dataSpline.copy_data   sk    &&))))!%t/C/C!D!]]4+;+;<dkk2--6rd   c                   > [         TU ]  U5      nU(       ac  UR                  S5      nU(       a2  [        U R	                  U5      5      nUR                  U[        USS9  U$ [        SUR                   S35      eU$ )Nrs   T)subclassrecoverz)missing 'AcDbSpline' subclass in SPLINE(#))	rx   load_dxf_attribssubclass_by_indexr   load_spline_datafast_load_dxfattribsacdb_spline_group_codesr   handle)r_   	processordxftagsry   s       ra   r   Spline.load_dxf_attribs   s     g&y1..q1DD11$78..04 /  
 (?

|1M  
rd   c              #  |  #    / n/ n/ n/ nU H  nUu  pxUS:X  a  UR                  U5        M   US:X  a  UR                  U5        M9  US:X  a  UR                  U5        MR  US:X  a  UR                  U5        Mk  US;   a  [        R                  " U5      (       a  M  Uv   M     X l        X0l        X@l        XPl        g7f)zLoad and set spline data (fit points, control points, weights,
knots) and remove invalid start- and end tangents.
Yields the remaining unprocessed tags.
rk   rl   rm   rn   )rG   rH   N)appendr    iscloser\   r[   r]   r^   )	r_   r   r\   r[   r]   r^   tagcodevalues	            ra   r   Spline.load_spline_data   s     
 
CKDrz%%e,!!%(U#u%!gooe&<&< 	   -$
s   B:B<c                  > [         TU ]  U5        UR                  [        [        R
                  5        U R                  R                  U/ SQ5        UR                  SU R                  5       5        UR                  SU R                  5       5        UR                  SU R                  5       5        U R                  R                  U/ SQ5        U R                  U5        g)z(Export entity specific data as DXF tags.)rU   rK   rL   r;   r?   rA   )rP   rQ   rR   rS   rT   N)rx   export_entity
write_tag2r   acdb_splinenamer   export_dxf_attribsr<   r@   rB   export_spline_data)r_   	tagwriterry   s     ra   r   Spline.export_entity   s    i(_k.>.>?##I/OPR!23R!9!9!;<R!5!5!78##		
 		*rd   c                4   U R                    H  nUR                  SU5        M     [        U R                  5      (       a%  U R                   H  nUR                  SU5        M     U R                  R                  USS9  U R                  R                  USS9  g )Nrm   rn   rk   )r   rl   )r   r   lenr   r   
export_dxfr   )r_   r   r   s      ra   r   Spline.export_spline_data   s    [[E  U+ ! t}}$$R/ ' 	''	';##IB#7rd   c                6    U R                  U R                  SS9$ )z``True`` if spline is closed. A closed spline has a connection from
the last control point to the first control point. (read/write)
rK   )r   )get_flag_stateCLOSEDr_   s    ra   closedSpline.closed   s    
 ""4;;W"==rd   c                :    U R                  U R                  USS9  g )NrK   )stater   )set_flag_stater   )r_   statuss     ra   r   r     s    DKKvGDrd   c                    U R                   $ )z(Knot values as :code:`array.array('d')`.)r   r   s    ra   r]   Spline.knots  s     {{rd   c                f    [        [        [           [        R                  " SU5      5      U l        g Nd)r   r   floatarrayr   r_   valuess     ra   r]   r     s    #'UU[[f5M#Nrd   c                ,    [        U R                  5      $ )zCount of knot values.)r   r   r   s    ra   r<   Spline.knot_count  s    4;;rd   c                    U R                   $ )z2Control point weights as :code:`array.array('d')`.)r   r   s    ra   r^   Spline.weights  s     }}rd   c                f    [        [        [           [        R                  " SU5      5      U l        g r   )r   r   r   r   r   r   s     ra   r^   r     s    %)$u+u{{37O%Prd   c                    U R                   $ )zN:class:`~ezdxf.lldxf.packedtags.VertexArray` of control points in
:ref:`WCS`.
)r   r   s    ra   r\   Spline.control_points  s    
 ###rd   c                h    [        [        [        [        R                  " U5      5      5      U l        g rZ   )r   ro   r   r   listr   r_   pointss     ra   r\   r   %  s"    )-k$))F"34*
rd   c                ,    [        U R                  5      $ )zCount of control points.)r   r\   r   s    ra   r@   Spline.control_point_count,  s    4&&''rd   c                    U R                   $ )zJ:class:`~ezdxf.lldxf.packedtags.VertexArray` of fit points in
:ref:`WCS`.
)r   r   s    ra   r[   Spline.fit_points0  s    
 rd   c                h    [        [        [        [        R                  " U5      5      5      U l        g rZ   )r   ro   r   r   r   r   r   s     ra   r[   r   7  s#    %)		&)*&
rd   c                ,    [        U R                  5      $ )zCount of fit points.)r   r[   r   s    ra   rB   Spline.fit_point_count?  s    4??##rd   c                j   U R                  5       (       a}  [        U R                  5      (       a  U R                  OSn[        U R                  5      (       a  U R                  OSn[	        U R
                  U R                  R                  S-   UUS9$ U R                  5       (       a  SnU R                  R                  S5      (       aL  U R                  R                  S5      (       a,  U R                  R                  U R                  R                  /n[        U R                  US9$ [        S5      e)z:Returns the construction tool :class:`ezdxf.math.BSpline`.Nr)   )r\   orderr]   r^   rS   rT   tangentsz2Construction tool requires control- or fit points.)r@   r   r^   r]   r$   r\   r   rL   rB   hasattrrS   rT   r(   r[   
ValueError)r_   r^   r]   r   s       ra   construction_toolSpline.construction_toolC  s    ##%%&)$,,&7&7dllTG"%djj//DJJtE#22hhoo)	  !!##Hxx00TXX5E5Em5T5T HH22DHH4H4HI'! 
 QRRrd   c                    UR                   U l         UR                  U R
                  l        / U l        UR                  5       U l        UR                  5       U l        U R                  [        R                  [        [        U R                  5      5      S9  U $ ! [         a*    [        R                  " U5      nUR                   U l          Nf = f)zyApply SPLINE data from a :class:`~ezdxf.math.BSpline` construction
tool or from a :class:`geomdl.BSpline.Curve` object.

)r   )r\   AttributeErrorr$   from_nurbs_python_curverL   r   r[   r]   r^   r   r5   RATIONALboolr   )r_   ss     ra   apply_construction_toolSpline.apply_construction_toolZ  s    
	3"#"2"2D
 ((WWY
yy{FOO4DLL8I3JK  	3//2A"#"2"2D	3s   B 1CCc                @    U R                  5       R                  X5      $ )a  Adaptive recursive flattening. The argument `segments` is the
minimum count of approximation segments between two knots, if the
distance from the center of the approximation segment to the curve is
bigger than `distance` the segment will be subdivided.

Args:
    distance: maximum distance from the projected curve point onto the
        segment chord.
    segments: minimum segment count between two knots

)r   
flattening)r_   distancesegmentss      ra   r   Spline.flatteningl  s     %%'228FFrd   c           
     J   UR                  5       nUS:X  a  [        SU5      R                  5       nGO9US:X  av  [        R                  " UR
                  R                  S[        5      [        UR
                  R                  SS5      5      UR
                  R                  S[        5      S9nOUS	:X  a  [        R                  " UR
                  R                  S[        5      [        UR
                  R                  SS5      5      UR
                  R                  S[        5      UR
                  R                  S
S5      UR
                  R                  SS5      S9nO[        S5      e[        R                  UR                  5       UR                  S9n[        R                   " U5      nUR"                  UR
                  l        [        R$                  UR
                  l        UR(                  Ul        UR+                  5       Ul        UR-                  5       Ul        U$ )zCreate a new SPLINE entity from a CIRCLE, ARC or ELLIPSE entity.

The new SPLINE entity has no owner, no handle, is not stored in
the entity database nor assigned to any layout!

ELLIPSEr2   CIRCLEcenterradiusg      ?rU   )r   r   rU   ARCstart_angler   	end_angleih  )r   r   rU   r   r   z'CIRCLE, ARC or ELLIPSE entity required.)
dxfattribsdoc)dxftyper   r   r   from_arcr   getr    absr   	TypeErrorr5   newgraphic_propertiesr   r$   from_ellipserL   r   rK   r\   r]   r^   )clsr   r   ellipser`   r   s         ra   r   Spline.from_arcz  s    .."i9f-??AG )22zz~~h86::>>(C89 **..f=G
 )22zz~~h86::>>(C89 **..f="JJNN=!< **..c:G EFFv'@'@'B

S  )HH

!??

 ! 0 0wwyrd   c                    SU R                   l        X R                   l        Xl        [	        [        U5      US-   5      U l        g)z`Open B-spline with a uniform knot vector, start and end at your first
and last control points.

r   r)   N)r   rK   rL   r\   r#   r   r]   r_   r\   rL   s      ra   set_open_uniformSpline.set_open_uniform  s5    
  ,-c..A6A:N
rd   c                    SU R                   l        X R                   l        Xl        [	        [        U5      US-   5      U l        g)zdB-spline with a uniform knot vector, does NOT start and end at your
first and last control points.

r   r)   N)r   rK   rL   r\   r"   r   r]   r   s      ra   set_uniformSpline.set_uniform  s5    
  ,(^)<fqjI
rd   c                
   U R                   U R                  -  U R                  l        X R                  l        Xl        U R
                  R                  USU 5        [        [        U R
                  5      US-   5      U l	        g)zXClosed B-spline with a uniform knot vector, start and end at your
first control point.

Nr)   )
PERIODICr   r   rK   rL   r\   extendr"   r   r]   r   s      ra   
set_closedSpline.set_closed  se    
 4 ,"">'6#:;
 )T-@-@)A6A:N
rd   c                    U R                  XS9  U R                  R                  U R                  -  U R                  l        [	        U5      [	        U R
                  5      :w  a  [        S5      eX l        g)zOpen rational B-spline with a uniform knot vector, start and end at
your first and last control points, and has additional control
possibilities by weighting each control point.

rL   3Control point count must be equal to weights count.N)r   r   rK   r   r   r\   r   r^   r_   r\   r^   rL   s       ra   set_open_rationalSpline.set_open_rational  sY     	n<$--7w<3t2233 UVVrd   c                    U R                  XS9  U R                  R                  U R                  -  U R                  l        [	        U5      [	        U R
                  5      :w  a  [        S5      eX l        g)zRational B-spline with a uniform knot vector, does NOT start and end
at your first and last control points, and has additional control
possibilities by weighting each control point.

r  r  N)r   r   rK   r   r   r\   r   r^   r  s       ra   set_uniform_rationalSpline.set_uniform_rational  sY     	7$--7w<3t2233 UVVrd   c                *   U R                  XS9  U R                  R                  U R                  -  U R                  l        [	        U5      nUR                  USU 5        [        U5      [        U R                  5      :w  a  [        S5      eX l	        g)zClosed rational B-spline with a uniform knot vector, start and end at
your first control point, and has additional control possibilities by
weighting each control point.

r  Nr  )
r  r   rK   r   r   r  r   r\   r   r^   r  s       ra   set_closed_rationalSpline.set_closed_rational  sr     	6$--7w-ww'(w<3t2233 UVVrd   c           	     L   U R                   R                  U5        U R                  R                  U5        U R                  nS HJ  nUR	                  U5      (       d  M  UR                  X1R                  UR                  U5      5      5        ML     U R                  U5        U $ )zATransform the SPLINE entity by transformation matrix `m` inplace.)rS   rT   rU   )	r   	transformr   r   r   settransform_directionr   post_transform)r_   mr   r   s       ra   r  Spline.transform  s    &&q)""1%hhAD{{4  33CGGDMBC B 	Ard   c                  > [         TU ]  U5        U R                  R                  n[	        U 5      nUS:  a7  UR                  [        R                  SU SU S3S9  UR                  U 5        g[        U R                  5      n[        U R                  5      nUS:X  a:  US:X  a4  UR                  [        R                  SU S3S9  UR                  U 5        gUS:  a  U R                  U5        gUS:  a  U R                  U5        gg)	zAudit the SPLINE entity.r)   Removed z with invalid degree: z < 1.r   messageNr   z" without any points (no geometry).)rx   auditr   rL   strfixed_errorr   INVALID_SPLINE_DEFINITIONtrashr   r\   r[   _audit_control_points_audit_fit_points)r_   auditorrL   r   rN   rO   ry   s         ra   r  Spline.audit  s   g4yA:99"4&(>vheL    MM$t2234??+q \Q%699"4&(JK    MM$a&&w/A""7+ rd   c           	     z   [        U 5      nU R                  R                  S-   n[        U R                  5      n[        U5      nXE:  a9  UR                  [        R                  SU SU SU 3S9  UR                  U 5        g [        U R                  5      n[        U R                  5      n[        XC5      nXx:  a9  UR                  [        R                  SU SU SU 3S9  UR                  U 5        g U(       a?  Xd:w  a9  UR                  [        R                  SU SU SU 3S9  UR                  U 5        g g g )	Nr)   r  z# with invalid control point count:  < r  z  with invalid knot value count: z with invalid weight count: z != )r  r   rL   r   r\   r'   r  r   "INVALID_SPLINE_CONTROL_POINT_COUNTr  r^   r]   r%   INVALID_SPLINE_KNOT_VALUE_COUNTINVALID_SPLINE_WEIGHT_COUNT)	r_   r"  r   r   rN   n_control_points_required	n_weightsrM   n_knots_requireds	            ra   r   Spline._audit_control_points"  s^   4y!#t223 %<E$B!7BB"4&(K#$C(A'BD   
 MM$%	djj//0@H% ??"4&(H)3/02   
 MM$6 ;;"4&(D+T"2!35   
 MM$ 79rd   c           	        [        U 5      nU R                  R                  S-   n[        USS9n[	        U R
                  5      nXT:  a9  UR                  [        R                  SU SU SU 3S9  UR                  U 5        g [	        U R                  5      (       a)  UR                  [        R                  SU S	3S9  / U l
        [	        U R                  5      (       a*  UR                  [        R                  S
U S	3S9  / U l        g g )Nr)   Tr   r  z with invalid fit point count: r%  r  zRemoved unused knot values for z defined by fit points.zRemoved unused weights for )r  r   rL   r&   r   r[   r  r   INVALID_SPLINE_FIT_POINT_COUNTr  r]   r'  r^   r(  )r_   r"  r   r   n_fit_points_requiredrO   s         ra   r!  Spline._audit_fit_pointsL  s   4y!# !4ED I 4??+/>>"4&(G.$9#:<   
 MM$ tzz????9$ @) *   
 DJ t||;;5dV;VW    DL rd   c                    [        5       $ rZ   )r!   r   s    ra   ocs
Spline.ocso  s     urd   )r   r   r   r   r\   r[   r]   r^   )r   r   returnNonerZ   )r   zOptional[SubclassProcessor]r4  r1   )r4  r	   )r   r3   r4  r5  )r   r3   )r4  r   )r   r   r4  r5  )r4  zlist[float])r   zIterable[float]r4  r5  )r4  int)r4  ro   )r   zIterable[UVec]r4  r5  )r4  r$   )r4  r5   )rt   )r   r   r   r6  r4  zIterator[Vec3])r   r-   r4  r5   )r:   )r\   Sequence[UVec]rL   r6  r4  r5  )r\   r7  r4  r5  )r\   r7  r^   zSequence[float]rL   r6  r4  r5  )r  r   r4  r5   )r"  r4   r4  r5  )r"  r4   )r4  r!   )5re   rf   rg   rh   __doc__DXFTYPEr   r*   r.   r   
DXFATTRIBSr   MIN_DXF_VERSION_FOR_EXPORTr   r   r   PLANARLINEARrb   r0   r   r   r   r   r   propertyr   setterr]   r<   r^   r\   r@   r[   rB   r   r   r   classmethodr   r   r   r  r  r  r  r  r  r   r!  r2  ri   __classcell__)ry   s   @ra   r5   r5      sS   Gz;DJ!(FHHFF 5A 7 8<4	 "<+*	8 > > ]]E E   \\O O    ^^Q Q $ $ 
 
(     
 
$S.$G " "HOJO& 	& ! 	
 
* 	& ! 	
 
* 	& ! 	
 
&
,>(T!F rd   )N
__future__r   typingr   r   r   r   r   r	   r
   typing_extensionsr   r   r   r}   ezdxf.auditr   ezdxf.lldxfr   ezdxf.lldxf.attributesr   r   r   r   r   r   ezdxf.lldxf.constr   r   r   r   ezdxf.lldxf.packedtagsr   r   
ezdxf.mathr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   	dxfentityr*   r+   r,   dxfgfxr-   r.   factoryr/   r0   ezdxf.entitiesr1   r2   ezdxf.lldxf.tagwriterr3   r4   __all__is_positivecallbackpoint3dis_not_null_vectorr   r   rW   REMOVE_CODESr   ro   __annotations__r5   rj   rd   ra   <module>rW     s   #   .   " !   5     @ ? + $ 47#*&  Q' "a93H3HI2U^^LI#enn-B
  %..ARS!"edC#*2ut#L UTB !--22	
 --22	
 --22 
E/2f -[9 & & ,8E?+) + `Z ` `rd   