00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031 #include <stdio.h>
00032 #include <fstream>
00033 #include <math.h>
00034
00036 #include "Noeuds.h"
00037 #include "Mesh.h"
00038 #include "Donnees.h"
00039
00040
00041
00042
00043
00044
00045
00049 void Ressort::SetLrepos()
00050 {
00051
00052 float var0, var1, var2, var3;
00053
00054
00055 Coord a = GetParticuleA()->GetPosition();
00056 Coord b = GetParticuleB()->GetPosition();
00057
00058 var1 = a.getX() - b.getX();
00059 var2 = a.getY() - b.getY();
00060 var3 = a.getZ() - b.getZ();
00061
00062 var0 = (var1 * var1) + (var2 * var2) + (var3 * var3);
00063
00064
00065 _Spring->_L0 = sqrt(var0);
00066
00067 }
00068
00069
00073 void Mesh::MakeFace(Particule *p1, Particule *p2, Particule *p3, Spring *R)
00074 {
00075
00076
00077 MakeEdge(p1, p2, R);
00078
00079
00080 MakeEdge(p2, p3, R);
00081
00082
00083 MakeEdge(p3, p1, R);
00084 }
00085
00086
00090 void Mesh::MakeEdge(Particule *p1, Particule *p2, Spring *R)
00091 {
00092
00093 bool exist = false;
00094
00095
00096 std::vector<Ressort *> ressortList = p1->GetRessortList();
00097
00098
00099 for(int i=0; i<ressortList.size(); ++i)
00100 {
00101
00102 if ( ((ressortList[i])->GetParticuleA() == p2) || ((ressortList[i])->GetParticuleB() == p2))
00103 {
00104
00105 exist = true;
00106
00107
00108 break;
00109 }
00110
00111 }
00112
00113
00114 if (!exist)
00115 {
00116
00117 Ressort *res = new Ressort(p1, p2, R);
00118
00119
00120 p1->AddRessort(res);
00121
00122
00123 p2->AddRessort(res);
00124
00125
00126 this->AddRessort(res);
00127 }
00128
00129 }
00130
00131
00135 void Mesh::AfficheMesh()
00136 {
00137 std::cout << " ____________________________________" << std::endl << std::endl;
00138
00139 Coord tmp;
00140
00141
00142 for(int i=0; i<_ParticuleList.size(); ++i)
00143 {
00144 std::cout << "Particule numero " << GetParticule(i)->GetId() << std::endl;
00145
00146
00147 tmp = GetParticule(i)->GetPosition();
00148 std::cout << "Position de la particule " << tmp.getX() << " " << tmp.getY() << " " << tmp.getZ() << std::endl;
00149
00150 std::cout << "Nombre de voisins de la particules " << GetParticule(i)->GetNbVoisins() << std::endl << std::endl;
00151 std::cout << "Voisins de la particule " << std::endl;
00152
00153
00154 std::vector<Ressort *> ListeRessort = GetParticule(i)->GetRessortList();
00155
00156
00157 for(int j=0; j<ListeRessort.size(); ++j)
00158 {
00159
00160 std::cout << " " << "Numero de la particule voisine " ;
00161
00162
00163 if ( (ListeRessort[j]->GetParticuleA())->GetId() == GetParticule(i)->GetId() )
00164 std::cout << (ListeRessort[j]->GetParticuleB())->GetId() << std::endl;
00165 else
00166 std::cout << (ListeRessort[j]->GetParticuleA())->GetId() << std::endl;
00167
00168
00169
00170 std::cout << " " << "Raideur du ressort " << ListeRessort[j]->GetRaideur() << std::endl;
00171 std::cout << " " << "Amortissement du ressort " << ListeRessort[j]->GetAmortissement() << std::endl;
00172 std::cout << " " << "Facteur d amortissement du ressort " << ListeRessort[j]->GetFactAmorti() << std::endl;
00173 std::cout << " " << "Longueur au repos " << ListeRessort[j]->GetLrepos() << std::endl << std::endl;
00174
00175 }
00176
00177
00178 std::cout << " ____________________________________" << std::endl << std::endl;
00179
00180 }
00181 }