Main Lemma Repository
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

RectilinearGridReader.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. */
  6. /**
  7. @file
  8. @date 09/23/2013 11:05:11 AM
  9. @version $Id$
  10. @author Trevor Irons (ti)
  11. @email Trevor.Irons@xri-geo.com
  12. @copyright Copyright (c) 2013, XRI Geophysics, LLC
  13. @copyright Copyright (c) 2013, Trevor Irons
  14. **/
  15. #ifndef RECTILINEARGRIDREADER_INC
  16. #define RECTILINEARGRIDREADER_INC
  17. #include "GridReader.h"
  18. #include "RectilinearGrid.h"
  19. #include "ASCIIParser.h"
  20. namespace Lemma {
  21. /**
  22. @class
  23. \ingroup LemmaCore
  24. \brief Base Class for rectilinear grid reader data files
  25. \details
  26. \todo this set of classes is deprecated, use serialize methods!
  27. */
  28. class RectilinearGridReader : public GridReader {
  29. friend std::ostream &operator<<(std::ostream &stream,
  30. const RectilinearGridReader &ob);
  31. public:
  32. // ==================== LIFECYCLE =======================
  33. /**
  34. * Factory method for generating concrete class.
  35. * @return a std::shared_ptr of type RectilinearGridReader
  36. */
  37. static std::shared_ptr< RectilinearGridReader > NewSP();
  38. // ==================== OPERATORS =======================
  39. // ==================== OPERATIONS =======================
  40. /**
  41. Reads a .mod file, a simple representation of the grid. These files
  42. have the following format:
  43. @verbatim
  44. nx ny nz // number of cells in x, y, and z
  45. ox oy oz // grid offset of top SW corner
  46. hx[0] hx[1] ... hx[nx-1] // grid cell spacing in x, from 0 to nx-1
  47. hy[0] hy[1] ... hy[ny-1] // grid cell spacing in y, from 0 to ny-1
  48. hz[0] hz[1] ... hz[nz-1] // grid cell spacing in z, from 0 to nz-1
  49. // c++ style (//) comments are allowed anywhere, c-style are not
  50. @endverbatim
  51. */
  52. void ReadASCIIGridFile( const std::string& name );
  53. // ==================== ACCESS =======================
  54. /**
  55. * Accessor method for the underlying RectilinearGrid class constructed
  56. * from the input file.
  57. */
  58. std::shared_ptr<Grid> GetGrid();
  59. // ==================== INQUIRY =======================
  60. /** Returns the name of the underlying class, similiar to Python's type */
  61. virtual inline std::string GetName() const {
  62. return this->CName;
  63. }
  64. protected:
  65. // ==================== LIFECYCLE =======================
  66. /** Default protected constructor, use New */
  67. RectilinearGridReader ( );
  68. /** Default protected constructor, use Delete */
  69. ~RectilinearGridReader ();
  70. private:
  71. // ==================== DATA MEMBERS =========================
  72. /** ASCII string representation of the class name */
  73. static constexpr auto CName = "RectilinearGridReader";
  74. /** Object holding constructed Grid */
  75. std::shared_ptr<RectilinearGrid> rGrid;
  76. /** Performs actual file parsing */
  77. std::shared_ptr<ASCIIParser> Parser;
  78. }; // ----- end of class RectilinearGridReader -----
  79. } // ----- end of Lemma name -----
  80. #endif // ----- #ifndef RECTILINEARGRIDREADER_INC -----