403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/inkscape/extensions/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/inkscape/extensions/__pycache__/polyhedron_3d.cpython-310.pyc
o

0�aU=�@sdZddlZddlmZmZmZmZmZmZddl	Z	ddl
mZddl	mZm
Z
ddlmZmZzddlZWndZYdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�ZGdd �d e�ZGd!d"�d"e	j �Z!e"d#kr�e!��#�dSdS)$as
This extension draws 3d objects from a Wavefront .obj 3D file stored in a local folder
Many settings for appearance, lighting, rotation, etc are available.

                              ^y
                              |
        __--``|               |_--``|     __--
  __--``      |         __--``|     |_--``
 |       z    |        |      |_--``|
 |       <----|--------|-----_0-----|----------------
 |            |        |_--`` |     |
 |      __--``     <-``|      |_--``
 |__--``           x   |__--``|
  IMAGE PLANE           SCENE|
                              |

 Vertices are given as "v" followed by three numbers (x,y,z).
 All files need a vertex list
 v  x.xxx   y.yyy   z.zzz

 Faces are given by a list of vertices
 (vertex 1 is the first in the list above, 2 the second, etc):
 f  1   2   3

 Edges are given by a list of vertices. These will be broken down
 into adjacent pairs automatically.
 l  1   2   3

 Faces are rendered according to the painter's algorithm and perhaps
 back-face culling, if selected. The parameter to sort the faces by
 is user-selectable between max, min and average z-value of the vertices
�N)�acos�cos�floor�pi�sin�sqrt)�pairwise)�Group�Circle)�Move�LinecCs<|�tt|�t|�t|�d��}dt|�|d�|_||_dS)zDraw an SVG circle)�cx�cy�r�#000000)�stroke�stroke-width�fillN)�addr
�str�style�label)rr
r�widthr�name�parent�circle�r�//usr/share/inkscape/extensions/polyhedron_3d.py�draw_circleBs 
rcCsH|�t���}dt|�ddd�|_|�d|�t||�t||�g|_dS)Nr�none�round)rrrzstroke-linecapzinkscape:label)	r�inkex�PathElementrr�setrr�path)�x1�y1�x2�y2rrr�elemrrr�	draw_lineIs
�r*c	Cs�dt|j�|j|j|j|jd�}t��}|D]/}|s0|�t	||dd||dd��q|�t
||dd||dd��q|��|�t�
��}||_||_||_dS)z
Draw polygoner)rrzstroke-linejoinzstroke-opacityrzfill-opacity�rN)r�th�linejoin�s_opacr�f_opacr!�Path�appendrr�closerr"rrr$)	�pts�face�strrrr$�facet�polyrrr�	draw_polyPs�,,
r8c	Cs�|D]?}||dddd�}||dddd�}dt|d�dt|d�}t|d|d|d|d|j||�qdS)Nrr+��Edge�-)rr*r,)�	edge_listr3r5r�edge�pt_1�pt_2rrrr�
draw_edgesbs ,�r@c	CsZ|D](}|rt||dt�|_nt|d�|_|d}t||j||dt|�|�qdS)Nr+�zFace:)�get_darkened_colourrrr8�fcer)	�
faces_datar3�obj�shading�fill_colr5rr4�face_norrr�
draw_facesjs �rIcCs@ddt||d�dt||d�dt||d�S)z<return a hex triplet of colour, reduced in lightness 0.0-1.0�#z%02Xrr+r9)r)�rgb�factorrrrrBus
��rBcCs�|jtd|j�d|jtd|j�d|jtd|j�d|jtd|j�d|jtd|j�d|jtd|j	�S)z[makes a string recording the axes and angles of each rotation, so an object can be repeatedz%.2f�:)
�r1_axr�r1_ang�r2_ax�r2_ang�r3_ax�r3_ang�r4_ang�r5_ang�r6_ang)�optionsrrr�make_rotation_log|s:��������������rXcCstt�||��}t�|�|S)zEreturn the unit vector pointing in the same direction as the argument)r�numpy�dot�array)�vector�lengthrrr�	normalise�sr^c	Cs`t�t�||dd�t�||dd�t�||dd�t�||dd����S)zRnormal vector for the plane passing though the first three elements of face of ptsrr+r9)rY�crossr[�flatten�r3r4rrr�
get_normal�s**��rbcCs|rdnd}|tt||��S)z}
    Returns the unit normal for the plane passing through the
    first three points of face, taking account of winding
    ���r+)r^rb)r3r4�cw_wound�windingrrr�get_unit_normal�srfcCs�|dkrt�gd�dt|�t|�gdt|�t|�gg�}n;|dkr<t�t|�dt|�ggd�t|�dt|�gg�}n|dkrYt�t|�t|�dgt|�t|�dggd�g�}t�||�S)z)choose the correct rotation matrix to use�x)r+rrr�y)rr+r�z)rrr+)rYr[rr�matmul)�matrix�rads�axis�	trans_matrrr�rotate�s(�(�(�roc@seZdZdd�ZdS)�StylecCsJ|j|_d|_d|_d|_t|jd�|_t|jd�|_d|_d|_dS)Nz#ff0000rr9�Y@r )	r,r�colrrr/r.�linecapr-)�selfrWrrr�__init__�s
zStyle.__init__N)�__name__�
__module__�__qualname__rurrrrrp�srpc@sleZdZdZedd��Zdd�Zdd�Zdd	�Ze	e
fd
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�ZdS)�WavefrontObjzQWavefront based 3d object defined by the vertices and the faces (eg a polyhedron)cCs|j�dd�S)Nr)�meta�get)rtrrr�<lambda>�szWavefrontObj.<lambda>cCs>dtj�|��dd�di|_g|_g|_g|_|�|�dS)Nr�.r+r)	�osr$�basename�rsplitrz�vtx�edgrC�_parse_file)rt�filenamerrrru�s�zWavefrontObj.__init__cCsbtj�|�s
td�|���t|d��}|D]	}|�|���qWd�dS1s*wYdS)Nz#Can't find wavefront object file {}r)r~r$�isfile�IOError�format�open�_parse_line�strip)rtr��fhl�linerrrr��s�"�zWavefrontObj._parse_filecCsx|�d�rd|vr|�dd�\}}||j|��<dSdS|r8|�dd�\}}d|}t||�r:t||�|�dSdSdS)NrJrMr+�add_)�
startswith�splitrz�lower�hasattr�getattr)rtr�r�value�kind�	kind_namerrrr��s
�
�zWavefrontObj._parse_linecs�fdd�|��D�S)Ncsg|]}�|�d�d��qS)�/r�r�)�.0�v��typrr�
<listcomp>�sz/WavefrontObj._parse_numbers.<locals>.<listcomp>r�)r�r�rr�r�_parse_numbers��zWavefrontObj._parse_numberscCs,|�|t�}t|�dkr|j�|�dSdS)zAdd vertex from parsed linerAN)r��float�lenr�r1)rtr��vertexrrr�add_v�s�zWavefrontObj.add_vcCs0|�|t�}t|�dkr|j�t|��dSdS)zAdd line from parsed liner+N)r��intr�r�r1r�rtr��vtxlistrrr�add_l�s�zWavefrontObj.add_lcCs,|�|t�}t|�dkr|j�|�dSdS)zAdd face from parsed liner9N)r�r�r�rCr1r�rrr�add_f�s�zWavefrontObj.add_fc	Cs4g}|jD]}|�t�|t�|�j�j���q|S)z/translate vertex points according to the matrix)r�r1rYrjr[�T�tolist)rtrn�transformed_ptsr�rrr�get_transformed_pts�s
"z WavefrontObj.get_transformed_ptsc
Csdg}|jD]}t|�D]\}}|�t|||dt|�g��qqdd�ttdd�|D���D�S)z:make an edge vertex list from an existing face vertex listr+cSsg|]}t|��qSr)�list�r�rgrrrr��sz.WavefrontObj.get_edge_list.<locals>.<listcomp>css�|]}t|�VqdS)N)�tupler�rrr�	<genexpr>�s�z-WavefrontObj.get_edge_list.<locals>.<genexpr>)rC�	enumerater1�sortedr�r#)rtr<r4�jr=rrr�
get_edge_list�s
$� zWavefrontObj.get_edge_listN)rvrwrx�__doc__�propertyrrur�r��staticmethodrr�r�r�r�r�r�rrrrry�s	ryc@sdeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��Ze
dd��Ze
dd��Z
dS)�Poly3Dz4Generate a polyhedron from a wavefront 3d model filecCs�|jddd�|jddd�|jddd�|jdtjd	d
�|jddd�|jd
dd�|jddd�|jddd�|jddd�|jddd�|jddd�|jdtdd
�|jdtdd
�|jdtdd
�|jdtdd
�|jdtdd
�|jdtdd
�|jdtdd
�|jd|�d�d�|jd tjd	d
�|jd!td"d
�|jd#td$d
�|jd%td$d
�|jd&td'd
�|jd(td'd
�|jd)td*d
�|jd+td,d
�|jd-td,d
�|jd.td/d
�|jd0tjd1d
�|jd2|�d3�|jd
�dS)4Nz--tab�object)�defaultz--obj�cubez--spec_filezgreat_rhombicuboct.objz
--cw_woundT)�typer�z--typer4z--r1_axrgz--r2_axz--r3_axz--r4_axz--r5_axz--r6_axz--r1_anggz--r2_angz--r3_angz--r4_angz--r5_angz--r6_angz--sclrqz--show�gen)r�z--shadez--f_r�z--f_grz--f_bz--f_opac�dz--s_opacz--thr9z--lv_xr+z--lv_yz--lv_z���z--backFz--z_sort�z_sort)�add_argumentr!�Booleanr��
arg_methodr��
z_sort_min)rt�parsrrr�
add_arguments�s>zPoly3D.add_argumentscCs>d}|jjdkr
|jj}n|jjd}|��}tj�|d|�S)z"Get the filename for the spec file��	from_filez.obj�
Poly3DObjects)rWrE�	spec_file�ext_pathr~r$�join)rtr�moddirrrr�get_filename#s
zPoly3D.get_filenamec
Cs�tdur	t�d��|j}t|���}|j�d�}t|�}t	�
|jdt|��}|jj
j\}}|j�||�|j�|�t�dt�}tdd�D]}	t|d�|	��}
t|d�|	��td	}t|||
�}qG||j}|�|�}|�||||�|S)
Nznumpy is required.�1pxrMrAr+�zr{}_axzr{}_ang�)rYr!�AbortExtensionrWryr��svg�unittouurpr	�newrrX�	namedview�center�	transform�
add_translate�	add_scale�identityr��ranger�r�rro�sclr��show)
rt�sorE�scaler5r7�pos_x�pos_yrn�irm�angler�rrr�generate-s&


zPoly3D.generatec
Cs>t|�D]\}}t|j|d|d|jddt|�|�qdS)zGenerate Vertexrr+r�PointN)r�rrr,r)rtrEr5r7r�r�r3rrr�gen_vtxKs*�zPoly3D.gen_vtxcCs&|j}|jr
|��}t||||�dS)zGenerate edgesN)r�rCr�r@)rtrEr5r7r�r<rrr�gen_edgPszPoly3D.gen_edgcCs�|j}|j|j|jf}t|j|j|jf�}|jrag}t	|j�D]+\}	}
t
||
|j�}tt
�||��}|�||
�}
|jsB|ddkrK|�|
|||	f�q |jdd�d�t||||j|||�dSt�d��)z
Generate facer9rcSs|dS)Nrr)rgrrrr|rsz Poly3D.gen_fce.<locals>.<lambda>)�keyzFace data not found.N)rW�f_r�f_g�f_br^�lv_x�lv_y�lv_zrCr�rfrdrrYrZr��backr1�sortrI�shader!r�)rtrEr5r7r�r�rG�lighting�z_listr�r4�normr��z_sort_paramrrr�gen_fceZs�
zPoly3D.gen_fcec�t�fdd�|D��S)z4returns the largest z_value of any point in the facec�g|]
}�|dd�qS�r+r9r�r�r6�r3rrr�{�z%Poly3D.z_sort_max.<locals>.<listcomp>)�maxrarr�r�
z_sort_maxxr�zPoly3D.z_sort_maxcr�)z5returns the smallest z_value of any point in the facecr�r�rr�r�rrr��r�z%Poly3D.z_sort_min.<locals>.<listcomp>)�minrarr�rr�}r�zPoly3D.z_sort_mincst�fdd�|D��t|�S)z5returns the centroid z_value of any point in the facecr�r�rr�r�rrr��r�z&Poly3D.z_sort_cent.<locals>.<listcomp>)�sumr�rarr�r�z_sort_cent�szPoly3D.z_sort_centN)rvrwrxr�r�r�r�r�r�r�r�r�r�rrrrrr��s%



r��__main__)$r�r~�mathrrrrrrr!�inkex.utilsrr	r
�inkex.pathsrrrYrr*r8r@rIrBrXr^rbrfror�rpry�GenerateExtensionr�rv�runrrrr�<module>s:! 		
I�

Youez - 2016 - github.com/yon3zu
LinuXploit