1 |
|
1 |
/*****************************************************************
|
2 |
|
|
|
3 |
|
|
oc_enreg.c Type:Func
|
4 |
|
|
|
5 |
|
|
Enregistrement des caracteristiques de l abre octal
|
6 |
|
|
|
7 |
|
|
Date de creation : Thu Jul 3 11:45:15 1997
|
8 |
|
|
|
9 |
|
|
Derniere version : Thu Jul 10 09:58:13 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 <math.h>
|
29 |
|
|
#include "const.h"
|
30 |
|
|
#include "memoire.h"
|
31 |
|
|
#include "struct.h"
|
32 |
|
|
#include "prototype.h"
|
33 |
|
|
|
34 |
|
|
/**************************/
|
35 |
|
|
/* variables globales */
|
36 |
|
|
extern struct s_acis *acis;
|
37 |
|
|
extern struct environnement env;
|
38 |
|
|
extern struct s_mesh *mesh;
|
39 |
|
|
extern struct s_param *para;
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
/**************************/
|
44 |
|
|
/* programme principal */
|
45 |
|
|
|
46 |
|
|
void oc_enreg(void)
|
47 |
|
|
{
|
48 |
|
|
struct s_octree *oct;
|
49 |
|
|
struct s_vertex *vertex;
|
50 |
|
|
struct s_edge *edge;
|
51 |
|
|
struct s_face *face;
|
52 |
|
|
struct s_straight *straight;
|
53 |
|
|
struct s_ellipse *ellipse;
|
54 |
|
|
struct s_plane *plane;
|
55 |
|
|
struct s_cone *cone;
|
56 |
|
|
char mess[255];
|
57 |
|
|
FILE *out;
|
58 |
|
|
int i,j;
|
59 |
|
|
float dir[4],ox[4],oy[4];
|
60 |
|
|
float x1,x2,y1,y2,z1,z2,x[12],y[12],z[12];
|
61 |
|
|
int nint[6];
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
strcpy(mess,env.fich);
|
65 |
|
|
mess[strlen(mess)-4]=0;
|
66 |
|
|
strcat(mess,".oct");
|
67 |
|
|
out=fopen(mess,"wt");
|
68 |
|
|
fprintf(out,"***** Parametres generaux *****\n");
|
69 |
|
|
fprintf(out,"%f %f %d %d\n",env.epsilon,env.dens,env.relatif,mesh->nb_octree);
|
70 |
|
|
fprintf(out,"***** Definition de l arbre *****\n");
|
71 |
|
|
for (i=0;i<mesh->nb_octree;i++)
|
72 |
|
|
{
|
73 |
|
|
oct=ADRESSE(i,octree,mesh->);
|
74 |
|
|
fprintf(out,"+ %d %d",i,oct->feuille);
|
75 |
|
|
fprintf(out," %f %f %f %f\n",oct->x,oct->y,oct->z,oct->taille);
|
76 |
|
|
if (oct->feuille==0)
|
77 |
|
|
{
|
78 |
|
|
fprintf(out," %d",oct->fils[0]->num);
|
79 |
|
|
fprintf(out," %d",oct->fils[1]->num);
|
80 |
|
|
fprintf(out," %d",oct->fils[2]->num);
|
81 |
|
|
fprintf(out," %d",oct->fils[3]->num);
|
82 |
|
|
fprintf(out," %d",oct->fils[4]->num);
|
83 |
|
|
fprintf(out," %d",oct->fils[5]->num);
|
84 |
|
|
fprintf(out," %d",oct->fils[6]->num);
|
85 |
|
|
fprintf(out," %d\n",oct->fils[7]->num);
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
fprintf(out,"***** Caracteristiques des feuilles *****\n");
|
92 |
|
|
for (i=0;i<mesh->nb_octree;i++)
|
93 |
|
|
{
|
94 |
|
|
oct=ADRESSE(i,octree,mesh->);
|
95 |
|
|
if (oct->feuille==1)
|
96 |
|
|
{
|
97 |
|
|
x1=oct->x;
|
98 |
|
|
y1=oct->y;
|
99 |
|
|
z1=oct->z;
|
100 |
|
|
x2=oct->x+oct->taille;
|
101 |
|
|
y2=oct->y+oct->taille;
|
102 |
|
|
z2=oct->z+oct->taille;
|
103 |
|
|
fprintf(out,"+ %d %f %d %d %d\n",i,oct->dens,oct->nb_vertex,oct->nb_edge,oct->nb_face);
|
104 |
|
|
for (j=0;j<oct->nb_vertex;j++)
|
105 |
|
|
{
|
106 |
|
|
vertex=oct->vertex[j];
|
107 |
|
|
fprintf(out," POINT %d %f %f %f\n",vertex->num,vertex->point->coord[0],vertex->point->coord[1],vertex->point->coord[2]);
|
108 |
|
|
}
|
109 |
|
|
for (j=0;j<oct->nb_edge;j++)
|
110 |
|
|
{
|
111 |
|
|
edge=oct->edge[j];
|
112 |
|
|
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
113 |
|
|
{
|
114 |
|
|
straight=(struct s_straight *)acis->entity[edge->curve];
|
115 |
|
|
memcpy(dir,straight->param->dir,3*sizeof(float));
|
116 |
|
|
eval_vecteur(dir);
|
117 |
|
|
fprintf(out," STRAIGHT %d %f %f %f\n",edge->num,dir[0],dir[1],dir[2]);
|
118 |
|
|
fprintf(out," 2 %d %d\n",edge->owning_coedge->owning_loop->owning_face->num,edge->owning_coedge->partner_coedge->owning_loop->owning_face->num);
|
119 |
|
|
nint[0]=geo_int_stra_plane(edge,straight,x1,y1,z1,x2,y1,z1,x1,y2,z1,&x[0],&y[0],&z[0]);
|
120 |
|
|
nint[1]=geo_int_stra_plane(edge,straight,x2,y1,z1,x2,y1,z2,x2,y2,z1,&x[1],&y[1],&z[1]);
|
121 |
|
|
nint[2]=geo_int_stra_plane(edge,straight,x2,y1,z2,x1,y1,z2,x2,y2,z2,&x[2],&y[2],&z[2]);
|
122 |
|
|
nint[3]=geo_int_stra_plane(edge,straight,x1,y1,z2,x1,y1,z1,x1,y2,z2,&x[3],&y[3],&z[3]);
|
123 |
|
|
nint[4]=geo_int_stra_plane(edge,straight,x1,y2,z1,x2,y2,z1,x1,y2,z2,&x[4],&y[4],&z[4]);
|
124 |
|
|
nint[5]=geo_int_stra_plane(edge,straight,x1,y1,z1,x2,y1,z1,x1,y1,z2,&x[5],&y[5],&z[5]);
|
125 |
|
|
fprintf(out," %d %d %d %d %d %d\n",nint[0],nint[1],nint[2],nint[3],nint[4],nint[5]);
|
126 |
|
|
if (nint[0]==1) fprintf(out," %f %f %f\n",x[0],y[0],z[0]);
|
127 |
|
|
if (nint[1]==1) fprintf(out," %f %f %f\n",x[1],y[1],z[1]);
|
128 |
|
|
if (nint[2]==1) fprintf(out," %f %f %f\n",x[2],y[2],z[2]);
|
129 |
|
|
if (nint[3]==1) fprintf(out," %f %f %f\n",x[3],y[3],z[3]);
|
130 |
|
|
if (nint[4]==1) fprintf(out," %f %f %f\n",x[4],y[4],z[4]);
|
131 |
|
|
if (nint[5]==1) fprintf(out," %f %f %f\n",x[5],y[5],z[5]);
|
132 |
|
|
}
|
133 |
|
|
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
134 |
|
|
{
|
135 |
|
|
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
136 |
|
|
memcpy(ox,ellipse->param->u,3*sizeof(float));
|
137 |
|
|
memcpy(oy,ellipse->param->v,3*sizeof(float));
|
138 |
|
|
eval_vecteur(ox);
|
139 |
|
|
eval_vecteur(oy);
|
140 |
|
|
fprintf(out," ELLIPSE %d %f %f %f %f %f %f %f %f %f %f %f\n",edge->num,ellipse->param->centre[0],ellipse->param->centre[1],ellipse->param->centre[2],ellipse->param->a,ox[0],ox[1],ox[2],ellipse->param->b,oy[0],oy[1],oy[2]);
|
141 |
|
|
fprintf(out," 2 %d %d\n",edge->owning_coedge->owning_loop->owning_face->num,edge->owning_coedge->partner_coedge->owning_loop->owning_face->num);
|
142 |
|
|
nint[0]=geo_int_elli_plane(edge,ellipse,x1,y1,z1,x2,y1,z1,x1,y2,z1,&x[0],&y[0],&z[0]);
|
143 |
|
|
nint[1]=geo_int_elli_plane(edge,ellipse,x2,y1,z1,x2,y1,z2,x2,y2,z1,&x[2],&y[2],&z[2]);
|
144 |
|
|
nint[2]=geo_int_elli_plane(edge,ellipse,x2,y1,z2,x1,y1,z2,x2,y2,z2,&x[4],&y[4],&z[4]);
|
145 |
|
|
nint[3]=geo_int_elli_plane(edge,ellipse,x1,y1,z2,x1,y1,z1,x1,y2,z2,&x[6],&y[6],&z[6]);
|
146 |
|
|
nint[4]=geo_int_elli_plane(edge,ellipse,x1,y2,z1,x2,y2,z1,x1,y2,z2,&x[8],&y[8],&z[8]);
|
147 |
|
|
nint[5]=geo_int_elli_plane(edge,ellipse,x1,y1,z1,x2,y1,z1,x1,y1,z2,&x[10],&y[10],&z[10]);
|
148 |
|
|
fprintf(out," %d %d %d %d %d %d\n",nint[0],nint[1],nint[2],nint[3],nint[4],nint[5]);
|
149 |
|
|
if (nint[0]>0) fprintf(out," %f %f %f\n",x[0],y[0],z[0]);
|
150 |
|
|
if (nint[0]>1) fprintf(out," %f %f %f\n",x[1],y[1],z[1]);
|
151 |
|
|
if (nint[1]>0) fprintf(out," %f %f %f\n",x[2],y[2],z[2]);
|
152 |
|
|
if (nint[1]>1) fprintf(out," %f %f %f\n",x[3],y[3],z[3]);
|
153 |
|
|
if (nint[2]>0) fprintf(out," %f %f %f\n",x[4],y[4],z[4]);
|
154 |
|
|
if (nint[2]>1) fprintf(out," %f %f %f\n",x[5],y[5],z[5]);
|
155 |
|
|
if (nint[3]>0) fprintf(out," %f %f %f\n",x[6],y[6],z[6]);
|
156 |
|
|
if (nint[3]>1) fprintf(out," %f %f %f\n",x[7],y[7],z[7]);
|
157 |
|
|
if (nint[4]>0) fprintf(out," %f %f %f\n",x[8],y[8],z[8]);
|
158 |
|
|
if (nint[4]>1) fprintf(out," %f %f %f\n",x[9],y[9],z[9]);
|
159 |
|
|
if (nint[5]>0) fprintf(out," %f %f %f\n",x[10],y[10],z[10]);
|
160 |
|
|
if (nint[5]>1) fprintf(out," %f %f %f\n",x[11],y[11],z[11]);
|
161 |
|
|
}
|
162 |
|
|
}
|
163 |
|
|
for (j=0;j<oct->nb_face;j++)
|
164 |
|
|
{
|
165 |
|
|
face=oct->face[j];
|
166 |
|
|
if (strcmp(acis->type_entite[face->surface],"plane-surface")==0)
|
167 |
|
|
{
|
168 |
|
|
plane=(struct s_plane *)acis->entity[face->surface];
|
169 |
|
|
memcpy(dir,plane->normal,3*sizeof(float));
|
170 |
|
|
eval_vecteur(dir);
|
171 |
|
|
fprintf(out," PLANE %d %f %f %f %f %f %f\n",face->num,plane->root[0],plane->root[1],plane->root[2],dir[0],dir[1],dir[2]);
|
172 |
|
|
}
|
173 |
|
|
if (strcmp(acis->type_entite[face->surface],"cone-surface")==0)
|
174 |
|
|
{
|
175 |
|
|
cone=(struct s_cone *)acis->entity[face->surface];
|
176 |
|
|
memcpy(dir,cone->param->w,3*sizeof(float));
|
177 |
|
|
memcpy(ox,cone->param->u,3*sizeof(float));
|
178 |
|
|
memcpy(oy,cone->param->v,3*sizeof(float));
|
179 |
|
|
eval_vecteur(ox);
|
180 |
|
|
eval_vecteur(oy);
|
181 |
|
|
eval_vecteur(dir);
|
182 |
|
|
fprintf(out," CONE %d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n",face->num,cone->param->centre[0],cone->param->centre[1],cone->param->centre[2],cone->param->a,ox[0],ox[1],ox[2],cone->param->b,oy[0],oy[1],oy[2],dir[0],dir[1],dir[2],cone->param->tg);
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
}
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
fclose(out);
|
191 |
|
|
}
|