ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/acismesh/m3d_ac_front.cpp
Revision: 1
Committed: Mon Jun 11 22:53:07 2007 UTC (17 years, 11 months ago)
File size: 3531 byte(s)
Log Message:

File Contents

# Content
1 /*****************************************************************
2
3 m3d_ac_front.c Type:Func
4
5 Actualisation du front
6
7 Date de creation : Fri Feb 14 11:00:54 1997
8
9 Derniere version : Wed May 28 11:48:59 1997
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 Vincent FRANCOIS
25
26 *****************************************************************/
27
28
29
30
31
32 /**************************/
33 /* include */
34 #include <stdio.h>
35 #include <string.h>
36 #include <stdlib.h>
37 #include "memoire.h"
38 #include "struct.h"
39 #include "const.h"
40 #include "prototype.h"
41
42 /**************************/
43 /* variables globales */
44 extern struct s_mesh *mesh;
45 extern struct environnement env;
46
47 /**************************/
48 /* programme principal */
49
50 void m3d_ac_front(struct s_front3d **ele,int operation)
51 {
52 struct s_front3d *tmp,*tmp2,**l_front;
53 struct s_noeud *no1,*no2,*no3;
54 float x,y,z;
55 int nb_liste,i,j,num;
56 struct s_octree **liste,*oct;
57
58
59
60 switch (operation)
61 {
62 case DETRUIT: /* suppression du lien avec l arbre */
63 liste=(struct s_octree **)calloc(mesh->nb_octree+1,sizeof(struct s_octree *));
64 ERREUR_ALLOC(liste);
65 l_front=(struct s_front3d **)calloc(mesh->nb_front3d_tot+1,sizeof(struct s_front3d *));
66 ERREUR_ALLOC(l_front);
67 no1=ADRESSE((*ele)->n1,noeud,mesh->);
68 no2=ADRESSE((*ele)->n2,noeud,mesh->);
69 no3=ADRESSE((*ele)->n3,noeud,mesh->);
70 x=0.3333333*(no1->x+no2->x+no3->x);
71 y=0.3333333*(no1->y+no2->y+no3->y);
72 z=0.3333333*(no1->z+no2->z+no3->z);
73 nb_liste=0;
74 oc_rechercher(x,y,z,(*ele)->longueur,mesh->first,liste,&nb_liste);
75 for (i=0;i<nb_liste;i++)
76 {
77 oct=liste[i];
78 j=0;
79 while ( (j<oct->nb_front3d) )
80 {
81 if (oct->front3d[j]==(*ele))
82 {
83 if (j!=(oct->nb_front3d-1))
84 {
85 memcpy(l_front,&(oct->front3d[j+1]),(oct->nb_front3d-1-j)*sizeof(struct s_front3d *));
86 memcpy(&(oct->front3d[j]),l_front,(oct->nb_front3d-1-j)*sizeof(struct s_front3d *));
87 }
88 oct->front3d[oct->nb_front3d-1]=NULL;
89 oct->nb_front3d--;
90 }
91 else j++;
92 }
93 }
94 free(liste);
95 free(l_front);
96 /* suppression de l element dans le front */
97 (*ele)->tri->ft=NULL;
98 (*ele)->tri->front=(*ele)->tri->front+1;
99 (*ele)->n1=0;
100 (*ele)->n2=0;
101 (*ele)->n3=0;
102 (*ele)->tri=NULL;
103 (*ele)->etat=(-1);
104 (*ele)->voisin[0].ft=NULL;
105 (*ele)->voisin[1].ft=NULL;
106 (*ele)->voisin[2].ft=NULL;
107 tmp=(*ele)->suivant;
108 tmp2=(*ele)->precedent;
109 num=(*ele)->type;
110 if (num>(-1))
111 {
112 if ((*ele)->precedent!=NULL) (*ele)->precedent->suivant=tmp;
113 else mesh->tete_front3d[num]=tmp;
114 if ((*ele)->suivant!=NULL) (*ele)->suivant->precedent=tmp2;
115 else mesh->queue_front3d[num]=tmp2;
116 }
117 (*ele)->precedent=NULL;
118 (*ele)->suivant=mesh->vide_front3d;
119 (*ele)->type=(-1);
120 mesh->vide_front3d=(*ele);
121 mesh->nb_front3d--;
122 break;
123 case NEW:
124 if (mesh->vide_front3d!=NULL)
125 {
126 (*ele)=mesh->vide_front3d;
127 mesh->vide_front3d=mesh->vide_front3d->suivant;
128 (*ele)->suivant=NULL;
129 mesh->nb_front3d++;
130 }
131 else
132 {
133 NEW_ENTITE(tmp,front3d,mesh->);
134 (*ele)=tmp;
135 (*ele)->num=mesh->nb_front3d-1;
136 mesh->nb_front3d_tot=mesh->nb_front3d_tot+1;
137 }
138 (*ele)->etat=1;
139 (*ele)->type=-1;
140 break;
141 }
142
143 }