%% syntaxe : solid coeff i solidaffine -> -
%% syntaxe : solid coeff array solidaffine -> -
%% syntaxe : solid coeff solidaffine -> -
%% syntaxe : solid coeff str solidaffine -> -
%% syntaxe : solid coeff bool solidaffine -> -
/solidaffine {
10 dict begin
dup isbool {
/rmfacecentrale exch def
} {
/rmfacecentrale true def
} ifelse
dup isstring {
/couleurface exch def
} if
2 copy pop issolid {
%% 2 arguments --> on affine tout
2 copy pop solidnombrefaces /n exch def
/table [n 1 sub -1 0 {} for] def
} {
%% 1 tableau --> il donne les faces a enlever
dup isarray {
/table exch bubblesort reverse def
} {
%% 1 seule face a enlever
[ exch ] /table exch def
} ifelse
} ifelse
/coeff exch def
/solid exch def
0 1 table length 1 sub {
/i exch def
solid coeff table i get
currentdict /couleurface known {
couleurface
} if
rmfacecentrale s@lidaffineface
} for
end
} def
%% syntaxe : solid coeff i s@lidaffineface
/s@lidaffineface {
10 dict begin
/rmfacecentrale exch def
dup isstring {
/couleurface exch def
} if
/indice_a_chamfreiner exch def
/i indice_a_chamfreiner def
/coeff exch def
/solid exch def
solid issolid not {
(Erreur : mauvais type d argument dans affine) ==
quit
} if
/n solid solidnombresommets def
/F solid i solidgetsommetsface def
/Findex solid i solidgetface def
/ni F length 3 idiv def
/couleurfaceorigine solid i solidgetfcolor def
F isobarycentre3d /G defpoint3d
%% on ajoute les nouveaux sommets
/Sindex [] def
0 1 ni 1 sub {
/j exch def
/Sindex [ Sindex aload pop
solid G F j getp3d vecteur3d coeff mulv3d G addv3d solidaddsommet
] store
} for
%% Sindex contient les indices des nouveaux sommets
%% on prepare les faces a ajouter
/facestoadd [] def
/facestoadd [facestoadd aload pop
0 1 ni 1 sub {
/j exch def
[Findex j get
Findex j 1 add ni mod get
Sindex j 1 add ni mod get
Sindex j get]
} for
] store
0 1 ni 1 sub {
/i exch def
solid facestoadd i get solidaddface
} for
%% on enleve la face d origine
solid indice_a_chamfreiner solidrmface
%% on ajuste les couleurs des nouvelles faces
/N solid solidnombrefaces def
0 1 ni 1 sub {
/i exch def
solid N 1 sub i sub couleurfaceorigine solidputfcolor
} for
%% puis on ajoute eventuellement la face centrale
rmfacecentrale not {
solid
[0 1 ni 1 sub {
/j exch def
Sindex j get
} for]
solidaddface
%% en ajustant la couleur de cette derniere
solid N
currentdict /couleurface known {
couleurface
} {
couleurfaceorigine
} ifelse
solidputfcolor
} if
end
} def
%% %% syntaxe : solid coeff i solidaffine -> -
%% %% syntaxe : solid coeff array solidaffine -> -
%% %% syntaxe : solid coeff solidaffine -> -
%% /solidaffine {
%% 10 dict begin
%% 2 copy pop issolid {
%% %% 2 arguments --> on affine tout
%% 2 copy pop solidnombrefaces /n exch def
%% /table [n 1 sub -1 0 {} for] def
%% } {
%% dup isarray {
%% /table exch bubblesort reverse def
%% } {
%% [ exch ] /table exch def
%% } ifelse
%% } ifelse
%% /coeff exch def
%% /solid exch def
%% 0 1 table length 1 sub {
%% /i exch def
%% solid coeff table i get s@lidaffineface
%% } for
%% end
%% } def
%%
%% %% syntaxe : solid coeff i s@lidaffineface
%% /s@lidaffineface {
%% 10 dict begin
%% /indice_a_chamfreiner exch def
%% /i indice_a_chamfreiner def
%% /coeff exch def
%% /solid exch def
%% solid issolid not {
%% (Erreur : mauvais type d argument dans affine) ==
%% quit
%% } if
%% /n solid solidnombresommets def
%% /F solid i solidgetsommetsface def
%% /Findex solid i solidgetface def
%% /ni F length 3 idiv def
%% F isobarycentre3d /G defpoint3d
%% %% on ajoute les nouveaux sommets
%% /Sindex [] def
%% 0 1 ni 1 sub {
%% /j exch def
%% /Sindex [ Sindex aload pop
%% solid G F j getp3d vecteur3d coeff mulv3d G addv3d solidaddsommet
%% ] store
%% } for
%% %% on prepare les faces a ajouter
%% /facestoadd [] def
%% /facestoadd [facestoadd aload pop
%% 0 1 ni 1 sub {
%% /j exch def
%% [Findex j get
%% Findex j 1 add ni mod get
%% Sindex j 1 add ni mod get
%% Sindex j get]
%% } for
%% ] store
%% 0 1 ni 1 sub {
%% /i exch def
%% solid facestoadd i get solidaddface
%% } for
%% solid indice_a_chamfreiner solidrmface
%% end
%% } def
|