
    3j                     l    S SK r S SKrS\S\R                  SS4S jrSS\S\S\R                  4S jjrg)	    Nfilename
pointcloudreturnc                    [        U [        5      (       a$  U R                  5       R                  S5      (       d  [	        SU < 35      e[
        R                  " U5      (       d  [	        S[        U5       35      eUR                  S:  d  UR                  S   S:w  a!  [	        S[        UR                  5       35      eUR                  SS5      n[
        R                  " U5      R                  SS	9nX#   nUR                  S
   n[        U SSS9 nUR                  SSSSU S3SSSS/5        US
:  ar  UR!                  5       R#                  5       R%                  [
        R&                  5      nUR)                  5        H#  u  pn
UR+                  US SU	S SU
S S35        M%     SSS5        g! , (       d  f       g= f)a*  Save to disk a pointcloud in PLY format.

Args:
    filename: the path to save the pointcloud.
    pointcloud: tensor containing the pointcloud to save.
      The tensor must be in the shape of :math:`(*, 3)` where the last
      component is assumed to be a 3d point coordinate :math:`(X, Y, Z)`.
.ply=Input filename must be a string with the .ply extension. Got z1Input pointcloud type is not a torch.Tensor. Got       z/Input pointcloud must have shape (..., 3). Got    )dimr   wutf-8)encodingzply
zformat ascii 1.0
zcomment arraiy generated
zelement vertex 
zproperty double x
zproperty double y
zproperty double z
zend_header
z.9g N)
isinstancestrlowerendswith	TypeErrortorch	is_tensortypendimshapetuplereshapeisfiniteanyopen
writelinesdetachcputofloat64tolistwrite)r   r   xyz
valid_maskvalid_pointsvalid_countfarrxyzs              T/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/geometry/pointcloud.pysave_pointcloud_plyr3      s    x%%(..*:*C*CF*K*KWX`Wcdee??:&&KDQ[L\K]^__j..r2a7I%PZP`P`JaIbcdd 

R
#C$((Q(/J?L$$Q'K	hg	.!	$,!+b1%%%		
 ?%%'++-00?C::<a1S'1S'1S'45 (' 
/	.	.s   BF11
F?header_sizec                 D   [        U [        5      (       a$  U R                  5       R                  S5      (       d  [	        SU < 35      e[
        R                  R                  U 5      (       d  [        S5      e[        U[        5      (       a  US:  d  [	        SU S35      e[        U S5       n[        U5       H  nUR                  5         M     UR                  5       nSSS5        WR                  S	S
S9nUR                  5       n[!        U5      S-  S:w  a  [        S[!        U5       S35      e["        R$                  " ['        [)        [*        US[!        U5      S-  S-   5      5      ["        R,                  S9R/                  SS5      nU$ ! , (       d  f       N= f)a  Load from disk a pointcloud in PLY format.

Args:
    filename: the path to the pointcloud.
    header_size: the number of header lines to skip.

Return:
    tensor containing the loaded points with shape :math:`(*, 3)` where
    :math:`*` represents the number of points.
r   r   z'Input filename is not an existing file.r   z2Input header_size must be a positive integer. Got .rbNr   ignore)errorsr   z-Expected 3 columns per point, got a total of z values.)dtyper
   )r   r   r   r   r   ospathisfile
ValueErrorintr!   rangereadlinereaddecodesplitlenr   tensorlistmapfloatfloat32view)r   r4   r-   _raw_datatextpartsrF   s           r2   load_pointcloud_plyrP   H   s]    x%%(..*:*C*CF*K*KWX`Wcdee77>>(##BCC{C(([1_L[MYZ[\\ 
h	{#AJJL $668	 
 ??78?4DJJLE 5zA~HUT\]^^ \\$s5%0G3u:?a2G*HIJRWR_R_`eefhjklFM! 
	s   .3F
F)   )r;   r   r   Tensorr3   r?   rP        r2   <module>rU      sJ   & 
 -6# -65<< -6D -6`## #C # #rT   