36 m_boundaryIndexOffset(0)
65 CepsInt nbToRead = indexEnd-indexStart;
68 std::getline(
m_file,dummy);
71 h <<
"Medit mesh reader: in file " <<
m_fileName <<
"," << std::endl
72 <<
" unable to read ";
74 for (
CepsInt i=0; i<nbToRead; i++)
106 CepsInt nbToRead = indexEnd-indexStart;
116 nbBoundaryToRead = nbToRead;
119 std::getline(
m_file,dummy);
125 nbBoundaryToRead = nbToRead-nbCellsToRead;
128 std::getline(
m_file,dummy);
133 for (i=0; i<nbCellsToRead; i++)
135 cellOffset+i,i,nodeOffset,nodeIndices,nodeIndicesPtr,cellAttr,cellAttrPtr,isBoundaryCell,
false
144 std::getline(
m_file,dummy);
148 for (; i < nbBoundaryToRead+nbCellsToRead; i++)
150 cellOffset+i,i,nodeOffset,nodeIndices,nodeIndicesPtr,cellAttr,cellAttrPtr,isBoundaryCell,
true
169 std::stringstream hh;
170 hh <<
"Medit mesh reader: in file " <<
m_fileName <<
"," << std::endl <<
" unable to read ";
183 cellAttrPtr [cellId+1] = cellAttrPtr [cellId] + nAttr;
184 nodeIndicesPtr[cellId+1] = nodeIndicesPtr[cellId] + nbPts;
186 isBoundaryCell[cellId] = boundaryFlag;
205 CEPS_ABORT_IF(line==-1,
"Failed to find any nodes in mesh file.");
220 "Could not find any cells of type \"" << kwV <<
"\" in current Medit mesh file." <<
m_fileName
#define CEPS_SAYS(message)
Writes a message in the debug log and in the terminal (stdio).
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
#define CEPS_WARNS(message)
Writes a warning in the debug log and in the terminal (stderr).
std::basic_string< CepsChar > CepsString
C++ format string.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
int32_t CepsInt
Need 32 bit integer.
CepsInt lineIndex(const CepsString &word)
Index of first line starting with word, search starting from the current stream position.
void reset()
Set file stream to the beginning of the file.
virtual CepsBool open()
Opens the designated file in read mode.
CepsString m_fileName
file to open
std::ifstream m_file
stream
virtual void close()
Close the file.
CepsVector< CepsString > m_keywordsT
Keywords used to separate cells in medit format, for simplices.
void initialize() override
Get the number of nodes cells and boundary cells before reading.
~MeditMeshReader() override
Destructor.
void readCells(CepsUInt indexStart, CepsUInt indexEnd, CepsUInt nodeOffset, CepsUInt cellOffset, CepsVector< CepsNodeGlobalIndex > &nodeIndices, CepsVector< CepsUInt > &nodeIndicesPtr, CepsVector< CepsAttribute > &cellAttr, CepsVector< CepsUInt > &cellAttrPtr, CepsVector< CepsChar > &isBoundaryCell) override
Reads several cells in mesh file.
MeditMeshReader(const CepsString &fileName, const CepsUInt &dim, CepsBool quads=false)
Constructor with full fileName and expected dimension.
void readNodes(CepsUInt indexStart, CepsUInt indexEnd, CepsUInt nodeOffset, CepsVector< CepsReal > &coords, CepsVector< CepsAttribute > &attr, CepsVector< CepsUInt > &attrPtr) override
Reads several nodes in mesh file.
void getNextCell(CepsUInt cellId, CepsUInt fileCellId, CepsUInt nodeOffset, CepsVector< CepsNodeGlobalIndex > &nodeIndices, CepsVector< CepsUInt > &nodeIndicesPtr, CepsVector< CepsAttribute > &cellAttr, CepsVector< CepsUInt > &cellAttrPtr, CepsVector< CepsChar > &isBoundaryCell, CepsBool boundaryFlag) override
Reads a single cell in mesh file.
CepsInt m_boundaryIndexOffset
Internal offset.
CepsVector< CepsString > m_keywordsQ
Keywords used to separate cells in medit format, for quads.
CepsInt m_indexOffset
Internal offset.
Abstract base class that encapsulates primary functionalities of each mesh reader.
CepsInt m_nodesBegin
line start of nodes
CepsUInt m_nbAttrPerCell
attributes per cell
CepsBool m_initialized
Flag to ensure call of initializeReader()
void checkCanReadNodes(CepsUInt indexStart, CepsUInt indexEnd) const
Aborts if passed indices are wrong.
CepsUInt m_nbNodesPerBdryCell
nb nodes per boundary cell
CepsBool m_quads
Reader for quadratic cells.
CepsUInt m_bdryCellsRead
Keeps track of already read boundary cells.
CepsUInt m_nbNodesPerCell
nb nodes per cell
CepsUInt m_nbBdryCells
number of boundary cells in mesh, appropriate for dimension
CepsUInt m_nbAttrPerBdryCell
attributes per boundary cell
CepsUInt m_cellsRead
Keeps track of already read cells.
CepsUInt m_nbAttrPerNode
attributes per node
virtual CepsBool checkExtension() const
Stop if extension is not ok, extension must be defined in child classes.
CepsInt m_cellsBegin
line start of cells
CepsUInt m_expectedDim
Expected dimension of mesh.
CepsUInt m_nbCellsTotal
number of all cells in file
CepsInt m_bdryCellsBegin
line start of boundary cells
CepsString m_extension
File name extension.
CepsUInt m_nbNodes
number of nodes in mesh
CepsUInt m_nbCells
number of cells in mesh, appropriate for dimension
void checkCanReadCells(CepsUInt indexStart, CepsUInt indexEnd) const
Aborts if passed indices are wrong.
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
CepsInt readInt(std::istream &file, const CepsString &errorMessage="")
Reads an integral number from an istream, aborts if conversion fails advances the stream by 1 word.
CepsReal readReal(std::istream &file, const CepsString &errorMessage="")
Reads a floating point number from an istream, aborts if conversion fails advances the stream by 1 wo...