/*! * Converts a string into a Field information. * @param[in] line_ string to be converted * @param[out] data_ Field information * \return true if successful */ bool vtk::convertStringToDataArray( const std::string &line_, VTKField &data_ ){ std::string type_, name_, code_, comp_, offs_ ; int components_(1), offset_ ; VTKFormat codex ; VTKDataType type ; VTKFieldType comp(VTKFieldType::SCALAR) ; bool success(true) ; if( bitpit::utils::keywordInString( line_, "<DataArray ") ){ success = success && bitpit::utils::getAfterKeyword( line_, "type=", '\"', type_) ; success = success && bitpit::utils::getAfterKeyword( line_, "Name=", '\"', name_) ; success = success && bitpit::utils::getAfterKeyword( line_, "format=", '\"', code_) ; if( bitpit::utils::getAfterKeyword( line_, "NumberOfComponents=", '\"', comp_) ){ bitpit::utils::convertString( comp_, components_ ) ; }; if(components_==3) comp=VTKFieldType::VECTOR ; vtk::convertStringToEnum( type_, type) ; vtk::convertStringToEnum( code_, codex) ; data_.setDataType(type) ; data_.setName(name_) ; data_.setCodification(codex) ; if(name_ != "connectivity") data_.setFieldType(comp) ; if(code_=="appended") { if( bitpit::utils::getAfterKeyword( line_, "offset=", '\"', offs_) ){ bitpit::utils::convertString( offs_, offset_ ) ; data_.setOffset(offset_) ; } else{ success = false ; }; } return success ; } else{ return false ; }; };
/*! * Converts a string into a Field information. * @param[in] line string to be converted * @param[out] field Field information * \return true if successful */ bool vtk::convertStringToDataArray( const std::string &line, VTKField &field ){ std::string typ, name, code, com, offs ; int components(1), offset ; VTKFormat codex ; VTKDataType type ; VTKFieldType comp(VTKFieldType::SCALAR) ; bool success(true) ; if( bitpit::utils::keywordInString( line, "<DataArray ") ){ success = success && bitpit::utils::getAfterKeyword( line, "type=", '\"', typ) ; success = success && bitpit::utils::getAfterKeyword( line, "Name=", '\"', name) ; success = success && bitpit::utils::getAfterKeyword( line, "format=", '\"', code) ; if( bitpit::utils::getAfterKeyword( line, "NumberOfComponents=", '\"', com) ){ bitpit::utils::convertString( com, components ) ; }; if(components==3) comp=VTKFieldType::VECTOR ; vtk::convertStringToEnum( typ, type) ; vtk::convertStringToEnum( code, codex) ; field.setDataType(type) ; field.setName(name) ; field.setCodification(codex) ; if(name != "connectivity") field.setFieldType(comp) ; if(code=="appended") { if( bitpit::utils::getAfterKeyword( line, "offset=", '\"', offs) ){ bitpit::utils::convertString( offs, offset ) ; field.setOffset(offset) ; } else{ success = false ; }; } return success ; } else{ return false ; }; };