Subversion Repositories wimsdev

Rev

Rev 7692 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

!if $wims_read_parm!=slib_header
  !goto proc
!endif

slib_author=Bernadette, Perrin-Riou

slib_example=v 0 0 0;v 1 0 0;v 1 1 0;v 0 1 0;v 0 0 1;v 1 0 1;v 1 1 1;v 0 1 1;f 1 2 3 4;f 5 6 7 8;f 1 5 2 6;l 1 5;l 2 6;l 3 7;l 4 8,name_vertex=[A,B,C,D,E]
slib_require=pari
!exit

:proc

!distribute items $wims_read_parm into slib_polyedre,slib_options

slib_polyedre=!declosing $slib_polyedre
slib_polyedre=!rows2lines $slib_polyedre

!reset slib_vertex, slib_face, slib_edge
!!********** Traitement des options
slib_k=0.7
slib_f=33
!!slib_k=0.6
!!slib_f=33

slib_Z0=-1
slib_Z1=-1000
!!slib_centre_rot=0.5,0.5,0.5

slib_name_vertex=!getopt name_vertex in $slib_options
slib_name_face=!getopt name_face in $slib_options
slib_name_edge=!getopt name_edge in $slib_options

slib_angle=!getopt angle in $slib_options
slib_angle=!declosing $slib_angle
slib_angle=!text select uvw, in $slib_angle

slib_option_face=!getopt face in $slib_options
slib_option_edge=!getopt edge in $slib_options


!default slib_option_face=1
!default slib_option_edge=0
!default slib_option_vertex=1
!default slib_angle=u v w

### option pour les couleurs des faces ?
 slib_randint=!randint 1000,2000
 slib_fichier=$wims_nowseconds$slib_randint.zir


!!********** Lecture des données polyedre
slib_polyedre=!translate $      $ to $\
$ in $slib_polyedre
slib_H=1
slib_u=!line 1 of $slib_polyedre
slib_nom=!replace internal # by $empty in $slib_u
!while # isin $slib_u
  !advance slib_H
  slib_u=!line $slib_H of $slib_polyedre
!endwhile
### pas de commentaires possibles !
slib_vertex_cnt, slib_face_cnt, slib_edge_cnt
slib_cnt=!linecnt $slib_polyedre
!distribute items 0,0,0 into slib_vertex_cnt,slib_edge_cnt,slib_face_cnt

!for slib_h=1 to $slib_cnt
  slib_u=!line $slib_h of $slib_polyedre
  !if v isin $slib_u
    slib_u=!word 2 to -1 of $slib_u
    slib_vertex=!append line $slib_u to $slib_vertex
    !advance slib_vertex_cnt
  !endif
  !if f isin $slib_u
    slib_u=!word 2 to -1 of $slib_u
    slib_face=!append line $slib_u to $slib_face
    !advance slib_face_cnt
  !endif
  !if l isin $slib_u
    slib_u=!word 2 to -1 of $slib_u
    slib_edge=!append line $slib_u to $slib_edge
    !advance slib_edge_cnt
  !endif
!next

!for slib_option in vertex,face,edge
  !if $(slib_name_$slib_option)!=$empty
    slib_show_$slib_option=showname="true"
    slib_name_$slib_option =!declosing $(slib_name_$slib_option)
    slib_name=$(slib_name_$slib_option)
    slib_name1_$slib_option=!makelist alias="x" for x in $(slib_name)
    slib_show_$slib_option=!makelist showname="true" for x=1 to $(slib_$(slib_option)_cnt)
    !for slib_a=1 to $(slib_$(slib_option)_cnt)
      !if $(slib_name[$slib_a])=$empty
        slib_show_$slib_option=!replace item number $slib_a by  in $(slib_show_$(slib_option))
      !endif
    !next
  !else
    slib_show_$slib_option=
  !endif
!next

!!*************programme de calcul des coordonnées de projection

slib_M=[1,0,0;0,1,0;0,0,1]
!if u isin $slib_angle
  slib_M=$slib_M*[1,0,0;0,cu,-su;0,su,cu]
!endif
!if v isin $slib_angle
  slib_M=$slib_M*[cv,0,sv;0,1,0;-sv,0,cv]
!endif
!if w isin $slib_angle
  slib_M=$slib_M*[cw,-sw,0;sw,cw,0;0,0,1]
!endif

slib_prog=!exec pari {slib_rot(slib_A) =print(slib_A*($slib_M)~);}

!!********** code de dessin des sommets
slib_compteur_init=50
slib_compteur=$[$slib_compteur_init+1]
slib_polyedre=
slib_vertex1=!singlespace $slib_vertex1
slib_vertex1=!lines2rows $slib_vertex

slib_vertex1=!words2items $slib_vertex1
slib_vertex1=!nonempty items $slib_vertex1
slib_vertex1=!replace internal ;, by ; in $slib_vertex1

slib_coordx=!sort numeric items $(slib_vertex1[;1])
slib_coordx=!nonempty items $slib_coordx
slib_minx=$(slib_coordx[1])
slib_maxx=$(slib_coordx[-1])
slib_coordy=!sort numeric items $(slib_vertex1[;2])
slib_coordy=!nonempty items $slib_coordy
slib_miny=$(slib_coordy[1])
slib_maxy=$(slib_coordy[-1])
slib_coordz=!sort numeric items $(slib_vertex1[;3])
slib_coordz=!nonempty items $slib_coordz
slib_minz=$(slib_coordz[3])
slib_maxz=$(slib_coordz[-3])


!reset slib_vertex1  slib_coordx slib_coordy
slib_centre_rot=$[($slib_minx+$slib_maxx)/2],$[($slib_miny+$slib_maxy)/2],$[($slib_minz+$slib_maxz)/2]
slib_centrex=$[($slib_minx+$slib_maxx)/2+0.2]
slib_centrey=$[($slib_miny+$slib_maxy)/2+0.2]
slib_width=$[max($slib_maxx-($slib_minx),$slib_maxy-($slib_miny))]


slib_prelim=<?xml version="1.0" encoding="utf-8"?>\
<CaR>\
<Construction>\
<Window x="$slib_centrex" y="$slib_centrey" w="$slib_width" />\
<Objects>\
<Point name="P0" n="1"  x="0"  y="1" hidden="true" fixed="true"></Point>\
<Point name="Q0" n="2"  x="360"  y="1"  hidden="true" fixed="true"></Point>\
<Segment name="s0" n="3"  from="P0" to="Q0"  hidden="true"></Segment>


slib_cercle=$[$slib_centrex+0.7*$slib_width],$[$slib_centrey+0.7*$slib_width]
slib_ray=$[0.05*$slib_width],$[0.1*$slib_width],$[0.15*$slib_width]
!if u isin $slib_angle
  slib_prelim=$slib_prelim\
<Point name="C1" n="4"  x="$(slib_cercle[1])" y="$(slib_cercle[2])"  hidden="true" fixed="true"></Point>\
<Circle name="c1" n="5" fixed="$(slib_ray[1])" midpoint="C1" acute="true" hidden="true"></Circle>\
<PointOn name="R1" n="6" type="thick" on="c1"></PointOn>\
<Parallel name="l1" n="7" color="5" point="C1" line="s0"  hidden="true"></Parallel>\
<Intersection name="I1" n="8"  first="l1" second="c1" which="first" hidden="true"></Intersection>\
<Angle name="u" n="9" alias="rx" color="1" first="I1" root="C1" second="R1" display="large" filled="true"></Angle>\
<Segment name="s1" n="10" from="C1" to="I1"></Segment>\
<Segment sname="t1" n="11" from="C1" to="R1"></Segment>
!endif
!if v isin $slib_angle
  slib_prelim=$slib_prelim\
<Point name="C2" n="12"  x="$(slib_cercle[1])" y="$(slib_cercle[2])"  hidden="true" fixed="true"></Point>\
<Circle name="c2" n="13" fixed="$(slib_ray[2])" midpoint="C2" acute="true"  hidden="true"></Circle>\
<PointOn name="R2" n="14" type="thick" on="c2"></PointOn>\
<Parallel name="l2" n="15" point="C2" line="s0"  hidden="true"></Parallel>\
<Intersection name="I2" n="16"  first="l2" second="c2" which="first" hidden="true"></Intersection>\
<Angle name="v" alias="ry" n="17" color="2" first="I2" root="C2" second="R2" display="large" filled="true"></Angle>\
<Segment name="s2" n="18" from="C2" to="I2"></Segment>\
<Segment sname="t2" n="19" from="C2" to="R2"></Segment>
!endif
!if w isin $slib_angle
  slib_prelim=$slib_prelim\
<Point name="C3" n="20"  x="$(slib_cercle[1])" y="$(slib_cercle[2])"  hidden="true" fixed="true"></Point>\
<Circle name="c3" n="21" fixed="$(slib_ray[3])" midpoint="C3" acute="true"  hidden="true"></Circle>\
<PointOn name="R3" n="22" type="thick" on="c3"></PointOn>\
<Parallel name="l3" n="23" point="C3" line="s0"  hidden="true"></Parallel>\
<Intersection name="I3" n="24"  first="l3" second="c3" which="first" hidden="true"></Intersection>\
<Angle name="w" alias="rz" n="25" color="3" first="I3" root="C3" second="R3" display="large" filled="true" actw="180"></Angle>\
<Segment name="s3" n="26" from="C3" to="I3"></Segment>\
<Segment sname="t3" n="27" from="C3" to="R3"></Segment>
!endif

!readproc oef/togetfile.proc $slib_fichier new\
$slib_prelim

slib_polyedre_vertex=
slib_test=$[min($slib_vertex_cnt,130)]

!for slib_na=1 to $slib_test
  slib_coord=!line $slib_na of $slib_vertex
  slib_coord=!words2items $slib_coord
  !! slib_maxx=$[max($(slib_coord[1]),$slib_maxx)]
  !! slib_maxy=$[max($(slib_coord[2]),$slib_maxy)]
  !! slib_minx=$[min($(slib_coord[1]),$slib_minx)]
  !! slib_miny=$[min($(slib_coord[2]),$slib_miny)]
  slib_liste=u,v,w
  slib_xyz=!exec pari print(round(1000*(([$slib_coord]-[$slib_centre_rot])*$slib_M +[$slib_centre_rot]))/1000.)
  !for slib_c in $slib_liste
  slib_xyz=!mathsubst c$slib_c=cos($slib_c) in $slib_xyz
  slib_xyz=!mathsubst s$slib_c=sin($slib_c) in $slib_xyz
!next
slib_xyz=!replace internal E- by *0* in $slib_xyz

slib_xy=$(slib_xyz[1])*(1-($(slib_xyz[3])-($slib_Z0))/($(slib_xyz[3])-($slib_Z1))),$(slib_xyz[2])*(1-($(slib_xyz[3])-($slib_Z0))/($(slib_xyz[3])-($slib_Z1)))
    slib_polyedre_vertex=$slib_polyedre_vertex\
<Point name="$slib_compteur" $(slib_name1_vertex[$slib_na]) n="$slib_compteur" $(slib_show_vertex[$slib_na]) x="($(slib_xy[1]))" y="($(slib_xy[2]))"  fixed="true"></Point>
  !advance slib_compteur
  !if $slib_na iswordof 25 50 75 100 150
    !readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_vertex
    !reset slib_polyedre_vertex
  !endif
!next

!readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_vertex

!if $slib_test != $slib_vertex_cnt
  !for slib_na= $[$slib_test+1] to $slib_vertex_cnt
    slib_coord=!line $slib_na of $slib_vertex
    slib_coord=!words2items $slib_coord
    !! slib_maxx=$[max($(slib_coord[1]),$slib_maxx)]
    !! slib_maxy=$[max($(slib_coord[2]),$slib_maxy)]
    !! slib_minx=$[min($(slib_coord[1]),$slib_minx)]
    !! slib_miny=$[min($(slib_coord[2]),$slib_miny)]
    slib_liste=u,v,w
    slib_xyz=!exec pari print(round(1000*(([$slib_coord]-[$slib_centre_rot])*$slib_M +[$slib_centre_rot]))/1000.)
    !for slib_c in $slib_liste
      slib_xyz=!mathsubst c$slib_c=cos($slib_c) in $slib_xyz
      slib_xyz=!mathsubst s$slib_c=sin($slib_c) in $slib_xyz
    !next
    slib_xyz=!replace internal E- by *0* in $slib_xyz

    slib_xy=$(slib_xyz[1])*(1-($(slib_xyz[3])-($slib_Z0))/($(slib_xyz[3])-($slib_Z1))),$(slib_xyz[2])*(1-($(slib_xyz[3])-($slib_Z0))/($(slib_xyz[3])-($slib_Z1)))
    slib_polyedre_vertex=$slib_polyedre_vertex\
  <Point name="$slib_compteur" $(slib_name1_vertex[$slib_na]) n="$slib_compteur" $(slib_show_vertex[$slib_na]) x="($(slib_xy[1]))" y="($(slib_xy[2]))"  fixed="true"></Point>
    !advance slib_compteur
    !if $slib_na iswordof  150 200
      !readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_vertex
      !reset slib_polyedre_vertex
    !endif
  !next

  !readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_vertex
!endif
!!********** code de dessin des arêtes
slib_polyedre_segments=
!if $slib_edge >0
  !for slib_nb=1 to $slib_edge_cnt
    slib_r=!line $slib_nb of $slib_edge
    slib_lien1=!word 1 of $slib_r
    slib_lien2=!word 2 of $slib_r
    slib_polyedre_segments=$slib_polyedre_segments\
<Segment name="$slib_compteur" $(slib_name1_edge[$slib_nb]) n="$slib_compteur" $(slib_show_edge[$slib_nb]) from="$[$slib_compteur_init+$slib_lien1]" to="$[$slib_compteur_init+$slib_lien2]"></Segment>
   !advance slib_compteur
   !if $slib_nb iswordof 50 100 150 200 250 300 350 400 450 500
     !readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_segments
     !reset slib_polyedre_segments
   !endif
 !next slib_nb
 !readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_segments
!endif

!!********** code de dessin des faces
slib_polyedre_face=
!if $slib_face>0
  !for slib_nc=1 to $slib_face_cnt
    slib_r=!line $slib_nc of $slib_face
    slib_nbcotes=!wordcnt $slib_r
    slib_sommetscote=
    !for slib_ns=1 to $slib_nbcotes
      slib_numerosommetscote=!word $slib_ns of $slib_r
      slib_sommetscote= $slib_sommetscote point$slib_ns="$[$slib_compteur_init+$slib_numerosommetscote]"
    !next slib_ns
    slib_sommetscote=!nonempty items $slib_sommetscote
    slib_polyedre_face=$slib_polyedre_face\
<Polygon name="$slib_compteur" $(slib_name1_face[$slib_nc]) color=$[$slib_compteur%5+1] n="$slib_compteur" $(slib_show_face[$slib_nc]) $slib_sommetscote></Polygon>
    !advance slib_compteur
    !if $slib_nb iswordof 50 100 150 200
      !readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_face
      !reset slib_polyedre_face
    !endif
  !next slib_nc
  !readproc oef/togetfile.proc $slib_fichier append\
$slib_polyedre_face
!endif

slib_fin= </Objects>\
</Construction>\
</CaR>

!readproc oef/togetfile.proc $slib_fichier append\
$slib_fin

slib_out=$wims_ref_name?session=$session&+cmd=getfile&+special_parm=$slib_fichier

slib_out=<object type="application/x-java-applet;jpi-version=1.4" id="CaR" \
classid="java:rene.zirkel.ZirkelApplet.class" width="420px" height="420px">\
<param name="java_codebase" value="java/zirkel" />\
<param name="java_archive" value="zirkel.jar" />\
<param name="java_code" value="rene.zirkel.ZirkelApplet.class" />\
<param name="file" value="$slib_out" />\
<param name="color" value="244,244,242" />\
<param name="style" value="full" />\
<param name="tools" value="move undo point midpoint msegment line" />\
<param name="options" value="" />\
<param name="editdigits" value="6" />\
<param name="displaydigits" value="2" />\
 Votre navigateur ne supporte pas JAVA\
 </object>