| 1 |
|
1 |
/*****************************************************************
|
| 2 |
|
|
|
| 3 |
|
|
m2d_i_tringle.c Type:Func
|
| 4 |
|
|
|
| 5 |
|
|
Insertion d un nouveau triangle
|
| 6 |
|
|
|
| 7 |
|
|
Date de creation : Wed Feb 26 15:41:50 1997
|
| 8 |
|
|
|
| 9 |
|
|
Derniere version : Wed Jul 2 17:11:02 1997
|
| 10 |
|
|
|
| 11 |
|
|
|
| 12 |
|
|
|
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
|
| 16 |
|
|
|
| 17 |
|
|
|
| 18 |
|
|
|
| 19 |
|
|
|
| 20 |
|
|
Vincent FRANCOIS
|
| 21 |
|
|
|
| 22 |
|
|
*****************************************************************/
|
| 23 |
|
|
|
| 24 |
|
|
|
| 25 |
|
|
|
| 26 |
|
|
|
| 27 |
|
|
|
| 28 |
|
|
/**************************/
|
| 29 |
|
|
/* include */
|
| 30 |
|
|
#include <stdio.h>
|
| 31 |
|
|
#include <stdlib.h>
|
| 32 |
|
|
#include <math.h>
|
| 33 |
|
|
#include "const.h"
|
| 34 |
|
|
#include "memoire.h"
|
| 35 |
|
|
#include "struct.h"
|
| 36 |
|
|
#include "prototype.h"
|
| 37 |
|
|
|
| 38 |
|
|
/**************************/
|
| 39 |
|
|
/* variables globales */
|
| 40 |
|
|
extern struct environnement env;
|
| 41 |
|
|
extern struct s_mesh *mesh;
|
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
/**************************/
|
| 45 |
|
|
/* programme principal */
|
| 46 |
|
|
|
| 47 |
|
|
void m2d_i_triangle(struct s_face *face,int n1,int n2,int n3,int origine)
|
| 48 |
|
|
{
|
| 49 |
|
|
struct s_triangle *ac_tri;
|
| 50 |
|
|
struct s_noeud *no1,*no2,*no3;
|
| 51 |
|
|
struct s_segment *seg;
|
| 52 |
|
|
int num,i,j,ok,npetit;
|
| 53 |
|
|
|
| 54 |
|
|
|
| 55 |
|
|
|
| 56 |
|
|
NEW_ENTITE(ac_tri,triangle,mesh->);
|
| 57 |
|
|
ac_tri->num=mesh->nb_triangle-1;
|
| 58 |
|
|
ac_tri->n1=n1;
|
| 59 |
|
|
ac_tri->n2=n2;
|
| 60 |
|
|
ac_tri->n3=n3;
|
| 61 |
|
|
ac_tri->crit=m2d_cal_qual(n1,n2,n3);
|
| 62 |
|
|
ac_tri->type=FACE;
|
| 63 |
|
|
ac_tri->num_ent=face->num;
|
| 64 |
|
|
ac_tri->origine=origine;
|
| 65 |
|
|
ac_tri->creation=CONSTRUIT;
|
| 66 |
|
|
if (mesh->nb_triangle==1)
|
| 67 |
|
|
{
|
| 68 |
|
|
mesh->critmin=ac_tri->crit;
|
| 69 |
|
|
mesh->critmax=ac_tri->crit;
|
| 70 |
|
|
mesh->critmoy=0.;
|
| 71 |
|
|
mesh->tabcrit[0]=0;
|
| 72 |
|
|
mesh->tabcrit[1]=0;
|
| 73 |
|
|
mesh->tabcrit[2]=0;
|
| 74 |
|
|
mesh->tabcrit[3]=0;
|
| 75 |
|
|
}
|
| 76 |
|
|
mesh->critmoy=mesh->critmoy+ac_tri->crit;
|
| 77 |
|
|
if (mesh->critmin>ac_tri->crit) mesh->critmin=ac_tri->crit;
|
| 78 |
|
|
if (mesh->critmax<ac_tri->crit) mesh->critmax=ac_tri->crit;
|
| 79 |
|
|
if (ac_tri->crit>0.75) mesh->tabcrit[3]++;
|
| 80 |
|
|
else if (ac_tri->crit>0.5) mesh->tabcrit[2]++;
|
| 81 |
|
|
else if (ac_tri->crit>0.25) mesh->tabcrit[1]++;
|
| 82 |
|
|
else mesh->tabcrit[0]++;
|
| 83 |
|
|
no1=ADRESSE(n1,noeud,mesh->);
|
| 84 |
|
|
NEW_POINTEUR(num,triangle,no1->);
|
| 85 |
|
|
no1->triangle[num]=ac_tri;
|
| 86 |
|
|
no2=ADRESSE(n2,noeud,mesh->);
|
| 87 |
|
|
NEW_POINTEUR(num,triangle,no2->);
|
| 88 |
|
|
no2->triangle[num]=ac_tri;
|
| 89 |
|
|
no3=ADRESSE(n3,noeud,mesh->);
|
| 90 |
|
|
NEW_POINTEUR(num,triangle,no3->);
|
| 91 |
|
|
no3->triangle[num]=ac_tri;
|
| 92 |
|
|
NEW_POINTEUR(num,triangle,face->);
|
| 93 |
|
|
face->triangle[num]=ac_tri;
|
| 94 |
|
|
o2d_ord_tri(ac_tri);
|
| 95 |
|
|
|
| 96 |
|
|
MINI(npetit,n1,n2);
|
| 97 |
|
|
MINI(npetit,npetit,n3);
|
| 98 |
|
|
no1=ADRESSE(npetit,noeud,mesh->);
|
| 99 |
|
|
if (no1->tete_tri_petit==NULL)
|
| 100 |
|
|
{
|
| 101 |
|
|
no1->tete_tri_petit=ac_tri;
|
| 102 |
|
|
no1->queue_tri_petit=ac_tri;
|
| 103 |
|
|
}
|
| 104 |
|
|
else
|
| 105 |
|
|
{
|
| 106 |
|
|
no1->queue_tri_petit->suiv=ac_tri;
|
| 107 |
|
|
no1->queue_tri_petit=ac_tri;
|
| 108 |
|
|
}
|
| 109 |
|
|
|
| 110 |
|
|
|
| 111 |
|
|
|
| 112 |
|
|
|
| 113 |
|
|
|
| 114 |
|
|
/* liaison triangle segment */
|
| 115 |
|
|
/* segment n1 n2 */
|
| 116 |
|
|
ok=0;i=0;
|
| 117 |
|
|
while ((i<no1->nb_segment) && (ok==0))
|
| 118 |
|
|
{
|
| 119 |
|
|
j=0;
|
| 120 |
|
|
while ( (j<no2->nb_segment) && (ok==0))
|
| 121 |
|
|
{
|
| 122 |
|
|
if (no1->segment[i]==no2->segment[j])
|
| 123 |
|
|
{
|
| 124 |
|
|
ok=1;
|
| 125 |
|
|
seg=no1->segment[i];
|
| 126 |
|
|
}
|
| 127 |
|
|
j++;
|
| 128 |
|
|
}
|
| 129 |
|
|
i++;
|
| 130 |
|
|
}
|
| 131 |
|
|
ac_tri->segment[0]=seg;
|
| 132 |
|
|
/* segment n1 n3 */
|
| 133 |
|
|
ok=0;i=0;
|
| 134 |
|
|
while ((i<no1->nb_segment) && (ok==0))
|
| 135 |
|
|
{
|
| 136 |
|
|
j=0;
|
| 137 |
|
|
while ( (j<no3->nb_segment) && (ok==0))
|
| 138 |
|
|
{
|
| 139 |
|
|
if (no1->segment[i]==no3->segment[j])
|
| 140 |
|
|
{
|
| 141 |
|
|
ok=1;
|
| 142 |
|
|
seg=no1->segment[i];
|
| 143 |
|
|
}
|
| 144 |
|
|
j++;
|
| 145 |
|
|
}
|
| 146 |
|
|
i++;
|
| 147 |
|
|
}
|
| 148 |
|
|
ac_tri->segment[1]=seg;
|
| 149 |
|
|
/* segment n3 n2 */
|
| 150 |
|
|
ok=0;i=0;
|
| 151 |
|
|
while ((i<no2->nb_segment) && (ok==0))
|
| 152 |
|
|
{
|
| 153 |
|
|
j=0;
|
| 154 |
|
|
while ( (j<no3->nb_segment) && (ok==0))
|
| 155 |
|
|
{
|
| 156 |
|
|
if (no2->segment[i]==no3->segment[j])
|
| 157 |
|
|
{
|
| 158 |
|
|
ok=1;
|
| 159 |
|
|
seg=no2->segment[i];
|
| 160 |
|
|
}
|
| 161 |
|
|
j++;
|
| 162 |
|
|
}
|
| 163 |
|
|
i++;
|
| 164 |
|
|
}
|
| 165 |
|
|
ac_tri->segment[2]=seg;
|
| 166 |
|
|
|
| 167 |
|
|
|
| 168 |
|
|
}
|