#!/bin/csh

#######################################################################################################################################
#                                                                                                                                     #
#         I N T E R S E C T I O N S   D E   S E G M E N T S   D E U X   A   D E U X                                                   #
#         E T   S U P P R E S S I O N   D E   C E U X   Q U I   " P E N D E N T "  :                                                  #
#                                                                                                                                     #
#                                                                                                                                     #
#         Utilisation :                                                                                                               #
#                                                                                                                                     #
#                   $xrv/intersection.11$Z   <APoints_1> <APoints_2> <RPoints_1> <RPoints_2> [<EpsD> [<EpsP> [<NeutI> [<NeutS>]]]]    #
#                                                                                                                                     #
#                                                                                                                                     #
#         Author of '$xrv/intersection.11$Z' :                                                                                        #
#                                                                                                                                     #
#                     Jean-Francois Colonna (LACTAMME, 20150817115411).                                                               #
#                                                                                                                                     #
#######################################################################################################################################

set                 APoints_1=$1
set                 APoints_2=$2
set                 RPoints_1=$3
set                 RPoints_2=$4
set                 EpsDeterminants=$5
set                 EpsProdVectoriels=$6
set                 IntersectioNeutre=$7
set                 SupPendantsNeutre=$8

setArgum            EpsDeterminants               `GetParam $xrv/intersection.11$X epsilon_determinants`

setArgum            EpsProdVectoriels             `GetParam $xrv/intersection.11$X epsilon_produits_vectoriels`

setArgum            IntersectioNeutre             FAUX

setArgum            SupPendantsNeutre             FAUX

if                  (         ("$APoints_1" != "$K_VIDE")                                                                               \
                    &&        ("$APoints_2" != "$K_VIDE")                                                                               \
                    &&        ("$RPoints_1" != "$K_VIDE")                                                                               \
                    &&        ("$RPoints_2" != "$K_VIDE")                                                                               \
                     ) then
                    FilSTmpB            FiLeTmP_points

                    $xrv/distance.12$X                                                                                                  \
                                        ne=0                                                                                            \
                                        LISTE_XA=$APoints_1$COORD_X                                                                     \
                                        LISTE_YA=$APoints_1$COORD_Y                                                                     \
                                        LISTE_ZA=$APoints_1$COORD_Z                                                                     \
                                        LISTE_XB=$APoints_2$COORD_X                                                                     \
                                        LISTE_YB=$APoints_2$COORD_Y                                                                     \
                                        LISTE_ZB=$APoints_2$COORD_Z                                                                     \
                                                                                                    >   $FiLeTmP_points.DISTANCE

                    $xrv/tri.11$X                                                                                                       \
                                        ne=0                                                                                            \
                                        fichier=$FiLeTmP_points.DISTANCE                                                                \
                                        permutation=VRAI                                                                                \
                                        inverser=VRAI                                                                                   \
                                                                                                    >   $FiLeTmP_points.PERMUTATION

                    $xrv/permute.11$X                                                                                                   \
                                        ne=0                                                                                            \
                                        fichier=$APoints_1$COORD_X                                                                      \
                                        permutation=$FiLeTmP_points.PERMUTATION                                                         \
                                                                                                    >   $FiLeTmP_points.1.1$COORD_X
                    $xrv/permute.11$X                                                                                                   \
                                        ne=0                                                                                            \
                                        fichier=$APoints_1$COORD_Y                                                                      \
                                        permutation=$FiLeTmP_points.PERMUTATION                                                         \
                                                                                                    >   $FiLeTmP_points.1.1$COORD_Y
                    $xrv/permute.11$X                                                                                                   \
                                        ne=0                                                                                            \
                                        fichier=$APoints_1$COORD_Z                                                                      \
                                        permutation=$FiLeTmP_points.PERMUTATION                                                         \
                                                                                                    >   $FiLeTmP_points.1.1$COORD_Z

                    $xrv/permute.11$X                                                                                                   \
                                        ne=0                                                                                            \
                                        fichier=$APoints_2$COORD_X                                                                      \
                                        permutation=$FiLeTmP_points.PERMUTATION                                                         \
                                                                                                    >   $FiLeTmP_points.1.2$COORD_X
                    $xrv/permute.11$X                                                                                                   \
                                        ne=0                                                                                            \
                                        fichier=$APoints_2$COORD_Y                                                                      \
                                        permutation=$FiLeTmP_points.PERMUTATION                                                         \
                                                                                                    >   $FiLeTmP_points.1.2$COORD_Y
                    $xrv/permute.11$X                                                                                                   \
                                        ne=0                                                                                            \
                                        fichier=$APoints_2$COORD_Z                                                                      \
                                        permutation=$FiLeTmP_points.PERMUTATION                                                         \
                                                                                                    >   $FiLeTmP_points.1.2$COORD_Z
                                        # Tri des aretes suivant leurs longueurs decroissantes. Ceci a ete introduit afin             #
                                        # d'eliminer en premier les grandes aretes qui coupent donc a priori beaucoup de              #
                                        # petites qui sont alors eliminees...                                                         #

                    $xrv/intersection.11$X                                                                                              \
                                        ne=0                                                                                            \
                                        LISTE_S_Xorg=$FiLeTmP_points.1.1$COORD_X                                                        \
                                        LISTE_S_Yorg=$FiLeTmP_points.1.1$COORD_Y                                                        \
                                        LISTE_S_Zorg=$FiLeTmP_points.1.1$COORD_Z                                                        \
                                        LISTE_S_Xext=$FiLeTmP_points.1.2$COORD_X                                                        \
                                        LISTE_S_Yext=$FiLeTmP_points.1.2$COORD_Y                                                        \
                                        LISTE_S_Zext=$FiLeTmP_points.1.2$COORD_Z                                                        \
                                        epsilon_determinants=$EpsDeterminants                                                           \
                                        epsilon_produits_vectoriels=$EpsProdVectoriels                                                  \
                                        neutre=$IntersectioNeutre                                                                       \
                                                                                                    >   $FiLeTmP_points.SEGMENTS1
                                        # Suppression des paires definissant une arete en intersectant une autre.                     #

                    $CA                 $FiLeTmP_points.SEGMENTS1                                                                 |     \
                    $AW                 ' { print $1 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $FiLeTmP_points.2.1$COORD_X
                    $CA                 $FiLeTmP_points.SEGMENTS1                                                                 |     \
                    $AW                 ' { print $2 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $FiLeTmP_points.2.1$COORD_Y
                    $CA                 $FiLeTmP_points.SEGMENTS1                                                                 |     \
                    $AW                 ' { print $3 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $FiLeTmP_points.2.1$COORD_Z

                    $CA                 $FiLeTmP_points.SEGMENTS1                                                                 |     \
                    $AW                 ' { print $4 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $FiLeTmP_points.2.2$COORD_X
                    $CA                 $FiLeTmP_points.SEGMENTS1                                                                 |     \
                    $AW                 ' { print $5 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $FiLeTmP_points.2.2$COORD_Y
                    $CA                 $FiLeTmP_points.SEGMENTS1                                                                 |     \
                    $AW                 ' { print $6 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $FiLeTmP_points.2.2$COORD_Z

                    $xrv/SupPendants.11$X                                                                                               \
                                        ne=0                                                                                            \
                                        LISTE_S_Xorg=$FiLeTmP_points.2.1$COORD_X                                                        \
                                        LISTE_S_Yorg=$FiLeTmP_points.2.1$COORD_Y                                                        \
                                        LISTE_S_Zorg=$FiLeTmP_points.2.1$COORD_Z                                                        \
                                        LISTE_S_Xext=$FiLeTmP_points.2.2$COORD_X                                                        \
                                        LISTE_S_Yext=$FiLeTmP_points.2.2$COORD_Y                                                        \
                                        LISTE_S_Zext=$FiLeTmP_points.2.2$COORD_Z                                                        \
                                        neutre=$SupPendantsNeutre                                                                       \
                                                                                                    >   $FiLeTmP_points.SEGMENTS2
                                        # Suppression des segments "pendants"...                                                      #

                    $CA                 $FiLeTmP_points.SEGMENTS2                                                                 |     \
                    $AW                 ' { print $1 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $RPoints_1$COORD_X
                    $CA                 $FiLeTmP_points.SEGMENTS2                                                                 |     \
                    $AW                 ' { print $2 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $RPoints_1$COORD_Y
                    $CA                 $FiLeTmP_points.SEGMENTS2                                                                 |     \
                    $AW                 ' { print $3 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $RPoints_1$COORD_Z

                    $CA                 $FiLeTmP_points.SEGMENTS2                                                                 |     \
                    $AW                 ' { print $4 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $RPoints_2$COORD_X
                    $CA                 $FiLeTmP_points.SEGMENTS2                                                                 |     \
                    $AW                 ' { print $5 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $RPoints_2$COORD_Y
                    $CA                 $FiLeTmP_points.SEGMENTS2                                                                 |     \
                    $AW                 ' { print $6 } '                                                                          |     \
                    $SE                 -e "s/^.*=//"                                                                                   \
                                                                                                    >   $RPoints_2$COORD_Z

                    FilSTmpE            FiLeTmP_points
else
                    EROR                "L'un au moins des quatre ensembles de fichiers argument est vide."
endif



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