MEDCoupling::DataArrayDouble* coordArray = MEDCoupling::DataArrayDouble::New();
setNodes(coordArray);
-
int nbEdges = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfEdges);
- int nbTria = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfTriangles);
int nbQuad = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfQuadrilaterals);
- int nbTet = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfTetrahedra );
- int nbPyr = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfPyramids);
- int nbHex = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfHexahedra);
int nbPrism = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfPrisms);
-
+ _nbTria = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfTriangles);
+ _nbTet = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfTetrahedra );
+ _nbPyr = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfPyramids);
+ _nbHex = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfHexahedra);
+
_dim1NbEl = nbEdges;
- _dim2NbEl = nbTria + nbQuad;
- _dim3NbEl = nbTet + nbPyr + nbHex + nbPrism;
+ _dim2NbEl = _nbTria + nbQuad;
+ _dim3NbEl = _nbTet + _nbPyr + _nbHex + nbPrism;
bool okdim1 = (nbEdges > 0), okdim2= (_dim2NbEl > 0), okdim3= (_dim3NbEl > 0);
MEDCoupling::MEDCouplingUMesh* dimMesh1;
}
/* Read triangles */
- if (nbTria)
+
+ if (_nbTria)
{
- setTriangles(dimMesh2, nbTria);
+ setTriangles(dimMesh2);
}
+
/* Read quadrangles */
if (nbQuad)
{
dimMesh2->decrRef();
}
/* Read terahedra */
- if ( nbTet )
+ if ( _nbTet )
{
- setTetrahedras( dimMesh3, nbTet);
+ setTetrahedras( dimMesh3);
}
/* Read pyramids */
- if ( nbPyr )
+ if ( _nbPyr )
{
- setPyramids( dimMesh3, nbPyr);
+ setPyramids( dimMesh3);
}
/* Read hexahedra */
- if ( nbHex )
+ if ( _nbHex )
{
- setHexahedras(dimMesh3, nbHex);
+ setHexahedras(dimMesh3);
}
/* Read prism */
_uMesh->setMeshAtLevel( 1 - _dim, dimMesh1 );
}
-void MeshFormatReader::setTriangles(MEDCoupling::MEDCouplingUMesh* dimMesh2, int nbTria)
+void MeshFormatReader::setTriangles(MEDCoupling::MEDCouplingUMesh* dimMesh2)
{
int iN[28]; // 28 - nb nodes in HEX27 (+ 1 for safety :)
int ref;
// read extra vertices for quadratic triangles
- std::vector< std::vector<int> > quadNodesAtTriangles( nbTria + 1 );
+ std::vector< std::vector<int> > quadNodesAtTriangles( _nbTria + 1 );
if ( int nbQuadTria = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtTriangles ))
{
_reader.GmfGotoKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtTriangles );
_reader.GmfGetLin(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtTriangles,
&iN[0], &iN[1], &iN[2], &iN[3], &iN[4],
&iN[5]); // iN[5] - preview TRIA7
- if ( iN[0] <= nbTria )
+ if ( iN[0] <= _nbTria )
{
std::vector<int>& nodes = quadNodesAtTriangles[ iN[0] ];
nodes.insert( nodes.end(), & iN[2], & iN[5+1] );
}
}
}
-
// create triangles
_reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfTriangles);
- for ( int i = 1; i <= nbTria; ++i )
+ for ( int i = 1; i <= _nbTria; ++i )
{
_reader.GmfGetLin(_myCurrentFileId, MeshFormat::GmfTriangles, &iN[0], &iN[1], &iN[2], &ref);
std::vector<int>& midN = quadNodesAtTriangles[ i ];
if ( !midN.empty() ) MeshFormat::FreeVector( midN );
}
-
}
void MeshFormatReader::setQuadrangles( MEDCoupling::MEDCouplingUMesh* dimMesh2, int nbQuad)
}
// create quadrangles
_reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfQuadrilaterals);
- for ( int i = 1; i <= nbQuad; ++i )
+ for ( int i = 1 ; i <= nbQuad; ++i )
{
_reader.GmfGetLin(_myCurrentFileId, MeshFormat::GmfQuadrilaterals, &iN[0], &iN[1], &iN[2], &iN[3], &ref);
std::vector<int>& midN = quadNodesAtQuadrilaterals[ i ];
};
backward_shift(nodalConnPerCell, 8);
dimMesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8, nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1);
+ MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1+_nbTria);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 2 -_dim);
}
else if ( midN.size() > 8-4 ) // QUAD9
};
backward_shift(nodalConnPerCell, 9);
dimMesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD9,9, nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1);
+ MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1+_nbTria);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 2 -_dim);
}
else // QUAD4
mcIdType nodalConnPerCell[4] = {iN[0], iN[1], iN[2], iN[3]};
backward_shift(nodalConnPerCell, 4);
dimMesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4, 4, nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1);
+ MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1+_nbTria);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 2 -_dim);
}
if ( !midN.empty() ) MeshFormat::FreeVector( midN );
}
-void MeshFormatReader::setTetrahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, int nbTet)
+void MeshFormatReader::setTetrahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3)
{
int iN[28]; // 28 - nb nodes in HEX27 (+ 1 for safety :)
int ref;
// read extra vertices for quadratic tetrahedra
- std::vector< std::vector<int> > quadNodesAtTetrahedra( nbTet + 1 );
+ std::vector< std::vector<int> > quadNodesAtTetrahedra( _nbTet + 1 );
if ( int nbQuadTetra = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtTetrahedra ))
{
_reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtTetrahedra);
{
_reader.GmfGetLin(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtTetrahedra,
&iN[0], &iN[1], &iN[2], &iN[3], &iN[4], &iN[5], &iN[6], &iN[7]);
- if ( iN[0] <= nbTet )
+ if ( iN[0] <= _nbTet )
{
std::vector<int>& nodes = quadNodesAtTetrahedra[ iN[0] ];
nodes.insert( nodes.end(), & iN[2], & iN[7+1] );
}
// create tetrahedra
_reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfTetrahedra);
- for ( int i = 1; i <= nbTet; ++i )
+ for ( int i = 1; i <= _nbTet; ++i )
{
_reader.GmfGetLin(_myCurrentFileId, MeshFormat::GmfTetrahedra, &iN[0], &iN[1], &iN[2], &iN[3], &ref);
std::vector<int>& midN = quadNodesAtTetrahedra[ i ];
}
-void MeshFormatReader::setPyramids( MEDCoupling::MEDCouplingUMesh* dimMesh3, int nbPyr)
+void MeshFormatReader::setPyramids( MEDCoupling::MEDCouplingUMesh* dimMesh3)
{
int iN[28]; // 28 - nb nodes in HEX27 (+ 1 for safety :)
int ref;
_reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfPyramids);
- for ( int i = 1; i <= nbPyr; ++i )
+ for ( int i = 1; i <= _nbPyr; ++i )
{
_reader.GmfGetLin(_myCurrentFileId, MeshFormat::GmfPyramids, &iN[0], &iN[1], &iN[2], &iN[3], &iN[4], &ref);
mcIdType nodalConnPerCell[5] = {iN[3], iN[2], iN[1], iN[0], iN[4]};
backward_shift(nodalConnPerCell, 5);
dimMesh3->insertNextCell(INTERP_KERNEL::NORM_PYRA5, 5,nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfPyramids, i-1);
+ MeshFormatElement e(MeshFormat::GmfPyramids, i-1+_nbTet);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 3 -_dim);
}
}
-void MeshFormatReader::setHexahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, int nbHex)
+void MeshFormatReader::setHexahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3)
{
int iN[28]; // 28 - nb nodes in HEX27 (+ 1 for safety :)
int ref;
// read extra vertices for quadratic hexahedra
- std::vector< std::vector<int> > quadNodesAtHexahedra( nbHex + 1 );
+ std::vector< std::vector<int> > quadNodesAtHexahedra( _nbHex + 1 );
if ( int nbQuadHexa = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtHexahedra ))
{
_reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtHexahedra);
&iN[15], &iN[16], &iN[17], &iN[18],
&iN[19],
&iN[20]); // HEXA27
- if ( iN[0] <= nbHex )
+ if ( iN[0] <= _nbHex )
{
std::vector<int>& nodes = quadNodesAtHexahedra[ iN[0] ];
nodes.insert( nodes.end(), & iN[2], & iN[20+1] );
}
// create hexhedra
-
_reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfHexahedra);
- for ( int i = 1; i <= nbHex; ++i )
+ for ( int i = 1; i <= _nbHex; ++i )
{
_reader.GmfGetLin(_myCurrentFileId, MeshFormat::GmfHexahedra, &iN[0], &iN[1], &iN[2], &iN[3],
&iN[4], &iN[5], &iN[6], &iN[7], &ref);
};
backward_shift(nodalConnPerCell, 20);
dimMesh3->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20, nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfHexahedra, i-1);
+ MeshFormatElement e(MeshFormat::GmfHexahedra, i-1+_nbTet+_nbPyr);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 3 -_dim);
};
backward_shift(nodalConnPerCell, 27);
dimMesh3->insertNextCell(INTERP_KERNEL::NORM_HEXA27,27, nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfHexahedra, i-1);
+ MeshFormatElement e(MeshFormat::GmfHexahedra, i-1+_nbTet+_nbPyr);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 3 -_dim);
}
};
backward_shift(nodalConnPerCell, 8);
dimMesh3->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8, nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfHexahedra, i-1);
+ MeshFormatElement e(MeshFormat::GmfHexahedra, i-1+_nbTet+_nbPyr);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 3 -_dim);
}
mcIdType nodalConnPerCell[8] = {iN[0], iN[2], iN[1], iN[3], iN[5], iN[4]};
backward_shift(nodalConnPerCell, 8);
dimMesh3->insertNextCell(INTERP_KERNEL::NORM_PENTA6, 6,nodalConnPerCell);
- MeshFormatElement e(MeshFormat::GmfPrisms, i-1);
+ MeshFormatElement e(MeshFormat::GmfPrisms, i-1+_nbTet+_nbPyr+_nbHex);
_fams.insert(std::pair <int, MeshFormatElement> (ref, e), 3 -_dim);
}