1 |
/*****************************************************************
|
2 |
|
3 |
acismesh.c Type:PP
|
4 |
|
5 |
maillage d'un solide ACIS
|
6 |
|
7 |
Date de creation : Mon Nov 25 17:03:26 1996
|
8 |
|
9 |
Derniere version : Wed Aug 6 11:36:03 1997
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
Vincent FRANCOIS
|
20 |
|
21 |
*****************************************************************/
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
/**************************/
|
28 |
/* include */
|
29 |
#include <stdio.h>
|
30 |
#include <string.h>
|
31 |
#include <math.h>
|
32 |
#include <stdlib.h>
|
33 |
#include "const.h"
|
34 |
#include "memoire.h"
|
35 |
#include "struct.h"
|
36 |
#include "prototype.h"
|
37 |
|
38 |
/**************************/
|
39 |
/* variables globales */
|
40 |
struct s_acis *acis;
|
41 |
struct environnement env;
|
42 |
struct s_mesh *mesh;
|
43 |
struct s_param *para;
|
44 |
struct s_maillage *maillage;
|
45 |
|
46 |
/**************************/
|
47 |
/* programme principal */
|
48 |
|
49 |
int acismesh(int argc,char argv[][100])
|
50 |
{
|
51 |
int i;
|
52 |
int batch=0;
|
53 |
struct s_face *face;
|
54 |
struct s_edge *edge;
|
55 |
struct s_noeud *noeud;
|
56 |
struct s_octree *octree;
|
57 |
struct s_vertex *vertex;
|
58 |
struct s_facette *facette;
|
59 |
struct s_mnoeud *mnoeud;
|
60 |
struct s_mfacette *mfacette;
|
61 |
struct s_mbodyette *mbodyette;
|
62 |
|
63 |
voir();
|
64 |
/* presentation */
|
65 |
aff_text("\n");
|
66 |
aff_text("\n");
|
67 |
aff_text("**********************\n");
|
68 |
aff_text("----------------------\n");
|
69 |
aff_text(" ACISMESH\n");
|
70 |
aff_text(" UQTR-ERIN 1996-97\n");
|
71 |
aff_text("----------------------\n");
|
72 |
aff_text("**********************\n");
|
73 |
aff_text("\n");
|
74 |
aff_text("\n");
|
75 |
/* recuperation des parametres de base */
|
76 |
env.dens=0.;
|
77 |
env.epsilon=0.05;
|
78 |
env.analyse=0;
|
79 |
env.opti=5;
|
80 |
env.opti2=0;
|
81 |
env.remesh=0;
|
82 |
env.zone=4;
|
83 |
env.geo=0;
|
84 |
i=0;
|
85 |
while (i<argc)
|
86 |
{
|
87 |
if (strcmp(argv[i],"-fich")==0) strcpy(env.fich,argv[i+1]);
|
88 |
if (strcmp(argv[i],"-mesh")==0)
|
89 |
{
|
90 |
strcpy(env.fich2,argv[i+1]);
|
91 |
env.remesh=1;
|
92 |
}
|
93 |
if (strcmp(argv[i],"-dens")==0) env.dens=(float)atof(argv[i+1]);
|
94 |
if (strcmp(argv[i],"-epsilon")==0) env.epsilon=(float)atof(argv[i+1]);
|
95 |
if (strcmp(argv[i],"-opti2d")==0) env.opti=(int)atoi(argv[i+1]);
|
96 |
if (strcmp(argv[i],"-opti3d")==0) env.opti2=1;
|
97 |
if (strcmp(argv[i],"-batch")==0) batch=1;
|
98 |
if (strcmp(argv[i],"-zone")==0) env.zone=(float)atof(argv[i+1]);
|
99 |
if (strcmp(argv[i],"-analyse")==0) env.analyse=1;
|
100 |
if (strcmp(argv[i],"-geo")==0)
|
101 |
{
|
102 |
env.geo=1;
|
103 |
batch=1;
|
104 |
}
|
105 |
i++;
|
106 |
}
|
107 |
if ((env.dens==0.)&&(env.remesh==0)&&(env.geo==0))
|
108 |
{
|
109 |
aff_text(MAIN_ERREUR);
|
110 |
goto fin;
|
111 |
}
|
112 |
if (env.epsilon<0.)
|
113 |
{
|
114 |
env.epsilon=(-env.epsilon);
|
115 |
env.relatif=1;
|
116 |
}
|
117 |
else env.relatif=0;
|
118 |
/* allocation de memoire pour acis*/
|
119 |
cal_cpu();
|
120 |
acis=(struct s_acis *)calloc(1,sizeof(struct s_acis));
|
121 |
NEW_ALLOC(body,acis->);
|
122 |
NEW_ALLOC(attrib,acis->);
|
123 |
NEW_ALLOC(lump,acis->);
|
124 |
NEW_ALLOC(shell,acis->);
|
125 |
NEW_ALLOC(face,acis->);
|
126 |
NEW_ALLOC(loop,acis->);
|
127 |
NEW_ALLOC(subshell,acis->);
|
128 |
NEW_ALLOC(wire,acis->);
|
129 |
NEW_ALLOC(coedge,acis->);
|
130 |
NEW_ALLOC(edge,acis->);
|
131 |
NEW_ALLOC(vertex,acis->);
|
132 |
NEW_ALLOC(cone,acis->);
|
133 |
NEW_ALLOC(ellipse,acis->);
|
134 |
NEW_ALLOC(pcurve,acis->);
|
135 |
NEW_ALLOC(plane,acis->);
|
136 |
NEW_ALLOC(point,acis->);
|
137 |
NEW_ALLOC(straight,acis->);
|
138 |
NEW_ALLOC(transform,acis->);
|
139 |
/* allocation pour parametrisation */
|
140 |
para=(struct s_param *)calloc(1,sizeof(struct s_param));
|
141 |
NEW_ALLOC(par_ellipse,para->);
|
142 |
NEW_ALLOC(par_straight,para->);
|
143 |
NEW_ALLOC(par_cone,para->);
|
144 |
NEW_ALLOC(par_plane,para->);
|
145 |
/* allocation structures de maillage */
|
146 |
mesh=(struct s_mesh *)calloc(1,sizeof(struct s_mesh));
|
147 |
NEW_ALLOC(noeud,mesh->);
|
148 |
NEW_ALLOC(segment,mesh->);
|
149 |
NEW_ALLOC(triangle,mesh->);
|
150 |
NEW_ALLOC(tetra,mesh->);
|
151 |
/* chargement du modele */
|
152 |
acis_charge();
|
153 |
if (env.remesh==0) /* maillage */
|
154 |
{
|
155 |
/* maillage des vertex */
|
156 |
m0d();
|
157 |
/* maillage des edges */
|
158 |
m1d();
|
159 |
/* enregistrement du maillage lineique */
|
160 |
if (env.geo==0)
|
161 |
{
|
162 |
m1d_enreg();
|
163 |
/* maillage des face */
|
164 |
m2d();
|
165 |
/* maillage du volume */
|
166 |
m3d();
|
167 |
/* resultat */
|
168 |
cal_cpu();
|
169 |
m2d_resultat(6);
|
170 |
m2d_resultat(10);
|
171 |
}
|
172 |
}
|
173 |
else /* remaillage */
|
174 |
{
|
175 |
maillage=(struct s_maillage *)calloc(1,sizeof(struct s_maillage));
|
176 |
NEW_ALLOC(mnoeud,maillage->);
|
177 |
NEW_ALLOC(msegment,maillage->);
|
178 |
NEW_ALLOC(mtriangle,maillage->);
|
179 |
NEW_ALLOC(mtetra,maillage->);
|
180 |
NEW_ALLOC(octree,mesh->);
|
181 |
NEW_ALLOC(mfacette,maillage->);
|
182 |
NEW_ALLOC(mbodyette,maillage->);
|
183 |
/* recuperation de l arbre */
|
184 |
r3d_c_octree();
|
185 |
/* comparaison des geometrie */
|
186 |
r3d_comp();
|
187 |
/* generation du maillage recupere */
|
188 |
r3d_gene();
|
189 |
LIBERE_LIEN(noeud,octree,mesh->);
|
190 |
LIBERE_LIEN(segment,octree,mesh->);
|
191 |
LIBERE_LIEN(triangle,octree,mesh->);
|
192 |
LIBERE_LIEN(tetra,octree,mesh->);
|
193 |
LIBERE_LIEN(vertex,octree,mesh->);
|
194 |
LIBERE_LIEN(face,octree,mesh->);
|
195 |
LIBERE_LIEN(edge,octree,mesh->);
|
196 |
LIBERE(octree,mesh->);
|
197 |
LIBERE_LIEN(triangle,facette,mesh->);
|
198 |
LIBERE(facette,mesh->);
|
199 |
LIBERE_LIEN(mtriangle,mfacette,maillage->);
|
200 |
LIBERE(mfacette,maillage->);
|
201 |
LIBERE_LIEN(mtetra,mbodyette,maillage->);
|
202 |
LIBERE(mbodyette,maillage->);
|
203 |
LIBERE_LIEN(mtriangle,mnoeud,maillage->);
|
204 |
LIBERE_LIEN(mtetra,mnoeud,maillage->);
|
205 |
LIBERE(mnoeud,maillage->);
|
206 |
LIBERE(msegment,maillage->);
|
207 |
LIBERE(mtriangle,maillage->);
|
208 |
LIBERE(mtetra,maillage->);
|
209 |
LIBERE_LIEN(mnoeud,octree,mesh->);
|
210 |
LIBERE_LIEN(msegment,octree,mesh->);
|
211 |
LIBERE_LIEN(mtriangle,octree,mesh->);
|
212 |
LIBERE_LIEN(mtetra,octree,mesh->);
|
213 |
free(maillage);
|
214 |
/*resultat */
|
215 |
cal_cpu();
|
216 |
m2d_resultat(6);
|
217 |
m2d_resultat(10);
|
218 |
}
|
219 |
/* liberation de memoire acis*/
|
220 |
LIBERE_LIEN(segment,edge,acis->);
|
221 |
LIBERE_LIEN(triangle,face,acis->);
|
222 |
LIBERE_LIEN(edge,vertex,acis->);
|
223 |
LIBERE(body,acis->);
|
224 |
LIBERE(attrib,acis->);
|
225 |
LIBERE(lump,acis->);
|
226 |
LIBERE(shell,acis->);
|
227 |
for (i=0;i<acis->nb_face;i++)
|
228 |
{
|
229 |
face=ADRESSE(i,face,acis->);
|
230 |
if (face->rap_face!=NULL) free(face->rap_face);
|
231 |
face->rap_face=NULL;
|
232 |
}
|
233 |
LIBERE(face,acis->);
|
234 |
LIBERE(loop,acis->);
|
235 |
LIBERE(subshell,acis->);
|
236 |
LIBERE(wire,acis->);
|
237 |
LIBERE(coedge,acis->);
|
238 |
for (i=0;i<acis->nb_edge;i++)
|
239 |
{
|
240 |
edge=ADRESSE(i,edge,acis->);
|
241 |
if (edge->dens_influ!=NULL) free(edge->dens_influ);
|
242 |
edge->dens_influ=NULL;
|
243 |
if (edge->rap_edge!=NULL) free(edge->rap_edge);
|
244 |
edge->rap_edge=NULL;
|
245 |
}
|
246 |
LIBERE(edge,acis->);
|
247 |
LIBERE(vertex,acis->);
|
248 |
LIBERE(cone,acis->);
|
249 |
LIBERE(ellipse,acis->);
|
250 |
LIBERE(pcurve,acis->);
|
251 |
LIBERE(plane,acis->);
|
252 |
LIBERE(point,acis->);
|
253 |
LIBERE(straight,acis->);
|
254 |
LIBERE(transform,acis->);
|
255 |
free(acis->entity);
|
256 |
for (i=0;i<acis->nb_entity;i++)
|
257 |
free(acis->type_entite[i]);
|
258 |
free(acis->type_entite);
|
259 |
free(acis);
|
260 |
/* liberation parametrisation */
|
261 |
LIBERE(par_ellipse,para->);
|
262 |
LIBERE(par_straight,para->);
|
263 |
LIBERE(par_cone,para->);
|
264 |
LIBERE(par_plane,para->);
|
265 |
free(para);
|
266 |
/* liberation maillage */
|
267 |
LIBERE_LIEN(segment,noeud,mesh->);
|
268 |
LIBERE_LIEN(triangle,noeud,mesh->);
|
269 |
LIBERE(noeud,mesh->);
|
270 |
LIBERE(segment,mesh->);
|
271 |
LIBERE(triangle,mesh->);
|
272 |
LIBERE(tetra,mesh->);
|
273 |
free(mesh);
|
274 |
fin:;
|
275 |
return(batch);
|
276 |
}
|