ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/mailleur/src/mailleur3d_dia.cpp
Revision: 169
Committed: Fri Feb 13 23:04:14 2009 UTC (16 years, 3 months ago) by francois
Original Path: magic/lib/mailleur/mailleur/src/mailleur3d_dia.cpp
File size: 5812 byte(s)
Log Message:
Resolution de bug avec la version de gcc 4.3.2 --> mise la norme de c++

File Contents

# User Rev Content
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     // mailleur3d_dia.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 à 11H23
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     #include "gestionversion.h"
26    
27    
28     #pragma hdrstop
29     #include <fstream>
30 francois 169 #include <string.h>
31 5 #include "mailleur3d_dia.h"
32     #include "mg_maillage.h"
33     #include "tpl_map_entite.h"
34     #include "tpl_set.h"
35     //---------------------------------------------------------------------------
36    
37     #pragma package(smart_init)
38    
39     #include "diamesh.h"
40    
41     MAILLEUR3D_DIA::MAILLEUR3D_DIA(MG_MAILLAGE* mgmai,MG_GEOMETRIE *mggeo,MG_VOLUME* mgvol):MAILLEUR(),mgmaillage(mgmai),mggeometrie(mggeo),mgvolume(mgvol)
42     {
43     }
44    
45     MAILLEUR3D_DIA::~MAILLEUR3D_DIA()
46     {
47     }
48    
49     void MAILLEUR3D_DIA::maille(void)
50     {
51     if (mgvolume==NULL)
52     {
53     int nbvol=mggeometrie->get_nb_mg_volume();
54     for (int i=0;i<nbvol;i++)
55     {
56     MG_VOLUME* vol=mggeometrie->get_mg_volume(i);
57     maille(vol);
58     }
59     }
60     else maille(mgvolume);
61     }
62    
63     void MAILLEUR3D_DIA::maille(MG_VOLUME* volume)
64     {
65     TPL_MAP_ENTITE<MG_TRIANGLE*> lst_tri;
66     MG_VOLUME* vol=volume;
67     int nbcoquille=vol->get_nb_mg_coquille();
68     for (int j=0;j<nbcoquille;j++)
69     {
70     MG_COQUILLE* coquille=vol->get_mg_coquille(j);
71     int nbcoface=coquille->get_nb_mg_coface();
72     for (int k=0;k<nbcoface;k++)
73     {
74     MG_COFACE* coface=coquille->get_mg_coface(k);
75     MG_FACE* face=coface->get_face();
76     TPL_SET<MG_ELEMENT_MAILLAGE*> * lien_maillage = face->get_lien_maillage();
77     TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it;
78     MG_ELEMENT_MAILLAGE* element;
79     for (element = lien_maillage->get_premier(it); element; element = lien_maillage->get_suivant(it) )
80     {
81     MG_TRIANGLE* tri=(MG_TRIANGLE*)element;
82     if (mgmaillage->contient(tri)) lst_tri.ajouter(tri);
83     }
84     }
85     }
86     char* dir=getenv("TEMP");
87     char chaine[1000];
88     sprintf(chaine,"%s\\fichmaille_2D.mai",dir);
89     std::ofstream of(chaine,std::ios::out|std::ios::trunc);
90     of.precision(16);
91     of.setf(std::ios::showpoint);
92     of << mgmaillage->get_nb_mg_noeud() << " " << lst_tri.get_nb() << std::endl;
93     for (int i=0;i<mgmaillage->get_nb_mg_noeud();i++)
94     {
95     MG_NOEUD* noeud=mgmaillage->get_mg_noeud(i);
96     if (noeud->get_lien_topologie()->get_dimension()<=3)
97     {
98     of << (i+1) << " " << noeud->get_x() << " " << noeud->get_y() << " " << noeud->get_z() << " " ;
99     if (noeud->get_lien_topologie()->get_dimension()==0) of << "vertex ";
100     if (noeud->get_lien_topologie()->get_dimension()==1) of << "edge ";
101     if (noeud->get_lien_topologie()->get_dimension()==2) of << "face ";
102     if (noeud->get_lien_topologie()->get_dimension()==3) of << "body ";
103     of << noeud->get_lien_topologie()->get_id() << std::endl;
104     noeud->change_nouveau_numero(i+1);
105     }
106     }
107     for (int i=0;i<lst_tri.get_nb();i++)
108     {
109     MG_TRIANGLE* triangle=lst_tri.get(i);
110     if (triangle->get_lien_topologie()->get_dimension()<3)
111     {
112     of << "3 " << triangle->get_noeud1()->get_nouveau_numero() << " " << triangle->get_noeud2()->get_nouveau_numero() << " " << triangle->get_noeud3()->get_nouveau_numero() << " " ;
113     if (triangle->get_lien_topologie()->get_dimension()==0) of << "vertex ";
114     if (triangle->get_lien_topologie()->get_dimension()==1) of << "edge ";
115     if (triangle->get_lien_topologie()->get_dimension()==2) of << "face ";
116     if (triangle->get_lien_topologie()->get_dimension()==3) of << "body ";
117     of << triangle->get_lien_topologie()->get_id() << std::endl;
118     }
119     }
120     char arg[100][100];
121     strcpy(arg[0],"Diamesh");
122     strcpy(arg[1],"-file");
123     strcpy(arg[2],chaine);
124     diamesh(3,arg);
125     sprintf(chaine,"%s\\fichmaille_3D.mai",dir);
126     FILE *in=fopen(chaine,"rt");
127     char mess[1000];
128     fgets(mess,1000,in);
129     int nbnoeud,nbtet;
130     sscanf(mess,"%d %d",&nbnoeud,&nbtet);
131     int nb_mg_noeud=mgmaillage->get_nb_mg_noeud();
132     for (int i=0;i<nbnoeud;i++)
133     {
134     fgets(mess,1000,in);
135     if (i>nb_mg_noeud-1)
136     {
137     double x,y,z;
138     int num;
139     sscanf(mess,"%d %lf %lf %lf",&num,&x,&y,&z);
140 francois 35 mgmaillage->ajouter_mg_noeud(volume,x,y,z,MAILLEUR_AUTO);
141 5 }
142     }
143     for (int i=0;i<nbtet;i++)
144     {
145     fgets(mess,1000,in);
146     int num,n1,n2,n3,n4;
147     sscanf(mess,"%d %d %d %d %d",&num,&n1,&n2,&n3,&n4);
148     MG_NOEUD* no1=mgmaillage->get_mg_noeud(n1-1);
149     MG_NOEUD* no2=mgmaillage->get_mg_noeud(n2-1);
150     MG_NOEUD* no3=mgmaillage->get_mg_noeud(n3-1);
151     MG_NOEUD* no4=mgmaillage->get_mg_noeud(n4-1);
152 francois 35 mgmaillage->ajouter_mg_tetra(volume,no1,no2,no3,no4,MAILLEUR_AUTO);
153 5 }
154     }