40 #include <lifev/core/filter/ImporterMesh3D.hpp> 52 UInt& numberBoundaryVertices,
53 UInt& numberBoundaryFaces,
54 UInt& numberBoundaryEdges,
67 while ( nextGoodLine ( myStream, line ).good() )
69 if ( line.find (
"odes" ) != std::string::npos )
71 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
72 numberVertices = atoi ( node_s );
74 numberBoundaryVertices = 0;
76 for ( i = 0; i < numberVertices; i++ )
78 myStream >> x >> y >> z >> ity >> ibc;
86 numberBoundaryVertices++;
91 if ( line.find (
"iangular" ) != std::string::npos )
93 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
94 numberBoundaryFaces = atoi ( node_s );
97 for ( i = 0; i < numberBoundaryFaces; i++ )
100 myStream >> p1 >> p2 >> p3 >> ity >> ibc;
103 myStream >> p1 >> p2 >> p3 >> ity >> ity_id >> ibc;
108 if ( line.find (
"oundary" ) != std::string::npos )
110 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
111 numberBoundaryEdges = atoi ( node_s );
113 for ( i = 0; i < numberBoundaryEdges; i++ )
116 myStream >> p1 >> p2 >> ity >> ibc;
118 myStream >> p1 >> p2 >> ity >> ity_id >> ibc;
124 if ( line.find (
"etrahedral" ) != std::string::npos )
126 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
127 numberVolumes = atoi ( node_s );
140 nextIntINRIAMeshField ( std::string
const& line,
141 std::istream& myStream )
150 for ( std::string::const_iterator is = line.begin(); is != line.end(); ++is )
154 return atoi ( line );
168 readINRIAMeshFileHead ( std::ifstream& myStream,
169 UInt& numberVertices,
170 UInt& numberBoundaryVertices,
171 UInt& numberBoundaryFaces,
172 UInt& numberBoundaryEdges,
174 UInt& numberStoredFaces,
176 InternalEntitySelector iSelect )
178 const int idOffset = 1;
188 UInt p1, p2, p3, p4, p5, p6, p7, p8;
189 UInt numReadFaces = 0;
190 numberStoredFaces = 0;
193 std::vector<
bool> isboundary;
196 while ( nextGoodLine ( myStream, line ).good() )
198 if ( line.find (
"MeshVersionFormatted" ) != std::string::npos )
200 idummy = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"d" ) + 1 ), myStream );
201 ASSERT_PRE0 ( idummy == 1,
"I can read only formatted INRIA Mesh files, sorry" );
204 if ( line.find (
"Dimension" ) != std::string:: npos )
206 idummy = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"n" ) + 1 ), myStream );
207 ASSERT_PRE0 ( idummy == 3,
"I can read only 3D INRIA Mesh files, sorry" );
211 if ( line.find (
"Vertices" ) != std::string::npos )
213 numberVertices = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
215 numberBoundaryVertices = 0;
216 isboundary.resize ( numberVertices,
false );
218 for ( i = 0; i < numberVertices; ++i )
220 myStream >> x >> y >> z >> ibc;
221 if ( ! iSelect ( markerID_Type ( ibc ) ) )
223 numberBoundaryVertices++;
224 isboundary[ i ] =
true;
229 if ( line.find (
"Triangles" ) != std::string::npos )
231 ASSERT_PRE0 ( shape != HEXA,
" Cannot have triangular faces in an HEXA INRIA MESH" );
233 numReadFaces = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
234 numberBoundaryFaces = 0;
238 for ( UInt k = 0; k < numReadFaces; k++ )
240 myStream >> p1 >> p2 >> p3 >> ibc;
241 if ( isboundary[ p1 - idOffset ] && isboundary [ p2 - idOffset ] && isboundary[ p3 - idOffset ])
243 if ( iSelect ( markerID_Type ( ibc ) ) )
245 std::cerr <<
"ATTENTION: Face (1-based numbering) " 248 << p3 <<
" has all vertices on the boundary yet is marked as interior: " 251 ++numberBoundaryFaces;
255 if ( !iSelect ( markerID_Type ( ibc ) ) )
257 std::cerr <<
"ATTENTION: Face (1-based numbering) " 261 <<
" has vertices in the interior yet is marked as boundary: " 266 numberStoredFaces = numReadFaces;
270 if ( line.find (
"Quadrilaterals" ) != std::string::npos )
272 ASSERT_PRE0 ( shape != TETRA,
" Cannot have quad faces in an TETRA INRIA MESH" );
274 numReadFaces = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
276 numberBoundaryFaces = 0;
278 for ( UInt k = 0; k < numReadFaces; k++ )
280 myStream >> p1 >> p2 >> p3 >> p4 >> ibc;
281 if ( isboundary[ p1 - idOffset ] && isboundary[ p2 - idOffset ]
282 && isboundary[ p3 - idOffset ] && isboundary[ p4 - idOffset ] )
284 if ( iSelect ( markerID_Type ( ibc ) ) )
286 std::cerr <<
"ATTENTION: Face (1-based numbering) " 291 <<
" has all vertices on the boundary yet is marked as interior: " 294 ++numberBoundaryFaces;
298 numberStoredFaces = numReadFaces;
301 if ( line.find (
"Tetrahedra" ) != std::string::npos )
303 ASSERT_PRE0 ( shape != HEXA,
" Cannot have tetras in a HEXA INRIA MESH" );
305 numberVolumes = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"a" ) + 1 ), myStream );
308 for ( i = 0; i < numberVolumes; i++ )
310 myStream >> p1 >> p2 >> p3 >> p4 >> ibc;
314 if ( line.find (
"Hexahedra" ) != std::string::npos )
316 ASSERT_PRE0 ( shape != TETRA,
" Cannot have Hexahedra in a TETRA INRIA MESH" );
318 numberVolumes = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"a" ) + 1 ), myStream );
321 for ( i = 0; i < numberVolumes; i++ )
323 myStream >> p1 >> p2 >> p3 >> p4 >> p5 >> p6 >> p7 >> p8 >> ibc;
327 if ( line.find (
"Edges" ) != std::string::npos )
329 numberBoundaryEdges = nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
331 for ( i = 0; i < numberBoundaryEdges; i++ )
333 myStream >> p1 >> p2 >> ibc;
#define ASSERT_PRE0(X, A)
int32_type Int
Generic integer data.
double Real
Generic real data.
bool readMppFileHead(std::ifstream &myStream, UInt &numberVertices, UInt &numberBoundaryVertices, UInt &numberBoundaryFaces, UInt &numberBoundaryEdges, UInt &numberVolumes)
readMppFileHead - reads mesh++ Tetra meshes.
uint32_type UInt
generic unsigned integer (used mainly for addressing)