ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/diamesh/src/m3d_rech3.cpp
Revision: 5
Committed: Tue Jun 12 20:26:34 2007 UTC (17 years, 11 months ago)
Original Path: magic/lib/diamesh/diamesh/src/m3d_rech3.cpp
File size: 2594 byte(s)
Log Message:

File Contents

# User Rev Content
1 5 #include <stdio.h>
2     #include <math.h>
3     #include "m3d_struct.h"
4     #include "m3d_const.h"
5     #include "m3d_hotes.h"
6     #include "m3d_erreur.h"
7     #include "prototype.h"
8     extern GEST_MEM *gest ;
9     extern int debug ;
10     int m3d_rech3(FACE *face,NOEUD **nresu)
11     {
12     int i, j, k, j1, j2, j3, j4 ;
13     int is_j1, is_j2, is_j3, is_j4, nump,nb, num, card, nele ;
14     int nb_noe_rec = 0 ;
15     int nb_ele_rec = 0 ;
16     float vab[3], vac[3], vn[3], pvec[3], norme, vap[3] ;
17     FILE *stream ;
18     float *coord ;
19     int iptr ;
20    
21     coord = gest->coord ;
22     j1 = j2 = j3 = j4 = 0 ;
23    
24     card = gest->card ;
25     num = face->n1->num ;
26     iptr = gest->tab_card[num] ;
27     k = 0 ;
28     nele = 0 ;
29     nele = gest->tab_ref[iptr+k] ;
30     while (nele>-1)
31     {
32     j1 = gest->tab_rec[4*nele] ;
33     j2 = gest->tab_rec[4*nele+1] ;
34     j3 = gest->tab_rec[4*nele+2] ;
35     j4 = gest->tab_rec[4*nele+3] ;
36    
37     nb = 0 ;
38     is_j1 = is_j2 = is_j3 = is_j4 = 0 ;
39    
40     if ((face->n1->num == j1) || (face->n2->num == j1) || (face->n3->num == j1)) { nb++ ; is_j1 = 1; }
41     if ((face->n1->num == j2) || (face->n2->num == j2) || (face->n3->num == j2)) { nb++ ; is_j2 = 1; }
42     if ((face->n1->num == j3) || (face->n2->num == j3) || (face->n3->num == j3)) { nb++ ; is_j3 = 1; }
43     if ((face->n1->num == j4) || (face->n2->num == j4) || (face->n3->num == j4)) { nb++ ; is_j4 = 1; }
44     if (nb == 3)
45     {
46     if (!is_j1) nump = j1 ;
47     if (!is_j2) nump = j2 ;
48     if (!is_j3) nump = j3 ;
49     if (!is_j4) nump = j4 ;
50    
51     /* calcul de la normale */
52     vab[0] = coord[x((face->n2)->num)] - coord[x((face->n1)->num)] ;
53     vab[1] = coord[y((face->n2)->num)] - coord[y((face->n1)->num)] ;
54     vab[2] = coord[z((face->n2)->num)] - coord[z((face->n1)->num)] ;
55    
56     vac[0] = coord[x((face->n3)->num)] - coord[x((face->n1)->num)] ;
57     vac[1] = coord[y((face->n3)->num)] - coord[y((face->n1)->num)] ;
58     vac[2] = coord[z((face->n3)->num)] - coord[z((face->n1)->num)] ;
59    
60     vn[0] = PVECX(vab,vac) ;
61     vn[1] = PVECY(vab,vac) ;
62     vn[2] = PVECZ(vab,vac) ;
63     norme = NORME(vn) ;
64     if (norme<EPSILON)
65     {
66     if (debug) printf("%s\n"," normale nulle M3D_RECH3 ") ;
67     m3d_erreur(ERR_FIN) ;
68     return(FAUX) ;
69     }
70     for (j=0;j<3;j++) vn[j] = vn[j]/norme ;
71    
72     vap[0] = coord[x(nump)] - coord[x((face->n1)->num)] ;
73     vap[1] = coord[y(nump)] - coord[y((face->n1)->num)] ;
74     vap[2] = coord[z(nump)] - coord[z((face->n1)->num)] ;
75    
76     if (PROSCA(vap,vn) > EPSILON) /* on a trouve le noeud solution */
77     {
78     ADRESSE(noeud,nump,*nresu)
79     return(VRAI) ;
80     }
81     }
82     k++ ;
83     nele = gest->tab_ref[iptr+k] ;
84     }
85     *nresu = NULL ;
86     return(VRAI) ;
87     }
88