1 |
|
1 |
/*****************************************************************
|
2 |
|
|
|
3 |
|
|
m3d_i_triangle.cpp Type:Func
|
4 |
|
|
|
5 |
|
|
Insertion d un triangle dans la phase 3D
|
6 |
|
|
|
7 |
|
|
Date de creation : 12-3-1999 14 :12 :4
|
8 |
|
|
Derniere version : 12-3-1999 14 :12 :4
|
9 |
|
|
|
10 |
|
|
Vincent FRANCOIS
|
11 |
|
|
|
12 |
|
|
*****************************************************************/
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
/**************************/
|
19 |
|
|
/* include */
|
20 |
|
|
#include <stdio.h>
|
21 |
|
|
#include <string.h>
|
22 |
|
|
#include <stdlib.h>
|
23 |
|
|
#include <math.h>
|
24 |
|
|
#include "const.h"
|
25 |
|
|
#include "memoire.h"
|
26 |
|
|
#include "struct.h"
|
27 |
|
|
#include "struct3d.h"
|
28 |
|
|
#include "prototype.h"
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/**************************/
|
32 |
|
|
/* variables globales */
|
33 |
|
|
extern struct environnment env;
|
34 |
|
|
extern struct s_mesh *mesh;
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
/**************************/
|
40 |
|
|
/* programme principal */
|
41 |
|
|
|
42 |
|
|
void m3d_i_triangle(struct s_triangle **tri,int n1, int n2, int n3, int type)
|
43 |
|
|
{
|
44 |
|
|
struct s_noeud *no1,*no2,*no3,*no;
|
45 |
|
|
struct s_triangle *tr,*trtmp;
|
46 |
|
|
struct s_segment *seg1,*seg2,*seg3;
|
47 |
|
|
int num,npetit;
|
48 |
|
|
|
49 |
|
|
no1=ADRESSE(n1,noeud,mesh->);
|
50 |
|
|
no2=ADRESSE(n2,noeud,mesh->);
|
51 |
|
|
no3=ADRESSE(n3,noeud,mesh->);
|
52 |
|
|
tr=NULL;
|
53 |
|
|
if (type!=CREATION)
|
54 |
|
|
{
|
55 |
|
|
/*for (i=0;i<no1->nb_triangle;i++)
|
56 |
|
|
for (j=0;j<no2->nb_triangle;j++)
|
57 |
|
|
for (k=0;k<no3->nb_triangle;k++)
|
58 |
|
|
if ((no1->triangle[i]==no2->triangle[j])&&(no1->triangle[i]==no3->triangle[k]))
|
59 |
|
|
tr=no1->triangle[i];
|
60 |
|
|
|
61 |
|
|
*tri=tr;*/
|
62 |
|
|
MINI(npetit,n1,n2);
|
63 |
|
|
MINI(npetit,npetit,n3);
|
64 |
|
|
no=ADRESSE(npetit,noeud,mesh->);
|
65 |
|
|
trtmp=no->tete_tri_petit;
|
66 |
|
|
while ((trtmp!=NULL)&&(tr==NULL))
|
67 |
|
|
{
|
68 |
|
|
if (((trtmp->n1==n1) && (trtmp->n2==n2) && (trtmp->n3==n3))
|
69 |
|
|
|| ((trtmp->n1==n1) && (trtmp->n3==n2) && (trtmp->n2==n3))
|
70 |
|
|
|| ((trtmp->n2==n1) && (trtmp->n3==n2) && (trtmp->n1==n3))
|
71 |
|
|
|| ((trtmp->n2==n1) && (trtmp->n1==n2) && (trtmp->n3==n3))
|
72 |
|
|
|| ((trtmp->n3==n1) && (trtmp->n2==n2) && (trtmp->n1==n3))
|
73 |
|
|
|| ((trtmp->n3==n1) && (trtmp->n1==n2) && (trtmp->n2==n3)))
|
74 |
|
|
tr=trtmp;
|
75 |
|
|
trtmp=trtmp->suiv;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
*tri=tr;
|
79 |
|
|
if (type==LIMITE) return;
|
80 |
|
|
}
|
81 |
|
|
if (tr==NULL)
|
82 |
|
|
{
|
83 |
|
|
NEW_ENTITE(tr,triangle,mesh->);
|
84 |
|
|
tr->num=mesh->nb_triangle-1;
|
85 |
|
|
tr->n1=n1;
|
86 |
|
|
tr->n2=n2;
|
87 |
|
|
tr->n3=n3;
|
88 |
|
|
m3d_i_segment(&seg1,n1,n2);
|
89 |
|
|
m3d_i_segment(&seg2,n1,n3);
|
90 |
|
|
m3d_i_segment(&seg3,n2,n3);
|
91 |
|
|
tr->segment[0]=seg1;
|
92 |
|
|
tr->segment[1]=seg2;
|
93 |
|
|
tr->segment[2]=seg3;
|
94 |
|
|
tr->type=BODY;
|
95 |
|
|
NEW_POINTEUR(num,triangle,no1->);
|
96 |
|
|
no1->triangle[num]=tr;
|
97 |
|
|
NEW_POINTEUR(num,triangle,no2->);
|
98 |
|
|
no2->triangle[num]=tr;
|
99 |
|
|
NEW_POINTEUR(num,triangle,no3->);
|
100 |
|
|
no3->triangle[num]=tr;
|
101 |
|
|
*tri=tr;
|
102 |
|
|
|
103 |
|
|
MINI(npetit,n1,n2);
|
104 |
|
|
MINI(npetit,npetit,n3);
|
105 |
|
|
no1=ADRESSE(npetit,noeud,mesh->);
|
106 |
|
|
if (no1->tete_tri_petit==NULL)
|
107 |
|
|
{
|
108 |
|
|
no1->tete_tri_petit=tr;
|
109 |
|
|
no1->queue_tri_petit=tr;
|
110 |
|
|
}
|
111 |
|
|
else
|
112 |
|
|
{
|
113 |
|
|
no1->queue_tri_petit->suiv=tr;
|
114 |
|
|
no1->queue_tri_petit=tr;
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
}
|
118 |
|
|
}
|