ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/mailleur/src/mailleur3d_dia.cpp
Revision: 35
Committed: Thu Aug 16 21:24:14 2007 UTC (17 years, 9 months ago) by francois
Original Path: magic/lib/mailleur/mailleur/src/mailleur3d_dia.cpp
File size: 5791 byte(s)
Log Message:
Mailleur 3D + divers bugs + origine des elements de maillages

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