%% solid = [Sommets Faces Colors_Faces InOut_Table]
/solidgetsommets {
0 get
} def
/solidgetpointstable {solidgetsommets} def
/solidgetfaces {
1 get
} def
/solidgetface {
1 dict begin
/i exch def
solidgetfaces i get
end
} def
/solidgetfcolors {
2 get
} def
%% syntaxe : solid i solidgetfcolor --> str
/solidgetfcolor {
1 dict begin
/i exch def
solidgetfcolors i get
end
} def
%% syntaxe : solid i str solidputfcolor --> -
/solidputfcolor {
2 dict begin
/str exch def
/i exch def
solidgetfcolors i str put
end
} def
/solidgetinouttable {
3 get
} def
/solidputsommets {
0 exch put
} def
/solidputpointstable {solidputsommets} def
/solidputfaces {
1 exch put
} def
%% syntaxe : solid solidfacesreverse -> -
/solidfacesreverse {
5 dict begin
/solid exch def
/n solid solidnombrefaces def
0 1 n 1 sub {
/i exch def
/F solid i solidgetface reverse def
/m F length def
solid i [F aload pop m 0 roll ] solidputface
} for
end
} def
/solidputfcolors {
2 exch put
} def
/solidputinouttable {
3 exch put
} def
%% syntaxe : any issolid --> booleen, vrai si any est de type solid
/issolid {
1 dict begin
/candidat exch def
candidat isarray {
candidat length 4 eq {
candidat 0 get isarray
candidat 1 get isarray and
candidat 2 get isarray and
candidat 2 get isarray and
/IO candidat 3 get def
IO length 4 eq and
IO 0 get isnum and
IO 1 get isnum and
IO 2 get isnum and
IO 3 get isnum and
} {
false
} ifelse
} {
false
} ifelse
end
} def
/dupsolid {
5 dict begin
/solid exch def
/S solid solidgetsommets def
/F solid solidgetfaces def
/FC solid solidgetfcolors def
/IO solid solidgetinouttable def
solid
[
S duparray exch pop
F duparray exch pop
FC duparray exch pop
IO duparray exch pop
]
end
} def
%% syntaxe : solid array solidputinfaces --> -
/solidputinfaces {
4 dict begin
/facesinternes exch def
/solid exch def
/n2 facesinternes length def
/IO solid solidgetinouttable def
/facesexternes solid solidgetoutfaces def
/n1 facesexternes length def
solid
[facesexternes aload pop facesinternes aload pop]
solidputfaces
IO 0 0 put
IO 1 n1 1 sub put
IO 2 n1 put
IO 3 n1 n2 add 1 sub put
end
} def
%% syntaxe : solid array solidputoutfaces --> -
/solidputoutfaces {
4 dict begin
/facesexternes exch def
/solid exch def
/n1 facesexternes length def
/IO solid solidgetinouttable def
/facesinternes solid solidgetinfaces def
/n2 facesinternes length def
solid
[facesexternes aload pop facesinternes aload pop]
solidputfaces
IO 0 0 put
IO 1 n1 1 sub put
IO 2 n1 put
IO 3 n1 n2 add 1 sub put
end
} def
/solidnombreinfaces {
1 dict begin
/solid exch def
solid solidwithinfaces {
/IO solid solidgetinouttable def
IO 3 get IO 2 get sub 1 add
} {
0
} ifelse
end
} def
/solidnombreoutfaces {
1 dict begin
/solid exch def
/IO solid solidgetinouttable def
IO 1 get IO 0 get sub 1 add
end
} def
%% syntaxe : solid solidgetinfaces --> array
/solidgetinfaces {
4 dict begin
/solid exch def
solid issolid not {
(Error : mauvais type d argument dans solidgetinfaces) ==
quit
} if
solid solidwithinfaces {
/IO solid solidgetinouttable def
/F solid solidgetfaces def
/n1 IO 2 get def
/n2 IO 3 get def
/n n2 n1 sub 1 add def
F n1 n getinterval
} {
[]
} ifelse
end
} def
%% syntaxe : solid solidgetoutfaces --> array
/solidgetoutfaces {
4 dict begin
/solid exch def
solid issolid not {
(Error : mauvais type d argument dans solidgetoutfaces) ==
quit
} if
/IO solid solidgetinouttable def
/F solid solidgetfaces def
/n1 IO 0 get def
/n2 IO 1 get def
/n n2 n1 sub 1 add def
F n1 n getinterval
end
} def
%% /tracelignedeniveau? false def
%% /hauteurlignedeniveau 1 def
%% /couleurlignedeniveau {rouge} def
%% /linewidthlignedeniveau 4 def
/solidgridOn {
/solidgrid true def
} def
/solidgridOff {
/solidgrid false def
} def
%% syntaxe : solid i string solidputfcolor
%% syntaxe : solid str outputcolors
%% syntaxe : solid str1 str2 inoutputcolors
%% syntaxe : solid string n solidputncolors
%% syntaxe : solid array solidputincolors --> -
%% syntaxe : solid array solidputoutcolors --> -
%% syntaxe : solid solidgetincolors --> array
%% syntaxe : solid solidgetoutcolors --> array
%% syntaxe : solid array solidputinfaces --> -
%% syntaxe : solid array solidputoutfaces --> -
%% syntaxe : solid solidgetinfaces --> array
%% syntaxe : solid solidgetoutfaces --> array
%% syntaxe : solid1 solid2 solidfuz -> solid
%% syntaxe : solid i solidgetsommetsface -> array
%% array = tableau de points 3d
/solidgetsommetsface {
1 dict begin
/i exch def
/solid exch def
/F solid i solidgetface def
[
0 1 F length 1 sub {
/k exch def
solid F k get solidgetsommet
} for
]
end
} def
%% syntaxe : solid index table solidputface -> -
/solidputface {
1 dict begin
/table exch def
/i exch def
solidgetfaces i table put
end
} def
%% syntaxe : solid table solidaddface -> -
%% syntaxe : solid table (couleur) solidaddface -> -
%% on ne se preoccupe pas des faces internes
/solidaddface {
6 dict begin
dup isstring {
/lac@uleur exch def
} {
/lac@uleur () def
} ifelse
/table exch def
/solid exch def
/IO solid solidgetinouttable def
/n2 IO 1 get def
/FC solid solidgetoutcolors def
IO 1 n2 1 add put
solid [ solid solidgetfaces aload pop table ] solidputfaces
solid IO solidputinouttable
% solid solidnombrefaces
solid [
FC aload pop lac@uleur
] solidputoutcolors
end
} def
/solidnombrefaces {
1 dict begin
/solid exch def
solid solidnombreinfaces
solid solidnombreoutfaces
add
end
} def
%% syntaxe : solid M solidaddsommetexterne -> -
%% on ajoute le sommet sans se preoccuper de rien
/solidaddsommetexterne {
2 dict begin
/M defpoint3d
/solid exch def
solid
[ solid solidgetsommets aload pop M ]
solidputsommets
end
} def
%% syntaxe : solid array solidaddsommets -> -
/solidaddsommets {
2 dict begin
/table exch def
/solid exch def
/n table length 3 idiv def
0 1 0 {
/i exch def
solid table i getp3d solidaddsommet pop
} for
end
} def
%% syntaxe : solid M solidaddsommet -> k
%% on ajoute le sommet M. Si il est deja sur une arete,
%% on l incorpore a la face concernee
%% s il est deja present, on ne le rajoute pas.
%% Renvoie l indice du sommet rajoute.
/solidaddsommet {
10 dict begin
/M defpoint3d
/solid exch def
/nbf solid solidnombrefaces def
/N solid solidnombresommets def
/sortie -1 def
%% le sommet est-il deja dans la structure
0 1 N 1 sub {
/i exch def
%% (addsommet) ==
%% solid i solidgetsommet == == ==
%% M == == ==
%% solid i solidgetsommet M eqp3d ==
% solid i solidgetsommet M eqp3d {
solid i solidgetsommet M distance3d 1e-5 le {
%% oui => c est fini
/sortie i store
} if
} for
sortie 0 lt {
%% non => on le rajoute
/sortie N def
solid M solidaddsommetexterne
%% est il sur une arete deja codee
0 1 nbf 1 sub {
%% face d indice i
/i exch def
solid i solidgetface /F exch def
/nbsf F length def
0 1 nbsf 1 sub {
/j exch def
M
solid j i solidgetsommetface
solid j 1 add nbsf mod i solidgetsommetface
point3dsursegment {
%% il est sur l arete concernee
solid i [
0 1 j {
/k exch def
F k get
} for
N
j 1 add nbsf mod dup 0 eq {
pop
} {
1 nbsf 1 sub {
/k exch def
F k get
} for
} ifelse
] solidputface
exit
} if
} for
} for
} if
sortie
end
} def
/solidintersectiontype -1 def
/solidintersectionlinewidth [1 2] def
/solidintersectioncolor [(bleu) (rouge)] def
/solidintersectionplan [[1 0 .5 0] [1 0 .5 -1]] def
/solidgrid true def
/aretescachees true def
/defaultsolidmode 2 def
%% %% syntaxe : solid M solidaddsommet -> k
%% %% on ajoute le sommet M. Si il est deja sur une arete,
%% %% on l incorpore a la face concernee
%% %% s il est deja present, on ne le rajoute pas.
%% %% Renvoie l indice du sommet rajoute.
%% /solidaddsommet {
%% 10 dict begin
%% /M defpoint3d
%% /solid exch def
%% /nbf solid solidnombrefaces def
%% /N solid solidnombresommets def
%% /sortie -1 def
%% 0 1 N 1 sub {
%% /i exch def
%% solid i solidgetsommet M eqp3d {
%% /sortie i store
%% } if
%% } for
%% sortie 0 lt {
%% /sortie N def
%% solid M solidaddsommetexterne
%% 0 1 nbf 1 sub {
%% /i exch def
%% solid i solidgetface /F exch def
%% /nbsf F length def
%% 0 1 F length 1 sub {
%% /j exch def
%% M
%% solid j i solidgetsommetface
%% solid j 1 add nbsf mod i solidgetsommetface
%% point3dsursegment {
%% solid i [
%% 0 1 j {
%% /k exch def
%% F k get
%% } for
%% N
%% j 1 add nbsf mod 1 nbsf 1 sub {
%% /k exch def
%% F k get
%% } for
%% ] solidputface
%% exit
%% } if
%% } for
%% } for
%% } if
%% sortie
%% end
%% } def
%% %% syntaxe : solid solidfacesreverse -> -
%% /solidfacesreverse {
%% 5 dict begin
%% /solid exch def
%% /n solid solidnombrefaces def
%% 0 1 n 1 sub {
%% /i exch def
%% solid i 2 copy solidgetface reverse solidputface
%% } for
%% end
%% } def
%% %% syntaxe : solid array solidputoutfaces --> -
%% /solidputoutfaces {
%% 4 dict begin
%% /facesexternes exch def
%% /solid exch def
%% /n1 facesexternes length def
%% /IO solid solidgetinouttable def
%% /facesinternes solid solidgetinfaces def
%% /n2 facesinternes length def
%% solid
%% [facesexternes aload pop facesinternes aload pop]
%% solidputfaces
%% IO 0 0 put
%% IO 1 n1 1 sub put
%% IO 2 n1 put
%% IO 3 n1 n2 add 1 sub put
%% end
%% } def
|