HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/share/inkscape/extensions/polyhedron_3d.pyo
�
��Yc@s�dZddlZddlZddlTddlZddlZddlmZej�yddl	TWn$ej
ed��ej�nXd�Z
d�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d e'fd!��YZ(d"e'fd#��YZ)d$ej*fd%��YZ+e,d&kr�e+�Z-e-j.�ndS('sy
Copyright (C) 2007 John Beard john.j.beard@gmail.com

##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

######LICENCE#######
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
i����N(t*(tcomputePointInNodes�Failed to import the numpy module. This module is required by this extension. Please install it and try again.  On a Debian-like system this can be done with the command 'sudo apt-get install python-numpy'.cCs,|jdkr|j}n
|jd}|S(Nt	from_files.obj(tobjt	spec_file(tself_optionstfile((s//usr/share/inkscape/extensions/polyhedron_3d.pytget_filenameGs
cCshddl}tdkr(tjd}nt}|jj|jj|��}|jj|d|�}|S(Ni����t__main__it
Poly3DObjects(	tos.patht__name__tsystargvt__file__tpathtabspathtdirnametjoin(tnametostfilenameR((s//usr/share/inkscape/extensions/polyhedron_3d.pytobjfileOscCs�tt|��}d}d}d|d|d|}d}d}d}xY|D]Q}	|	dd	kr�tj||	�}
|
r�|
jd
�|_q�qQ|	ddkrtj||	�}
|
r�|jjt|
jd
��t|
jd��t|
jd
��g�q�qQ|	ddkr�tj||	�}
|
r�g}xV|	r�tj||	�}|r�|jt	|jd���|jd�}	q<d}	q<Wt|�dkr�xCtt|�d�D](}
|j
j||
||
df�q�Wq�q�qQ|	ddkrQtj||	�}
|
r�g}xV|	rvtj||	�}|rm|jt	|jd���|jd�}	q!d}	q!Wt|�d
kr�|jj|�q�q�qQqQW|jdkr�|dd!|_ndS(Ns(.[nN]ame:\s*)(.*)s([\-\+\d*\.e]*)s(v\s+)s\s+s
(l\s+)(.*)s
(f\s+)(.*)s(\d+)([/\d]*)(.*)it#itviitlitfti����(topenRtretsearchtgroupRtvtxtappendtfloattinttNonetlentrangetedgtfce(RRtinfiletgetnametfloatingt	getvertextgetedgelinetgetfacelinet
getnextinttlinetmtvtxlisttm2ti((s//usr/share/inkscape/extensions/polyhedron_3d.pytget_obj_dataYsV
L	
/	
cCs�|\}}idd6t|j�d6|jd6|jd6|jd6}itj|�d6|tjdd	�6t|j	�d
6t|�d6t|�d6}tj
j|tjd
d�|�dS(Ns#000000tstrokesstroke-widthtfillsstroke-opacitysfill-opacitytstyletlabeltinkscapetrtcxtcytcircletsvg(tstrtthR7ts_opactf_opactsimplestyletformatStyletinkextaddNSR;tetreet
SubElement(t.0tstRtparentR<R=R8tcirc_attribs((s//usr/share/inkscape/extensions/polyhedron_3d.pytdraw_SVG_dot�s	;cCs�|\}}|\}}idd6t|j�d6|jd6}	itj|	�d6|tjdd�6dt|�d	t|�d
t|�d	t|�d6}
tjj|tjdd
�|
�dS(Ns#000000R6sstroke-widthsstroke-linecapR8R9R:sM t,s L tdRR?(	R@RAtlinecapRDRERFRGRHRI(RJt.1RKRRLtx1ty1tx2ty2R8tline_attribs((s//usr/share/inkscape/extensions/polyhedron_3d.pyt
draw_SVG_line�s'@c	Cs idd6t|j�d6|jd6|jd6|jd6|jd6}xxtt|��D]d}|dkrsd	}n
|d
}|t|||dd�dt|||dd�}qXW|d
}itj	|�d6|t
jdd�6|d6}t
jj
|t
jdd�|�dS(Ns#000000R6sstroke-widthsstroke-linejoinsstroke-opacityR7sfill-opacityitMtLiROtzR8R9R:RPRR?(R@RAtlinejoinRBR7RCR&R%RDRERFRGRHRI(	tptstfaceRKRRLR8R4RPRW((s//usr/share/inkscape/extensions/polyhedron_3d.pyt
draw_SVG_poly�s$!	
C
cCs�x||D]t}||dddd!}||dddd!}dt|d�dt|d�}t|||||�qWdS(NiiitEdget-(R@RX(t	edge_listR]RKRLtedgetpt_1tpt_2R((s//usr/share/inkscape/extensions/polyhedron_3d.pyt
draw_edges�s

&c	Cs{xt|D]l}|r0t||dt�|_nt|d�|_|d}t||j||dt|�|�qWdS(NiisFace:(tget_darkened_colourtpiR7R_R(R@(	t
faces_dataR]Rtshadingtfill_colRKRLR^tface_no((s//usr/share/inkscape/extensions/polyhedron_3d.pyt
draw_faces�s

cCsI|\}}}ddt||�dt||�dt||�S(NRs%02X(tfloor(RJtfactorR;tgtb((s//usr/share/inkscape/extensions/polyhedron_3d.pyRg�scCs�|jtd|j�d|jtd|j�d|jtd|j�d|jtd|j�d|jtd|j�d|jtd|j	�S(Ns%.2ft:(
tr1_axR@tr1_angtr2_axtr2_angtr3_axtr3_angtr4_angtr5_angtr6_ang(toptions((s//usr/share/inkscape/extensions/polyhedron_3d.pytmake_rotation_log�scCstt||��S(N(tacostdot(tvector1tvector2((s//usr/share/inkscape/extensions/polyhedron_3d.pyt	get_angle�scCstt||��S(N(tsqrtR(tvector((s//usr/share/inkscape/extensions/polyhedron_3d.pytlength�scCs|t|�S(N(R�(R�((s//usr/share/inkscape/extensions/polyhedron_3d.pyt	normalise�scCsot||dd�t||dd�}t||dd�t||dd�}t||�j�S(Niii(tarraytcrosstflatten(R]R^taRq((s//usr/share/inkscape/extensions/polyhedron_3d.pyt
get_normal�s..cCs,|rd}nd}|tt||��S(Ni����i(R�R�(R]R^tcw_woundtwinding((s//usr/share/inkscape/extensions/polyhedron_3d.pytget_unit_normal�s	cCs^|dkrt||�}n<|dkr<t||�}n|dkrZt||�}n|S(NtxtyR[(trot_xtrot_ytrot_z(tmatrixtangletaxis((s//usr/share/inkscape/extensions/polyhedron_3d.pytrotate�scCsWttt|�t|�dgt|�t|�dgdddgg��}||S(Nii(tmatR�tcostsin(R�R�t	trans_mat((s//usr/share/inkscape/extensions/polyhedron_3d.pyR��scCsWttt|�dt|�gdddgt|�dt|�gg��}||S(Nii(R�R�R�R�(R�R�R�((s//usr/share/inkscape/extensions/polyhedron_3d.pyR��s%cCsWttdddgdt|�t|�gdt|�t|�gg��}||S(Nii(R�R�R�R�(R�R�R�((s//usr/share/inkscape/extensions/polyhedron_3d.pyR��s$cCsBg}x5|D]-}|j|t|�jjj�d�q
W|S(Ni(R!R�tTttolist(tvtx_listR�ttransformed_ptsR ((s//usr/share/inkscape/extensions/polyhedron_3d.pytget_transformed_pts�s
+cCso||ddd}xRtdt|��D];}||ddd|kr,||ddd}q,q,W|S(Niii(R&R%(R]R^tmax_zR4((s//usr/share/inkscape/extensions/polyhedron_3d.pyt	get_max_zs
cCso||ddd}xRtdt|��D];}|||dd|kr,|||dd}q,q,W|S(Niii(R&R%(R]R^tmin_zR4((s//usr/share/inkscape/extensions/polyhedron_3d.pyt	get_min_zs
cCsKd}x4tt|��D] }||||dd7}qW|t|�S(Niii(R&R%(R]R^tsumR4((s//usr/share/inkscape/extensions/polyhedron_3d.pyt
get_cent_zscCsUd}|dkr$t||�}n-|dkrBt||�}nt||�}|S(NRtmaxtmin(R�R�R�(R]R^tmethodtz_sort_param((s//usr/share/inkscape/extensions/polyhedron_3d.pytget_z_sort_paramscCsc|j�|d}xHtt|�ddd�D]*}|||krQ||=q1||}q1W|S(Ni����i(tsortR&R%(tlisttlastR4((s//usr/share/inkscape/extensions/polyhedron_3d.pytremove_duplicates$s

#
cCs�g}x|tt|��D]h}t||�}xOt|�D]A}||||||d|g}|j�|j|�q<WqWt|�S(Ni(R&R%R�R!R�(t	face_listRbR4tedgestjtnew_edge((s//usr/share/inkscape/extensions/polyhedron_3d.pytmake_edge_list/s$
tStylecBseZd�ZRS(cCsi|j|_d|_d|_d|_t|jd�|_t|jd�|_d|_d|_dS(Ns#ff0000s#000000igY@tround(	RAR7tcolR;R@RCRBRQR\(tselfR|((s//usr/share/inkscape/extensions/polyhedron_3d.pyt__init__;s				(Rt
__module__R�(((s//usr/share/inkscape/extensions/polyhedron_3d.pyR�:stObjcBseZd�Zd�ZRS(cCs(g|_g|_g|_d|_dS(NR(R R'R(R(R�((s//usr/share/inkscape/extensions/polyhedron_3d.pyR�Gs			cCs�|jdkr\|jgkr*d|_q�tjtd��tjtd��d|_nJ|jgkrwd|_n/tjtd��tjtd��d|_dS(NR^s%No face data found in specified file.s6Try selecting "Edge Specified" in the Model File tab.
terrorRcs%No edge data found in specified file.s6Try selecting "Face Specified" in the Model File tab.
(ttypeR(RFterrormsgt_R'(R�R|((s//usr/share/inkscape/extensions/polyhedron_3d.pytset_typeMs(RR�R�R�(((s//usr/share/inkscape/extensions/polyhedron_3d.pyR�Es	tPoly_3DcBseZd�Zd�ZRS(c
Cstjj|�|jjddddddddd	�|jjd
dddddddd�|jjd
dddddddd�|jjddddddddd�|jjddddddddd�|jjddddddddd�|jjddddddddd�|jjddddddddd�|jjddddddddd�|jjddddddd dd�|jjd!dddddd"dd�|jjd#dddd$dd%dd&�|jjd'dddd$dd(dd&�|jjd)dddd$dd*dd&�|jjd+dddd$dd,dd&�|jjd-dddd$dd.dd&�|jjd/dddd$dd0dd&�|jjd1dddd$dd2dd3�|jjd4dddddd5dd6�|jjd7dddddd8dd�|jjd9dddd:dd;dd<�|jjd=dddd:dd>dd&�|jjd?dddd:dd@dd&�|jjdAdddd:ddBddC�|jjdDdddd:ddEddC�|jjdFdddd$ddGddH�|jjdIdddd$ddJddK�|jjdLdddd$ddMddK�|jjdNdddd$ddOddP�|jjdQddddddRddS�|jjdTddddddUdd�|jjdVddddddWddX�dS(YNs--tabtactiontstoreR�tstringtdestttabtdefaulttobjects--objRtcubes--spec_fileRsgreat_rhombicuboct.objs
--cw_woundtinkboolR�ttrues--typeR^s--r1_axRssX-Axiss--r2_axRus--r3_axRws--r4_axtr4_axs--r5_axtr5_axs--r6_axtr6_axs--r1_angR"Rtis--r2_angRvs--r3_angRxs--r4_angRys--r5_angRzs--r6_angR{s--scltsclgY@s--showtshowtfacess--shadetshades--f_rR#tf_ri�s--f_gtf_gs--f_btf_bs--f_opacRCids--s_opacRBs--thRAis--lv_xtlv_xis--lv_ytlv_ys--lv_ztlv_zi����s--backtbacktfalses--normtnorms--z_sorttz_sortR�(RFtEffectR�tOptionParsert
add_option(R�((s//usr/share/inkscape/extensions/polyhedron_3d.pyR�^s�






























cCs�|j}t�}t|�}t||�|j|�|jd�}t|�}|j|j|j	f}t
|j|j|j
f�}tt|j�|j�}dt|d�dt|d�d}	|dkr�|	dt|�d7}	n|jdt|�}
i|
tjd	d
�6|	d6}tjj|jd|�}ttd
t��}
xetdd�D]T}tdt|�d�}tdt|�d�td}t|
||�}
qmW|
|j }
t!|j"|
�}|j#dkrFx�tt$|��D]9}t%||d||dg|dt|�|�qWni|j#dkr�|j&dkrvt'|j(�}n	|j)}t*||||�n|j#dkr�|j&dkr�g}x�tt$|j(��D]�}|j(|}t+|||j,�}t-||�}t.|||j/�}|j0s4|ddkr�|j1||||f�q�q�W|j2d��t3||||j4|||�q�tj5t6d��ntj5t6d��dS(Nt1pxs
translate(iROit)s scale(RrR9R:t	transformRpiisso.rt_axt_angi�R tPointR'R^R(icSst|d|d�S(Ni(tcmp(R�R�((s//usr/share/inkscape/extensions/polyhedron_3d.pyt<lambda>	ss�Face Data Not Found. Ensure file contains face data, and check the file is imported as "Face-Specified" under the "Model File" tab.
s&Internal Error. No view type selected
(7R|R�RR5R�tunittouuR�R�R�R�R�R�R�R�RR�tview_centert
current_layerR@RR}RFRGRHRIR�tidentityR"R&tevalRhR�R�R�R R�R%RNR�R�R(R'RfR�R�R�R�R�R�R!R�RmR�R�R�(R�tsoRRtscaleRKRktlightingR�tpoly_transformt	poly_nametpoly_attribstpolyR�R4R�R�R�Rbtz_listR^R�R�((s//usr/share/inkscape/extensions/polyhedron_3d.pyteffect�s\		

*
"
:	
 "(RR�R�R�(((s//usr/share/inkscape/extensions/polyhedron_3d.pyR�]s	hR(/t__doc__RRtmathRFRDtsimpletransformRtlocalizetnumpyR�R�texitRRR5RNRXR_RfRmRgR}R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�Rtetaffect(((s//usr/share/inkscape/extensions/polyhedron_3d.pyt<module>2sX

		
	5					
		
																	�