///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Ceetron Solutions AS // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RigWellLogFile.h" #include "well.hpp" #include "laswell.hpp" #include #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigWellLogFile::RigWellLogFile() : cvf::Object() { m_wellLogFile = NULL; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigWellLogFile::~RigWellLogFile() { close(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RigWellLogFile::open(const QString& fileName) { close(); int wellFormat = NRLib::Well::LAS; NRLib::Well* well = NRLib::Well::ReadWell(fileName.toStdString(), wellFormat); if (!well) { // TODO: Error handling return false; } QStringList wellLogNames; const std::map >& contLogs = well->GetContLog(); std::vector contLogNames; std::map >::const_iterator itCL; for (itCL = contLogs.begin(); itCL != contLogs.end(); itCL++) { wellLogNames.append(QString::fromStdString(itCL->first)); } // TODO: Possibly handle discrete logs // const std::map >& discLogs = well->GetDiscLog(); // std::vector discLogNames; // std::map >::const_iterator itDL; // for (itDL = discLogs.begin(); itDL != discLogs.end(); itDL++) // { // wellLogNames.append(QString::fromStdString(itDL->first)); // } m_wellLogChannelNames = wellLogNames; m_wellLogFile = well; return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RigWellLogFile::close() { if (m_wellLogFile) { delete m_wellLogFile; m_wellLogFile = NULL; } m_wellLogChannelNames.clear(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RigWellLogFile::wellName() const { CVF_ASSERT(m_wellLogFile); return QString::fromStdString(m_wellLogFile->GetWellName()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QStringList RigWellLogFile::wellLogChannelNames() const { return m_wellLogChannelNames; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector RigWellLogFile::depthValues() const { return values("DEPT"); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector RigWellLogFile::values(const QString& name) const { // TODO: Possibly handle discrete logs CVF_ASSERT(m_wellLogFile); if (m_wellLogFile->HasContLog(name.toStdString())) { return m_wellLogFile->GetContLog(name.toStdString()); } return std::vector(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RigWellLogFile::depthUnit() const { QString unit; NRLib::LasWell* lasWell = dynamic_cast(m_wellLogFile); if (lasWell) { unit = QString::fromStdString(lasWell->depthUnit()); } return unit; }