MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
CAD4FE_MCFile.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// CAD4FE_MCFile.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:56 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 
23 
24 #pragma hdrstop
25 
26 #include "gestionversion.h"
27 
28 #include "CAD4FE_MCFile.h"
29 
30 
31 #pragma package(smart_init)
32 
33 #include "mg_file.h"
34 #include "CAD4FE_MCFile.h"
35 #include "pars_argument.h"
36 #include "parse.h"
37 
38 #include "CAD4FE_MCEdge.h"
39 #include "CAD4FE_MCFace.h"
40 #include "CAD4FE_MCVertex.h"
41 #include "CAD4FE_PolySurface.h"
42 #include "CAD4FE_PolyCurve.h"
43 #include "CAD4FE_MCNode.h"
44 #include "CAD4FE_MCSegment.h"
45 #include "CAD4FE_MCTriangle.h"
46 #include "CAD4FE_m3d_MCTriangle.h"
47 
48 
49 
50 #pragma package(smart_init)
51 
52 using namespace CAD4FE;
53 
55 {
56 }
57 
58 MCFile::MCFile(char* chemin):MG_FILE(chemin)
59 {
60 FILE *in;
61 char ligne[3000];
62 in=fopen(chemin,"rt");
63 if (in!=NULL)
64 {
65 PARS_ARGUMENT param[100];
66 PARSE parse;
67 
68 MG_GEOMETRIE *mggeo;
69 MG_MAILLAGE *mgmai;
70 
71 
72 do
73  {
74  int ierr;
75  std::string ligne=parse.lire(in,';',&ierr);
76  parse.decode(ligne.c_str(),"@;",param);
77  const char *chaine=param[0].argument[0].c_str();
78  if ((chaine[0]=='/') && (chaine[1]=='/'))
79  {
80  if ((chaine[2]=='*')&&(chaine[3]=='i'))
81  {
82  unsigned long id;
83  sscanf(chaine,"//*i:%lu;",&id);
84  entiteidmax=id;
85  }
86  }
87  else if (param[0].argument[0]!="FIN")
88  {
89  parse.decode(ligne.c_str(),"%@=@(@);",param);
90  std::string entite=param[1].argument[0];
91  long id=atol(param[0].argument[0].c_str());
92  std::string data=param[2].argument[0] ;
93  MG_MAILLAGE *mgmai;
94  FEM_MAILLAGE *femmai;
95 
96  if (entite=="MAILLAGE")
97  {
98  parse.decode(data.c_str(),"@",param+2);
99  long idgeo=cid(param[2].argument[0]);
100  mggeo=get_mg_geometrieid(idgeo);
101  mgmai=get_mg_maillageid(id);
102  }
103  if (entite=="TETRAEDRE")
104  {
105  if (mgmai->get_mg_tetraid(id) != NULL) continue;
106  parse.decode(data.c_str(),"@,@,@,@,@",param+2);
107  long idtopo=cid(param[2].argument[0]);
108  long idn1=cid(param[3].argument[0]);
109  long idn2=cid(param[4].argument[0]);
110  long idn3=cid(param[5].argument[0]);
111  long idn4=cid(param[6].argument[0]);
112  MG_NOEUD* noeud1=mgmai->get_mg_noeudid(idn1);
113  MG_NOEUD* noeud2=mgmai->get_mg_noeudid(idn2);
114  MG_NOEUD* noeud3=mgmai->get_mg_noeudid(idn3);
115  MG_NOEUD* noeud4=mgmai->get_mg_noeudid(idn4);
117  if (idtopo>-1) topo=mggeo->get_mg_volumeid(idtopo);
118  else topo=NULL;
119  if (noeud1&&noeud2&&noeud3&&noeud4) mgmai->ajouter_mg_tetra(topo,noeud1,noeud2,noeud3,noeud4,id);
120  }
121  /*if (entite=="TRIANGLE")
122  {
123  if (mgmai->get_mg_triangleid(id) != NULL) continue;
124  parse.decode(data.c_str(),"@,@,@,@",param+2);
125  long idtopo=cid(param[2].argument[0]);
126  long idn1=cid(param[3].argument[0]);
127  long idn2=cid(param[4].argument[0]);
128  long idn3=cid(param[5].argument[0]);
129  MG_NOEUD* noeud1=mgmai->get_mg_noeudid(idn1);
130  MG_NOEUD* noeud2=mgmai->get_mg_noeudid(idn2);
131  MG_NOEUD* noeud3=mgmai->get_mg_noeudid(idn3);
132  MG_ELEMENT_TOPOLOGIQUE* topo;
133  if (idtopo>-1)
134  {
135  topo=mggeo->get_mg_faceid(idtopo);
136  if (topo==NULL) topo=mggeo->get_mg_volumeid(idtopo);
137  }
138  else topo=NULL;
139  if (noeud1&&noeud2&&noeud3)mgmai->ajouter_mg_triangle(topo,noeud1,noeud2,noeud3,id);
140  }
141  if (entite=="SEGMENT")
142  {
143  if (mgmai->get_mg_segmentid(id) != NULL) continue;
144  parse.decode(data.c_str(),"@,@,@",param+2);
145  long idtopo=cid(param[2].argument[0]);
146  long idn1=cid(param[3].argument[0]);
147  long idn2=cid(param[4].argument[0]);
148  MG_NOEUD* noeud1=mgmai->get_mg_noeudid(idn1);
149  MG_NOEUD* noeud2=mgmai->get_mg_noeudid(idn2);
150  MG_ELEMENT_TOPOLOGIQUE* topo;
151  if (idtopo>-1)
152  {
153  topo=mggeo->get_mg_areteid(idtopo);
154  if (topo==NULL) topo=mggeo->get_mg_faceid(idtopo);
155  if (topo==NULL) topo=mggeo->get_mg_volumeid(idtopo);
156  }
157  else topo=NULL;
158  MG_SEGMENT* seg=new MG_SEGMENT(id,topo,noeud1,noeud2);
159  if (noeud1&&noeud2) mgmai->ajouter_mg_segment(seg);
160  } */
161  if (entite=="CAD4FE_MCSEGMENT")
162  {
163  parse.decode(data.c_str(),"@,@,@",param+2);
164  long idtopo=cid(param[2].argument[0]);
165  long idn1=cid(param[3].argument[0]);
166  long idn2=cid(param[4].argument[0]);
167  MCNode* noeud1=(MCNode*)mgmai->get_mg_noeudid(idn1);
168  MCNode* noeud2=(MCNode*)mgmai->get_mg_noeudid(idn2);
170  if (idtopo>-1)
171  {
172  topo=mggeo->get_mg_areteid(idtopo);
173  if (topo==NULL) topo=mggeo->get_mg_faceid(idtopo);
174  if (topo==NULL) topo=mggeo->get_mg_volumeid(idtopo);
175  }
176  else topo=NULL;
177  MCSegment * seg = new MCSegment(id,topo,noeud1,noeud2);
178  mgmai->ajouter_mg_segment(seg);
179  }
180  if (entite=="CAD4FE_MCNODE")
181  {
182  parse.decode(data.c_str(),"@,@,@,@,@",param+2);
183  long idRefTopo=cid(param[2].argument[0]);
184  long idMCTopo=cid(param[3].argument[0]);
185  double x=atof(param[4].argument[0].c_str());
186  double y=atof(param[5].argument[0].c_str());
187  double z=atof(param[6].argument[0].c_str());
188  MG_ELEMENT_TOPOLOGIQUE* refTopo=NULL;
189  if (refTopo==NULL) refTopo=mggeo->get_mg_sommetid(idRefTopo);
190  if (refTopo==NULL) refTopo=mggeo->get_mg_areteid(idRefTopo);
191  if (refTopo==NULL) refTopo=mggeo->get_mg_faceid(idRefTopo);
192  if (refTopo==NULL) refTopo=mggeo->get_mg_volumeid(idRefTopo);
193  MG_ELEMENT_TOPOLOGIQUE* mcTopo=NULL;
194  if (mcTopo==NULL) mcTopo=mggeo->get_mg_sommetid(idMCTopo);
195  if (mcTopo==NULL) mcTopo=mggeo->get_mg_areteid(idMCTopo);
196  if (mcTopo==NULL) mcTopo=mggeo->get_mg_faceid(idMCTopo);
197  if (mcTopo==NULL) mcTopo=mggeo->get_mg_volumeid(idMCTopo);
198  MCNode* noeud=new MCNode(id,mcTopo,refTopo,x,y,z);
199  mgmai->ajouter_mg_noeud(noeud);
200  }
201  if (entite=="CAD4FE_MCTRIANGLE")
202  {
203  parse.decode(data.c_str(),"@,@,@,@",param+2);
204  long idtopo=cid(param[2].argument[0]);
205  long idn1=cid(param[3].argument[0]);
206  long idn2=cid(param[4].argument[0]);
207  long idn3=cid(param[5].argument[0]);
208  MCNode* noeud1=(MCNode*)mgmai->get_mg_noeudid(idn1);
209  MCNode* noeud2=(MCNode*)mgmai->get_mg_noeudid(idn2);
210  MCNode* noeud3=(MCNode*)mgmai->get_mg_noeudid(idn3);
211  MCSegment* mgsegment[3];
212  MCNode *mgnoeud[3]={noeud1,noeud2,noeud3};
213  // la topo. d'un MCTriangle est obligatoirement une MCFace
214  MCFace* mcFace=(MCFace*)mggeo->get_mg_faceid(idtopo);
215  for (int i=0;i<3;i++)
216  {
217  mgsegment[i]=(MCSegment*)mgmai->get_mg_segment(mgnoeud[i]->get_id(),mgnoeud[(i+1)%3]->get_id());
218  if (mgsegment[i]==NULL)
219  {
220  mgsegment[i]=new MCSegment(mcFace,mgnoeud[i],mgnoeud[(i+1)%3]);
221  mgmai->ajouter_mg_segment(mgsegment[i]);
222  }
223  }
224  M3D_MCTriangle *triangle = new M3D_MCTriangle(id,mcFace,noeud1,noeud2,noeud3,mgsegment[0],mgsegment[1],mgsegment[2]);
225  mgmai->ajouter_mg_triangle(triangle);
226  }
227 
228  }
229  }
230 while (param[0].argument[0]!="FIN");
231 
232 fclose(in);
233 
234 }
235 
236 }
237 
239 {
240 }
241 
242 
243 
244 
MG_MAILLAGE::ajouter_mg_tetra
MG_TETRA * ajouter_mg_tetra(MG_ELEMENT_TOPOLOGIQUE *topo, class MG_NOEUD *mgnoeud1, class MG_NOEUD *mgnoeud2, class MG_NOEUD *mgnoeud3, class MG_NOEUD *mgnoeud4, int origine, unsigned long num=0)
Definition: mg_maillage.cpp:1158
gestionversion.h
CAD4FE_MCFile.h
CAD4FE::MCFile::~MCFile
~MCFile()
Definition: CAD4FE_MCFile.cpp:238
MG_MAILLAGE::ajouter_mg_segment
MG_SEGMENT * ajouter_mg_segment(MG_ELEMENT_TOPOLOGIQUE *topo, class MG_NOEUD *mgnoeud1, class MG_NOEUD *mgnoeud2, int origine, double longue=0.0, unsigned long num=0)
Definition: mg_maillage.cpp:565
MG_GEOMETRIE::get_mg_areteid
MG_ARETE * get_mg_areteid(unsigned long num)
Definition: mg_geometrie.cpp:775
MG_IDENTIFICATEUR::get_id
unsigned long get_id()
Definition: mg_identificateur.cpp:53
MG_GESTIONNAIRE::entiteidmax
unsigned long entiteidmax
Definition: mg_gestionnaire.h:173
CAD4FE::MCSegment
Definition: CAD4FE_MCSegment.h:50
mg_file.h
CAD4FE_MCTriangle.h
parse.h
MG_ELEMENT_TOPOLOGIQUE
Definition: mg_element_topologique.h:51
MG_MAILLAGE::ajouter_mg_triangle
MG_TRIANGLE * ajouter_mg_triangle(MG_ELEMENT_TOPOLOGIQUE *topo, class MG_NOEUD *mgnoeud1, class MG_NOEUD *mgnoeud2, class MG_NOEUD *mgnoeud3, int origine, unsigned long num=0)
Definition: mg_maillage.cpp:731
FEM_MAILLAGE
Definition: fem_maillage.h:66
MG_GEOMETRIE::get_mg_volumeid
MG_VOLUME * get_mg_volumeid(unsigned long num)
Definition: mg_geometrie.cpp:1658
MG_NOEUD
Definition: mg_noeud.h:41
CAD4FE::M3D_MCTriangle
Definition: CAD4FE_m3d_MCTriangle.h:40
PARSE::decode
void decode(char *code, std::string masque, class PARS_ARGUMENT *arg)
Definition: parse.cpp:71
CAD4FE_MCVertex.h
CAD4FE_PolySurface.h
PARSE
Definition: parse.h:32
MG_FILE
Definition: mg_file.h:31
CAD4FE_MCSegment.h
CAD4FE_MCEdge.h
MG_MAILLAGE::get_mg_noeudid
MG_NOEUD * get_mg_noeudid(unsigned long num)
Definition: mg_maillage.cpp:451
MG_MAILLAGE::get_mg_segment
MG_SEGMENT * get_mg_segment(unsigned int num)
Definition: mg_maillage.cpp:619
CAD4FE_MCNode.h
PARS_ARGUMENT::argument
std::vector< std::string > argument
Definition: pars_argument.h:44
CAD4FE::MCFile::MCFile
MCFile()
Definition: CAD4FE_MCFile.cpp:54
CAD4FE_m3d_MCTriangle.h
CAD4FE_PolyCurve.h
PARS_ARGUMENT
Definition: pars_argument.h:37
MG_GESTIONNAIRE::get_mg_maillageid
MG_MAILLAGE * get_mg_maillageid(unsigned long num)
Definition: mg_gestionnaire.cpp:538
MG_GEOMETRIE::get_mg_faceid
MG_FACE * get_mg_faceid(unsigned long num)
Definition: mg_geometrie.cpp:1226
MG_GEOMETRIE
Definition: mg_geometrie.h:84
CAD4FE
Definition: CAD4FE_ClosestPoint_Segment_MG_ARETE.h:34
MG_MAILLAGE::get_mg_tetraid
MG_TETRA * get_mg_tetraid(unsigned long num)
Definition: mg_maillage.cpp:1201
MG_MAILLAGE
Definition: mg_maillage.h:62
CAD4FE::MCNode
Definition: CAD4FE_MCNode.h:47
pars_argument.h
CAD4FE::MCFace
Definition: CAD4FE_MCFace.h:50
CAD4FE_MCFace.h
PARSE::lire
std::string lire(FILE *in, char fin, int *ierr)
Definition: parse.cpp:50
MG_GEOMETRIE::get_mg_sommetid
MG_SOMMET * get_mg_sommetid(unsigned long num)
Definition: mg_geometrie.cpp:513
MG_GESTIONNAIRE::get_mg_geometrieid
MG_GEOMETRIE * get_mg_geometrieid(unsigned long num)
Definition: mg_gestionnaire.cpp:319
MG_FILE::cid
virtual long cid(std::string str)
Definition: mg_file.cpp:152
MG_MAILLAGE::ajouter_mg_noeud
MG_NOEUD * ajouter_mg_noeud(MG_ELEMENT_TOPOLOGIQUE *topo, double xx, double yy, double zz, int origine, unsigned long num=0)
Definition: mg_maillage.cpp:421