
    3j6)                     :   S r SSKJr  SSKJrJrJr  SSKJ	r	  SSK
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rSS	KJr  S
r " S S\	R*                  \R,                  5      r\R.                  " \5      \R0                  l        S r\R6                  R9                  5        HG  u  rr\" \5      r\\R@                  \'   \\R6                  \   :X  d   e\RB                  S   \:X  a  MG   e    CCCS r$\" \R0                  5      S 5       r\" \RJ                  5      S 5       r%Sr&S r'S r(\" \RR                  5      S 5       r)\" \RT                  5      S 5       r*\" \RV                  5      S 5       r+\" \RX                  5      S 5       r,g! \" a
  r# Sr#C#NSr#C#ff = f)a  Implementation of GLU Nurbs structure and callback methods

Same basic pattern as seen with the gluTess* functions, just need to
add some bookkeeping to the structure class so that we can keep the
Python function references alive during the calling process.
    )GLU)platform
converterswrapper)	glustruct)lazy)arrayserrorN)PLATFORM)_configflags)GLUnurbsgluNewNurbsRenderergluNurbsCallbackgluNurbsCallbackDatagluNurbsCallbackDataEXTgluNurbsCurvegluNurbsSurfacegluPwlCurvec                      \ rS rSrSr\R                  " \R                  5      r0 r	\
R                  \" S\
R                  5      \
R                  \" S\
R                  \R                  " \
R                   5      5      \
R"                  \" S\R                  " \
R$                  5      5      \
R&                  \" S\R                  " \
R$                  5      \R                  " \
R                   5      5      \
R(                  \" S\R                  " \
R$                  5      5      \
R*                  \" S\R                  " \
R$                  5      \R                  " \
R                   5      5      \
R,                  \" S\R                  " \
R$                  5      5      \
R.                  \" S\R                  " \
R$                  5      \R                  " \
R                   5      5      \
R0                  \" S\R                  " \
R$                  5      5      \
R2                  \" S\R                  " \
R$                  5      \R                  " \
R                   5      5      \
R4                  \" S5      \
R6                  \" S\R                  " \
R                   5      5      \
R8                  \" S\
R                  5      0r\
R                  S\
R                  S\
R"                  S\
R&                  S\
R(                  S\
R*                  S\
R,                  S\
R.                  S\
R0                  S\
R2                  S\
R4                  S\
R6                  S\
R8                  S0rS rSS	 jr S
 r!S r"Sr#g)r      a  GLU Nurbs structure with oor and callback storage support

IMPORTANT NOTE: the texture coordinate callback receives a raw ctypes
data-pointer, as without knowing what type of evaluation is being done
(1D or 2D) we cannot safely determine the size of the array to convert
it.  This is a limitation of the C implementation.  To convert to regular
data-pointer, just call yourNurb.ptrAsArray( ptr, size, arrays.GLfloatArray )
with the size of data you expect.
N_justOOR_vec3_vec4_texc                    ^ ^ UU 4S jnU$ )z#Just do OOR on the last argument...c                  D   > U S S TR                  U S   5      4-   n T" U 6 $ )N)originalObject)argsfunctionselfs    M/home/wildlama/miniconda3/lib/python3.13/site-packages/OpenGL/GLU/glunurbs.pygetOOR!GLUnurbs._justOOR.<locals>.getOORh   s0    9 3 3DH =??Dd$$     )r!   r    r#   s   `` r"   r   GLUnurbs._justOORf   s    	% r%   c                    ^ ^^ UU U4S jnU$ )zBConvert first arg to size-element array, do OOR on arg2 if presentc                     > TR                  U S   T[        R                  5      n[        U 5      S:  a  TR	                  U S   5      nT" X5      $ T" U5      $ )Nr      )
ptrAsArrayr	   GLfloatArraylenr   )r   vecoorr    r!   sizes      r"   r.   GLUnurbs._vec3.<locals>.vecn   sS    //$q'$v/B/BCC4y1}))$q'2++&r%   r&   )r!   r    r0   r.   s   ``` r"   r   GLUnurbs._vec3l   s    	' 
r%   c                 &    U R                  US5      $ )zSize-4 vector version...   )r   )r!   r    s     r"   r   GLUnurbs._vec4v   s    zz8Q((r%   c                    ^ ^ UU 4S jnU$ )zTexture coordinate callback

NOTE: there is no way for *us* to tell what size the array is, you will
get back a raw data-point, not an array, as you do for all other callback
types!!!
c                  x   > [        U 5      S:  a   TR                  U S   5      nT" U S   U5      $ T" U S   5      $ )Nr*   r   )r-   r   )r   r/   r    r!   s     r"   r/   GLUnurbs._tex.<locals>.oor   sB    4y1}))$q'2a#//a**r%   r&   )r!   r    r/   s   `` r"   r   GLUnurbs._texy   s    	+ 
r%   r&   )   )$__name__
__module____qualname____firstlineno____doc__r   functionTypeForr   FUNCTION_TYPECALLBACK_FUNCTION_REGISTRARS_simpleGLU_NURBS_BEGINGLenumGLU_NURBS_BEGIN_DATActypesPOINTERGLvoidGLU_NURBS_VERTEXGLfloatGLU_NURBS_VERTEX_DATAGLU_NURBS_NORMALGLU_NURBS_NORMAL_DATAGLU_NURBS_COLORGLU_NURBS_COLOR_DATAGLU_NURBS_TEXTURE_COORDGLU_NURBS_TEXTURE_COORD_DATAGLU_NURBS_ENDGLU_NURBS_END_DATAGLU_NURBS_ERRORCALLBACK_TYPESWRAPPER_METHODSr   r   r   r   __static_attributes__r&   r%   r"   r   r      s    ,,X\\:M$  	'.."
 	$$m'..&.."@'
 	  -&..1#
 	%%}&..16>>'..3Q(
 	  -&..1#
 	%%}&..16>>'..3Q(
 	&..1"
 	$$m&..16>>'..3Q'
 	''&..1*
 	,,m&..16>>'..3Q/
 	m
 	""M&..0%
 	'..!
M)NV 	$$j  '%%w  '%%w$$g'',,ft""JO	)r%   r   c                     [         R                  " [        R                  5      n[        R
                  " [        5      [        R                  U /Ul        UR                  S   U :X  d   eU$ )z4Get gluNurbsCallback function with set last arg-typer   )	r   copyBaseFunctionrC   r   rG   rH   r   rE   argtypes)funcTyperesults     r"   _callbackWithTyper^      sT    ''  F ~~h/JFO??2(***Mr%   r   c                 $    U R                  X5      $ )z,Dispatch to the nurb's addCallback operation)addCallback)nurbwhichCallBackFuncs      r"   r   r      s    U22r%   c                     U " 5       nUS   nU$ )zAReturn a new nurbs renderer for the system (dereferences pointer)r   r&   )baseFunctionnewSetnews      r"   r   r      s     ^F
)CJr%   c                 0    U " XR                  U5      5      $ z6Note the Python object for use as userData by the nurb
noteObjectre   ra   userDatas      r"   r   r           oox) r%      c           	         U S:  a  [         R                  " U< SU < 35      eU [        :  a%  [         R                  " U< S[        < SU < 35      eUSU -  :  a%  [         R                  " SU< SU< SSU -  < 35      eg	)
zCheck that order is valid...r*   z should be 1 or more, is z should be z or less, is    zKnotcount must be at least 2x z is z should be at least N)r
   GLUError	MAX_ORDER)order	knotCountnames      r"   
checkOrderrw      s}    qynn26u>
 	
 
	nn37EJ
 	
 
ag	nnQUW`bcdibij
 	
 
r%   c                     [        U 5      (       a8  U S   nU SS  H)  nX2:  d  M
  [        R                  " U< SU< SU< 35      e   gg)z'Check that knots are in ascending orderr   r*   Nz has decreasing knot z after )r-   r
   rr   )knotsrv   knotnexts       r"   
checkKnotsr|      sI    
5zzQx!"ID{nn?CT4Q   r%   c                 0    U " XR                  U5      5      $ ri   rj   rl   s      r"   r   r      rn   r%   c           	         [         R                  R                  U5      n[         R                  R                  U5      n[         R                  R                  U5      n [         R                  R	                  U5      u  pgXV-
  n	[        R                  (       a  [        XS5        [        US5        U " XX'X9U5      $ ! [
         a  n[        R                  " S5      eSnAff = f)zYPythonic version of gluNurbsCurve

Calculates knotCount, stride, and order automatically
z"Need a 2-dimensional control arrayNzorder of NURBS curvezknots of NURBS curver	   r,   asArray	arraySize
dimensions
ValueErrorr
   rr   r   ERROR_CHECKINGrw   r|   )
re   ra   ry   controltyperu   lengthsteperrrt   s
             r"   r   r      s     ''0E##--u6I!!))74GI))44g? E""E&<=E12gd   InnFHHIs   !B< <
C!CC!c                    [         R                  R                  U5      n[         R                  R                  U5      n[         R                  R                  U5      n[         R                  R                  U5      n[         R                  R                  U5      n [         R                  R	                  U5      u  pn
Xh-
  nXy-
  nX-  nU
n[        R                  (       a0  [        XS5        [        XS5        [        US5        [        US5        Xl-
  X}-
  -  X-  :X  d  [        R                  " SXX'UXUXU5      eU " XX'UXUXU5      nU$ ! [
         a  n[        R                  " S5      eSnAff = f)z[Pythonic version of gluNurbsSurface

Calculates knotCount, stride, and order automatically
z"Need a 3-dimensional control arrayNzsOrder of NURBS surfaceztOrder of NURBS surfacezsKnots of NURBS surfaceztKnots of NURBS surfacezInvalid NURB structurer   )re   ra   sKnotstKnotsr   r   
sKnotCount
tKnotCountr   widthr   r   sOrdertOrdersStridetStrider]   s                    r"   r   r      sj      ((&2F$$..8J  ((&2F$$..8J!!))74GI"//::GET  FFjGG""F(ABF(ABF56F56
 12flBnn(f&g
 	
 &f'	F M5  InnFHHIs   "E 
E3E..E3c                 $   [         R                  R                  U5      nU[        R                  :X  a  SnO%U[        R
                  :X  a  SnO[        SU-  5      e[         R                  R                  U5      n[        XT-  5      nU " XX$U5      $ )zgluPwlCurve -- piece-wise linear curve within GLU context

data -- the data-array
type -- determines number of elements/data-point
rq   r:   zUnrecognised type constant: %s)	r	   r,   r   rC   GLU_MAP1_TRIM_2GLU_MAP_TRIM_3r   r   int)re   ra   datar   divisorr0   s         r"   r   r     s     &&.Dw&&&	''	'>EFF(($0Dt}DTD::r%   )-r?   
OpenGL.rawr   rC   OpenGLr   r   r   
OpenGL.GLUr   OpenGL.lazywrapperr   _lazyr	   r
   rG   weakrefOpenGL.platformr   r   __all__	GLUStructr   rH   r   restyper^   rV   itemscr\   cbrB   r[   	NameErrorr   r   r   rs   rw   r|   r   r   r   r   r&   r%   r"   <module>r      s   & 0 0   ,     $  	hy""G$4$4 hV '-nnh&@   # ++113LQx	H	&B13H))1.x..q1111;;r?h&&&	 4
		"h3 ##% & $$& ' 	
 '') *   ( !' "'R ; ;m  		s   +F
 
FF