1 |
|
5 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuillière et Vincent FRANCOIS
|
5 |
|
|
// Département de Génie Mécanique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du département
|
8 |
|
|
// de génie mécanique de l'Université du Québec à
|
9 |
|
|
// Trois Rivières
|
10 |
|
|
// Les librairies ne peuvent être utilisées sans l'accord
|
11 |
|
|
// des auteurs (contact : francois@uqtr.ca)
|
12 |
|
|
//------------------------------------------------------------
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//
|
15 |
|
|
// mg_segment.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H22
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
#include <math.h>
|
27 |
|
|
#include "mg_segment.h"
|
28 |
|
|
#include "mg_sommet.h"
|
29 |
|
|
#include "ot_decalage_parametre.h"
|
30 |
|
|
#include "mg_maillage.h"
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
MG_SEGMENT::MG_SEGMENT(unsigned long num,MG_ELEMENT_TOPOLOGIQUE* topo,MG_NOEUD *mgnoeud1,MG_NOEUD *mgnoeud2,double longue):MG_ELEMENT_MAILLAGE(num,topo),OT_REFERENCE(),noeud1(mgnoeud1),noeud2(mgnoeud2),longueur(longue)
|
34 |
|
|
{
|
35 |
|
|
if (longueur==0.) calcule_longueur();
|
36 |
|
|
if (noeud1!=NULL) noeud1->get_lien_segment()->ajouter(this);
|
37 |
|
|
if (noeud2!=NULL) noeud2->get_lien_segment()->ajouter(this);
|
38 |
|
|
if ((noeud1!=NULL) && (noeud2!=NULL))
|
39 |
|
|
if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->ajouter(this); else noeud2->get_lien_petit_segment()->ajouter(this);
|
40 |
|
|
noeud1->incrementer();
|
41 |
|
|
noeud2->incrementer();
|
42 |
|
|
if (liaison_topologique==NULL) return;
|
43 |
|
|
if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->ajouter(this);
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
MG_SEGMENT::MG_SEGMENT(MG_ELEMENT_TOPOLOGIQUE* topo,MG_NOEUD *mgnoeud1,MG_NOEUD *mgnoeud2,double longue):MG_ELEMENT_MAILLAGE(topo),OT_REFERENCE(),noeud1(mgnoeud1),noeud2(mgnoeud2),longueur(longue)
|
47 |
|
|
{
|
48 |
|
|
if (longueur==0.) calcule_longueur();
|
49 |
|
|
if (noeud1!=NULL) noeud1->get_lien_segment()->ajouter(this);
|
50 |
|
|
if (noeud2!=NULL) noeud2->get_lien_segment()->ajouter(this);
|
51 |
|
|
if ((noeud1!=NULL) && (noeud2!=NULL))
|
52 |
|
|
if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->ajouter(this); else noeud2->get_lien_petit_segment()->ajouter(this);
|
53 |
|
|
noeud1->incrementer();
|
54 |
|
|
noeud2->incrementer();
|
55 |
|
|
if (liaison_topologique==NULL) return;
|
56 |
|
|
if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->ajouter(this);
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
MG_SEGMENT::MG_SEGMENT(MG_SEGMENT& mdd):MG_ELEMENT_MAILLAGE(mdd),OT_REFERENCE(),noeud1(mdd.noeud1),noeud2(mdd.noeud2),longueur(mdd.longueur)
|
60 |
|
|
{
|
61 |
|
|
if (noeud1!=NULL) noeud1->get_lien_segment()->ajouter(this);
|
62 |
|
|
if (noeud2!=NULL) noeud2->get_lien_segment()->ajouter(this);
|
63 |
|
|
if ((noeud1!=NULL) && (noeud2!=NULL))
|
64 |
|
|
if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->ajouter(this); else noeud2->get_lien_petit_segment()->ajouter(this);
|
65 |
|
|
noeud1->incrementer();
|
66 |
|
|
noeud2->incrementer();
|
67 |
|
|
if (liaison_topologique==NULL) return;
|
68 |
|
|
if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->ajouter(this);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
MG_SEGMENT* MG_SEGMENT::dupliquer(MG_MAILLAGE *mgmai,long decalage)
|
73 |
|
|
{
|
74 |
|
|
MG_NOEUD* nd1=mgmai->get_mg_noeudid(noeud1->get_id()+decalage);
|
75 |
|
|
MG_NOEUD* nd2=mgmai->get_mg_noeudid(noeud2->get_id()+decalage);
|
76 |
|
|
if (nd1==NULL)
|
77 |
|
|
noeud1->get_id();
|
78 |
|
|
if (nd2==NULL)
|
79 |
|
|
noeud2->get_id();
|
80 |
|
|
MG_SEGMENT* seg=new MG_SEGMENT(this->get_id()+decalage,liaison_topologique,nd1,nd2,longueur);
|
81 |
|
|
mgmai->ajouter_mg_segment(seg);
|
82 |
|
|
return seg;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
MG_SEGMENT::~MG_SEGMENT()
|
87 |
|
|
{
|
88 |
|
|
if (noeud1!=NULL) noeud1->get_lien_segment()->supprimer(this);
|
89 |
|
|
if (noeud2!=NULL) noeud2->get_lien_segment()->supprimer(this);
|
90 |
|
|
if ((noeud1!=NULL) && (noeud2!=NULL))
|
91 |
|
|
if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->supprimer(this); else noeud2->get_lien_petit_segment()->supprimer(this);
|
92 |
|
|
noeud1->decrementer();
|
93 |
|
|
noeud2->decrementer();
|
94 |
|
|
if (liaison_topologique==NULL) return;
|
95 |
|
|
if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->supprimer(this);
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
int MG_SEGMENT::get_type_entite(void)
|
100 |
|
|
{
|
101 |
|
|
return IDMG_SEGMENT;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
MG_NOEUD* MG_SEGMENT::get_noeud1(void)
|
106 |
|
|
{
|
107 |
|
|
return noeud1;
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
MG_NOEUD* MG_SEGMENT::get_noeud2(void)
|
111 |
|
|
{
|
112 |
|
|
return noeud2;
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
double MG_SEGMENT::get_longueur(void)
|
116 |
|
|
{
|
117 |
|
|
return longueur;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
void MG_SEGMENT::change_noeud1(MG_NOEUD* mgnoeud,double longue)
|
121 |
|
|
{
|
122 |
|
|
if (noeud1!=NULL) noeud1->get_lien_segment()->supprimer(this);
|
123 |
|
|
if (noeud1!=NULL)
|
124 |
|
|
if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->supprimer(this);
|
125 |
|
|
noeud1=mgnoeud;
|
126 |
|
|
longueur=longue;
|
127 |
|
|
if (longueur==0.) calcule_longueur();
|
128 |
|
|
if (noeud1!=NULL) noeud1->get_lien_segment()->ajouter(this);
|
129 |
|
|
if (noeud1!=NULL)
|
130 |
|
|
if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->ajouter(this);
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
void MG_SEGMENT::change_noeud2(MG_NOEUD* mgnoeud,double longue)
|
135 |
|
|
{
|
136 |
|
|
if (noeud2!=NULL) noeud2->get_lien_segment()->supprimer(this);
|
137 |
|
|
if (noeud2!=NULL)
|
138 |
|
|
if (noeud2->get_id()<noeud1->get_id()) noeud2->get_lien_petit_segment()->supprimer(this);
|
139 |
|
|
noeud2=mgnoeud;
|
140 |
|
|
longueur=longue;
|
141 |
|
|
if (longueur==0.) calcule_longueur();
|
142 |
|
|
if (noeud2!=NULL) noeud2->get_lien_segment()->ajouter(this);
|
143 |
|
|
if (noeud2!=NULL)
|
144 |
|
|
if (noeud2->get_id()<noeud1->get_id()) noeud2->get_lien_petit_segment()->ajouter(this);
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
void MG_SEGMENT::enregistrer(std::ostream& o)
|
149 |
|
|
{
|
150 |
|
|
if (liaison_topologique==NULL) return;
|
151 |
|
|
if (liaison_topologique->get_dimension()==1) o << "%" << get_id() << "=SEGMENT($"<< get_lien_topologie()->get_id() << ",$" << noeud1->get_id() << ",$" << noeud2->get_id() << ");" << std::endl;
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
int MG_SEGMENT::get_dimension(void)
|
155 |
|
|
{
|
156 |
|
|
return 1;
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
void MG_SEGMENT::calcule_longueur(void)
|
161 |
|
|
{
|
162 |
|
|
double *coo1=noeud1->get_coord();
|
163 |
|
|
double *coo2=noeud2->get_coord();
|
164 |
|
|
longueur=sqrt( (coo1[0]-coo2[0])*(coo1[0]-coo2[0])+(coo1[1]-coo2[1])*(coo1[1]-coo2[1])+(coo1[2]-coo2[2])*(coo1[2]-coo2[2]));
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
BOITE_2D MG_SEGMENT::get_boite_2D(double periodeu,double periodev)
|
168 |
|
|
{
|
169 |
|
|
OT_DECALAGE_PARAMETRE decalage(periodeu,periodev);
|
170 |
|
|
double coouv1[2];
|
171 |
|
|
double coouvd1[2];
|
172 |
|
|
double coouv2[2];
|
173 |
|
|
double coouvd2[2];
|
174 |
|
|
|
175 |
|
|
coouv1[0]=noeud1->get_u();
|
176 |
|
|
coouv1[1]=noeud1->get_v();
|
177 |
|
|
coouv2[0]=noeud2->get_u();
|
178 |
|
|
coouv2[1]=noeud2->get_v();
|
179 |
|
|
double du=decalage.calcul_decalage_parametre_u(coouv1[0]);
|
180 |
|
|
double dv=decalage.calcul_decalage_parametre_v(coouv1[1]);
|
181 |
|
|
coouvd1[0]=decalage.decalage_parametre_u(coouv1[0],du);
|
182 |
|
|
coouvd1[1]=decalage.decalage_parametre_v(coouv1[1],dv);
|
183 |
|
|
coouvd2[0]=decalage.decalage_parametre_u(coouv2[0],du);
|
184 |
|
|
coouvd2[1]=decalage.decalage_parametre_v(coouv2[1],dv);
|
185 |
|
|
double umin,vmin,umax,vmax;
|
186 |
|
|
umin=std::min(coouvd1[0],coouvd2[0]);
|
187 |
|
|
umax=std::max(coouvd1[0],coouvd2[0]);
|
188 |
|
|
vmin=std::min(coouvd1[1],coouvd2[1]);
|
189 |
|
|
vmax=std::max(coouvd1[1],coouvd2[1]);
|
190 |
|
|
umin=umin-du;
|
191 |
|
|
umax=umax-du;
|
192 |
|
|
vmin=vmin-dv;
|
193 |
|
|
vmax=vmax-dv;
|
194 |
|
|
BOITE_2D boite(umin,vmin,umax,vmax);
|
195 |
|
|
return boite;
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
BOITE_3D MG_SEGMENT::get_boite_3D(void)
|
199 |
|
|
{
|
200 |
|
|
double coo1[3];
|
201 |
|
|
double coo2[3];
|
202 |
|
|
|
203 |
|
|
coo1[0]=noeud1->get_x();
|
204 |
|
|
coo1[1]=noeud1->get_y();
|
205 |
|
|
coo1[2]=noeud1->get_z();
|
206 |
|
|
coo2[0]=noeud2->get_x();
|
207 |
|
|
coo2[1]=noeud2->get_y();
|
208 |
|
|
coo2[2]=noeud2->get_z();
|
209 |
|
|
double xmin,ymin,zmin,xmax,ymax,zmax;
|
210 |
|
|
xmin=std::min(coo1[0],coo2[0]);
|
211 |
|
|
xmax=std::max(coo1[0],coo2[0]);
|
212 |
|
|
ymin=std::min(coo1[1],coo2[1]);
|
213 |
|
|
ymax=std::max(coo1[1],coo2[1]);
|
214 |
|
|
zmin=std::min(coo1[2],coo2[2]);
|
215 |
|
|
zmax=std::max(coo1[2],coo2[2]);
|
216 |
|
|
BOITE_3D boite(xmin,ymin,zmin,xmax,ymax,zmax);
|
217 |
|
|
return boite;
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
TPL_LISTE_ENTITE<class MG_TRIANGLE*>* MG_SEGMENT::get_lien_triangle(void)
|
222 |
|
|
{
|
223 |
|
|
return ▵
|
224 |
|
|
}
|