Main Lemma Repository
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

RectilinearGridVTKImporter.h 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 07/28/18 18:04:54
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@LemmaSoftware.org
  14. * @copyright Copyright (c) 2018, University of Utah
  15. * @copyright Copyright (c) 2018, Lemma Software, LLC
  16. */
  17. #pragma once
  18. #ifndef RECTILINEARGRIDVTKIMPORTER_INC
  19. #define RECTILINEARGRIDVTKIMPORTER_INC
  20. #ifdef LEMMAUSEVTK
  21. #pragma once
  22. #include "LemmaObject.h"
  23. #include "RectilinearGrid.h"
  24. #include "vtkSmartPointer.h"
  25. #include "vtkRectilinearGrid.h"
  26. #include "vtkDataArray.h"
  27. namespace Lemma {
  28. /**
  29. * \ingroup LemmaCore
  30. * \brief
  31. * \details
  32. */
  33. class RectilinearGridVTKImporter : public LemmaObject {
  34. friend std::ostream &operator<<(std::ostream &stream, const RectilinearGridVTKImporter &ob);
  35. protected:
  36. /*
  37. * This key is used to lock the constructor. It is protected so that inhereted
  38. * classes also have the key to contruct their base class.
  39. */
  40. struct ctor_key {};
  41. public:
  42. // ==================== LIFECYCLE =======================
  43. /**
  44. * Default constructor.
  45. * @note This method is locked, and cannot be called directly.
  46. * The reason that the method is public is to enable the use
  47. * of make_shared whilst enforcing the use of shared_ptr,
  48. * in c++-17, this curiosity may be resolved.
  49. * @see RectilinearGridVTKImporter::NewSP
  50. */
  51. explicit RectilinearGridVTKImporter ( const ctor_key& );
  52. /**
  53. * DeSerializing constructor.
  54. * @note This method is locked, and cannot be called directly.
  55. * The reason that the method is public is to enable the use
  56. * of make_shared whilst enforcing the use of shared_ptr,
  57. * in c++-17, this curiosity may be resolved.
  58. * @see RectilinearGridVTKImporter::DeSerialize
  59. */
  60. RectilinearGridVTKImporter ( const YAML::Node& node, const ctor_key& );
  61. /**
  62. * Default destructor.
  63. * @note This method should never be called due to the mandated
  64. * use of smart pointers. It is necessary to keep the method
  65. * public in order to allow for the use of the more efficient
  66. * make_shared constructor.
  67. */
  68. virtual ~RectilinearGridVTKImporter ();
  69. /**
  70. * Uses YAML to serialize this object.
  71. * @return a YAML::Node
  72. * @see RectilinearGridVTKImporter::DeSerialize
  73. */
  74. virtual YAML::Node Serialize() const;
  75. /*
  76. * Factory method for generating concrete class.
  77. * @return a std::shared_ptr of type RectilinearGridVTKImporter
  78. */
  79. static std::shared_ptr< RectilinearGridVTKImporter > NewSP();
  80. /**
  81. * Constructs an RectilinearGridVTKImporter object from a YAML::Node.
  82. * @see RectilinearGridVTKImporter::Serialize
  83. */
  84. static std::shared_ptr<RectilinearGridVTKImporter> DeSerialize(const YAML::Node& node);
  85. // ==================== OPERATORS =======================
  86. // ==================== OPERATIONS =======================
  87. // ==================== ACCESS =======================
  88. /**
  89. * Sets the name of the VTK file to convert
  90. */
  91. void SetVTKInput( vtkSmartPointer<vtkRectilinearGrid> vgrid );
  92. /**
  93. * Performs the actual grid conversion
  94. * @param[in] xshift is additional offset to apply in x direction.
  95. * @param[in] yshift is additional offset to apply in y direction.
  96. * @param[in] zshift is additional offset to apply in z direction.
  97. */
  98. void ConvertGrid( const Real& xshift, const Real& yshift, const Real& zshift );
  99. /**
  100. * @return smart pointer to RectilinearGrid class
  101. */
  102. std::shared_ptr<RectilinearGrid> GetGrid() {
  103. return this->rGrid;
  104. }
  105. // ==================== INQUIRY =======================
  106. /**
  107. * Returns the name of the underlying class, similiar to Python's type
  108. * @return string of class name
  109. */
  110. virtual inline std::string GetName() const {
  111. return CName;
  112. }
  113. protected:
  114. // ==================== LIFECYCLE =======================
  115. /** Copy is disabled */
  116. RectilinearGridVTKImporter( const RectilinearGridVTKImporter& ) = delete;
  117. // ==================== DATA MEMBERS =========================
  118. private:
  119. /** ASCII string representation of the class name */
  120. static constexpr auto CName = "RectilinearGridVTKImporter";
  121. /** VTK file to import */
  122. vtkSmartPointer<vtkRectilinearGrid> vtkGrid;
  123. /** container to hold imported grid */
  124. std::shared_ptr<RectilinearGrid> rGrid = nullptr;
  125. }; // ----- end of class RectilinearGridVTKImporter -----
  126. } // ----- end of namespace Lemma ----
  127. /* vim: set tabstop=4 expandtab: */
  128. /* vim: set filetype=cpp: */
  129. #endif // ----- LEMMAUSEVTK -----
  130. #endif // ----- #ifndef RECTILINEARGRIDVTKIMPORTER_INC -----