1 |
|
1 |
/*****************************************************************
|
2 |
|
|
|
3 |
|
|
m1d_dis.c Type:func
|
4 |
|
|
|
5 |
|
|
discretisation des edges
|
6 |
|
|
|
7 |
|
|
Date de creation : Fri Nov 29 15:23:59 1996
|
8 |
|
|
|
9 |
|
|
Derniere version : Tue Jun 3 13:26:21 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 <stdlib.h>
|
30 |
|
|
#include "const.h"
|
31 |
|
|
#include "struct.h"
|
32 |
|
|
#include "memoire.h"
|
33 |
|
|
#include "prototype.h"
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/**************************/
|
37 |
|
|
/* variables globales */
|
38 |
|
|
extern struct s_param *para;
|
39 |
|
|
extern struct environnement env;
|
40 |
|
|
extern struct s_acis *acis;
|
41 |
|
|
extern struct s_mesh *mesh;
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
/**************************/
|
46 |
|
|
/* programme principal */
|
47 |
|
|
|
48 |
|
|
void m1d_dis(void)
|
49 |
|
|
{
|
50 |
|
|
struct s_edge *edge;
|
51 |
|
|
struct s_straight *straight;
|
52 |
|
|
struct s_ellipse *ellipse;
|
53 |
|
|
struct s_segment *seg;
|
54 |
|
|
struct s_noeud *no,*no1,*no2;
|
55 |
|
|
int i,j,num;
|
56 |
|
|
float a,inf,dens,l,vec[4],coord[4];
|
57 |
|
|
float t,ti,tii,aprec,tprec,limit;
|
58 |
|
|
int n1,n2,n,noe,pointe;
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
for (i=0;i<acis->nb_edge;i++)
|
62 |
|
|
{
|
63 |
|
|
voir();
|
64 |
|
|
edge=ADRESSE(i,edge,acis->);
|
65 |
|
|
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
66 |
|
|
{
|
67 |
|
|
straight=(struct s_straight *)acis->entity[edge->curve];
|
68 |
|
|
memcpy(vec,straight->param->dir,3*sizeof(float));
|
69 |
|
|
NORME(vec);
|
70 |
|
|
l=vec[3]*edge->t2;
|
71 |
|
|
}
|
72 |
|
|
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
73 |
|
|
{
|
74 |
|
|
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
75 |
|
|
l=(ellipse->param->a+ellipse->param->b)/2*edge->t2;
|
76 |
|
|
}
|
77 |
|
|
num=(int)(edge->t2/PI*36)+1;
|
78 |
|
|
for (j=0;j<num+1;j++)
|
79 |
|
|
{
|
80 |
|
|
dens=eval_fdn1(edge,edge->t1+j*1./num*edge->t2);
|
81 |
|
|
if (j==0) inf=dens;
|
82 |
|
|
else if (dens<inf) inf=dens;
|
83 |
|
|
}
|
84 |
|
|
num=(int)(10*l/inf)+1;
|
85 |
|
|
a=0.;
|
86 |
|
|
for (j=0;j<num;j++)
|
87 |
|
|
{
|
88 |
|
|
voir();
|
89 |
|
|
ti=edge->t1+edge->t2*j/num;
|
90 |
|
|
tii=edge->t1+edge->t2*(j+1)/num;
|
91 |
|
|
t=0.7886751345*ti+0.2113248654*tii;
|
92 |
|
|
eval_edge(edge,t,DERIVE,coord);
|
93 |
|
|
a=a+(float)sqrt(coord[0]*coord[0]+coord[1]*coord[1]+coord[2]*coord[2])/eval_fdn1(edge,t);
|
94 |
|
|
t=0.7886751345*tii+0.2113248654*ti;
|
95 |
|
|
eval_edge(edge,t,DERIVE,coord);
|
96 |
|
|
a=a+(float)sqrt(coord[0]*coord[0]+coord[1]*coord[1]+coord[2]*coord[2])/eval_fdn1(edge,t);
|
97 |
|
|
}
|
98 |
|
|
a=a*edge->t2/num/2;
|
99 |
|
|
n=(int)floor((double)a);
|
100 |
|
|
if (a-floor((double)a)>0.5) n++;
|
101 |
|
|
if (n<1) n=1;
|
102 |
|
|
limit=a/(float)n;
|
103 |
|
|
j=0;
|
104 |
|
|
a=0.;
|
105 |
|
|
if (edge->sense==0) n1=edge->start_vertex->noeud->num;
|
106 |
|
|
else n1=edge->end_vertex->noeud->num;
|
107 |
|
|
for (noe=0;noe<n;noe++)
|
108 |
|
|
{
|
109 |
|
|
if (noe!=n-1)
|
110 |
|
|
{
|
111 |
|
|
while (a<limit)
|
112 |
|
|
{
|
113 |
|
|
voir();
|
114 |
|
|
aprec=a;
|
115 |
|
|
tprec=tii;
|
116 |
|
|
ti=edge->t1+edge->t2*j/num;
|
117 |
|
|
tii=edge->t1+edge->t2*(j+1)/num;
|
118 |
|
|
t=0.7886751345*ti+0.2113248654*tii;
|
119 |
|
|
eval_edge(edge,t,DERIVE,coord);
|
120 |
|
|
a=a+edge->t2/num/2*(float)sqrt(coord[0]*coord[0]+coord[1]*coord[1]+coord[2]*coord[2])/eval_fdn1(edge,t);
|
121 |
|
|
t=0.7886751345*tii+0.2113248654*ti;
|
122 |
|
|
eval_edge(edge,t,DERIVE,coord);
|
123 |
|
|
a=a+edge->t2/num/2*(float)sqrt(coord[0]*coord[0]+coord[1]*coord[1]+coord[2]*coord[2])/eval_fdn1(edge,t);
|
124 |
|
|
j++;
|
125 |
|
|
}
|
126 |
|
|
t=tprec+(tii-tprec)*(limit-aprec)/(a-aprec);
|
127 |
|
|
NEW_ENTITE(no,noeud,mesh->);
|
128 |
|
|
no->num=mesh->nb_noeud-1;
|
129 |
|
|
eval_edge(edge,t,FONCTION,coord);
|
130 |
|
|
no->x=coord[0];
|
131 |
|
|
no->y=coord[1];
|
132 |
|
|
no->z=coord[2];
|
133 |
|
|
no->dens=env.dens;
|
134 |
|
|
no->type=EDGE;
|
135 |
|
|
no->num_ent=edge->num;
|
136 |
|
|
no->pos=t;
|
137 |
|
|
n2=no->num;
|
138 |
|
|
}
|
139 |
|
|
else
|
140 |
|
|
if (edge->sense==0) n2=edge->end_vertex->noeud->num;
|
141 |
|
|
else n2=edge->start_vertex->noeud->num;
|
142 |
|
|
NEW_ENTITE(seg,segment,mesh->);
|
143 |
|
|
seg->num=mesh->nb_segment-1;
|
144 |
|
|
seg->n1=n1;
|
145 |
|
|
seg->n2=n2;
|
146 |
|
|
seg->type=EDGE;
|
147 |
|
|
seg->num_ent=edge->num;
|
148 |
|
|
no=ADRESSE(seg->n1,noeud,mesh->);
|
149 |
|
|
NEW_POINTEUR(pointe,segment,no->);
|
150 |
|
|
no->segment[pointe]=seg;
|
151 |
|
|
no=ADRESSE(seg->n2,noeud,mesh->);
|
152 |
|
|
NEW_POINTEUR(pointe,segment,no->);
|
153 |
|
|
no->segment[pointe]=seg;
|
154 |
|
|
NEW_POINTEUR(pointe,segment,edge->);
|
155 |
|
|
edge->segment[pointe]=seg;
|
156 |
|
|
n1=n2;
|
157 |
|
|
a=a-limit;
|
158 |
|
|
no1=ADRESSE(seg->n1,noeud,mesh->);
|
159 |
|
|
no2=ADRESSE(seg->n2,noeud,mesh->);
|
160 |
|
|
VEC(vec,no1,no2);
|
161 |
|
|
seg->longueur=(float)sqrt(PSCA(vec,vec));
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
}
|