ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_segment.cpp
Revision: 308
Committed: Mon Jan 23 21:47:45 2012 UTC (13 years, 3 months ago) by francois
File size: 8816 byte(s)
Log Message:
Ajout des elements hexaedrique dans le maillage mg

File Contents

# User Rev Content
1 francois 283 //------------------------------------------------------------
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 francois 288 MG_SEGMENT::MG_SEGMENT(unsigned long num,MG_ELEMENT_TOPOLOGIQUE* topo,MG_NOEUD *mgnoeud1,MG_NOEUD *mgnoeud2,int origine,double longue):MG_ELEMENT_MAILLAGE(num,topo,origine),OT_REFERENCE(),noeud1(mgnoeud1),noeud2(mgnoeud2),longueur(longue),dimension(0)
34 francois 283 {
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);
40     else noeud2->get_lien_petit_segment()->ajouter(this);
41     noeud1->incrementer();
42     noeud2->incrementer();
43     if (liaison_topologique==NULL) return;
44     if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->ajouter(this);
45     }
46    
47 francois 288 MG_SEGMENT::MG_SEGMENT(MG_ELEMENT_TOPOLOGIQUE* topo,MG_NOEUD *mgnoeud1,MG_NOEUD *mgnoeud2,int origine,double longue):MG_ELEMENT_MAILLAGE(topo,origine),OT_REFERENCE(),noeud1(mgnoeud1),noeud2(mgnoeud2),longueur(longue),dimension(0)
48 francois 283 {
49     if (longueur==0.) calcule_longueur();
50     if (noeud1!=NULL) noeud1->get_lien_segment()->ajouter(this);
51     if (noeud2!=NULL) noeud2->get_lien_segment()->ajouter(this);
52     if ((noeud1!=NULL) && (noeud2!=NULL))
53     if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->ajouter(this);
54     else noeud2->get_lien_petit_segment()->ajouter(this);
55     noeud1->incrementer();
56     noeud2->incrementer();
57     if (liaison_topologique==NULL) return;
58     if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->ajouter(this);
59     }
60    
61 francois 288 MG_SEGMENT::MG_SEGMENT(MG_SEGMENT& mdd):MG_ELEMENT_MAILLAGE(mdd),OT_REFERENCE(),noeud1(mdd.noeud1),noeud2(mdd.noeud2),longueur(mdd.longueur),dimension(mdd.dimension)
62 francois 283 {
63     if (noeud1!=NULL) noeud1->get_lien_segment()->ajouter(this);
64     if (noeud2!=NULL) noeud2->get_lien_segment()->ajouter(this);
65     if ((noeud1!=NULL) && (noeud2!=NULL))
66     if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->ajouter(this);
67     else noeud2->get_lien_petit_segment()->ajouter(this);
68     noeud1->incrementer();
69     noeud2->incrementer();
70     if (liaison_topologique==NULL) return;
71     if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->ajouter(this);
72     }
73    
74    
75     MG_SEGMENT* MG_SEGMENT::dupliquer(MG_MAILLAGE *mgmai,long decalage)
76     {
77     MG_NOEUD* nd1=mgmai->get_mg_noeudid(noeud1->get_id()+decalage);
78     MG_NOEUD* nd2=mgmai->get_mg_noeudid(noeud2->get_id()+decalage);
79     if (nd1==NULL)
80     noeud1->get_id();
81     if (nd2==NULL)
82     noeud2->get_id();
83     MG_SEGMENT* seg=new MG_SEGMENT(this->get_id()+decalage,liaison_topologique,nd1,nd2,DUPLIQUER,longueur);
84     mgmai->ajouter_mg_segment(seg);
85     return seg;
86     }
87    
88    
89     MG_SEGMENT::~MG_SEGMENT()
90     {
91     if (noeud1!=NULL) noeud1->get_lien_segment()->supprimer(this);
92     if (noeud2!=NULL) noeud2->get_lien_segment()->supprimer(this);
93     if ((noeud1!=NULL) && (noeud2!=NULL))
94     if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->supprimer(this);
95     else noeud2->get_lien_petit_segment()->supprimer(this);
96     noeud1->decrementer();
97     noeud2->decrementer();
98     if (liaison_topologique==NULL) return;
99     if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_maillage()->supprimer(this);
100     }
101    
102    
103     int MG_SEGMENT::get_type_entite(void)
104     {
105     return IDMG_SEGMENT;
106     }
107    
108    
109     MG_NOEUD* MG_SEGMENT::get_noeud1(void)
110     {
111     return noeud1;
112     }
113    
114     MG_NOEUD* MG_SEGMENT::get_noeud2(void)
115     {
116     return noeud2;
117     }
118    
119     double MG_SEGMENT::get_longueur(void)
120     {
121     return longueur;
122     }
123    
124     void MG_SEGMENT::change_noeud1(MG_NOEUD* mgnoeud,double longue)
125     {
126     if (noeud1!=NULL) noeud1->get_lien_segment()->supprimer(this);
127     if (noeud1!=NULL)
128     if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->supprimer(this);
129     noeud1=mgnoeud;
130     longueur=longue;
131     if (longueur==0.) calcule_longueur();
132     if (noeud1!=NULL) noeud1->get_lien_segment()->ajouter(this);
133     if (noeud1!=NULL)
134     if (noeud1->get_id()<noeud2->get_id()) noeud1->get_lien_petit_segment()->ajouter(this);
135     }
136    
137    
138     void MG_SEGMENT::change_noeud2(MG_NOEUD* mgnoeud,double longue)
139     {
140     if (noeud2!=NULL) noeud2->get_lien_segment()->supprimer(this);
141     if (noeud2!=NULL)
142     if (noeud2->get_id()<noeud1->get_id()) noeud2->get_lien_petit_segment()->supprimer(this);
143     noeud2=mgnoeud;
144     longueur=longue;
145     if (longueur==0.) calcule_longueur();
146     if (noeud2!=NULL) noeud2->get_lien_segment()->ajouter(this);
147     if (noeud2!=NULL)
148     if (noeud2->get_id()<noeud1->get_id()) noeud2->get_lien_petit_segment()->ajouter(this);
149     }
150    
151    
152     void MG_SEGMENT::enregistrer(std::ostream& o)
153     {
154     if ((liaison_topologique==NULL) && (MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO!=1)) return;
155     if (liaison_topologique==NULL) o << "%" << get_id() << "=SEGMENT(NULL,$" << noeud1->get_id() << ",$" << noeud2->get_id() << "," << origine_creation << ");" << std::endl;
156     else if (liaison_topologique->get_dimension()==1) o << "%" << get_id() << "=SEGMENT($"<< get_lien_topologie()->get_id() << ",$" << noeud1->get_id() << ",$" << noeud2->get_id() << "," << origine_creation << ");" << std::endl;
157     }
158    
159     int MG_SEGMENT::get_dimension(void)
160     {
161     return 1;
162     }
163    
164    
165     void MG_SEGMENT::calcule_longueur(void)
166     {
167     double *coo1=noeud1->get_coord();
168     double *coo2=noeud2->get_coord();
169     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]));
170     }
171    
172     BOITE_2D MG_SEGMENT::get_boite_2D(double periodeu,double periodev)
173     {
174     OT_DECALAGE_PARAMETRE decalage(periodeu,periodev);
175     double coouv1[2];
176     double coouvd1[2];
177     double coouv2[2];
178     double coouvd2[2];
179    
180     coouv1[0]=noeud1->get_u();
181     coouv1[1]=noeud1->get_v();
182     coouv2[0]=noeud2->get_u();
183     coouv2[1]=noeud2->get_v();
184     double du=decalage.calcul_decalage_parametre_u(coouv1[0]);
185     double dv=decalage.calcul_decalage_parametre_v(coouv1[1]);
186     coouvd1[0]=decalage.decalage_parametre_u(coouv1[0],du);
187     coouvd1[1]=decalage.decalage_parametre_v(coouv1[1],dv);
188     coouvd2[0]=decalage.decalage_parametre_u(coouv2[0],du);
189     coouvd2[1]=decalage.decalage_parametre_v(coouv2[1],dv);
190     double umin,vmin,umax,vmax;
191     umin=std::min(coouvd1[0],coouvd2[0]);
192     umax=std::max(coouvd1[0],coouvd2[0]);
193     vmin=std::min(coouvd1[1],coouvd2[1]);
194     vmax=std::max(coouvd1[1],coouvd2[1]);
195     umin=umin-du;
196     umax=umax-du;
197     vmin=vmin-dv;
198     vmax=vmax-dv;
199     BOITE_2D boite(umin,vmin,umax,vmax);
200     return boite;
201     }
202    
203     BOITE_3D MG_SEGMENT::get_boite_3D(void)
204     {
205     double coo1[3];
206     double coo2[3];
207    
208     coo1[0]=noeud1->get_x();
209     coo1[1]=noeud1->get_y();
210     coo1[2]=noeud1->get_z();
211     coo2[0]=noeud2->get_x();
212     coo2[1]=noeud2->get_y();
213     coo2[2]=noeud2->get_z();
214     double xmin,ymin,zmin,xmax,ymax,zmax;
215     xmin=std::min(coo1[0],coo2[0]);
216     xmax=std::max(coo1[0],coo2[0]);
217     ymin=std::min(coo1[1],coo2[1]);
218     ymax=std::max(coo1[1],coo2[1]);
219     zmin=std::min(coo1[2],coo2[2]);
220     zmax=std::max(coo1[2],coo2[2]);
221     BOITE_3D boite(xmin,ymin,zmin,xmax,ymax,zmax);
222     return boite;
223     }
224    
225     void MG_SEGMENT::extrapoler_solution_noeud(void)
226     {
227     noeud1->change_solution(solution);
228     noeud2->change_solution(solution);
229     }
230    
231     TPL_LISTE_ENTITE<class MG_TRIANGLE*>* MG_SEGMENT::get_lien_triangle(void)
232     {
233     return &triangle;
234     }
235 francois 308 TPL_LISTE_ENTITE<class MG_QUADRANGLE*>* MG_SEGMENT::get_lien_quadrangle(void)
236     {
237     return &quadrangle;
238     }
239 francois 288 void MG_SEGMENT::change_dimension_topo_null(int num)
240     {
241     dimension=num;
242     }
243    
244     int MG_SEGMENT::get_dimension_topo_null(void)
245     {
246     return dimension;
247     }