1 |
/*****************************************************************
|
2 |
|
3 |
r3d_gene_noeud.c Type:Func
|
4 |
|
5 |
Regeneration d un noeud
|
6 |
|
7 |
Date de creation : Wed Jul 30 14:18:08 1997
|
8 |
|
9 |
Derniere version : Tue Aug 5 11:45:17 1997
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
Vincent FRANCOIS
|
16 |
|
17 |
*****************************************************************/
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
/**************************/
|
24 |
/* include */
|
25 |
#include <stdio.h>
|
26 |
#include <string.h>
|
27 |
#include <stdlib.h>
|
28 |
#include <math.h>
|
29 |
#include "const.h"
|
30 |
#include "memoire.h"
|
31 |
#include "struct.h"
|
32 |
#include "struct3d.h"
|
33 |
#include "prototype.h"
|
34 |
|
35 |
/**************************/
|
36 |
/* variables globales */
|
37 |
extern struct environnement env;
|
38 |
extern struct s_mesh *mesh;
|
39 |
extern struct s_maillage *maillage;
|
40 |
extern struct s_acis *acis;
|
41 |
|
42 |
|
43 |
|
44 |
/**************************/
|
45 |
/* programme principal */
|
46 |
|
47 |
int r3d_gene_noeud(struct s_mnoeud *mno,struct s_octree **liste,int nb_liste)
|
48 |
{
|
49 |
struct s_noeud *no;
|
50 |
struct s_octree *oct;
|
51 |
struct s_vertex *vertex;
|
52 |
struct s_edge *edge;
|
53 |
struct s_ellipse *ellipse;
|
54 |
struct s_straight *straight;
|
55 |
float tt,t[3],xtmp,ytmp,ztmp,vec[4];
|
56 |
int i;
|
57 |
|
58 |
if (mno->nv_num==(-1))
|
59 |
{
|
60 |
NEW_ENTITE(no,noeud,mesh->);
|
61 |
no->x=mno->x;
|
62 |
no->y=mno->y;
|
63 |
no->z=mno->z;
|
64 |
no->num=mesh->nb_noeud-1;
|
65 |
no->creation=RECUPERER;
|
66 |
mno->nv_num=no->num;
|
67 |
no->an_num=mno->num;
|
68 |
/* rattachement a la geometrie */
|
69 |
nb_liste=0;
|
70 |
oc_rechercher(no->x,no->y,no->z,0.,mesh->first,liste,&nb_liste);
|
71 |
oct=liste[0];
|
72 |
for (i=0;i<oct->nb_vertex;i++)
|
73 |
{
|
74 |
vertex=oct->vertex[i];
|
75 |
if (EGAL(no->x,vertex->point->coord[0],0.0001))
|
76 |
if (EGAL(no->y,vertex->point->coord[1],0.0001))
|
77 |
if (EGAL(no->z,vertex->point->coord[2],0.0001))
|
78 |
{
|
79 |
no->type=VERTEX;
|
80 |
no->num_ent=vertex->num;
|
81 |
vertex->noeud=no;
|
82 |
return(mno->nv_num);
|
83 |
}
|
84 |
}
|
85 |
for (i=0;i<oct->nb_edge;i++)
|
86 |
{
|
87 |
edge=oct->edge[i];
|
88 |
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
89 |
{
|
90 |
straight=(struct s_straight *)acis->entity[edge->curve];
|
91 |
t[0]=no->x-straight->param->root[0];
|
92 |
t[1]=no->y-straight->param->root[1];
|
93 |
t[2]=no->z-straight->param->root[2];
|
94 |
PVEC(vec,t,straight->param->dir);
|
95 |
NORME(vec);
|
96 |
if (EGAL(vec[3],0.,0.0001))
|
97 |
{
|
98 |
if (!(EGAL(straight->param->dir[0],0.0,0.0001))) tt=t[0]/straight->param->dir[0];
|
99 |
else if (!(EGAL(straight->param->dir[1],0.0,0.0001))) tt=t[1]/straight->param->dir[1];
|
100 |
else tt=t[2]/straight->param->dir[2];
|
101 |
if (((edge->t2>0.)&&(tt>edge->t1)&&(tt<edge->t2+edge->t1))
|
102 |
|| ((edge->t2<0.)&&(tt<edge->t1)&&(tt>edge->t2+edge->t1)))
|
103 |
{
|
104 |
no->pos=tt;
|
105 |
no->type=EDGE;
|
106 |
no->num_ent=edge->num;
|
107 |
return(mno->nv_num);
|
108 |
}
|
109 |
}
|
110 |
}
|
111 |
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
112 |
{
|
113 |
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
114 |
xtmp=ellipse->param->u[0]*(no->x-ellipse->param->centre[0])+ellipse->param->u[1]*(no->y-ellipse->param->centre[1])+ellipse->param->u[2]*(no->z-ellipse->param->centre[2]);
|
115 |
ytmp=ellipse->param->v[0]*(no->x-ellipse->param->centre[0])+ellipse->param->v[1]*(no->y-ellipse->param->centre[1])+ellipse->param->v[2]*(no->z-ellipse->param->centre[2]);
|
116 |
ztmp=ellipse->param->w[0]*(no->x-ellipse->param->centre[0])+ellipse->param->w[1]*(no->y-ellipse->param->centre[1])+ellipse->param->w[2]*(no->z-ellipse->param->centre[2]);
|
117 |
t[0]=xtmp/ellipse->param->a;
|
118 |
t[1]=ytmp/ellipse->param->b;
|
119 |
t[2]=t[0]*t[0]+t[1]*t[1];
|
120 |
if (EGAL(ztmp,0.0,0.0001))
|
121 |
if (EGAL(t[2],1.,0.0001))
|
122 |
{
|
123 |
if (t[0]<(-1.)) t[0]=(-1);
|
124 |
if (t[0]>1.) t[0]=1;
|
125 |
tt=(float)acos((double)t[0]);
|
126 |
if (t[1]<0.) tt=(-tt);
|
127 |
if (tt<0.) tt=tt+2*PI;
|
128 |
if (tt<edge->t1) tt=tt+2*PI;
|
129 |
if (tt<edge->t1+edge->t2)
|
130 |
{
|
131 |
no->pos=tt;
|
132 |
no->type=EDGE;
|
133 |
no->num_ent=edge->num;
|
134 |
return(mno->nv_num);
|
135 |
}
|
136 |
}
|
137 |
}
|
138 |
}
|
139 |
}
|
140 |
return(mno->nv_num);
|
141 |
}
|