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