1 |
/*****************************************************************
|
2 |
|
3 |
oc_ins_obj.c Type:Func
|
4 |
|
5 |
Insertion d un objet dans l octree
|
6 |
|
7 |
Date de creation : Wed Jun 25 09:29:44 1997
|
8 |
|
9 |
Derniere version : Wed Jul 16 11:06:09 1997
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
Vincent FRANCOIS
|
17 |
|
18 |
*****************************************************************/
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
/**************************/
|
25 |
/* include */
|
26 |
#include <stdio.h>
|
27 |
#include <string.h>
|
28 |
#include "const.h"
|
29 |
#include "memoire.h"
|
30 |
#include "struct.h"
|
31 |
#include "prototype.h"
|
32 |
|
33 |
/**************************/
|
34 |
/* variables globales */
|
35 |
extern struct s_acis *acis;
|
36 |
extern struct environnement env;
|
37 |
extern struct s_mesh *mesh;
|
38 |
extern struct s_param *para;
|
39 |
extern struct s_maillage *maillage;
|
40 |
|
41 |
|
42 |
/**************************/
|
43 |
/* programme principal */
|
44 |
|
45 |
void oc_ins_obj(int type,int num,struct s_octree *octree)
|
46 |
{
|
47 |
|
48 |
struct s_vertex *vertex1,*vertex;
|
49 |
struct s_point *point;
|
50 |
struct s_straight *straight;
|
51 |
struct s_ellipse *ellipse;
|
52 |
struct s_edge *edge;
|
53 |
struct s_coedge *coedge;
|
54 |
struct s_loop *loop;
|
55 |
struct s_cone *cone;
|
56 |
struct s_face *face;
|
57 |
struct s_noeud *no,*no1,*no2,*no3,*no4;
|
58 |
struct s_triangle *tri;
|
59 |
struct s_tetra *tet;
|
60 |
struct s_mnoeud *mno,*mno1,*mno2,*mno3,*mno4;
|
61 |
struct s_mtriangle *mtri;
|
62 |
struct s_mtetra *mtet;
|
63 |
struct s_msegment *mseg;
|
64 |
struct s_frontiere3d *fr;
|
65 |
struct s_front3d *ft;
|
66 |
float bxmin,bymin,bzmin;
|
67 |
float bxmax,bymax,bzmax;
|
68 |
void *entite;
|
69 |
|
70 |
if (type==VERTEX)
|
71 |
{
|
72 |
vertex=ADRESSE(num,vertex,acis->);
|
73 |
point=vertex->point;
|
74 |
type=POINT;
|
75 |
entite=(void *)vertex;
|
76 |
}
|
77 |
|
78 |
|
79 |
if (type==EDGE)
|
80 |
{
|
81 |
edge=ADRESSE(num,edge,acis->);
|
82 |
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
83 |
{
|
84 |
straight=(struct s_straight *)acis->entity[edge->curve];
|
85 |
type=STRAIGHT;
|
86 |
}
|
87 |
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
88 |
{
|
89 |
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
90 |
type=ELLIPSE;
|
91 |
}
|
92 |
entite=(void *)edge;
|
93 |
}
|
94 |
|
95 |
if (type==FACE)
|
96 |
{
|
97 |
face=ADRESSE(num,face,acis->);
|
98 |
if (strcmp(acis->type_entite[face->surface],"cone-surface")==0)
|
99 |
{
|
100 |
cone=(struct s_cone *)acis->entity[face->surface];
|
101 |
type=CONE;
|
102 |
}
|
103 |
if (strcmp(acis->type_entite[face->surface],"plane-surface")==0)
|
104 |
{
|
105 |
type=PLANE;
|
106 |
}
|
107 |
entite=(void *)face;
|
108 |
}
|
109 |
|
110 |
if (type==POINT)
|
111 |
{
|
112 |
bxmin=point->coord[0];
|
113 |
bymin=point->coord[1];
|
114 |
bzmin=point->coord[2];
|
115 |
bxmax=point->coord[0];
|
116 |
bymax=point->coord[1];
|
117 |
bzmax=point->coord[2];
|
118 |
}
|
119 |
if (type==STRAIGHT)
|
120 |
{
|
121 |
vertex1=edge->start_vertex;
|
122 |
bxmin=vertex1->point->coord[0];
|
123 |
bymin=vertex1->point->coord[1];
|
124 |
bzmin=vertex1->point->coord[2];
|
125 |
bxmax=vertex1->point->coord[0];
|
126 |
bymax=vertex1->point->coord[1];
|
127 |
bzmax=vertex1->point->coord[2];
|
128 |
oc_boite_straight(edge,straight,&bxmin,&bymin,&bzmin,&bxmax,&bymax,&bzmax);
|
129 |
}
|
130 |
if (type==ELLIPSE)
|
131 |
{
|
132 |
vertex1=edge->start_vertex;
|
133 |
bxmin=vertex1->point->coord[0];
|
134 |
bymin=vertex1->point->coord[1];
|
135 |
bzmin=vertex1->point->coord[2];
|
136 |
bxmax=vertex1->point->coord[0];
|
137 |
bymax=vertex1->point->coord[1];
|
138 |
bzmax=vertex1->point->coord[2];
|
139 |
oc_boite_ellipse(edge,ellipse,&bxmin,&bymin,&bzmin,&bxmax,&bymax,&bzmax);
|
140 |
}
|
141 |
if (type==CONE)
|
142 |
{
|
143 |
bxmin=cone->center[0];
|
144 |
bymin=cone->center[1];
|
145 |
bzmin=cone->center[2];
|
146 |
bxmax=cone->center[0];
|
147 |
bymax=cone->center[1];
|
148 |
bzmax=cone->center[2];
|
149 |
for (loop=face->first_loop;loop!=NULL;loop=loop->next_loop)
|
150 |
{
|
151 |
coedge=loop->first_coedge;
|
152 |
do
|
153 |
{
|
154 |
edge=coedge->edge;
|
155 |
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
156 |
{
|
157 |
straight=(struct s_straight *)acis->entity[edge->curve];
|
158 |
oc_boite_straight(edge,straight,&bxmin,&bymin,&bzmin,&bxmax,&bymax,&bzmax);
|
159 |
}
|
160 |
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
161 |
{
|
162 |
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
163 |
oc_boite_ellipse(edge,ellipse,&bxmin,&bymin,&bzmin,&bxmax,&bymax,&bzmax);
|
164 |
}
|
165 |
coedge=coedge->next_coedge;
|
166 |
}
|
167 |
while (coedge!=loop->first_coedge);
|
168 |
}
|
169 |
}
|
170 |
if (type==PLANE)
|
171 |
{
|
172 |
bxmin=face->first_loop->first_coedge->edge->start_vertex->point->coord[0];
|
173 |
bymin=face->first_loop->first_coedge->edge->start_vertex->point->coord[1];
|
174 |
bzmin=face->first_loop->first_coedge->edge->start_vertex->point->coord[2];
|
175 |
bxmax=face->first_loop->first_coedge->edge->start_vertex->point->coord[0];
|
176 |
bymax=face->first_loop->first_coedge->edge->start_vertex->point->coord[1];
|
177 |
bzmax=face->first_loop->first_coedge->edge->start_vertex->point->coord[2];
|
178 |
for (loop=face->first_loop;loop!=NULL;loop=loop->next_loop)
|
179 |
{
|
180 |
coedge=loop->first_coedge;
|
181 |
do
|
182 |
{
|
183 |
edge=coedge->edge;
|
184 |
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
185 |
{
|
186 |
straight=(struct s_straight *)acis->entity[edge->curve];
|
187 |
oc_boite_straight(edge,straight,&bxmin,&bymin,&bzmin,&bxmax,&bymax,&bzmax);
|
188 |
}
|
189 |
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
190 |
{
|
191 |
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
192 |
oc_boite_ellipse(edge,ellipse,&bxmin,&bymin,&bzmin,&bxmax,&bymax,&bzmax);
|
193 |
}
|
194 |
coedge=coedge->next_coedge;
|
195 |
}
|
196 |
while (coedge!=loop->first_coedge);
|
197 |
}
|
198 |
|
199 |
}
|
200 |
|
201 |
if (type==NOEUD)
|
202 |
{
|
203 |
no=ADRESSE(num,noeud,mesh->);
|
204 |
entite=(void *)no;
|
205 |
bxmin=no->x;
|
206 |
bymin=no->y;
|
207 |
bzmin=no->z;
|
208 |
bxmax=no->x;
|
209 |
bymax=no->y;
|
210 |
bzmax=no->z;
|
211 |
}
|
212 |
if (type==TRIANGLE)
|
213 |
{
|
214 |
tri=ADRESSE(num,triangle,mesh->);
|
215 |
entite=(void *)tri;
|
216 |
no1=ADRESSE(tri->n1,noeud,mesh->);
|
217 |
no2=ADRESSE(tri->n2,noeud,mesh->);
|
218 |
no3=ADRESSE(tri->n3,noeud,mesh->);
|
219 |
MINI(bxmin,no1->x,no2->x);
|
220 |
MINI(bymin,no1->y,no2->y);
|
221 |
MINI(bzmin,no1->z,no2->z);
|
222 |
MAXI(bxmax,no1->x,no2->x);
|
223 |
MAXI(bymax,no1->y,no2->y);
|
224 |
MAXI(bzmax,no1->z,no2->z);
|
225 |
MINI(bxmin,bxmin,no3->x);
|
226 |
MINI(bymin,bymin,no3->y);
|
227 |
MINI(bzmin,bzmin,no3->z);
|
228 |
MAXI(bxmax,bxmax,no3->x);
|
229 |
MAXI(bymax,bymax,no3->y);
|
230 |
MAXI(bzmax,bzmax,no3->z);
|
231 |
}
|
232 |
if (type==FRONTIERE3D)
|
233 |
{
|
234 |
fr=ADRESSE(num,frontiere3d,mesh->);
|
235 |
entite=(void *)fr;
|
236 |
no1=fr->no1;
|
237 |
no2=fr->no2;
|
238 |
no3=fr->no3;
|
239 |
MINI(bxmin,no1->x,no2->x);
|
240 |
MINI(bymin,no1->y,no2->y);
|
241 |
MINI(bzmin,no1->z,no2->z);
|
242 |
MAXI(bxmax,no1->x,no2->x);
|
243 |
MAXI(bymax,no1->y,no2->y);
|
244 |
MAXI(bzmax,no1->z,no2->z);
|
245 |
MINI(bxmin,bxmin,no3->x);
|
246 |
MINI(bymin,bymin,no3->y);
|
247 |
MINI(bzmin,bzmin,no3->z);
|
248 |
MAXI(bxmax,bxmax,no3->x);
|
249 |
MAXI(bymax,bymax,no3->y);
|
250 |
MAXI(bzmax,bzmax,no3->z);
|
251 |
}
|
252 |
if (type==FRONT3D)
|
253 |
{
|
254 |
ft=ADRESSE(num,front3d,mesh->);
|
255 |
entite=(void *)ft;
|
256 |
no1=ADRESSE(ft->n1,noeud,mesh->);
|
257 |
no2=ADRESSE(ft->n2,noeud,mesh->);
|
258 |
no3=ADRESSE(ft->n3,noeud,mesh->);
|
259 |
MINI(bxmin,no1->x,no2->x);
|
260 |
MINI(bymin,no1->y,no2->y);
|
261 |
MINI(bzmin,no1->z,no2->z);
|
262 |
MAXI(bxmax,no1->x,no2->x);
|
263 |
MAXI(bymax,no1->y,no2->y);
|
264 |
MAXI(bzmax,no1->z,no2->z);
|
265 |
MINI(bxmin,bxmin,no3->x);
|
266 |
MINI(bymin,bymin,no3->y);
|
267 |
MINI(bzmin,bzmin,no3->z);
|
268 |
MAXI(bxmax,bxmax,no3->x);
|
269 |
MAXI(bymax,bymax,no3->y);
|
270 |
MAXI(bzmax,bzmax,no3->z);
|
271 |
}
|
272 |
if (type==TETRA)
|
273 |
{
|
274 |
tet=ADRESSE(num,tetra,mesh->);
|
275 |
entite=(void *)tet;
|
276 |
no1=ADRESSE(tet->n1,noeud,mesh->);
|
277 |
no2=ADRESSE(tet->n2,noeud,mesh->);
|
278 |
no3=ADRESSE(tet->n3,noeud,mesh->);
|
279 |
no4=ADRESSE(tet->n4,noeud,mesh->);
|
280 |
MINI(bxmin,no1->x,no2->x);
|
281 |
MINI(bymin,no1->y,no2->y);
|
282 |
MINI(bzmin,no1->z,no2->z);
|
283 |
MAXI(bxmax,no1->x,no2->x);
|
284 |
MAXI(bymax,no1->y,no2->y);
|
285 |
MAXI(bzmax,no1->z,no2->z);
|
286 |
MINI(bxmin,bxmin,no3->x);
|
287 |
MINI(bymin,bymin,no3->y);
|
288 |
MINI(bzmin,bzmin,no3->z);
|
289 |
MAXI(bxmax,bxmax,no3->x);
|
290 |
MAXI(bymax,bymax,no3->y);
|
291 |
MAXI(bzmax,bzmax,no3->z);
|
292 |
MINI(bxmin,bxmin,no4->x);
|
293 |
MINI(bymin,bymin,no4->y);
|
294 |
MINI(bzmin,bzmin,no4->z);
|
295 |
MAXI(bxmax,bxmax,no4->x);
|
296 |
MAXI(bymax,bymax,no4->y);
|
297 |
MAXI(bzmax,bzmax,no4->z);
|
298 |
}
|
299 |
|
300 |
if (type==MNOEUD)
|
301 |
{
|
302 |
mno=ADRESSE(num,mnoeud,maillage->);
|
303 |
entite=(void *)mno;
|
304 |
bxmin=mno->x;
|
305 |
bymin=mno->y;
|
306 |
bzmin=mno->z;
|
307 |
bxmax=mno->x;
|
308 |
bymax=mno->y;
|
309 |
bzmax=mno->z;
|
310 |
}
|
311 |
if (type==MSEGMENT)
|
312 |
{
|
313 |
mseg=ADRESSE(num,msegment,maillage->);
|
314 |
entite=(void *)mseg;
|
315 |
mno1=ADRESSE(mseg->n1,mnoeud,maillage->);
|
316 |
mno2=ADRESSE(mseg->n2,mnoeud,maillage->);
|
317 |
MINI(bxmin,mno1->x,mno2->x);
|
318 |
MINI(bymin,mno1->y,mno2->y);
|
319 |
MINI(bzmin,mno1->z,mno2->z);
|
320 |
MAXI(bxmax,mno1->x,mno2->x);
|
321 |
MAXI(bymax,mno1->y,mno2->y);
|
322 |
MAXI(bzmax,mno1->z,mno2->z);
|
323 |
}
|
324 |
if (type==MTRIANGLE)
|
325 |
{
|
326 |
mtri=ADRESSE(num,mtriangle,maillage->);
|
327 |
entite=(void *)mtri;
|
328 |
mno1=ADRESSE(mtri->n1,mnoeud,maillage->);
|
329 |
mno2=ADRESSE(mtri->n2,mnoeud,maillage->);
|
330 |
mno3=ADRESSE(mtri->n3,mnoeud,maillage->);
|
331 |
MINI(bxmin,mno1->x,mno2->x);
|
332 |
MINI(bymin,mno1->y,mno2->y);
|
333 |
MINI(bzmin,mno1->z,mno2->z);
|
334 |
MAXI(bxmax,mno1->x,mno2->x);
|
335 |
MAXI(bymax,mno1->y,mno2->y);
|
336 |
MAXI(bzmax,mno1->z,mno2->z);
|
337 |
MINI(bxmin,bxmin,mno3->x);
|
338 |
MINI(bymin,bymin,mno3->y);
|
339 |
MINI(bzmin,bzmin,mno3->z);
|
340 |
MAXI(bxmax,bxmax,mno3->x);
|
341 |
MAXI(bymax,bymax,mno3->y);
|
342 |
MAXI(bzmax,bzmax,mno3->z);
|
343 |
}
|
344 |
if (type==MTETRA)
|
345 |
{
|
346 |
mtet=ADRESSE(num,mtetra,maillage->);
|
347 |
entite=(void *)mtet;
|
348 |
mno1=ADRESSE(mtet->n1,mnoeud,maillage->);
|
349 |
mno2=ADRESSE(mtet->n2,mnoeud,maillage->);
|
350 |
mno3=ADRESSE(mtet->n3,mnoeud,maillage->);
|
351 |
mno4=ADRESSE(mtet->n4,mnoeud,maillage->);
|
352 |
MINI(bxmin,mno1->x,mno2->x);
|
353 |
MINI(bymin,mno1->y,mno2->y);
|
354 |
MINI(bzmin,mno1->z,mno2->z);
|
355 |
MAXI(bxmax,mno1->x,mno2->x);
|
356 |
MAXI(bymax,mno1->y,mno2->y);
|
357 |
MAXI(bzmax,mno1->z,mno2->z);
|
358 |
MINI(bxmin,bxmin,mno3->x);
|
359 |
MINI(bymin,bymin,mno3->y);
|
360 |
MINI(bzmin,bzmin,mno3->z);
|
361 |
MAXI(bxmax,bxmax,mno3->x);
|
362 |
MAXI(bymax,bymax,mno3->y);
|
363 |
MAXI(bzmax,bzmax,mno3->z);
|
364 |
MINI(bxmin,bxmin,mno4->x);
|
365 |
MINI(bymin,bymin,mno4->y);
|
366 |
MINI(bzmin,bzmin,mno4->z);
|
367 |
MAXI(bxmax,bxmax,mno4->x);
|
368 |
MAXI(bymax,bymax,mno4->y);
|
369 |
MAXI(bzmax,bzmax,mno4->z);
|
370 |
}
|
371 |
|
372 |
|
373 |
oc_place_boite(type,entite,bxmin,bymin,bzmin,bxmax,bymax,bzmax,octree);
|
374 |
|
375 |
|
376 |
}
|