#!/bin/csh

#######################################################################################################################################
#                                                                                                                                     #
#         V I S U A L I S A T I O N   D ' U N   E N S E M B L E   D E   P O I N T S   T R I D I M E N S I O N N E L S  :              #
#                                                                                                                                     #
#                                                                                                                                     #
#         Utilisation :                                                                                                               #
#                                                                                                                                     #
#                   $xrv/pts_3D.11$Z    [<Fichier3DA>] [<imageR>]                                                                  \  #
#                                       [<Isoles>] [<NPoints>] [<Grossissement>]                                                   \  #
#                                       [<Rotation_OX>] [<Rotation_OY>] [<Rotation_OZ>]                                            \  #
#                                       [<Translation_OX>] [<Translation_OY>] [<Translation_OZ>]                                   \  #
#                                       [<Zoom>]                                                                                   \  #
#                                       [<Ax>] [<Bx>]                                                                              \  #
#                                       [<Ay>] [<By>]                                                                              \  #
#                                       [<Az>] [<Bz>]                                                                              \  #
#                                       [<Zminimum>] [<Zmaximum>] [<ZminimumT>] [<ZmaximumT>]                                      \  #
#                                       [<RayonCorrectZ>] [<RayonCorrect1>]                                                        \  #
#                                       [<Ajuster>] [<Auto>]                                                                       \  #
#                                       [<Brume>]                                                                                  \  #
#                                       [<NCarre>]                                                                                    #
#                                                                                                                                     #
#                                                                                                                                     #
#         Author of '$xrv/pts_3D.11$Z' :                                                                                              #
#                                                                                                                                     #
#                     Jean-Francois Colonna (LACTAMME, AAAAMMJJhhmmss).                                                               #
#                                                                                                                                     #
#######################################################################################################################################

GetArg    Fichier3DA=$xT/Fichier3DA                                                                                                     \
          imageR=$xT/imageR                                                                                                             \
          Isoles=VRAI                                                                                                                   \
          NPoints=50                                                                                                                    \
          Grossissement=1.0                                                                                                             \
          Rotation_OX=`GetParam $xrv/particule.10$X ROTATION_OX`                                                                        \
          Rotation_OY=`GetParam $xrv/particule.10$X ROTATION_OY`                                                                        \
          Rotation_OZ=`GetParam $xrv/particule.10$X ROTATION_OZ`                                                                        \
          Translation_OX=`GetParam $xrv/particule.10$X TRANSLATION_OX`                                                                  \
          Translation_OY=`GetParam $xrv/particule.10$X TRANSLATION_OY`                                                                  \
          Translation_OZ=`GetParam $xrv/particule.10$X TRANSLATION_OZ`                                                                  \
          Zoom=1.0                                                                                                                      \
          Ax=`GetParam $xrv/particule.10$X AX`                                                                                          \
          Bx=`GetParam $xrv/particule.10$X BX`                                                                                          \
          Ay=`GetParam $xrv/particule.10$X AY`                                                                                          \
          By=`GetParam $xrv/particule.10$X BY`                                                                                          \
          Az=`GetParam $xrv/particule.10$X AZ`                                                                                          \
          Bz=`GetParam $xrv/particule.10$X BZ`                                                                                          \
          Zminimum=`GetParam $xrv/particule.10$X Zminimum`                                                                              \
          Zmaximum=`GetParam $xrv/particule.10$X Zmaximum`                                                                              \
          ZminimumT=`GetParam $xrv/particule.10$X ZminimumT`                                                                            \
          ZmaximumT=`GetParam $xrv/particule.10$X ZmaximumT`                                                                            \
          RayonCorrectZ=VRAI                                                                                                            \
          RayonCorrect1=VRAI                                                                                                            \
          Ajuster=VRAI                                                                                                                  \
          Auto=FAUX                                                                                                                     \
          Brume=FAUX                                                                                                                    \
          NCarre=VRAI
                                        # Isoles          : permet de selectionner entre le mode "points isoles" ('VRAI') ou bien     #
                                        #                   le mode "points chaines".                                                 #
                                        #                                                                                             #
                                        # NPoints         : nombre de points sur une chaine de connexion.                             #
                                        #                                                                                             #
                                        # Grossissement   : facteur permettant de distinguer les points extremites des points         #
                                        #                   constitutifs des chaines de connexion.                                    #
                                        #                                                                                             #
                                        # Rotation_OX     : rotation autour de l'axe 'OX'.                                            #
                                        #                                                                                             #
                                        # Rotation_OY     : rotation autour de l'axe 'OY'.                                            #
                                        #                                                                                             #
                                        # Rotation_OZ     : rotation autour de l'axe 'OZ'.                                            #
                                        #                                                                                             #
                                        # Translation_OX  : translation parallele a l'axe 'OX' (introduite le 20111020122250).        #
                                        #                                                                                             #
                                        # Translation_OY  : translation parallele a l'axe 'OY' (introduite le 20111020122250).        #
                                        #                                                                                             #
                                        # Translation_OZ  : translation parallele a l'axe 'OZ' (introduite le 20111020122250).        #
                                        #                                                                                             #
                                        # Zoom            : facteur de zoom de l'image Resultat.                                      #
                                        #                                                                                             #
                                        # {Ax,Bx}         : parametres de 'AXPB(...)' pour les 'X's (introduits le 20111020125145),   #
                                        # {Ay,By}         : parametres de 'AXPB(...)' pour les 'Y's (introduits le 20111020125145),   #
                                        # {Az,Bz}         : parametres de 'AXPB(...)' pour les 'Z's (introduits le 20111020125145).   #
                                        #                                                                                             #
                                        # {Zminimum,Zmaximum,ZminimumT,ZmaximumT}                                                     #
                                        #                 : gestion du depth-cueing. Avec :                                           #
                                        #                                                                                             #
                                        #                                       Zminimum=ZminimumT=1.0        pas de                  #
                                        #                                       Zmaximum=ZmaximumT=1.0               depth-cueing,    #
                                        #                                                                                             #
                                        #                                       Zminimum=ZminimumT=0.0        depth-cueing            #
                                        #                                       Zmaximum=ZmaximumT=1.0                     maximal,   #
                                        #                                                                                             #
                                        #                                                           (introduits le 20111020191227).   #
                                        #                                                                                             #
                                        # RayonCorrectZ   : afin de calculer correctement le rayon des spheres projetees.             #
                                        # RayonCorrect1   : afin de calculer correctement le rayon des spheres projetees.             #
                                        #                                                                                             #
                                        # Ajuster         : afin de "remettre a l'echelle" les coordonnees {X,Y,Z}.                   #
                                        #                                                                                             #
                                        # Auto            : afin de ne pas ajuster automatiquement les coordonnees {X,Y,Z}.           #
                                        #                                                                                             #
                                        # Brume           : afin de generer des images dans la brume...                               #
                                        #                                                                                             #
                                        # NCarre          : afin de parametrer le tri (introduit le 20111020112330).                  #

if        (($Ajuster == FAUX) && ($Auto == VRAI)) then
          EROR      "Il y a certainement conflit entre '$K_DOLLAR""Ajuster=$Ajuster' et '$K_DOLLAR""Auto=$Auto'."
else
endif

if        (-e $Fichier3DA) then
          FileTmpB  nomTA

          FileTmpB  nomT1

          FileTmpB  nomTX
          FileTmpB  nomTY
          FileTmpB  nomTZ
          FileTmpB  nomTR
          FileTmpB  nomTV
          FileTmpB  nomTB
          FileTmpB  nomTr

          FileTmpB  nomTI
#20111020110657____:          set       nomTI=`echo "$nomTI" | $SE -e 's+^\(.*/\)[^/]**\(.......\)$+\1\2+'`                           #
          set       nomTI=`echo "$nomTI" | $SE -e 's+^\(.*/\)[^/][^/]*\(.......\)$+\1\2+'`
                                        # Creation de noms temporaires (dont un nom bref '$nomTI' afin d'eviter des problemes avec    #
                                        # '$LONGUEUR_NOMS' dans '$xci/acces$X').                                                      #

          $CA       $Fichier3DA                                                                                                         \
                              |  $SE       -e '/^ *$/d'                                                                                 \
                                                                                >   $nomTA
                                        # Nettoyage du fichier Argument...                                                            #

          set       Npoints3D=`$WC $nomTA`
          set       Npoints3D=$Npoints3D[$WC1]
                                        # Nombre de points tridimensionnels. Chacun d'entre-eux occupe une ligne du fichier           #
                                        # '$Fichier3DA' et aura en general la forme :                                                 #
                                        #                                                                                             #
                                        #         X=... Y=... Z=...             [RAYON=...] [ROUGE=...] [VERTE=...] [BLEUE=...]       #
                                        #                                                                                             #
                                        # ou :                                                                                        #
                                        #                                                                                             #
                                        #         X0001=... X0002=... X0003=... [RAYON=...] [ROUGE=...] [VERTE=...] [BLEUE=...]       #
                                        #                                                                                             #

          set       Xa_priori=$Xmin
          set       Ya_priori=$Ymin
          set       Za_priori=$Zmin

          set       Ra_priori=$GRIS_8
          set       Va_priori=$GRIS_8
          set       Ba_priori=$GRIS_8

          set       ra_priori=0.05
                                        # Valeurs a priori destinees a faire qu'aucun des fichiers ne soit vide...                    #

          $CA       $nomTA                                                                                                              \
                                        |  $SE       -e 's/$/ /'                                                                        \
                                                                                                    >   $nomT1
                                        # On ajoute un espace au bout de chaque ligne afin de pouvoir recuperer le dernier champ      #
                                        # de chaque ligne grace aux '$SE' qui suivent...                                              #

          $CA       $nomT1                                                                                                              \
                                        |  $EGRE     -e "X=|X0001="                                                                     \
                                        |  $SE       -e 's/.*X=\([^ ][^ ]*\) .*$/\1/'                                                   \
                                                     -e 's/.*X0001=\([^ ][^ ]*\) .*$/\1/'                                               \
                                                                                                    >   $nomTX
          (repeat    $Npoints3D          eval "echo $Xa_priori")                                                                        \
                                                                                                    >>! $nomTX

          $CA       $nomT1                                                                                                              \
                                        |  $EGRE     -e "Y=|X0002"                                                                      \
                                        |  $SE       -e 's/.*Y=\([^ ][^ ]*\) .*$/\1/'                                                   \
                                                     -e 's/.*X0002=\([^ ][^ ]*\) .*$/\1/'                                               \
                                                                                                    >   $nomTY
          (repeat    $Npoints3D          eval "echo $Ya_priori")                                                                        \
                                                                                                    >>! $nomTY

          $CA       $nomT1                                                                                                              \
                                        |  $EGRE     -e "Z=|X0003"                                                                      \
                                        |  $SE       -e 's/.*Z=\([^ ][^ ]*\) .*$/\1/'                                                   \
                                                     -e 's/.*X0003=\([^ ][^ ]*\) .*$/\1/'                                               \
                                                                                                    >   $nomTZ
          (repeat    $Npoints3D          eval "echo $Za_priori")                                                                        \
                                                                                                    >>! $nomTZ

          $CA       $nomT1                                                                                                              \
                                        |  $GRE      "RAYON="                                                                           \
                                        |  $SE       -e 's/.*RAYON=\([^ ][^ ]*\) .*$/\1/'                                               \
                                                                                                    >   $nomTr
          (repeat    $Npoints3D          eval "echo $ra_priori")                                                                        \
                                                                                                    >>! $nomTr

          $CA       $nomT1                                                                                                              \
                                        |  $GRE      "ROUGE="                                                                           \
                                        |  $SE       -e 's/.*ROUGE=\([^ ][^ ]*\) .*$/\1/'                                               \
                                                                                                    >   $nomTR
          (repeat    $Npoints3D          eval "echo $Ra_priori")                                                                        \
                                                                                                    >>! $nomTR

          $CA       $nomT1                                                                                                              \
                                        |  $GRE      "VERTE="                                                                           \
                                        |  $SE       -e 's/.*VERTE=\([^ ][^ ]*\) .*$/\1/'                                               \
                                                                                                    >   $nomTV
          (repeat    $Npoints3D          eval "echo $Va_priori")                                                                        \
                                                                                                    >>! $nomTV

          $CA       $nomT1                                                                                                              \
                                        |  $GRE      "BLEUE="                                                                           \
                                        |  $SE       -e 's/.*BLEUE=\([^ ][^ ]*\) .*$/\1/'                                               \
                                                                                                    >   $nomTB
          (repeat    $Npoints3D          eval "echo $Ba_priori")                                                                        \
                                                                                                    >>! $nomTB

          set       Ajustement="$K_VIDE"
                                        # A priori...                                                                                 #

          if        (($Ajuster == VRAI) && ($Auto == FAUX)) then

                    set  MinimumX=`$xrv/extrema.01$X ne=$Npoints3D fichier=$nomTX |& $GRE "^minimum *=" | $SE -e 's/^.*\([-+].*\)$/\1/'`
                    set  MinimumY=`$xrv/extrema.01$X ne=$Npoints3D fichier=$nomTY |& $GRE "^minimum *=" | $SE -e 's/^.*\([-+].*\)$/\1/'`
                    set  MinimumZ=`$xrv/extrema.01$X ne=$Npoints3D fichier=$nomTZ |& $GRE "^minimum *=" | $SE -e 's/^.*\([-+].*\)$/\1/'`
                    set       MinimumXY=`$xcg/MIN2.01$X nombre_1=$MinimumX nombre_2=$MinimumY`
                    set       MinimumXYZ=`$xcg/MIN2.01$X nombre_1=$MinimumXY nombre_2=$MinimumZ`

                    set  MaximumX=`$xrv/extrema.01$X ne=$Npoints3D fichier=$nomTX |& $GRE "^maximum *=" | $SE -e 's/^.*\([-+].*\)$/\1/'`
                    set  MaximumY=`$xrv/extrema.01$X ne=$Npoints3D fichier=$nomTY |& $GRE "^maximum *=" | $SE -e 's/^.*\([-+].*\)$/\1/'`
                    set  MaximumZ=`$xrv/extrema.01$X ne=$Npoints3D fichier=$nomTZ |& $GRE "^maximum *=" | $SE -e 's/^.*\([-+].*\)$/\1/'`
                    set       MaximumXY=`$xcg/MAX2.01$X nombre_1=$MaximumX nombre_2=$MaximumY`
                    set       MaximumXYZ=`$xcg/MAX2.01$X nombre_1=$MaximumXY nombre_2=$MaximumZ`

                    set       ExtensionX=`$xcg/SOUS.01$X nombre_1=$MaximumX nombre_2=$MinimumX`
                    set       ExtensionX=`$xcg/ABSO.01$X nombre=$ExtensionX`

                    set       ExtensionY=`$xcg/SOUS.01$X nombre_1=$MaximumY nombre_2=$MinimumY`
                    set       ExtensionY=`$xcg/ABSO.01$X nombre=$ExtensionY`

                    set       ExtensionZ=`$xcg/SOUS.01$X nombre_1=$MaximumZ nombre_2=$MinimumZ`
                    set       ExtensionZ=`$xcg/ABSO.01$X nombre=$ExtensionZ`

                    set       ExtensionXY=`$xcg/MAX2.01$X nombre_1=$ExtensionX nombre_2=$ExtensionY`
                    set       ExtensionXYZ=`$xcg/MAX2.01$X nombre_1=$ExtensionXY nombre_2=$ExtensionZ`

                    set       Homothetie=`$xcg/DIVZ.01$X nombre_1=1 nombre_2=$ExtensionXYZ`

                    set       TranslationX=`$xcg/MUL2.01$X nombre_1=-1 nombre_2=$MinimumX`
                    set       TranslationX=`$xcg/MUL2.01$X nombre_1=$Homothetie nombre_2=$TranslationX`

                    set       TranslationY=`$xcg/MUL2.01$X nombre_1=-1 nombre_2=$MinimumY`
                    set       TranslationY=`$xcg/MUL2.01$X nombre_1=$Homothetie nombre_2=$TranslationY`

                    set       TranslationZ=`$xcg/MUL2.01$X nombre_1=-1 nombre_2=$MinimumZ`
                    set       TranslationZ=`$xcg/MUL2.01$X nombre_1=$Homothetie nombre_2=$TranslationZ`

                    set       Ajustement="$Ajustement"" AX=$Homothetie BX=$TranslationX"
                    set       Ajustement="$Ajustement"" AY=$Homothetie BY=$TranslationY"
                    set       Ajustement="$Ajustement""                BZ=$TranslationZ"
                                        # Mise a jour des valeurs d'ajustement des coordonnees. On notera l'absence de "AZ=" afin     #
                                        # d'exploiter au mieux la dynamique des 'Z' (on verra a ce propos 'v $xiirv/MAPN.12').        #
          else
          endif

          if        (-e $Rotation_OX) then
                    set       SRotation_OX=`$WC $Rotation_OX`
                    set       SRotation_OX=$SRotation_OX[$WC1]
          else
                    set       SRotation_OX=1
          endif

          if        (-e $Rotation_OY) then
                    set       SRotation_OY=`$WC $Rotation_OY`
                    set       SRotation_OY=$SRotation_OY[$WC1]
          else
                    set       SRotation_OY=1
          endif

          if        (-e $Rotation_OZ) then
                    set       SRotation_OZ=`$WC $Rotation_OZ`
                    set       SRotation_OZ=$SRotation_OZ[$WC1]
          else
                    set       SRotation_OZ=1
          endif

          set       Nimages=`$xcg/MAX2.01$X nombre_1=$SRotation_OX nombre_2=$SRotation_OY`
          set       Nimages=`$xcg/MAX2.01$X nombre_1=$SRotation_OZ nombre_2=$Nimages`
          set       Nimages=`echo $Nimages | $SE -e "s/^[-+]//"`
                                        # Nombre d'images a generer en supprimant le signe a cause du test 'if(...)' qui suit...      #

          if        ($Nimages == 1) then
                    set       VnomTI=$nomTI$K_sepP
                                        # Lorsqu'une seule image est demandee, on ne vas pas generer de numero d'image.               #
          else
                    set       VnomTI=$imageR
                                        # Par contre, lorsque plusieurs images sont demandees, il convient de generer des numeros...  #
          endif

          $xrv/particule.10$X           np=$Nimages                                                                                     \
                                        iterations=$Npoints3D                                                                           \
                                        AX=$Ax BX=$Bx                                                                                   \
                                        AY=$Ay BY=$By                                                                                   \
                                        AZ=$Az BZ=$Bz                                                                                   \
                                        LISTE_X=$nomTX                                                                                  \
                                        LISTE_Y=$nomTY                                                                                  \
                                        LISTE_Z=$nomTZ                                                                                  \
                                        LISTE_ROUGE=$nomTR                                                                              \
                                        LISTE_VERTE=$nomTV                                                                              \
                                        LISTE_BLEUE=$nomTB                                                                              \
                                        LISTE_RAYON=$nomTr                                                                              \
                                        ajuster=$Auto $Ajustement                                                                       \
                                        rayon_correct_ZOOM=$RayonCorrectZ                                                               \
                                        rayon_correct_une_seule_fois=$RayonCorrect1                                                     \
                                        ZOOM=$Zoom                                                                                      \
                                        ROTATION_OX=$Rotation_OX                                                                        \
                                        ROTATION_OY=$Rotation_OY                                                                        \
                                        ROTATION_OZ=$Rotation_OZ                                                                        \
                                        TRANSLATION_OX=$Translation_OX                                                                  \
                                        TRANSLATION_OY=$Translation_OY                                                                  \
                                        TRANSLATION_OZ=$Translation_OZ                                                                  \
                                        isoles=$Isoles points=$NPoints grossissement=$Grossissement                                     \
                                        Lz=1000                                                                                         \
                                        brume=$Brume                                                                                    \
                                        Zminimum=$Zminimum ZminimumT=$ZminimumT                                                         \
                                        Zmaximum=$Zmaximum ZmaximumT=$ZmaximumT                                                         \
                                        N_AU_CARRE=$NCarre                                                                              \
                                        editer_extrema_hors=FAUX                                                                        \
                                        R=$VnomTI                                                                                       \
                                                                                                                        $formatI        \
                                                            |& $SE      -f $xrv/supATTENTION$sed
                                        # Le 20111020110657 l'option "N2=VRAI" a ete remplacee par "N_AU_CARRE=$NCarre" qui permet    #
                                        # avec 'FAUX' d'aller plus vite...                                                            #
                                        #                                                                                             #
                                        # Le 20111020121352 fut introduit le "editer_extrema_hors=FAUX"...                            #

          if        ($Nimages == 1) then
                    set       Premiere=1

#20091105190248____:                    set       Premiere="$K_sepP""`$xci/nombres$X premiere=$Premiere derniere=$Premiere`"          #

                    set       Premiere_1="`$xci/nombres$X premiere=$Premiere derniere=$Premiere`"
                    set       Premiere="$K_sepP""$Premiere_1"
                    unset     Premiere_1
                                        # Pour la modification du 20091105190248 : 'v $Falias_GetXTmp 20091105172200'...              #

                    $xci/acces$X                  A=$nomTI$Premiere$ROUGE R=$imageR$ROUGE                                               \
                                                                                                                        $formatI
                    $xci/acces$X                  A=$nomTI$Premiere$VERTE R=$imageR$VERTE                                               \
                                                                                                                        $formatI
                    $xci/acces$X                  A=$nomTI$Premiere$BLEUE R=$imageR$BLEUE                                               \
                                                                                                                        $formatI

                    ($DELETE   $nomTI*)                                                                       >& $nul
          else
          endif

          FileTmpE  nomTA

          FileTmpE  nomT1

          FileTmpE  nomTX
          FileTmpE  nomTY
          FileTmpE  nomTZ
          FileTmpE  nomTR
          FileTmpE  nomTV
          FileTmpE  nomTB
          FileTmpE  nomTr

          FileTmpE  nomTI $NEXIST
                                        # Nettoyage a posteriori...                                                                   #
else
          EROR      "Le fichier '$Fichier3DA' des points tridimensionnels n'existe pas."
endif



Copyright © Jean-François Colonna, 2019-2021.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / Ecole Polytechnique, 2019-2021.