TABLE OF CONTENTS
NUM/raycasting [ Modules ]
NOM
raycasting(sol,x,y,z,chi)
DESCRIPTION
Algorithme de raycasting permettant de determiner si la cellule courante est dans le "solide" ou non.
raycasting algorithm to determine whether the current cell is in the ‘solid’ or not.
ENTREES / INPUT
sol : solide / solid
x,y,z : coordonnees du point a tester / coordinates of the point to be tested
SORTIES / OUTPUT
chi : indicatrice de presence (0: non, 1: oui) / presence indicator (0: no, 1: yes)
SOURCE
! Ce logiciel est regi par la licence [CeCILL-B] ! This software is governed by the [CeCILL-B] license !=========================== DEBUT DES DECLARATIONS ==================== !.1----- Implicit, Use use num_typ IMPLICIT NONE !.2----- Declaration real(kind=kind(0.d0)), intent(in) :: x,y,z !! coordonnees du centre de la cellule a tester / coordinates of the centre of the cell to be tested type(solide), intent(inout) :: sol !! Objet solide / Solid object real(kind=kind(0.d0)), intent(out) :: chi !! Indicatrice de presence (0: non, 1: oui) / Presence indicator (0: no, 1: yes) integer :: k,ind real(kind=kind(0.d0)) :: xn type(point) :: ori,v0,v1,v2 integer :: cpt,intersect type(vect_3) :: dir !=========================== DEBUT DU CODE EXECUTABLE ================== ind=0 !~! !~! ! 3D : voir "Fast, minimum storage Ray/triangle intersection" (1997) - Moller et Trumbore !~! ori%x=x ! Origine du rayon ori%y=y ! Origine du rayon ori%z=z ! Origine du rayon dir%v(1)=sol%xg%v(1) - x ! Vecteur directeur du rayon dir%v(2)=sol%xg%v(2) - y dir%v(3)=sol%xg%v(3) - z dir%v(1)=1.d0 ! Vecteur directeur du rayon dir%v(2)=0.d0 dir%v(3)=0.d0 xn=dsqrt(dir%v(1)**2+dir%v(2)**2+dir%v(3)**2) cpt = 0 if (xn.ne.0.d0)dir%v=dir%v/xn !call display(ori) !write(*,*)dir,sol%xg DO k=1,sol%nb_face ! Boucle sur les faces/triangles ! Construction des points du triangle v0=sol%list_vertex(sol%list_facette(k)%vertex(1)) v1=sol%list_vertex(sol%list_facette(k)%vertex(2)) v2=sol%list_vertex(sol%list_facette(k)%vertex(3)) ! Compteur d intersection cpt = cpt + intersect(V0,V1,V2,ori,dir) !write(*,*)intersect(V0,V1,V2,ori,dir) !call display(v0) !call display(v1) !call display(v2) END DO ind=0 IF (mod(cpt,2).EQ.1) ind=1 ! Si le nombre d intersection est impair, alors la maille est dans le polygone. IF (ind.NE.0) chi=sol%id*1.d0 !=========================== FIN DE LA ROUTINE ==================== END SUBROUTINE raycasting