%%
%% COPYRIGHT 2008-2017 by Manuel Luque, Arnaud Schmittbuhl, 
%%                        Jean-Paul Vignault, Herbert Voss.
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
% 
%% This work consists of the file pstricks.tex, PostScript macros 
%% for Generic TeX.
%% See the PSTricks User's Guide for description.
%
\csname PSTSOLIDESIIIDLoaded\endcsname
\let\PSTSOLIDESIIIDLoaded\endinput
% Requires PSTricks, pst-xkey and pst-node packages
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node \fi
\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey \fi
\ifx\MultidoLoaded\endinput\else \input multido.tex \fi 
% JPV & ML & AS & HV
\def\fileversion{4.34a}
\def\filedate{2018/12/27}
\message{`PSTSOLIDESIIID' v\fileversion, \filedate}
%
\pstheader{pst-solides3d.pro}
\pstheader{pst-implicitsurface.pro}

\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\pst@addfams{pst-solides3d}
\SpecialCoor
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Definition des differentes variables pour PSTricks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%% variables numeriques %%%%%%%%%%%%%%%%%
%
% point de vue et rotations de l'objet
% distance de l'ecran a l'observateur
%
\define@key[psset]{pst-solides3d}{viewpoint}{\def\pst@solides@viewpoint{#1 }}% position de l'observateur
\psset[pst-solides3d]{viewpoint=10 10 10}% coordonnees cartesiennes
\define@key[psset]{pst-solides3d}{Decran}{\def\pst@solides@Decran{#1 }}% distance de l'ecran
\define@key[psset]{pst-solides3d}{RotX}{\def\psk@solides@RotX{#1}}% rotation autour de Ox en degres
\define@key[psset]{pst-solides3d}{RotY}{\def\psk@solides@RotY{#1}}% rotation autour de Oy en degres
\define@key[psset]{pst-solides3d}{RotZ}{\def\psk@solides@RotZ{#1}}% rotation autour de Oz en degres
\psset[pst-solides3d]{RotZ=0,RotX=0,RotY=0,Decran=50}% valeurs par defaut
% parametres propres a chaque objet
\define@key[psset]{pst-solides3d}{resolution}{\def\pst@solides@resolution{#1 }} % nb points par courbe
\define@key[psset]{pst-solides3d}{no}{\def\pst@solides@no{#1 }} % numero face du solide
\define@key[psset]{pst-solides3d}{phi}{\def\pst@solides@phi{#1 }} % angle calotte sphere
\define@key[psset]{pst-solides3d}{theta}{\def\pst@solides@theta{#1 }} % angle calotte sphere
\define@key[psset]{pst-solides3d}{r0}{\def\pst@solides@rO{#1}} % rayon interieur tore
\define@key[psset]{pst-solides3d}{r1}{\def\pst@solides@rI{#1}} % rayon moyen tore
\define@key[psset]{pst-solides3d}{R}{\def\pst@solides@R{#1}} % rayon moyen tore
\define@key[psset]{pst-solides3d}{r}{\def\pst@solides@r{#1}} % rayon de la sphere circonscrite
\define@key[psset]{pst-solides3d}{a}{\def\pst@solides@a{#1}} % arete du cube (1 du parallelepipede)
\define@key[psset]{pst-solides3d}{b}{\def\pst@solides@b{#1}} % arete 2 du parallelepipede
\define@key[psset]{pst-solides3d}{c}{\def\pst@solides@c{#1 }} % arete 3 du parallelepipede
\define@key[psset]{pst-solides3d}{h}{\def\pst@solides@h{#1}} % hauteur du cylindre, du cone, du prisme
\define@key[psset]{pst-solides3d}{chanfreincoeff}{\def\pst@solides@chanfreincoeff{#1}} % coeff de chanfreinage
\define@key[psset]{pst-solides3d}{trunccoeff}{\def\pst@solides@trunccoeff{#1}} % coeff de troncature
\define@key[psset]{pst-solides3d}{affinagecoeff}{\def\pst@solides@affinagecoeff{#1}} % coeff de affinage
\define@key[psset]{pst-solides3d}{dualregcoeff}{\def\pst@solides@dualregcoeff{#1}} % coeff de dual
\define@key[psset]{pst-solides3d}{intersectiontype}{\def\pst@solides@intersectiontype{#1}} %
%
%% les affectations par defaut
\psset[pst-solides3d]{R=4,r1=4,r0=1.5,r=2,no=0,a=4,b=a,c=a,h=6,phi=0,theta=90,resolution=36,
trunccoeff=.25,chanfreincoeff=.8,affinagecoeff=.8,dualregcoeff=1,intersectiontype=-1}
%
%%%%%%%%%%%%%%%%% variables complexes %%%%%%%%%%%%%%%%%
%
\define@key[psset]{pst-solides3d}{base}{\def\pst@solides@base{#1}} % base du prisme
\psset[pst-solides3d]{base=-1 -1 1 -1 0 1}% coordonnees d'un triangle, base triangulaire par defaut
\define@key[psset]{pst-solides3d}{axe}{\def\pst@solides@axe{#1}} % axe du prisme
\psset[pst-solides3d]{axe=0 0 1}% vecteur definissant la direction de l'axe du prisme
\define@key[psset]{pst-solides3d}{plansection}{\def\pst@solides@plansection{#1}} % le plan de section
\psset[pst-solides3d]{plansection=}% pas de section par defaut
\define@key[psset]{pst-solides3d}{plansepare}{\def\pst@solides@plansepare{#1}} % le plan de separation
\psset[pst-solides3d]{plansepare=}% pas de separation par defaut
\define@key[psset]{pst-solides3d}{intersectionlinewidth}{\def\pst@solides@intersectionlinewidth{#1}}%
\psset[pst-solides3d]{intersectionlinewidth=1}%
\define@key[psset]{pst-solides3d}{intersectioncolor}{\def\pst@solides@intersectioncolor{#1}}%
\psset[pst-solides3d]{intersectioncolor=(rouge)}%
\define@key[psset]{pst-solides3d}{intersectionplan}{\def\pst@solides@intersectionplan{#1}}%
\psset[pst-solides3d]{intersectionplan=[0 0 1 0]}%
\define@key[psset]{pst-solides3d}{definition}{\def\pst@solides@definition{#1}} %
\psset[pst-solides3d]{definition=}%
\define@key[psset]{pst-solides3d}{args}{\def\pst@solides@args{#1}} %
\psset[pst-solides3d]{args=}%
\define@key[psset]{pst-solides3d}{transform}{\def\pst@solides@transform{#1}} %
\psset[pst-solides3d]{transform=}%
\define@key[psset]{pst-solides3d}{zcolor}{\def\pst@solides@zcolor{#1}} %
\psset[pst-solides3d]{zcolor=}%
\define@key[psset]{pst-solides3d}{tablez}{\def\pst@solides@tablez{#1}} %
\psset[pst-solides3d]{tablez=}%
\define@key[psset]{pst-solides3d}{RotSequence}{\def\pst@solides@RotSequence{#1}}%  20140607
\psset[pst-solides3d]{RotSequence=xyz}%

\def\Sol@Section{%
         R h 2 div neg % sommet 1
         R h 2 div % sommet 2
         r h 2 div % sommet 3
         r h 2 div neg % sommet 4
            }
\define@key[psset]{pst-solides3d}{section}{\def\pst@solides@section{#1}} % section de l'objet de revolution
\psset[pst-solides3d]{section=\Sol@Section}% coordonnees des sommets de la section

%% decalage pourle prisme
\define@key[psset]{pst-solides3d}{decal}{\def\pst@solides@decal{#1}}
\psset[pst-solides3d]{decal=-2}% decalage par defaut

% teinte des faces exterieures de l'objet a partir de PSTricks
% donnee par filcollor
% teinte des faces interieures de l'objet a partir de PSTricks
\define@key[psset]{pst-solides3d}{incolor}{\pst@getcolor{#1}\psincolor}
\psset[pst-solides3d]{incolor=green}
%
%% couleurs definies par l'utilisateur
\define@key[psset]{pst-solides3d}{color1}{\pst@getcolor{#1}\pscolora}
\psset[pst-solides3d]{color1=cyan}
%
\define@key[psset]{pst-solides3d}{color2}{\pst@getcolor{#1}\pscolorb}
\psset[pst-solides3d]{color2=magenta}
%
\define@key[psset]{pst-solides3d}{color3}{\pst@getcolor{#1}\pscolorc}
\psset[pst-solides3d]{color3=blue}
%
\define@key[psset]{pst-solides3d}{color4}{\pst@getcolor{#1}\pscolord}
\psset[pst-solides3d]{color4=red}
%
% resolution du trace
\newcount\test@mode
\define@key[psset]{pst-solides3d}{mode}{% resolution : mode=0,1,2, 3,4 ou 5
  \test@mode=#1\relax%
  \ifnum\test@mode>4%
    \typeout{mode must be 0,1,2,3 or 4 and not `\the\test@mode'. Value 4 forced.}\test@mode=4%
  \fi%
\edef\pst@solides@mode{\the\test@mode}}%
\psset[pst-solides3d]{mode=2}%
%
%%%%%%%%%%%%%%%%% variables booleennes %%%%%%%%%%%%%%%%%
%
%\define@boolkey[psset]{pst-solides3d}[Pst@]{SphericalCoor}[true]{%
%  \ifPst@SphericalCoor
%  \def\pst@solides@viewpoint{ 17.320509 45 35.264389 }%
%  \fi}
%\psset{SphericalCoor=false} 
%
\define@boolkey[psset]{pst-solides3d}[Pst@]{isolatin}[false]{}
\psset{isolatin=true}
\define@boolkey[psset]{pst-solides3d}[Pst@]{affinagerm}[false]{}
\psset{affinagerm=true}
\define@boolkey[psset]{pst-solides3d}[Pst@]{chanfrein}[true]{}
\psset{chanfrein=false}
\define@boolkey[psset]{pst-solides3d}[Pst@]{grid}[false]{}
\psset[pst-solides3d]{grid=true}
\define@boolkey[psset]{pst-solides3d}[Pst@]{dualreg}[true]{}
\psset{dualreg=false}
\define@boolkey[psset]{pst-solides3d}[Pst@]{geode}[true]{}
\psset{geode=false}
\define@boolkey[psset]{pst-solides3d}[Pst@]{hollow}[true]{}
\psset{hollow=false}
\define@boolkey[psset]{pst-solides3d}[Pst@]{biface}[true]{}
\psset{biface=true}%
\define@boolkey[psset]{pst-solides3d}[Pst@]{axesboxed}[true]{}
\psset{axesboxed=false}%
\define@boolkey[psset]{pst-solides3d}[Pst@]{showAxes}[true]{}
\psset{showAxes=true}%
\define@boolkey[psset]{pst-solides3d}[Pst@]{planmarks}[true]{}
\psset{planmarks=false}%
\define@boolkey[psset]{pst-solides3d}[Pst@]{plangrid}[true]{}
\psset{plangrid=false}%
\define@boolkey[psset]{pst-solides3d}[Pst@]{showbase}[true]{}
\psset{showbase=false}%
\define@boolkey[psset]{pst-solides3d}[Pst@]{showBase}[true]{}
\psset{showBase=false}%
\define@boolkey[psset]{pst-solides3d}[Pst@]{deactivatecolor}[true]{}
\psset{deactivatecolor=false}%

%% faces a enlever
\define@key[psset]{pst-solides3d}{rm}{\def\pst@solides@CoordinatesRm{#1}}
\psset[pst-solides3d]{rm=}% pas de faces par defaut
%% nom de la variable de sauvegarde du solide considere
\define@key[psset]{pst-solides3d}{name}{\def\pst@solides@name{#1}}
\psset[pst-solides3d]{name={}}% pas de nom par defaut
%% nom de la variable de sauvegarde du solide sur lequel on doit projeter
\define@key[psset]{pst-solides3d}{solidname}{\def\pst@solides@solidname{#1}}
\psset[pst-solides3d]{solidname=}% pas de nom par defaut
%% nom du fichier externe
\define@key[psset]{pst-solides3d}{file}{\def\pst@solides@file{#1}}
\psset[pst-solides3d]{file=}% pas de fichier par defaut
%% nom de l'objet de type plan
\define@key[psset]{pst-solides3d}{planname}{\def\pst@solides@planname{#1}}
\psset[pst-solides3d]{planname=}% pas de nom par defaut
%% nom de l'objet a charger (load)
\define@key[psset]{pst-solides3d}{load}{\def\pst@solides@load{#1}}
\psset[pst-solides3d]{load=}% pas de load par defaut
%% couleur face pour affinage
\define@key[psset]{pst-solides3d}{fcolor}{\def\pst@solides@fcolor{#1}}
\psset[pst-solides3d]{fcolor=}% pas de couleur par defaut
%% couleurs de faces isolees
\define@key[psset]{pst-solides3d}{fcol}{\def\pst@solides@fcol{#1}}
\psset[pst-solides3d]{fcol=}% pas de faces par defaut
%% les degrades ``hue''
\define@key[psset]{pst-solides3d}{hue}{\def\pst@solides@hue{#1}}
\psset[pst-solides3d]{hue=}% pas de degrade externe par defaut
\define@key[psset]{pst-solides3d}{inhue}{\def\pst@solides@inhue{#1}}
\psset[pst-solides3d]{inhue=}% pas de degrade interne par defaut
\define@key[psset]{pst-solides3d}{inouthue}{\def\pst@solides@inouthue{#1}}
\psset[pst-solides3d]{inouthue=}% pas de degrade total par defaut
%% definition des faces et des sommets d'un nouveau solide
\define@key[psset]{pst-solides3d}{sommets}{\def\pst@solides@sommets{#1}}
\psset[pst-solides3d]{sommets=}% pas de sommet par defaut
%% \define@key[psset]{pst-solides3d}{faces}{\def\pst@solides@faces{#1}}
%% \psset[pst-solides3d]{faces=}% pas de face par defaut
\define@key[psset]{pst-solides3d}{faces}{\def\pst@solides@faces{#1}}
\psset[pst-solides3d]{faces={}}% valeurs par defaut
%% numerotation des faces
\define@key[psset]{pst-solides3d}{numfaces}{\def\pst@solides@numfaces{#1}}
\define@key[psset]{pst-solides3d}{numsep}{\pst@getlength{#1}\pst@solides@numsep}
\psset[pst-solides3d]{numfaces=,numsep=15pt}% pas de numerotation par defaut
%% troncature des sommets
\define@key[psset]{pst-solides3d}{trunc}{\def\pst@solides@trunc{#1}}
\psset[pst-solides3d]{trunc=}% pas de troncature par defaut
%% affinage des faces
\define@key[psset]{pst-solides3d}{affinage}{\def\pst@solides@affinage{#1}}
\psset[pst-solides3d]{affinage=}% pas de affinage par defaut
%% numerotation des sommets
\define@key[psset]{pst-solides3d}{num}{\def\pst@solides@num{#1}}
\psset[pst-solides3d]{num=}% pas de numerotation defaut
%% pointage des sommets
\define@key[psset]{pst-solides3d}{show}{\def\pst@solides@show{#1}}
\psset[pst-solides3d]{show=}% pas de pointage par defaut
%% maillage de l'utilisateur
\define@key[psset]{pst-solides3d}{ngrid}{\def\pst@solides@ngrid{#1}}
\psset[pst-solides3d]{ngrid=}% pas de faces par defaut
%\psset[pst-solides3d]{ngrid=20 20}% pas de faces par defaut

% source de la lumiere :
\define@key[psset]{pst-solides3d}{lightsrc}{\def\pst@solides@CoordinatesLight{#1}}
\psset[pst-solides3d]{lightsrc=}% pas de coordonnees par defaut
% intensite de la lumiere
\define@key[psset]{pst-solides3d}{lightintensity}{\def\pst@solides@lightintensity{#1}}
\psset[pst-solides3d]{lightintensity=2}

%% Reservation des noms de macros
% #1=type de reservation (action, object...) associee a une liste qui
% doit forcement etre du type pst@solides@list@#1
\def\pst@solides@reservednames#1{%
\edef\@tempa{\csname pst@solides@list@#1\endcsname}
\@for \name:=\@tempa\do{%
  \expandafter\def\csname pst@solides@#1@\name\endcsname{}%
}}
% type de dessin
\def\pst@solides@list@action{none,draw,draw*,draw**,writeobj,writesolid,writeoff}
%% Reservation de macros correspondants aux actions
\pst@solides@reservednames{action}
\define@key[psset]{pst-solides3d}{action}{%
  \ifcsname pst@solides@action@#1\endcsname
    \def\pst@solides@action{#1}%
  \else
    \@pstrickserr{This action is not authorized, the procedure draw** is
    chosen by default}{}%
  \fi}
% type par defaut = faces vues remplies
\psset[pst-solides3d]{action=draw**}%
%
% choix de la police et de la taille des caracteres en cm !!
\define@key[psset]{pst-solides3d}{PSfont}[NimbusRomNo9L-Regu]{\def\pst@solides@PSfont{/#1 }}
\define@key[psset]{pst-solides3d}{fontsize}{\def\pst@solides@fontsize{#1 }}
\psset[pst-solides3d]{PSfont=NimbusRomNo9L-Regu,fontsize=10}

% nature de l'objet
\def\pst@solides@list@object{%
tore,cube,tetrahedron,octahedron,icosahedron,dodecahedron,sphere,%
cylindre,cylindrecreux,cone,conecreux,tronccone,troncconecreux,%
grille,prisme,anneau,parallelepiped,prismecreux,ruban,calottesphere,face,%
Surface,Surface*,surface,calottespherecreuse,polygoneregulier,fusion,new,chemin,courbeR2,courbe,%
surfaceparametree,texte,trigospherique,vecteur,line,objfile,datfile,surface*,%
plan,offfile,geode,load,plantype,point,pie,droite,polygone,cercle,rightangle}
%
%% Reservation de macros correspondants aux objects
\pst@solides@reservednames{object}
\define@key[psset]{pst-solides3d}{object}{%
 \ifcsname pst@solides@object@#1\endcsname
   \def\psk@solides@object{pst-#1}%
 \else
    \@pstrickserr{The solid #1 is not defined, the solid by default is
    drawn}{}%
 \fi}
%% Ajout de solides  la liste des objets
\def\addtosolideslistobject#1{%
% ajouter les nouveaux objets  la liste
\expandafter\def\expandafter\pst@solides@list@object\expandafter%
 {\pst@solides@list@object,#1}%
% Reserver le nom des nouveaux objets
 \edef\@tempa{#1}%
 \@for \name:=\@tempa\do{%
  \expandafter\def\csname pst@solides@object@\name\endcsname{}%
 }}
% solide par defaut
\psset[pst-solides3d]{object=tore}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% pour le quadrillage 3d
\define@key[psset]{pst-solides3d}{spotX}{\def\pst@solides@@spotX{#1}}%
\define@key[psset]{pst-solides3d}{spotY}{\def\pst@solides@@spotY{#1}}%
\define@key[psset]{pst-solides3d}{spotZ}{\def\pst@solides@@spotZ{#1}}%
\define@key[psset]{pst-solides3d}{QZ}{\def\pst@solides@@QZ{#1}}%
\define@key[psset]{pst-solides3d}{Zmin}{\def\pst@solides@@Zmin{#1 }}%
\define@key[psset]{pst-solides3d}{Zmax}{\def\pst@solides@@Zmax{#1 }}%
\psset[pst-solides3d]{spotX=dr,spotY=dl,spotZ=l,QZ=0,Zmin=-4,Zmax=4}
% spotX, Y, Z vaut de 0 a 360 degres pour placer les valeurs correctement
% QZ translation du quadrillage suivant l'axe Oz

\define@key[psset]{pst-solides3d}{stepX}{\pst@getint{#1}\psk@solides@stepX}
\define@key[psset]{pst-solides3d}{stepY}{\pst@getint{#1}\psk@solides@stepY}
\define@key[psset]{pst-solides3d}{stepZ}{\pst@getint{#1}\psk@solides@stepZ}
\define@key[psset]{pst-solides3d}{ticklength}{\pst@checknum{#1}\psk@solides@ticklength}
%\define@key[psset]{pst-solides3d}{Dx}{\pst@checknum{#1}\psk@solides@Dx }
%\define@key[psset]{pst-solides3d}{Dy}{\pst@checknum{#1}\psk@solides@Dy }
%\define@key[psset]{pst-solides3d}{Dz}{\pst@checknum{#1}\psk@solides@Dz }
\psset[pst-solides3d]{stepX=1,stepY=1,stepZ=1,ticklength=0.2}% the step for the axes labels
\define@key[psset]{pst-solides3d}{xytranslate}{\def\pst@solides@xytranslate{#1 }} 
\psset[pst-solides3d]{xytranslate=0 0} 
%
\def\gridIIID{\pst@object{gridIIID}}
%% usage : \gridIIID[options](x_min,x_max)(y_min,y_max)
\def\gridIIID@i(#1,#2)(#3,#4){%
  \@ifnextchar[{\gridIIID@ii(#1,#2)(#3,#4)}{\gridIIID@ii(#1,#2)(#3,#4)[2,2,3]}}
\def\gridIIID@ii(#1,#2)(#3,#4)[#5,#6,#7]{%
  \pst@killglue%
  \addbefore@par{planmarks}%
  \begingroup%
  \use@par%
  \psSolid[object=parallelepiped,
    intersectiontype=-1,
    a={#2 #1 sub},b={#4 #3 sub},
    c={\pst@solides@@Zmax\space \pst@solides@@Zmin\space sub},
    action=draw](#1 #2 add 2 div,#3 #4 add 2 div,\pst@solides@@Zmax \pst@solides@@Zmin add 2 div )%
  \ifPst@planmarks
  \ifnum#1<0 \pst@cnta=-#1 \def\pst@minus{-}\else\pst@cnta=#1 \def\pst@minus{}\fi
  \divide\pst@cnta by \psk@solides@stepX
  \multido{\ix=\psk@solides@stepX+\psk@solides@stepX}{\pst@cnta}{%
    \psPoint(\pst@minus\ix,#4,\pst@solides@@Zmin){X1}%
    \psPoint(\pst@minus\ix,#4 \psk@solides@ticklength\space add,\pst@solides@@Zmin){X2}%
    \psline(X1)(X2)%
    \uput[\pst@solides@@spotX](X1){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@minus\ix\ifPst@mathLabel$\fi}}%
  \ifnum#2<0 \pst@cnta=-#2 \def\pst@minus{-}\else\pst@cnta=#2 \def\pst@minus{}\fi
  \divide\pst@cnta by \psk@solides@stepX%
  \advance\pst@cnta by \@ne
  \multido{\ix=0+\psk@solides@stepX}{\the\pst@cnta}{%
    \psPoint(\pst@minus\ix,#4,\pst@solides@@Zmin){X1}
    \psPoint(\pst@minus\ix,#4 \psk@solides@ticklength\space add,\pst@solides@@Zmin){X2}
    \psline(X1)(X2)
    \uput[\pst@solides@@spotX](X1){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@minus\ix\ifPst@mathLabel$\fi}}
%
  \ifnum#3<0 \pst@cnta=-#3 \def\pst@minus{-}\else\pst@cnta=#3 \def\pst@minus{}\fi
  \divide\pst@cnta by \psk@solides@stepY
  \multido{\iy=\psk@solides@stepY+\psk@solides@stepY}{\pst@cnta}{%
    \psPoint(#2,\pst@minus\iy,\pst@solides@@Zmin){Y1}
    \psPoint(#2 \psk@solides@ticklength\space add,\pst@minus\iy,\pst@solides@@Zmin){Y2}
    \psline(Y1)(Y2)
    \uput[\pst@solides@@spotY](Y1){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@minus\iy\ifPst@mathLabel$\fi}}
  \ifnum#4<0 \pst@cnta=-#4 \def\pst@minus{-}\else\pst@cnta=#4 \def\pst@minus{}\fi
  \divide\pst@cnta by \psk@solides@stepY
  \advance\pst@cnta by \@ne
  \multido{\iy=0+\psk@solides@stepY}{\pst@cnta}{%
    \psPoint(#2,\pst@minus\iy,\pst@solides@@Zmin){Y1}
    \psPoint(#2 \psk@solides@ticklength\space add,\pst@minus\iy,\pst@solides@@Zmin){Y2}
    \psline(Y1)(Y2)
    \uput[\pst@solides@@spotY](Y1){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@minus\iy\ifPst@mathLabel$\fi}}
%
  \pst@cnta=\pst@solides@@Zmin \pst@cntb=\pst@solides@@Zmax 
  \ifnum\pst@cnta=\pst@cntb\else% same z values?
    \pst@cnta=\pst@solides@@Zmin
    \ifnum\pst@cnta<0 \pst@cnta=-\pst@cnta \def\pst@minus{-}
    \else\def\pst@minus{}\fi%
    \divide\pst@cnta by \psk@solides@stepZ
    \multido{\iz=\psk@solides@stepZ+\psk@solides@stepZ}{\pst@cnta}{%
      \psPoint(#2,#3,\pst@minus\iz){Z1}
      \psPoint(#2,#3 \psk@solides@ticklength\space sub,\pst@minus\iz){Z2}
      \psline(Z1)(Z2)
      \uput[\pst@solides@@spotZ](Z1){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@minus\iz\ifPst@mathLabel$\fi}}
    \pst@cnta=\pst@solides@@Zmax %
    \ifnum\pst@cnta<0 \pst@cnta=-\pst@pst@cnta \def\pst@minus{-}
    \else\def\pst@minus{}\fi%
    \divide\pst@cnta by \psk@solides@stepZ
    \advance\pst@cnta by \@ne
    \multido{\iz=0+\psk@solides@stepZ}{\pst@cnta}{%
      \psPoint(#2,#3,\pst@minus\iz){Z1}
      \psPoint(#2,#3 \psk@solides@ticklength\space sub,\pst@minus\iz){Z2}
      \psline(Z1)(Z2)
      \uput[\pst@solides@@spotZ](Z1){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@minus\iz\ifPst@mathLabel$\fi}}
  \fi
  \fi% \ifPst@planmarks
%
  \ifPst@showAxes
    \psPoint(0,0,\pst@solides@@Zmax #7 add){Z'}
    \psPoint(#2 #5 add,0,0){X'}
    \psPoint(0,#4 #6 add, 0){Y'}
    \psPoint(0,0,\pst@solides@@Zmax){Z}
    \psPoint(#2,0,0){X}
    \psPoint(0,#4,0){Y}
    \psPoint(0,0,0){O}
    \uput[\pst@solides@@spotY](X'){$x$}
    \uput[\pst@solides@@spotX](Y'){$y$}
    \uput[u](Z'){$z$}
    \ifPst@showOrigin
      \psline[linestyle=dashed](O)(X)
      \psline[linestyle=dashed](O)(Y)
      \psline[linestyle=dashed](O)(Z)
    \fi
%\psset{linewidth=2\pslinewidth}
    \psline{->}(Z)(Z')\psline{->}(Y)(Y')\psline{->}(X)(X')
  \fi%
  \endgroup%
  \ignorespaces%
}
%
\@ifundefined{pst@linetype}{\def\pst@linetype{0}}{}%  preventing errors hv 2009-07-03
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% code insere dans le .ps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
\pst@def{optionssolides}<
  /PSfont  \pst@solides@PSfont\space  def
  /pst@fill { \psk@opacityalpha .setopacityalpha fill } def
  /strokeopacity \psk@opacityalpha def
  /fillopacity \psk@opacityalpha def
  /xunit {\pst@number\psunit } def
%% /cm {\pst@number\psunit mul} def
%% /cm_1 {\pst@number\psunit div} def
  /decal \pst@solides@decal\space def % decalage
  /viewpointXYZ { \pst@solides@viewpoint } def
  /Decran \pst@solides@Decran\space def % distance de l'ecran
%
  /RotX \psk@solides@RotX\space def
  /RotY \psk@solides@RotY\space def
  /RotZ \psk@solides@RotZ\space def
  /RotSequence (\pst@solides@RotSequence) def
     RotSequence (xyz) eq RotSequence (xzy) eq or
     RotSequence (yxz) eq or RotSequence (yzx) eq or
     RotSequence (zxy) eq or RotSequence (zyx) eq or {} { /RotSequence (xyz) def } ifelse
%
  /fontsize \pst@solides@fontsize\space \pst@number\psunit mul 28.45 div def
%
  /projectionsifacevisible \ifPst@visibility true \else false \fi def
%
/R \pst@solides@R\space def % pour le tore
/r1 \pst@solides@rI\space def % pour le tore
/r0 \pst@solides@rO\space def % pour le tore
%/resolution \pst@solides@resolution\space def % pour le nb de points par courbe
\pst@solides@resolution setresolution % ------ hv 20110713
/phi \pst@solides@phi\space def % pour la calotte spherique
/theta \pst@solides@theta\space def % pour la calotte spherique
/r \pst@solides@r\space def % rayon sphere circonscrite
/a \pst@solides@a\space def % arete du cube (1 du parallelepipede)
/b \pst@solides@b\space def % arete 2 du parallelepipede
/c \pst@solides@c\space def % arete 3 du parallelepipede
/h \pst@solides@h\space def % hauteur du cylindre, du cone, du prisme
/trunccoeff \pst@solides@trunccoeff\space def % coeff de troncature
/chanfreincoeff \pst@solides@chanfreincoeff\space def % coeff de chanfreinage
/affinagecoeff \pst@solides@affinagecoeff\space def % coeff de affinage
/dualregcoeff \pst@solides@dualregcoeff\space def % coeff de dual
/solidintersectiontype \pst@solides@intersectiontype\space def % type d'intersection
/section {\pst@solides@section} def % section de l'objet de revolution
/base [ \pst@solides@base ] def
/solidintersectionlinewidth [ \pst@solides@intersectionlinewidth ] def
/solidintersectioncolor [ \pst@solides@intersectioncolor ] def
/solidintersectionplan [ \pst@solides@intersectionplan ] def
/axe  { \pst@solides@axe } def
/plansection  [ \pst@solides@plansection ] def
\ifx\pst@solides@function\@empty\else /function (\pst@solides@function) def \fi
%
/definition  (\pst@solides@definition) def
/args  { \pst@solides@args} def
/Mode \pst@solides@mode\space def % resolution du trace
/lightintensity \pst@solides@lightintensity\space def % intensite de la lumiere
/tablez  [\pst@solides@tablez] def
/zcolor  [\pst@solides@zcolor] def
%
/solidlinewidth {\pst@number\pslinewidth} def
/linecolor  {\pst@usecolor\pslinecolor} def
/linestyle  {\pslinestyle} def
/fillcolor  {\pst@usecolor\psfillcolor currentrgbcolor} def
/fillincolor  {\pst@usecolor\psincolor currentrgbcolor} def
%
/color1 {\pst@usecolor\pscolora } def
/color2 {\pst@usecolor\pscolorb } def
/color3 {\pst@usecolor\pscolorc } def
/color4 {\pst@usecolor\pscolord } def
%
/range [ \pst@solides@range ] def
/action (\pst@solides@action) def
/texte (\pst@solides@text) def
/pos (\pst@solides@pos) def
/proj-fontsize {\pst@solides@fontsize\space \pst@number\psunit mul 28.45 div } bind def
%
\ifx\pst@solides@CoordinatesLight\@empty\else /lightsrc {\pst@solides@CoordinatesLight} def \fi
%
/rmfaces [\pst@solides@CoordinatesRm] def
\ifx\pst@solides@plansepare\@empty\else/plansepare {\pst@solides@plansepare} def\fi
\ifx\pst@solides@transform\@empty \else/pst-transformoption { \pst@solides@transform} def\fi
\ifx\pst@solides@name\@empty      \else/solidname (\pst@solides@name) def\fi
\ifx\pst@solides@file\@empty      \else/solidfilename (\pst@solides@file) def\fi
\ifx\pst@solides@planname\@empty  \else/solidplanname (\pst@solides@planname) def\fi
\ifx\pst@solides@load\@empty      \else/solidloadname {\pst@solides@load} def\fi
\ifx\pst@solides@fcolor\@empty    \else/solidfcolor (\pst@solides@fcolor) def\fi
%
/fcol [\pst@solides@fcol] def
/solidhue [\pst@solides@hue] def
/solidinouthue [\pst@solides@inouthue] def
/solidinhue [\pst@solides@inhue] def
/origin {\pst@solides@origin} def
%
%% /solidhue \ifPst@hue true \else false \fi def
%
/sommets [\pst@solides@sommets] def
/faces [\pst@solides@faces] def
/solidshow [\pst@solides@show] def
/solidnum [\pst@solides@num] def
SolidesDict begin /solidnumsep \pst@solides@numsep\space def end
/solidnumf [\pst@solides@numfaces] def
/solidtrunc [\pst@solides@trunc] def
/solidaffinage [\pst@solides@affinage] def
/ngrid [\pst@solides@ngrid] def
%
/isolatin \ifPst@isolatin true \else false \fi def
/affinagerm \ifPst@affinagerm true \else false \fi def
/chanfrein \ifPst@chanfrein true \else false \fi def
/solidgrid \ifPst@grid true \else false \fi def
/solidplanmarks \ifPst@planmarks true \else false \fi def
/solidplangrid \ifPst@plangrid true \else false \fi def
/solidshowbase3d \ifPst@showBase true \else false \fi def
/activationgestioncouleurs \ifPst@deactivatecolor false \else true \fi def
/solidshowbase \ifPst@showbase true \else false \fi def
/soliddualreg \ifPst@dualreg true \else false \fi def
/solidgeode \ifPst@geode true \else false \fi def
/solidhollow \ifPst@hollow true \else false \fi def
/solidbiface \ifPst@biface true \else false \fi def
%
%% /solidnum \ifPst@num true \else false \fi def
%
viewpointXYZ /ZpointVue ED /YpointVue ED /XpointVue ED
/THETA {YpointVue XpointVue atan} bind def
/PHI   {ZpointVue XpointVue dup mul YpointVue dup mul add sqrt atan} bind def
/Dobs  {XpointVue dup mul YpointVue dup mul add ZpointVue dup mul add sqrt} bind def
%    CoefficientsMT
XpointVue YpointVue ZpointVue /viewpoint defpoint3d
\pst@solides@xytranslate /transY ED /transX ED 
>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro \psSolid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\define@boolkey[psset]{pst-solides3d}[Pst@]{solidmemory}[true]{}
\psset{solidmemory=false}
%
\let\composeSolid\use@pscode
\let\endpspictureS@lid\endpspicture%  redefine \endpspicture (hv)
\def\endpspicture{\ifPst@solidmemory\use@pscode\fi\endpspictureS@lid\global\Pst@solidmemoryfalse}
%
\def\psSolid{\def\pst@par{PSfont=NimbusSanL-Regu}\pst@object{psSolid}}
\def\psSolid@i{\@ifnextchar({\psSolid@ii}{\psSolid@iv{ 0. 0. 0. }}}
\def\psSolid@ii(#1){\expandafter\psSolid@iii#1,,,\@nil}
\def\psSolid@iii#1,#2,#3,#4\@nil{%
  \ifx\relax#2\relax\psSolid@iv{#1}\else\psSolid@iv{#1 #2 #3}\fi}
\def\psSolid@iv#1{%
  \pst@killglue
  \ifPst@solidmemory\begingroup\use@par\else\begin@ClosedObj\fi
  \addto@pscode{
    \pst@prepscode
    \tx@setTransparency
    1 setlinejoin
    \tx@optionssolides 
    SolidesDict begin
    #1 
    /CZ exch def
    /CY exch def
    /CX exch def
    % nature du solide
    \psk@solides@object\space
    end
    \pst@postpscode
  }% fin du code ps
  \ifPst@solidmemory\endgroup\else\end@ClosedObj\fi
  \ignorespaces}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro \codejps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\codejps#1{{%
  \define@key[psset]{pst-solides3d}{object}{\def\psk@solides@object{#1}}%
  \psSolid[object={#1} exec](0,0,0)}}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro \psTransformPoint
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% transformation d'un point
% \pstransformIIID[RotX=,...](x y z)(CX,CY,CZ)
% Rotation d'un point(x y z)
% autour des axes Ox, Oy et Oz
% suivie
% de la translation au point (CX,CY,CZ)
\def\psTransformPoint{\def\pst@par{}\pst@object{psTransformPoint}}
\def\psTransformPoint@i(#1)(#2,#3,#4)#5{{% coordonnees cartesiennes
  \begin@SpecialObj
\pnode(!
    \tx@optionssolides
    SolidesDict begin
    #1 RotX RotY RotZ rotateOpoint3d
    #2 #3 #4 translatepoint3d
   3dto2d cm_1 exch cm_1 exch
   end){#5}%
   \end@SpecialObj
  }\ignorespaces}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro \psPoint
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% placer un point en particulier
% \psPoint[options du point de vue](x y z)
\def\psPoint{\def\pst@par{}\pst@object{psPoint}}
\def\psPoint@i(#1,#2,#3)#4{{% coordonnees cartesiennes
%  \begin@SpecialObj
  \pnode(!
    \tx@optionssolides
    SolidesDict begin
    #1 #2 #3
    3dto2d cm_1 exch cm_1 exch
    end){#4}%
%  \end@SpecialObj
}\ignorespaces%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Vecteur normal a un plan
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\Normale{\pst@object{Normale}}
\def\Normale@i(#1,#2,#3){%
% #1 rayon
% #2 longitude
% #3 latitude
\pst@killglue%
\begingroup%
\use@par%
\pstVerb{/latitude #3 def
         /longitude #2 def
         /Rayon #1 def
         /xP Rayon #2 cos #3 cos mul mul def
         /yP Rayon #2 sin #3 cos mul mul def
         /zP Rayon #3 sin mul def}%
\psSolid[object=vecteur,RotZ=#2,RotY=-#3,
         args=1.7 0 0](xP,yP,zP)
  \endgroup%
  \ignorespaces%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% les axes IIId
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% axisemph

\define@boolkey[psset]{pst-solides3d}[Pst@]{showOrigin}[true]{}
\define@boolkey[psset]{pst-solides3d}[Pst@]{mathLabel}[true]{}
\psset[pst-solides3d]{showOrigin,mathLabel}%

\def\pst@solides@axisnames@i#1,#2,#3,#4\@nil{%
 \def\pst@solides@axesIIID@xname{#1}
 \def\pst@solides@axesIIID@yname{#2}
 \def\pst@solides@axesIIID@zname{#3}}

\define@key[psset]{pst-solides3d}{axisnames}{\expandafter\pst@solides@axisnames@i#1,,,\@nil}%
\psset[pst-solides3d]{axisnames={x,y,z}}

\define@key[psset]{pst-solides3d}{axisemph}{\def\pst@solides@axesIIID@emph{#1}}
\psset[pst-solides3d]{axisemph=}

\def\axesIIID{\pst@object{axesIIID}}
\def\axesIIID@i(#1,#2,#3){%
\@ifnextchar({\axesIIID@ii(#1,#2,#3)}{\axesIIID@ii(0,0,0)(#1,#2,#3)}}
\def\axesIIID@ii(#1,#2,#3)(#4,#5,#6){% axes 3d 
  \pst@killglue%
  \begingroup%
  \addbefore@par{arrows=->}%
  \use@par%
  \psPoint(0,0,0){O}
  \psPoint(#1,0,0){X}
  \psPoint(0,#2,0){Y}
  \psPoint(0,0,#3){Z}
  \psPoint(#4,0,0){X'}
  \psPoint(0,#5,0){Y'}
  \psPoint(0,0,#6){Z'}
  \psPoint(#4 \pst@number\pslabelsep \pst@number\psunit div add,0, 0)
  {Xname}
  \psPoint(0, #5 \pst@number\pslabelsep \pst@number\psunit div add, 0)
  {Yname}
  \psPoint(0, 0, #6 \pst@number\pslabelsep \pst@number\psunit div add)
  {Zname}
  \ifPst@showOrigin
    \psline[linestyle=dashed,arrows=-](O)(X)
    \psline[linestyle=dashed,arrows=-](O)(Y)
    \psline[linestyle=dashed,arrows=-](O)(Z)
  \fi
  \psline(X)(X')
  \psline(Y)(Y')
  \psline(Z)(Z')
  \rput(Xname){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@solides@axesIIID@xname\ifPst@mathLabel$\fi}
  \rput(Yname){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@solides@axesIIID@yname\ifPst@mathLabel$\fi}
  \rput(Zname){\ifPst@mathLabel$\fi\pst@solides@axesIIID@emph\pst@solides@axesIIID@zname\ifPst@mathLabel$\fi}
  \endgroup%
  \ignorespaces%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro \psSurface
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\psSurface{\@ifnextchar*{\@startrue\psSurface@i}{\@starfalse\psSurface@i*}}
\def\psSurface@i*{\@ifnextchar[{\psSurface@ii}{\psSurface@ii[]}}
\def\psSurface@ii[#1](#2,#3)(#4,#5)#6{%
%% \def\hue{0 1 #4 #2 sub \pst@solides@dx\space div
%%              #5 #3 sub \pst@solides@dy\space div mul
%%  {/iF ED iF [1 iF #4 #2 sub \pst@solides@dx\space div
%%                   #5 #3 sub \pst@solides@dy\space div
%%                    mul div sub 0.75 1] (sethsbcolor) astr2str} for}
  \pst@killglue%
  \begingroup%
  \psset{axisemph=\small,planmarks,#1}%
  \init@pscode%
  \addto@pscode{
    1 setlinejoin
    \tx@optionssolides
    SolidesDict begin
    /CX 0 def /CY 0 def /CZ 0 def
    /base [ #2 #4 #3 #5 ] def
    \ifPst@algebraic
      /fonction (#6) tx@AlgToPs begin AlgToPs end cvx def
    \else
      /fonction  { #6 } def
    \fi
    /f {2 dict begin
      /y exch def
      /x exch def
      fonction end 
    } def
    \if@star pst-Surface* \else  pst-Surface \fi
    end
  }% fin du code ps
  \@starfalse
  \ifPst@axesboxed\gridIIID(#2,#4)(#3,#5)\fi
  \ifPst@solidmemory\else%
    \ifpsshadow \pst@closedshadow \fi
    \ifdim\psk@border\p@>\z@ \pst@addborder \fi
    \psk@fillstyle
    \pst@stroke
    \ifpsdoubleline \pst@doublestroke \fi
    \ifshowpoints\pst@OpenShowPoints\fi
    \use@pscode%
  \fi%
  \endgroup%
  \ignorespaces}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro \defFunction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\defFunction{\pst@object{defFunction}}%
\def\defFunction@i#1(#2)#3#4#5{%
  \pst@killglue
  \global\Pst@solidmemorytrue 
  \begingroup
  \use@par%
  \defFunction@ii{#2}\edef\@tempa{\the\toks@}%
  \ifPst@algebraic
    \toks@={}%
    \def\@tempb{#3}\ifx\@tempb\@empty \else\store@toks@after\@tempb\fi
    \def\@tempb{#4}\ifx\@tempb\@empty \else\store@toks@after\@tempb\fi
    \def\@tempb{#5}\ifx\@tempb\@empty \else\store@toks@after\@tempb\fi
    \codejps{%
      /#1 { 3 dict begin \@tempa \the\toks@
         gere_pst-deffunction end } def }% 20080625
  \else
    \codejps{%
       /#1 { 3 dict begin \the\toks@ #3 #4 #5
         gere_pst-deffunction end } def }% 20080625
  \fi
  \endgroup}%
%
\def\defFunction@ii#1{\defFunction@iii#1,,,\end}%
\def\defFunction@iii#1,#2,#3,#4\end{%
  \toks@={}%
   \def\arg@ii{#1}\ifx\arg@ii\@empty \else\store@toks@before\arg@ii\fi
   \def\arg@ii{#2}\ifx\arg@ii\@empty \else\store@toks@before\arg@ii\fi
   \def\arg@ii{#3}\ifx\arg@ii\@empty \else\store@toks@before\arg@ii\fi
   \edef\@tmpPSDefns{\the\toks@ mark }%       20080625
   \global\toks@=\expandafter{\@tmpPSDefns}}% 20080625
\def\store@toks@before#1{%
  \edef\@tmpPSDefns{/#1 exch def \the\toks@}%
  \global\toks@=\expandafter{\@tmpPSDefns}%
}%
\def\store@toks@after#1{%
  \edef\@tmpPSDefns{\the\toks@ (#1) tx@AlgToPs begin AlgToPs end cvx }%
  \global\toks@=\expandafter{\@tmpPSDefns}%
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro de projection
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% creation des variables pour PSTricks
\define@boolkey[psset]{pst-solides3d}[Pst@]{visibility}[false]{}
\psset[pst-solides3d]{visibility=true}
\define@key[psset]{pst-solides3d}{normal}{\def\pst@solides@normal{#1 }}
\psset[pst-solides3d]{normal=0 0 1}
% origine du plan
\define@key[psset]{pst-solides3d}{origine}{\def\pst@solides@origin{#1 }} % origine du plan
\psset[pst-solides3d]{origine=0 0 0 }%
%% le range pour les fonctions numeriques
\define@key[psset]{pst-solides3d}{range}{\def\pst@solides@range{#1}}
\psset[pst-solides3d]{range=-5 5}% le range par defaut
%% le chemin a projeter
\define@key[psset]{pst-solides3d}{path}{\def\pst@solides@path{#1}}%
\psset[pst-solides3d]{path=newpath 0 0 moveto}% valeur par defaut
%% fonctions utilisees
\define@key[psset]{pst-solides3d}{function}{\def\pst@solides@function{#1}}%
\psset[pst-solides3d]{function=}% pas de valeur par defaut
% rotation du texte dans son plan
\define@key[psset]{pst-solides3d}{RotationAngleText}{\def\pst@solides@RotationAngleText{#1}} % origine du plan
\psset[pst-solides3d]{RotationAngleText=0 }%
% texte a projeter
\define@key[psset]{pst-solides3d}{text}{\def\pst@solides@text{#1}}
\psset[pst-solides3d]{text=}% pas de texte par defaut
% plan de projection
\define@key[psset]{pst-solides3d}{plan}{\def\pst@solides@plan{#1}}
\psset[pst-solides3d]{plan=}% pas de plan par defaut
% position du texte a projeter
\define@key[psset]{pst-solides3d}{pos}{\def\pst@solides@pos{#1}}
\psset[pst-solides3d]{pos=cc}% centre par defaut

%% transcription et inclusion des variables dans le fichier postscript
\pst@def{psProjection}<%
/projectionsifacevisible \ifPst@visibility true \else false \fi def
/isolatin \ifPst@isolatin true \else false \fi def
/solidlinewidth {\pst@number\pslinewidth} def
/PSfont {\pst@solides@PSfont} def
/normale {\pst@solides@normal} bind def
/fontsize {\pst@solides@fontsize\space \pst@number\psunit mul 28.45 div } def
/origin {\pst@solides@origin} def
/RotationAngleText {\pst@solides@RotationAngleText} def
/range [ \pst@solides@range ] def
/path  { \pst@solides@path } def
/function  { \pst@solides@function } def
/texte (\pst@solides@text) def
/pos (\pst@solides@pos) def
/proj-definition (\pst@solides@definition) def
/proj-args  { \pst@solides@args} def
/proj-action (\pst@solides@action) def
\ifx\pst@solides@name\@empty      \else/solidname (\pst@solides@name) def\fi
\ifx\pst@solides@name\@empty     \else/projname (\pst@solides@name) def \fi
\ifx\pst@solides@plan\@empty     \else/planprojpst \pst@solides@plan \space def \fi
\ifx\pst@solides@solidname\@empty\else/solidprojname {\pst@solides@solidname\space} def \fi
/noface \pst@solides@no\space def % no de la face du solide
%/resolution \pst@solides@resolution\space def % pour le nb de points par courbe
\pst@solides@resolution setresolution % ------ hv 20110713
>

%\makeatletter
%% la macro de projection
\def\psProjection{\def\pst@par{}\pst@object{psProjection}}
\def\psProjection@i{\@ifnextchar({\psProjection@ii}{\psProjection@ii(0,0)}}
\def\psProjection@ii(#1){\expandafter\psProjection@iii#1,,\@nil}
\def\psProjection@iii#1,#2,#3\@nil{{%
  \addbefore@par{PSfont=NimbusSanL-ReguCond,pos=cc,range=0 360}%
  \def\pst@tempA{#2}%
  \ifPst@solidmemory\use@par\else\begin@ClosedObj\fi%
  \addto@pscode{%
    \tx@optionssolides
    \pst@prepscode
    SolidesDict begin
    \tx@psProjection
    /CX 0 def
    /CY 0 def
    /CZ 0 def
    #1/xorigine exch def
    \ifx\pst@tempA\@empty
        /yorigine xorigine def
        /xorigine exch def\space\else
    \pst@tempA\space /yorigine exch def
    \fi
    % nature du solide : texte, chemin, courbe
    gsave proj-\psk@solides@object\space
    end
  }%<- fin du code ps
  \psk@fillstyle
  \pst@stroke
  \addto@pscode{grestore newpath}%
  \ifPst@solidmemory\else\end@ClosedObj\fi
}}%
%\makeatother
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% \psLineIIID est
%% adapt de la macro \pstThreeDLine du package pst-3dplot (H.Voss)
%% http://tug.ctan.org/tex-archive/graphics/pstricks/contrib/pst-3dplot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\cartesianIIID@coor#1,#2,#3,#4\@nil{\edef\pst@coor{#1 #2 #3 }}
\def\NormalIIID@Coor{%
  \def\pst@@getcoor##1{\pst@expandafter\cartesianIIID@coor{##1}, ,\@nil}%
  \def\psput@##1{\pst@@getcoor{##1}\leavevmode\psput@cartesian}}%
%
\def\psLineIIID{\NormalIIID@Coor\pst@object{lineIIID}}
\def\lineIIID@i{%
  \pst@killglue%
  \pst@getarrows{%
    \begin@OpenObj%
      \pst@getcoors[\lineIIID@ii%
  }%
}
\def\lineIIID@ii{%
  \addto@pscode{%
    \tx@optionssolides
    SolidesDict begin
   counttomark
  /n exch def /n3 n 3 div cvi def
  n3 {
    n -3 roll
      3dto2d
      xunit mul exch xunit mul exch
    /n n 1 sub def
  } repeat
    end
    \pst@cp\space \psline@iii\space \tx@Line
  }%
  \end@OpenObj%
  \ignorespaces%
  \SpecialCoor%
}

\def\psPolygonIIID{\NormalIIID@Coor\pst@object{polygonIIID}}
\def\polygonIIID@i{%
  \pst@killglue%
  \pst@getarrows{%
    \begin@ClosedObj%
      \pst@getcoors[\polygonIIID@ii%
  }%
}
\def\polygonIIID@ii{%
  \addto@pscode{%
    \tx@optionssolides
    SolidesDict begin
   counttomark
  /n exch def /n3 n 3 div cvi def
  n3 {
    n -3 roll
      3dto2d
      xunit mul exch xunit mul exch
    /n n 1 sub def
  } repeat
    end
    \pst@cp\space \psline@iii\space \tx@Polygon
  }%
  \end@ClosedObj%
  \ignorespaces%
  \SpecialCoor%
}
%
%% === Chemin pour les dessins ---------------------------------------------
%\define@key[psset]{pst-solides3d}{fichier}{\edef\psk@solides@fichier{#1}} % chemin des dessins
%\psset{fichier=}
%% === Echelle pour l'image  -----------------------------------------------
\define@key[psset]{pst-solides3d}{unitPicture}{\edef\psk@solides@unitPicture{#1 }}
\psset{unitPicture=28.45}
%% === nombre de divisions des segments  -----------------------------------------------
\define@key[psset]{pst-solides3d}{divisions}{\edef\psk@solides@divisions{#1 }}
\psset{divisions=5}
%
\def\psImage{\pst@object{psImage}}
\def\psImage@i{\@ifnextchar({\psImage@ii}{\psImage@ii(0,0)}}
\def\psImage@ii(#1,#2){{%
  \ifPst@solidmemory\use@par\else\begin@ClosedObj\fi%
\addto@pscode{
%% === adapté de Jean-Michel Sarlat dans pst-anamorphosis ----------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% === Capture de commandes de systemdict --------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/LINETO    { systemdict /lineto get exec    } def
/MOVETO    { systemdict /moveto get exec    } def
/CURVETO   { systemdict /curveto get exec   } def
/CLOSEPATH { systemdict /closepath get exec } def
/RLINETO   { systemdict /rlineto get exec   } def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% === Transformation des commandes de construction des path(s) ----------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/tx@projectionDict 20 dict def
tx@projectionDict begin
/moveto {
  /s@y ED /s@x ED /c@x s@x def /c@y s@y def
  s@x unit_image div
  s@y unit_image div
  2 copy
  sinPhi mul neg exch cosPhi mul add % x'
  3 1 roll
  cosPhi mul exch sinPhi mul add     % y'
  /Ypoint exch def
  /Xpoint exch def
  projectionimage
  MOVETO
} bind def
/lineto {
  /c@yt ED /c@xt ED /dx c@xt c@x sub ND div def /dy c@yt c@y sub ND div def
  1 1 ND {dup dx mul c@x add exch dy mul c@y add
%/Ypoint exch unit_image div def
%/Xpoint exch unit_image div def
 unit_image div exch
 unit_image div exch
  2 copy
  sinPhi mul neg exch cosPhi mul add % x'
  3 1 roll
  cosPhi mul exch sinPhi mul add     % y'
  /Ypoint exch def
  /Xpoint exch def
  projectionimage
  LINETO} for
  /c@x c@xt def /c@y c@yt def
} bind def
/closepath {
  s@x s@y lineto CLOSEPATH
} bind def
/curveto {
  /c@yt ED /c@xt ED
  /c@yb ED /c@xb ED
  /c@ya ED /c@xa ED
  1 1 NDC {
    NDC div /s ED 1 s sub /t ED
    t c@x mul 3 s c@xa mul mul add t mul 3 s s c@xb mul mul mul add t mul s 3 exp c@xt mul add
    t c@y mul 3 s c@ya mul mul add t mul 3 s s c@yb mul mul mul add t mul s 3 exp c@yt mul add
 unit_image div exch
 unit_image div exch
  2 copy
  sinPhi mul neg exch cosPhi mul add % x'
  3 1 roll
  cosPhi mul exch sinPhi mul add     % y'
  /Ypoint exch def
  /Xpoint exch def
   projectionimage
   LINETO
  } for
  /c@x c@xt def /c@y c@yt def
} bind def
end
/Atan { /atan load stopped { pop pop 0 } if } def
save
\tx@optionssolides
    SolidesDict begin
/cm {\pst@number\psunit mul } bind def
/cm_1 {\pst@number\psunit div } bind def
/unit_image \psk@solides@unitPicture def
/fichier (\pst@solides@file) def
/Normale {\pst@solides@normal\space unitaire3d } bind def
/ND \psk@solides@divisions def
/NDC {\psk@solides@divisions 3 mul} bind def
/origin {\pst@solides@origin\space } def
/cosPhi {phi cos} bind def
/sinPhi {phi sin} bind def
Normale
/nz exch def
/ny exch def
/nx exch def
/Phi {90 nz arccos sub} bind def
/Theta {ny nx Atan} bind  def
/sinT {Theta sin} bind def
/cosT {Theta cos} bind def
/sinP {Phi sin} bind def
/cosP {Phi cos} bind def
origin
       /zO' exch def
       /yO' exch def
       /xO' exch def
/projectionimage {
% projection sur le plan
Xpoint sinT mul neg Ypoint sinP cosT mul mul sub xO' add % x'
Xpoint cosT mul Ypoint sinP mul sinT mul sub yO' add     % y'
Ypoint cosP mul zO' add                                  % z'
3dto2d %
   } def
 projectionsifacevisible not origin Normale planvisible? or {
      /showpage {} def
gsave
tx@projectionDict begin
#1 sinT mul neg #2 sinP cosT mul mul sub
#1 cosT mul #2 sinP mul sinT mul sub
#2 cosP mul
3dto2d
translate
fichier run
end
grestore
    } if
end
restore
}%
  \ifPst@solidmemory\else\end@ClosedObj\fi}\ignorespaces%
}
%
\define@key[psset]{pst-solides3d}{XMinMax}{\def\pst@solides@XMinMax{#1}}
\define@key[psset]{pst-solides3d}{YMinMax}{\def\pst@solides@YMinMax{#1}}
\define@key[psset]{pst-solides3d}{ZMinMax}{\def\pst@solides@ZMinMax{#1}}
\define@key[psset]{pst-solides3d}{ImplFunction}{\def\pst@solides@ImplFunction{#1}}
\psset{XMinMax=-2 2 0.2,YMinMax=-2 2 0.2,ZMinMax=-2 2 0.2,ImplFunction=x dup mul y dup mul add}
%
\def\psImplicitSurface{\pst@object{psImplicitSurface}}
\def\psImplicitSurface@i{\@ifnextchar(\psImplicitSurface@ii{\psImplicitSurface@ii(0,0,0)}}%
\def\psImplicitSurface@ii(#1){%
  \begin@SpecialObj
  \addto@pscode{
    \ifPst@algebraic
      /ImplFunction ( \pst@solides@ImplFunction ) tx@AlgToPs begin AlgToPs end cvx def
    \else
      /ImplFunction  { \pst@solides@ImplFunction } def
    \fi
    SolidesDict begin
    MarchingCubes
    /plagesXYZ [% min  max  dx
      [\pst@solides@XMinMax][\pst@solides@YMinMax][\pst@solides@ZMinMax]
    ] def
    /function {
      3 dict begin
      /z exch def /y exch def /x exch def
      ImplFunction
      end
    } def
    calculs
    /Sommets exch def
    /Faces exch def
    /lesPoints {
      0 1 Sommets length 1 sub {/iP exch def
         Sommets iP get aload pop
      } for
    } def
    end
   }%
  \psSolid[object=new,faces={Faces aload pop},sommets=lesPoints](#1)%
  \end@SpecialObj
  \ignorespaces
}

%
\def\psResetSolidKeys{%
\psset[pst-solides3d]{%
action=draw**,%
affinage=,% pas de affinage par defaut
affinagerm=true,
args=,%
axe=0 0 1,% vecteur definissant la direction de l'axe du prisme
axesboxed=false,%
axisemph=,
axisnames={x,y,z},
base=-1 -1 1 -1 0 1,% coordonnees d'un triangle, base triangulaire par defaut
biface=true,%
chanfrein=false,
color1=cyan,
color2=magenta,
color3=blue,
color4=red,
deactivatecolor=false,%
decal=-2,% decalage par defaut
definition=,%
dualreg=false,
faces={},% valeurs par defaut
fcolor=,% pas de couleur par defaut
fcol=,% pas de faces par defaut
file=,% pas de fichier par defaut
function=,% pas de valeur par defaut
geode=false,
grid=true,
hollow=false,
hue=,% pas de degrade externe par defaut
incolor=green,
inhue=,% pas de degrade interne par defaut
inouthue=,% pas de degrade total par defaut
intersectioncolor=(rouge),%
intersectionlinewidth=1,%
intersectionplan=[0 0 1 0],%
isolatin=true,
lightintensity=2,
lightsrc=,% pas de coordonnees par defaut
load=,% pas de load par defaut
mathLabel,
mode=2,%
name=,% pas de nom par defaut
ngrid=,% pas de faces par defaut
normal=0 0 1,
numfaces=,
numsep=15pt,% pas de numerotation par defaut
num=,% pas de numerotation defaut
object=tore,%
origine=0 0 0,%
path=newpath 0 0 moveto,% valeur par defaut
plangrid=false,%
planmarks=false,%
planname=,% pas de nom par defaut
plan=,% pas de plan par defaut
plansection=,% pas de section par defaut
plansepare=,% pas de separation par defaut
pos=cc,% centre par defaut
PSfont=NimbusRomNo9L-Regu,fontsize=10,
R=4,r1=4,r0=1.5,r=2,no=0,a=4,b=a,c=a,h=6,phi=0,theta=90,resolution=36,%
range=-5 5,% le range par defaut
rm=,% pas de faces par defaut
RotationAngleText=0,%
RotZ=0,RotX=0,RotY=0,Decran=50,% valeurs par defaut
section=\Sol@Section,% coordonnees des sommets de la section
showbase=false,%
showBase=false,%
showAxes=true,
showOrigin,
show=,% pas de pointage par defaut
solidmemory=false,
solidname=,% pas de nom par defaut
sommets=,% pas de sommet par defaut
spotX=dr,
spotY=dl,
spotZ=l,
QZ=0,
Zmin=-4,
Zmax=4,
stepX=1,
stepY=1,
stepZ=1,
ticklength=0.2,% the step for the axes labels
tablez=,%
text=,% pas de texte par defaut
transform=,%
trunc=,% pas de troncature par defaut
viewpoint=10 10 10,% coordonnees cartesiennes
visibility=true,
zcolor=}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\@=\PstAtCode\relax
%
\endinput
