diff options
Diffstat (limited to 'macros/latex/contrib/profcollege/latex/PfCVueCubes.tex')
-rw-r--r-- | macros/latex/contrib/profcollege/latex/PfCVueCubes.tex | 110 |
1 files changed, 97 insertions, 13 deletions
diff --git a/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex b/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex index 5f284e051e..196358d9bf 100644 --- a/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex +++ b/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex @@ -1,35 +1,116 @@ %%% % Vue Cubes %%% -\setKVdefault[VueCubes]{Solution=false,Hauteur=5,Profondeur=4,Largeur=3,Angle=60,Nom=Ex1,Trou=false,Echelle=0.25,CouleurCube=LightSteelBlue,CouleurFleche=LightGray,Face=false,Creation=false,Grilles=false,Seul=false} +\def\filedateVueCubes{2024/08/26}% +\def\fileversionVueCubes{0.1a}% +\message{-- \filedateVueCubes\space v\fileversionVueCubes}% +% +\setKVdefault[VueCubes]{Solution=false,Hauteur=5,Profondeur=4,Largeur=3,Angle=60,Nom=Ex1,Trou=false,Echelle=0.25,CouleurCube=LightSteelBlue,CouleurFleche=LightGray,Face=false,Creation=false,Grilles=false,Seul=false,Perso=false,EclateX=0,EclateZ=0,EclateY=0} \newtoks\toklisteVueCube% \def\UpdatetoksVueCube#1\nil{\addtotok\toklisteVueCube{#1,}}% +\def\UpdatetoksEmpilementPerso#1\nil{\addtotok\toklisteVueCube{"#1",}}% \NewDocumentCommand\VueCubes{o m}{% \useKVdefault[VueCubes]% - \setKV[VueCubes]{#1} - \ifboolKV[VueCubes]{Solution}{% - \BuildVueCubesSolution% + \setKV[VueCubes]{#1}% + \toklisteVueCube{}% + \ifboolKV[VueCubes]{Perso}{% + \setsepchar[*]{,*/}\ignoreemptyitems% + \readlist*\ListeCouches{#2}% + \reademptyitems% + \foreachitem\compteur\in\ListeCouches{% + \foreachitem\compteurdeux\in\ListeCouches[\compteurcnt]{% + \expandafter\UpdatetoksEmpilementPerso\compteurdeux\nil% + }% + }% + \BuildMPEmpilementPerso{\the\toklisteVueCube}{\ListeCoucheslen}{\listlen\ListeCouches[1]}% }{% - \ifboolKV[VueCubes]{Creation}{%Le nombre de données doit être compatible avec le "volume du pavé droit" - \ignoreemptyitems% - \readlist*\PfCListeHauteursCubes{#2}% - \reademptyitems% - \toklisteVueCube{}% - \foreachitem\compteur\in\PfCListeHauteursCubes{\expandafter\UpdatetoksVueCube\compteur\nil}% - \BuildVueCubes{\useKV[VueCubes]{Angle}}{\the\toklisteVueCube}% + \ifboolKV[VueCubes]{Solution}{% + \BuildVueCubesSolution% }{% - \BuildVueCubes{\useKV[VueCubes]{Angle}}{}% + \ifboolKV[VueCubes]{Creation}{%Le nombre de données doit être compatible avec le "volume du pavé droit" + \ignoreemptyitems% + \readlist*\PfCListeHauteursCubes{#2}% + \reademptyitems% + \foreachitem\compteur\in\PfCListeHauteursCubes{\expandafter\UpdatetoksVueCube\compteur\nil}% + \BuildVueCubes{\useKV[VueCubes]{Angle}}{\the\toklisteVueCube}{\useKV[VueCubes]{Nom}}% + }{% + \BuildVueCubes{\useKV[VueCubes]{Angle}}{}{\useKV[VueCubes]{Nom}}% + }% }% }% }% -\NewDocumentCommand\BuildVueCubes{m m}{% +\NewDocumentCommand{\BuildMPEmpilementPerso}{mmm}{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + nbcouches=#2; + nblignes:=#3; + + input PfCSolid; + + intensite:=1.5; + + Ferme[0]:=false; + outcolor:=\useKV[VueCubes]{CouleurCube};% + incolor:=white; + nb:=1;subh:=1; + creux:=true; + + Phi := \useKV[VueCubes]{Angle}; + Echelle:=\useKV[VueCubes]{Echelle}; + EclateX:=\useKV[VueCubes]{EclateX}; + EclateY:=\useKV[VueCubes]{EclateY}; + EclateZ:=\useKV[VueCubes]{EclateZ}; + + string LesSymboles[]; + string LesLignes[][]; + + TotalObj:=0; + + vardef CreationSolide(text t)= + n:=0; + for p_=t: + n:=n+1; + LesSymboles[n]=p_; + endfor; + for l=nbcouches downto 1: + for k=nblignes downto 1: + LesLignes[l][k]=LesSymboles[(nbcouches-l)*nblignes+(nblignes-k+1)]; + endfor; + endfor; + for l=nbcouches downto 1: + for k=nblignes downto 1: + for m=0 upto (length(LesLignes[l][k])-1): + if (substring((m,m+1)) of LesLignes[l][k])="x": + TotalObj:=incr TotalObj; + TR:=(Echelle*(nblignes-k)+Echelle*(nblignes-k)*EclateX,Echelle*(m+m*EclateY),Echelle*l-Echelle*(nbcouches-l)*EclateZ); + ObjetDeplacement[TotalObj](0); + fi; + endfor; + endfor; + endfor; + enddef; + + Initialisation(2500,Phi,20,50); + Objetcube0("a="&decimal(Echelle)); + + CreationSolide(#1); + nbobj:=TotalObj; + DessineFusion; + \end{mplibcode} + \fi +} + +\NewDocumentCommand\BuildVueCubes{m m m}{% \ifluatex \mplibforcehmode \xdef\PfCVueCubeNom{\useKV[VueCubes]{Nom}}% \begin{mplibcode}[\PfCVueCubeNom] + string NomRetenu; + NomRetenu=str #3; input PfCSolid; intensite:=1.5; @@ -101,6 +182,9 @@ endfor; fi; + write decimal(TotalObj) to "PfCNombreCubes"&NomRetenu&".tex";% + write EOF to "PfCNombreCubes"&NomRetenu&".tex";% + % Pour la fleche path Fleche; color A[]; |